Skip to content

Commit a1e1928

Browse files
Baochen Qiangjeff-t-johnson
authored andcommitted
wifi: ath12k: move firmware stats request outside of atomic context
In ath12k_mac_op_link_sta_statistics(), the atomic context scope introduced by dp_lock also covers firmware stats request. Since that request could block, below issue is hit: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:575 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 6866, name: iw preempt_count: 201, expected: 0 RCU nest depth: 0, expected: 0 3 locks held by iw/6866: #0:[...] #1:[...] #2: ffff9748f43230c8 (&dp->dp_lock){+.-.}-{3:3}, at: ath12k_mac_op_link_sta_statistics+0xc6/0x380 [ath12k] Preemption disabled at: [<ffffffffc0349656>] ath12k_mac_op_link_sta_statistics+0xc6/0x380 [ath12k] Call Trace: <TASK> show_stack dump_stack_lvl dump_stack __might_resched.cold __might_sleep __mutex_lock mutex_lock_nested ath12k_mac_get_fw_stats ath12k_mac_op_link_sta_statistics </TASK> Since firmware stats request doesn't require protection from dp_lock, move it outside to fix this issue. While moving, also refine that code hunk to make function parameters get populated when really necessary. Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3 Signed-off-by: Baochen Qiang <[email protected]> Reviewed-by: Vasanthakumar Thiagarajan <[email protected]> Link: https://patch.msgid.link/20251119-ath12k-ng-sleep-in-atomic-v1-1-5d1a726597db@oss.qualcomm.com Signed-off-by: Jeff Johnson <[email protected]>
1 parent 5a38485 commit a1e1928

File tree

1 file changed

+23
-21
lines changed
  • drivers/net/wireless/ath/ath12k

1 file changed

+23
-21
lines changed

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12792,10 +12792,12 @@ void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw,
1279212792
db2dbm = test_bit(WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT,
1279312793
ar->ab->wmi_ab.svc_map);
1279412794

12795-
guard(spinlock_bh)(&ar->ab->dp->dp_lock);
12795+
spin_lock_bh(&ar->ab->dp->dp_lock);
1279612796
peer = ath12k_dp_link_peer_find_by_addr(ar->ab->dp, arsta->addr);
12797-
if (!peer)
12797+
if (!peer) {
12798+
spin_unlock_bh(&ar->ab->dp->dp_lock);
1279812799
return;
12800+
}
1279912801

1280012802
link_sinfo->rx_duration = peer->rx_duration;
1280112803
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION);
@@ -12822,35 +12824,35 @@ void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw,
1282212824
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
1282312825
}
1282412826

12827+
link_sinfo->signal_avg = ewma_avg_rssi_read(&peer->avg_rssi);
12828+
if (!db2dbm)
12829+
link_sinfo->signal_avg += ATH12K_DEFAULT_NOISE_FLOOR;
12830+
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
12831+
12832+
link_sinfo->tx_retries = peer->tx_retry_count;
12833+
link_sinfo->tx_failed = peer->tx_retry_failed;
12834+
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
12835+
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
12836+
1282512837
/* TODO: Use real NF instead of default one. */
1282612838
signal = peer->rssi_comb;
1282712839

12828-
params.pdev_id = ar->pdev->pdev_id;
12829-
params.vdev_id = 0;
12830-
params.stats_id = WMI_REQUEST_VDEV_STAT;
12840+
spin_unlock_bh(&ar->ab->dp->dp_lock);
1283112841

12832-
if (!signal &&
12833-
ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
12834-
!(ath12k_mac_get_fw_stats(ar, &params)))
12835-
signal = arsta->rssi_beacon;
12842+
if (!signal && ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA) {
12843+
params.pdev_id = ar->pdev->pdev_id;
12844+
params.vdev_id = 0;
12845+
params.stats_id = WMI_REQUEST_VDEV_STAT;
12846+
12847+
if (!ath12k_mac_get_fw_stats(ar, &params))
12848+
signal = arsta->rssi_beacon;
12849+
}
1283612850

1283712851
if (signal) {
1283812852
link_sinfo->signal =
1283912853
db2dbm ? signal : signal + ATH12K_DEFAULT_NOISE_FLOOR;
1284012854
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
1284112855
}
12842-
12843-
link_sinfo->signal_avg = ewma_avg_rssi_read(&peer->avg_rssi);
12844-
12845-
if (!db2dbm)
12846-
link_sinfo->signal_avg += ATH12K_DEFAULT_NOISE_FLOOR;
12847-
12848-
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
12849-
12850-
link_sinfo->tx_retries = peer->tx_retry_count;
12851-
link_sinfo->tx_failed = peer->tx_retry_failed;
12852-
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
12853-
link_sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
1285412856
}
1285512857
EXPORT_SYMBOL(ath12k_mac_op_link_sta_statistics);
1285612858

0 commit comments

Comments
 (0)