[PATCH 1/2] wifi: ath11k: Fix 2 second busywait during stats request

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


This diff fixes a 2-second busy loop inside
the ath11k_debugfs_fw_stats_request function. The code in question was
added during the initial import of the ath11 driver. While the ath11 code
is based on ath10, the latter doesn't have this bug. This diffs changes
the wait loop to be similar to the ath10 driver. It also adds an explicit
delay before retrying. An explicit delay avoids spamming FW with stats
requests.
---
 drivers/net/wireless/ath/ath11k/debugfs.c | 33 +++++++++++------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wireless/ath/ath11k/debugfs.c
index 57281a135dd7..436197113ced 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -182,24 +182,22 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k *ar,
 
 	ath11k_debugfs_fw_stats_reset(ar);
 
-	reinit_completion(&ar->fw_stats_complete);
-
-	ret = ath11k_wmi_send_stats_request_cmd(ar, req_param);
-
-	if (ret) {
-		ath11k_warn(ab, "could not request fw stats (%d)\n",
-			    ret);
-		return ret;
-	}
-
-	time_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ);
-
-	if (!time_left)
-		return -ETIMEDOUT;
-
 	for (;;) {
-		if (time_after(jiffies, timeout))
-			break;
+		if (time_after(jiffies, timeout)) {
+			ath11k_warn(ab, "could not request fw stats, timeout\n");
+			return -ETIMEDOUT;
+		}
+
+		reinit_completion(&ar->fw_stats_complete);
+
+		ret = ath11k_wmi_send_stats_request_cmd(ar, req_param);
+		if (ret) {
+			ath11k_warn(ab, "could not request fw stats (%d)\n",
+				    ret);
+			return ret;
+		}
+
+		time_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ);
 
 		spin_lock_bh(&ar->data_lock);
 		if (ar->fw_stats_done) {
@@ -207,6 +205,7 @@ static int ath11k_debugfs_fw_stats_request(struct ath11k *ar,
 			break;
 		}
 		spin_unlock_bh(&ar->data_lock);
+		msleep(200);
 	}
 	return 0;
 }
-- 
2.39.5




More information about the ath11k mailing list