Skip to content

Commit 6db2329

Browse files
Kang Yanggregkh
authored andcommitted
wifi: ath11k: use work queue to process beacon tx event
[ Upstream commit 177b49d ] Commit 3a415da ("wifi: ath11k: add P2P IE in beacon template") from Feb 28, 2024 (linux-next), leads to the following Smatch static checker warning: drivers/net/wireless/ath/ath11k/wmi.c:1742 ath11k_wmi_p2p_go_bcn_ie() warn: sleeping in atomic context The reason is that ath11k_bcn_tx_status_event() will directly call might sleep function ath11k_wmi_cmd_send() during RCU read-side critical sections. The call trace is like: ath11k_bcn_tx_status_event() -> rcu_read_lock() -> ath11k_mac_bcn_tx_event() -> ath11k_mac_setup_bcn_tmpl() …… -> ath11k_wmi_bcn_tmpl() -> ath11k_wmi_cmd_send() -> rcu_read_unlock() Commit 886433a ("ath11k: add support for BSS color change") added the ath11k_mac_bcn_tx_event(), commit 01e782c ("ath11k: fix warning of RCU usage for ath11k_mac_get_arvif_by_vdev_id()") added the RCU lock to avoid warning but also introduced this BUG. Use work queue to avoid directly calling ath11k_mac_bcn_tx_event() during RCU critical sections. No need to worry about the deletion of vif because cancel_work_sync() will drop the work if it doesn't start or block vif deletion until the running work is done. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30 Fixes: 3a415da ("wifi: ath11k: add P2P IE in beacon template") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/all/2d277abd-5e7b-4da0-80e0-52bd96337f6e@moroto.mountain/ Signed-off-by: Kang Yang <quic_kangyang@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://patch.msgid.link/20240626053543.1946-1-quic_kangyang@quicinc.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7424ab4 commit 6db2329

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

drivers/net/wireless/ath/ath11k/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ struct ath11k_vif {
399399
u8 bssid[ETH_ALEN];
400400
struct cfg80211_bitrate_mask bitrate_mask;
401401
struct delayed_work connection_loss_work;
402+
struct work_struct bcn_tx_work;
402403
int num_legacy_stations;
403404
int rtscts_prot_mode;
404405
int txpower;

drivers/net/wireless/ath/ath11k/mac.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6599,6 +6599,16 @@ static int ath11k_mac_vdev_delete(struct ath11k *ar, struct ath11k_vif *arvif)
65996599
return ret;
66006600
}
66016601

6602+
static void ath11k_mac_bcn_tx_work(struct work_struct *work)
6603+
{
6604+
struct ath11k_vif *arvif = container_of(work, struct ath11k_vif,
6605+
bcn_tx_work);
6606+
6607+
mutex_lock(&arvif->ar->conf_mutex);
6608+
ath11k_mac_bcn_tx_event(arvif);
6609+
mutex_unlock(&arvif->ar->conf_mutex);
6610+
}
6611+
66026612
static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw,
66036613
struct ieee80211_vif *vif)
66046614
{
@@ -6637,6 +6647,7 @@ static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw,
66376647
arvif->vif = vif;
66386648

66396649
INIT_LIST_HEAD(&arvif->list);
6650+
INIT_WORK(&arvif->bcn_tx_work, ath11k_mac_bcn_tx_work);
66406651
INIT_DELAYED_WORK(&arvif->connection_loss_work,
66416652
ath11k_mac_vif_sta_connection_loss_work);
66426653

@@ -6879,6 +6890,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,
68796890
int i;
68806891

68816892
cancel_delayed_work_sync(&arvif->connection_loss_work);
6893+
cancel_work_sync(&arvif->bcn_tx_work);
68826894

68836895
mutex_lock(&ar->conf_mutex);
68846896

drivers/net/wireless/ath/ath11k/wmi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7404,7 +7404,9 @@ static void ath11k_bcn_tx_status_event(struct ath11k_base *ab, struct sk_buff *s
74047404
rcu_read_unlock();
74057405
return;
74067406
}
7407-
ath11k_mac_bcn_tx_event(arvif);
7407+
7408+
queue_work(ab->workqueue, &arvif->bcn_tx_work);
7409+
74087410
rcu_read_unlock();
74097411
}
74107412

0 commit comments

Comments
 (0)