Skip to content

Commit ed30fd7

Browse files
Manish DharanenthiranRealzhq
authored andcommitted
UPSTREAM: wifi: ath12k: Make firmware stats reset caller-driven
Currently, ath12k_fw_stats_reset() is called in ath12k_mac_get_fw_stats() before fetching the required stats from the firmware. However, ath12k_open_bcn_stats() requests firmware stats for each enabled BSS individually. Since the firmware stats are reset before fetching, only the last BSS's data is displayed. Also, in ath12k_mac_op_get_txpower(), ath12k_mac_op_sta_statistics(), and ath12k_mac_op_link_sta_statistics(), after getting the stats from the firmware, the reset function is not called until the next firmware stats are requested or while unloading the module. Hence, the stats buffer will not be freed until one of the above sequences is executed. However, in ath12k_open_vdev_stats(), ath12k_open_bcn_stats() and ath12k_open_pdev_stats(), firmware stats are reset after copying the necessary data in ath12k_wmi_fw_stats_dump(). This leads to inconsistent usage of ath12k_fw_stats_reset() for freeing the firmware stats. Avoid these discrepancies by making it the caller's responsibility to free the stats buffer, thereby removing the need to free the stats buffer in ath12k_mac_get_fw_stats() and ath12k_wmi_fw_stats_dump(). Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Signed-off-by: Manish Dharanenthiran <manish.dharanenthiran@oss.qualcomm.com> Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com> Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com> Signed-off-by: Qian Zhang <qian.zhang@oss.qualcomm.com> Link: https://lore.kernel.org/all/20251031-beacon_stats-v1-1-f52fce7b03ac@qti.qualcomm.com/
1 parent 8dd59c5 commit ed30fd7

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ static int ath12k_open_vdev_stats(struct inode *inode, struct file *file)
12831283

12841284
ath12k_wmi_fw_stats_dump(ar, &ar->fw_stats, param.stats_id,
12851285
buf);
1286+
ath12k_fw_stats_reset(ar);
12861287

12871288
file->private_data = no_free_ptr(buf);
12881289

@@ -1349,12 +1350,7 @@ static int ath12k_open_bcn_stats(struct inode *inode, struct file *file)
13491350

13501351
ath12k_wmi_fw_stats_dump(ar, &ar->fw_stats, param.stats_id,
13511352
buf);
1352-
/* since beacon stats request is looped for all active VDEVs, saved fw
1353-
* stats is not freed for each request until done for all active VDEVs
1354-
*/
1355-
spin_lock_bh(&ar->data_lock);
1356-
ath12k_fw_stats_bcn_free(&ar->fw_stats.bcn);
1357-
spin_unlock_bh(&ar->data_lock);
1353+
ath12k_fw_stats_reset(ar);
13581354

13591355
file->private_data = no_free_ptr(buf);
13601356

@@ -1415,6 +1411,7 @@ static int ath12k_open_pdev_stats(struct inode *inode, struct file *file)
14151411

14161412
ath12k_wmi_fw_stats_dump(ar, &ar->fw_stats, param.stats_id,
14171413
buf);
1414+
ath12k_fw_stats_reset(ar);
14181415

14191416
file->private_data = no_free_ptr(buf);
14201417

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4837,8 +4837,6 @@ int ath12k_mac_get_fw_stats(struct ath12k *ar,
48374837
if (ah->state != ATH12K_HW_STATE_ON)
48384838
return -ENETDOWN;
48394839

4840-
ath12k_fw_stats_reset(ar);
4841-
48424840
reinit_completion(&ar->fw_stats_complete);
48434841
reinit_completion(&ar->fw_stats_done);
48444842

@@ -4936,6 +4934,7 @@ static int ath12k_mac_op_get_txpower(struct ieee80211_hw *hw,
49364934
ar->chan_tx_pwr = pdev->chan_tx_power / 2;
49374935
spin_unlock_bh(&ar->data_lock);
49384936
ar->last_tx_power_update = jiffies;
4937+
ath12k_fw_stats_reset(ar);
49394938

49404939
send_tx_power:
49414940
*dbm = ar->chan_tx_pwr;
@@ -12701,14 +12700,18 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
1270112700

1270212701
if (!signal &&
1270312702
ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
12704-
!(ath12k_mac_get_fw_stats(ar, &params)))
12703+
!(ath12k_mac_get_fw_stats(ar, &params))) {
1270512704
signal = arsta->rssi_beacon;
12705+
ath12k_fw_stats_reset(ar);
12706+
}
1270612707

1270712708
params.stats_id = WMI_REQUEST_RSSI_PER_CHAIN_STAT;
1270812709
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL)) &&
1270912710
ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
12710-
!(ath12k_mac_get_fw_stats(ar, &params)))
12711+
!(ath12k_mac_get_fw_stats(ar, &params))) {
1271112712
ath12k_mac_put_chain_rssi(sinfo, arsta);
12713+
ath12k_fw_stats_reset(ar);
12714+
}
1271212715

1271312716
spin_lock_bh(&ar->data_lock);
1271412717
noise_floor = ath12k_pdev_get_noise_floor(ar);
@@ -12792,8 +12795,10 @@ static void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw,
1279212795

1279312796
if (!signal &&
1279412797
ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
12795-
!(ath12k_mac_get_fw_stats(ar, &params)))
12798+
!(ath12k_mac_get_fw_stats(ar, &params))) {
1279612799
signal = arsta->rssi_beacon;
12800+
ath12k_fw_stats_reset(ar);
12801+
}
1279712802

1279812803
if (signal) {
1279912804
link_sinfo->signal =

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8017,8 +8017,6 @@ void ath12k_wmi_fw_stats_dump(struct ath12k *ar,
80178017
buf[len - 1] = 0;
80188018
else
80198019
buf[len] = 0;
8020-
8021-
ath12k_fw_stats_reset(ar);
80228020
}
80238021

80248022
static void

0 commit comments

Comments
 (0)