Skip to content

Commit 2bcf73b

Browse files
Baochen Qiangjeff-t-johnson
authored andcommitted
wifi: ath11k: don't use static variables in ath11k_debugfs_fw_stats_process()
Currently ath11k_debugfs_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, we will fail due to the condition above will never be satisfied. The same applies to num_bcn as well. Change to use non-static counters so that we have a chance to clear them each time firmware stats is requested. Currently only ath11k_fw_stats_request() and ath11k_debugfs_fw_stats_request() are requesting firmware stats, so clear counters there. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.37 Fixes: da3a9d3 ("ath11k: refactor debugfs code into debugfs.c") Signed-off-by: Baochen Qiang <[email protected]> Acked-by: Kalle Valo <[email protected]> Reviewed-by: Vasanthakumar Thiagarajan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jeff Johnson <[email protected]>
1 parent 9f6e82d commit 2bcf73b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,8 @@ struct ath11k_fw_stats {
600600
struct list_head pdevs;
601601
struct list_head vdevs;
602602
struct list_head bcn;
603+
u32 num_vdev_recvd;
604+
u32 num_bcn_recvd;
603605
};
604606

605607
struct ath11k_dbg_htt_stats {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ static void ath11k_debugfs_fw_stats_reset(struct ath11k *ar)
9898
spin_lock_bh(&ar->data_lock);
9999
ath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);
100100
ath11k_fw_stats_vdevs_free(&ar->fw_stats.vdevs);
101+
ar->fw_stats.num_vdev_recvd = 0;
102+
ar->fw_stats.num_bcn_recvd = 0;
101103
spin_unlock_bh(&ar->data_lock);
102104
}
103105

@@ -106,7 +108,6 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *
106108
struct ath11k_base *ab = ar->ab;
107109
struct ath11k_pdev *pdev;
108110
bool is_end;
109-
static unsigned int num_vdev, num_bcn;
110111
size_t total_vdevs_started = 0;
111112
int i;
112113

@@ -131,15 +132,14 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *
131132
total_vdevs_started += ar->num_started_vdevs;
132133
}
133134

134-
is_end = ((++num_vdev) == total_vdevs_started);
135+
is_end = ((++ar->fw_stats.num_vdev_recvd) == total_vdevs_started);
135136

136137
list_splice_tail_init(&stats->vdevs,
137138
&ar->fw_stats.vdevs);
138139

139-
if (is_end) {
140+
if (is_end)
140141
complete(&ar->fw_stats_done);
141-
num_vdev = 0;
142-
}
142+
143143
return;
144144
}
145145

@@ -151,15 +151,13 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *
151151
/* Mark end until we reached the count of all started VDEVs
152152
* within the PDEV
153153
*/
154-
is_end = ((++num_bcn) == ar->num_started_vdevs);
154+
is_end = ((++ar->fw_stats.num_bcn_recvd) == ar->num_started_vdevs);
155155

156156
list_splice_tail_init(&stats->bcn,
157157
&ar->fw_stats.bcn);
158158

159-
if (is_end) {
159+
if (is_end)
160160
complete(&ar->fw_stats_done);
161-
num_bcn = 0;
162-
}
163161
}
164162
}
165163

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9391,6 +9391,8 @@ static int ath11k_fw_stats_request(struct ath11k *ar,
93919391

93929392
spin_lock_bh(&ar->data_lock);
93939393
ath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs);
9394+
ar->fw_stats.num_vdev_recvd = 0;
9395+
ar->fw_stats.num_bcn_recvd = 0;
93949396
spin_unlock_bh(&ar->data_lock);
93959397

93969398
reinit_completion(&ar->fw_stats_complete);

0 commit comments

Comments
 (0)