]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: Make firmware stats reset caller-driven
authorManish Dharanenthiran <manish.dharanenthiran@oss.qualcomm.com>
Fri, 31 Oct 2025 03:07:45 +0000 (08:37 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Thu, 6 Nov 2025 15:33:31 +0000 (07:33 -0800)
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>
Link: https://patch.msgid.link/20251031-beacon_stats-v1-1-f52fce7b03ac@qti.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/debugfs.c
drivers/net/wireless/ath/ath12k/mac.c
drivers/net/wireless/ath/ath12k/wmi.c

index 15219429d4ed88c77941533b1ab4c9202ea9da57..d6a86f075d73b92504bef6939ddaa3baa9ce9c1d 100644 (file)
@@ -1286,6 +1286,7 @@ static int ath12k_open_vdev_stats(struct inode *inode, struct file *file)
 
        ath12k_wmi_fw_stats_dump(ar, &ar->fw_stats, param.stats_id,
                                 buf);
+       ath12k_fw_stats_reset(ar);
 
        file->private_data = no_free_ptr(buf);
 
@@ -1352,12 +1353,7 @@ static int ath12k_open_bcn_stats(struct inode *inode, struct file *file)
 
        ath12k_wmi_fw_stats_dump(ar, &ar->fw_stats, param.stats_id,
                                 buf);
-       /* since beacon stats request is looped for all active VDEVs, saved fw
-        * stats is not freed for each request until done for all active VDEVs
-        */
-       spin_lock_bh(&ar->data_lock);
-       ath12k_fw_stats_bcn_free(&ar->fw_stats.bcn);
-       spin_unlock_bh(&ar->data_lock);
+       ath12k_fw_stats_reset(ar);
 
        file->private_data = no_free_ptr(buf);
 
@@ -1418,6 +1414,7 @@ static int ath12k_open_pdev_stats(struct inode *inode, struct file *file)
 
        ath12k_wmi_fw_stats_dump(ar, &ar->fw_stats, param.stats_id,
                                 buf);
+       ath12k_fw_stats_reset(ar);
 
        file->private_data = no_free_ptr(buf);
 
index 0348601ecc50c727134874bdf6d1317b429e6a28..65e0ac19ad1177c8ee09124c88d016f7591153e3 100644 (file)
@@ -5091,8 +5091,6 @@ int ath12k_mac_get_fw_stats(struct ath12k *ar,
        if (ah->state != ATH12K_HW_STATE_ON)
                return -ENETDOWN;
 
-       ath12k_fw_stats_reset(ar);
-
        reinit_completion(&ar->fw_stats_complete);
        reinit_completion(&ar->fw_stats_done);
 
@@ -5190,6 +5188,7 @@ static int ath12k_mac_op_get_txpower(struct ieee80211_hw *hw,
        ar->chan_tx_pwr = pdev->chan_tx_power / 2;
        spin_unlock_bh(&ar->data_lock);
        ar->last_tx_power_update = jiffies;
+       ath12k_fw_stats_reset(ar);
 
 send_tx_power:
        *dbm = ar->chan_tx_pwr;
@@ -13220,14 +13219,18 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
 
        if (!signal &&
            ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
-           !(ath12k_mac_get_fw_stats(ar, &params)))
+           !(ath12k_mac_get_fw_stats(ar, &params))) {
                signal = arsta->rssi_beacon;
+               ath12k_fw_stats_reset(ar);
+       }
 
        params.stats_id = WMI_REQUEST_RSSI_PER_CHAIN_STAT;
        if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL)) &&
            ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
-           !(ath12k_mac_get_fw_stats(ar, &params)))
+           !(ath12k_mac_get_fw_stats(ar, &params))) {
                ath12k_mac_put_chain_rssi(sinfo, arsta);
+               ath12k_fw_stats_reset(ar);
+       }
 
        spin_lock_bh(&ar->data_lock);
        noise_floor = ath12k_pdev_get_noise_floor(ar);
@@ -13311,8 +13314,10 @@ static void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw,
 
        if (!signal &&
            ahsta->ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
-           !(ath12k_mac_get_fw_stats(ar, &params)))
+           !(ath12k_mac_get_fw_stats(ar, &params))) {
                signal = arsta->rssi_beacon;
+               ath12k_fw_stats_reset(ar);
+       }
 
        if (signal) {
                link_sinfo->signal =
index 5075d86df36ff5a7863bd9c4b379c61997b02618..f812da24b21e68893327d61fe0ff9deb222bd54b 100644 (file)
@@ -8089,8 +8089,6 @@ void ath12k_wmi_fw_stats_dump(struct ath12k *ar,
                buf[len - 1] = 0;
        else
                buf[len] = 0;
-
-       ath12k_fw_stats_reset(ar);
 }
 
 static void