wifi: ath12k: don't use static variables in ath12k_wmi_fw_stats_process()
authorBaochen Qiang <quic_bqiang@quicinc.com>
Thu, 12 Jun 2025 01:31:51 +0000 (09:31 +0800)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Tue, 17 Jun 2025 23:28:35 +0000 (16:28 -0700)
Currently ath12k_wmi_fw_stats_process() is using static variables to count
firmware stat events. Taking num_vdev as an example, if for whatever
reason (say ar->num_started_vdevs is 0 or firmware bug etc.) the following
condition

(++num_vdev) == total_vdevs_started

is not met, is_end is not set thus num_vdev won't be cleared. Next time
when firmware stats is requested again, even if everything is working
fine, failure is expected due to the condition above will never be
satisfied.

The same applies to num_bcn as well.

Change to use non-static counters and reset them each time before firmware
stats is requested.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00284.1-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: QCN9274 hw2.0 WLAN.WBE.1.5-01651-QCAHKSWPL_SILICONZ-1

Fixes: e367c924768b ("wifi: ath12k: Request vdev stats from firmware")
Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
Link: https://patch.msgid.link/20250612-ath12k-fw-fixes-v1-3-12f594f3b857@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/core.c
drivers/net/wireless/ath/ath12k/core.h
drivers/net/wireless/ath/ath12k/wmi.c

index fbc62209086fe5fde007193755f6116bfa72ab77..89ae80934b3048f850939c25c160af0e2d05b8e2 100644 (file)
@@ -1230,6 +1230,8 @@ void ath12k_fw_stats_reset(struct ath12k *ar)
 {
        spin_lock_bh(&ar->data_lock);
        ath12k_fw_stats_free(&ar->fw_stats);
+       ar->fw_stats.num_vdev_recvd = 0;
+       ar->fw_stats.num_bcn_recvd = 0;
        spin_unlock_bh(&ar->data_lock);
 }
 
index 2b2e0c16b64e6105cf4fc21ff974c59b90552977..7bcd9c70309fdb733830a19323012a389d17fd9c 100644 (file)
@@ -632,6 +632,8 @@ struct ath12k_fw_stats {
        struct list_head pdevs;
        struct list_head vdevs;
        struct list_head bcn;
+       u32 num_vdev_recvd;
+       u32 num_bcn_recvd;
 };
 
 struct ath12k_dbg_htt_stats {
index e8323581a5afc80173df37229f8355d94cb7627a..533e4ddb9a5088585da62ae5569e1a40b446eb5c 100644 (file)
@@ -8166,7 +8166,6 @@ static void ath12k_wmi_fw_stats_process(struct ath12k *ar,
        struct ath12k_base *ab = ar->ab;
        struct ath12k_pdev *pdev;
        bool is_end;
-       static unsigned int num_vdev, num_bcn;
        size_t total_vdevs_started = 0;
        int i;
 
@@ -8186,15 +8185,14 @@ static void ath12k_wmi_fw_stats_process(struct ath12k *ar,
                }
                rcu_read_unlock();
 
-               is_end = ((++num_vdev) == total_vdevs_started);
+               is_end = ((++ar->fw_stats.num_vdev_recvd) == total_vdevs_started);
 
                list_splice_tail_init(&stats->vdevs,
                                      &ar->fw_stats.vdevs);
 
-               if (is_end) {
+               if (is_end)
                        complete(&ar->fw_stats_done);
-                       num_vdev = 0;
-               }
+
                return;
        }
 
@@ -8206,15 +8204,13 @@ static void ath12k_wmi_fw_stats_process(struct ath12k *ar,
                /* Mark end until we reached the count of all started VDEVs
                 * within the PDEV
                 */
-               is_end = ((++num_bcn) == ar->num_started_vdevs);
+               is_end = ((++ar->fw_stats.num_bcn_recvd) == ar->num_started_vdevs);
 
                list_splice_tail_init(&stats->bcn,
                                      &ar->fw_stats.bcn);
 
-               if (is_end) {
+               if (is_end)
                        complete(&ar->fw_stats_done);
-                       num_bcn = 0;
-               }
        }
 }