Commit d3e20fd1 authored by Yan-Hsuan Chuang's avatar Yan-Hsuan Chuang Committed by Kalle Valo

rtw88: LPS enter/leave should be protected by lock

Protect LPS enter/leave routine with rtwdev->mutex.
This helps to synchronize with driver's states correctly.
Signed-off-by: default avatarYan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 5235d636
...@@ -464,10 +464,10 @@ static void rtw_ops_sw_scan_start(struct ieee80211_hw *hw, ...@@ -464,10 +464,10 @@ static void rtw_ops_sw_scan_start(struct ieee80211_hw *hw,
struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
u32 config = 0; u32 config = 0;
rtw_leave_lps(rtwdev);
mutex_lock(&rtwdev->mutex); mutex_lock(&rtwdev->mutex);
rtw_leave_lps(rtwdev);
ether_addr_copy(rtwvif->mac_addr, mac_addr); ether_addr_copy(rtwvif->mac_addr, mac_addr);
config |= PORT_SET_MAC_ADDR; config |= PORT_SET_MAC_ADDR;
rtw_vif_port_config(rtwdev, rtwvif, config); rtw_vif_port_config(rtwdev, rtwvif, config);
......
...@@ -152,8 +152,10 @@ static void rtw_watch_dog_work(struct work_struct *work) ...@@ -152,8 +152,10 @@ static void rtw_watch_dog_work(struct work_struct *work)
struct rtw_watch_dog_iter_data data = {}; struct rtw_watch_dog_iter_data data = {};
bool busy_traffic = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); bool busy_traffic = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags);
mutex_lock(&rtwdev->mutex);
if (!test_bit(RTW_FLAG_RUNNING, rtwdev->flags)) if (!test_bit(RTW_FLAG_RUNNING, rtwdev->flags))
return; goto unlock;
ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work, ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work,
RTW_WATCH_DOG_DELAY_TIME); RTW_WATCH_DOG_DELAY_TIME);
...@@ -186,11 +188,14 @@ static void rtw_watch_dog_work(struct work_struct *work) ...@@ -186,11 +188,14 @@ static void rtw_watch_dog_work(struct work_struct *work)
rtw_leave_lps(rtwdev); rtw_leave_lps(rtwdev);
if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags)) if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
return; goto unlock;
rtw_phy_dynamic_mechanism(rtwdev); rtw_phy_dynamic_mechanism(rtwdev);
rtwdev->watch_dog_cnt++; rtwdev->watch_dog_cnt++;
unlock:
mutex_unlock(&rtwdev->mutex);
} }
static void rtw_c2h_work(struct work_struct *work) static void rtw_c2h_work(struct work_struct *work)
......
...@@ -95,6 +95,8 @@ void rtw_enter_lps(struct rtw_dev *rtwdev, u8 port_id) ...@@ -95,6 +95,8 @@ void rtw_enter_lps(struct rtw_dev *rtwdev, u8 port_id)
{ {
struct rtw_lps_conf *conf = &rtwdev->lps_conf; struct rtw_lps_conf *conf = &rtwdev->lps_conf;
lockdep_assert_held(&rtwdev->mutex);
if (test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags)) if (test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags))
return; return;
...@@ -108,6 +110,8 @@ void rtw_leave_lps(struct rtw_dev *rtwdev) ...@@ -108,6 +110,8 @@ void rtw_leave_lps(struct rtw_dev *rtwdev)
{ {
struct rtw_lps_conf *conf = &rtwdev->lps_conf; struct rtw_lps_conf *conf = &rtwdev->lps_conf;
lockdep_assert_held(&rtwdev->mutex);
if (!test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags)) if (!test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags))
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment