rtw88: leave PS state for dynamic mechanism
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Wed, 2 Oct 2019 02:31:23 +0000 (10:31 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 2 Oct 2019 04:33:45 +0000 (07:33 +0300)
Dynamic mechanism requires BB/RF working to adjust
hardware settings. But PS state periodically turns
off BB/RF, could lead to wrong setting.

So leave PS state before DM to make sure it works.
And then check if we can enter PS state again.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtw88/main.c

index f55eda9..00ebf8c 100644 (file)
@@ -174,6 +174,14 @@ static void rtw_watch_dog_work(struct work_struct *work)
        rtwdev->stats.tx_cnt = 0;
        rtwdev->stats.rx_cnt = 0;
 
+       if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
+               goto unlock;
+
+       /* make sure BB/RF is working for dynamic mech */
+       rtw_leave_lps(rtwdev);
+
+       rtw_phy_dynamic_mechanism(rtwdev);
+
        /* use atomic version to avoid taking local->iflist_mtx mutex */
        rtw_iterate_vifs_atomic(rtwdev, rtw_vif_watch_dog_iter, &data);
 
@@ -184,13 +192,6 @@ static void rtw_watch_dog_work(struct work_struct *work)
        if (rtw_fw_support_lps &&
            data.rtwvif && !data.active && data.assoc_cnt == 1)
                rtw_enter_lps(rtwdev, data.rtwvif->port);
-       else
-               rtw_leave_lps(rtwdev);
-
-       if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
-               goto unlock;
-
-       rtw_phy_dynamic_mechanism(rtwdev);
 
        rtwdev->watch_dog_cnt++;