[PATCH 2/2] wifi: ath11k: Fix race condition during stats processing

Yury Vostrikov mon at unformed.ru
Thu Nov 21 05:44:24 PST 2024


This diff fixes the race condition in stats processing. This race
condition results in an unbounded loop of stats requests. The loop
results in poor network performance because FW is busy with those
extra requests. The timeout of ath11k_debugfs_fw_stats_request
should be the upper bound of how long the driver retries stats.
However, sometimes some other code keeps calling failing
ath11k_debugfs_fw_stats_request, repeating a vicious cycle
indefinitely.

ath11k_debugfs_fw_stats_process assumes that num_vdev is always
less or equal to total_vdevs_started. This is not true. I've
captured the state of num_vdev and total_vdev_started during the
re-association request:

ath11k_pci 0000:01:00.0: wmi num_vdev:1 total_vdevs_started:0
ath11k_pci 0000:01:00.0: wmi num_vdev:2 total_vdevs_started:0
ath11k_pci 0000:01:00.0: wmi num_vdev:3 total_vdevs_started:1
ath11k_pci 0000:01:00.0: wmi num_vdev:4 total_vdevs_started:1
[...]
ath11k_pci 0000:01:00.0: wmi num_vdev:116 total_vdevs_started:1
[...]

This diff fixes the check to account for this and also adds a warning.
---
 drivers/net/wireless/ath/ath11k/debugfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wireless/ath/ath11k/debugfs.c
index 436197113ced..ec4683695e73 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -132,7 +132,9 @@ void ath11k_debugfs_fw_stats_process(struct ath11k *ar, struct ath11k_fw_stats *
 				total_vdevs_started += ar->num_started_vdevs;
 		}
 
-		is_end = ((++num_vdev) == total_vdevs_started);
+		is_end = ((++num_vdev) >= total_vdevs_started);
+		if (num_vdev > total_vdevs_started)
+			ath11k_warn(ab, "spurious stats");
 
 		list_splice_tail_init(&stats->vdevs,
 				      &ar->fw_stats.vdevs);
-- 
2.39.5




More information about the ath11k mailing list