Skip to contentSkip to conversation

wifi: ath9k_htc: count a frame as queued before it is sent

PATCH Superseded Mehmet Fide 2 participants 3 messages Nov 11 – Nov 17 Qualcomm Atheros ATH9K wireless driver

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: ath9k_htc: count a frame as queued before it is sent

From: Mehmet Fide <[email protected]>

ath9k_htc_tx() hands the frame to the device and counts it in tx.queued_cnt afterwards. The TX status of the frame is handled in the WMI event tasklet, which can run before the sender gets to the counter. ath9k_htc_tx_process() then takes the counter below zero, warns and sets it to zero, and the sender's increment leaves it one too high for good:

WARNING: CPU: 0 PID: 348 at drivers/net/wireless/ath/ath9k/htc_drv_txrx.c:510 ath9k_htc_tx_process+0x400/0x558 [ath9k_htc]
Call trace:
 ath9k_htc_tx_process+0x400/0x558 [ath9k_htc]
 ath9k_htc_txstatus+0x58/0x140 [ath9k_htc]
 ath9k_wmi_event_tasklet+0x16c/0x17c [ath9k_htc]
 tasklet_action_common+0x108/0x150

Count the frame before it is sent and take it back if the send fails.

Fixes 8e86a54715c4 ("ath9k_htc: Fix TX queue management")
---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +6 -2
index 0d6272ac0dac..ee87352d1241 100644
@@ -888,17 +888,21 @@ static void ath9k_htc_tx(struct ieee80211_hw *hw,
 		goto fail_tx;
 	}
 
+	ath9k_htc_check_stop_queues(priv);
+
 	ret = ath9k_htc_tx_start(priv, control->sta, skb, slot, false);
 	if (ret != 0) {
 		ath_dbg(common, XMIT, "Tx failed\n");
 		goto clear_slot;
 	}
 
-	ath9k_htc_check_stop_queues(priv);
-
 	return;
 
 clear_slot:
+	spin_lock_bh(&priv->tx.tx_lock);
+	priv->tx.queued_cnt--;
+	spin_unlock_bh(&priv->tx.tx_lock);
+	ath9k_htc_check_wake_queues(priv);
 	ath9k_htc_tx_clear_slot(priv, slot);
 fail_tx:
 	dev_kfree_skb_any(skb);

base-commit: ff4c7359e310744a7abe53cf66d921fa2969eb19

Signature · 1 line
2.56.0
#1 lore raw

drivers/net/wireless/ath/ath9k/htc_drv_main.c static void ath9k_htc_tx(struct ieee80211_hw *hw, · line 905

Quoted 12 lines · Mehmet Fide
drivers/net/wireless/ath/ath9k/htc_drv_main.c +0 -0
index b46be3682f21..9467b8e512a6 100644
@@ -888,17 +888,21 @@ static void ath9k_htc_tx(struct ieee80211_hw *hw,

[ ... skip 14 lines ... ]

clear_slot:

drivers/net/wireless/ath/ath9k/htc_drv_main.c +4 -0
+	spin_lock_bh(&priv->tx.tx_lock);
+	priv->tx.queued_cnt--;
+	spin_unlock_bh(&priv->tx.tx_lock);
+	ath9k_htc_check_wake_queues(priv);

Hmm, so this results in taking the lock twice, once for decrementing and once for checking. How about we define a __ath9k_htc_check_wake_queues() function which takes a boolean "decrement" as the second parameter, and does the decrement under the lock if set? Then we can turn ath9k_htc_check_wake_queues(priv) into a wrapper which just calls __ath9k_htc_check_wake_queues(priv, false).

-Toke

#2 lore raw

Hi Toke,

Quoted 4 lines

How about we define a __ath9k_htc_check_wake_queues() function which takes a boolean "decrement" as the second parameter, and does the decrement under the lock if set? Then we can turn ath9k_htc_check_wake_queues(priv) into a wrapper which just calls __ath9k_htc_check_wake_queues(priv, false).

Sure, will do in v2.

Mehmet