From: Mehmet Fide <mehmet.fide@gmail.com>
To: "Toke Høiland-Jørgensen" <toke@toke.dk>
Cc: "John W . Linville" <linville@tuxdriver.com>,
Sujith Manoharan <Sujith.Manoharan@atheros.com>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
mehmet.fide@screeningeagle.com
Subject: [PATCH ath-next v2] wifi: ath9k_htc: count a frame as queued before it is sent
Date: Tue, 17 Nov 2026 08:16:20 +0100 [thread overview]
Message-ID: <20261117071620.1650281-1-mehmet.fide@gmail.com> (raw)
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
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. If the send fails, take the count
back and wake the queues it may have stopped, under one lock.
Fixes: 8e86a54715c4 ("ath9k_htc: Fix TX queue management")
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
v2:
- the count is taken back and the queues woken under one lock, in
__ath9k_htc_check_wake_queues() (Toke)
- rebased on ath9k-pending main
v1: https://lore.kernel.org/r/20261111215902.574916-1-mehmet.fide@gmail.com/
drivers/net/wireless/ath/ath9k/htc.h | 1 +
drivers/net/wireless/ath/ath9k/htc_drv_main.c | 5 +++--
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 9 ++++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 59e0b3cf7f0f..0aaa6a96b86e 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -581,6 +581,7 @@ int get_hw_qnum(u16 queue, int *hwq_map);
int ath_htc_txq_update(struct ath9k_htc_priv *priv, int qnum,
struct ath9k_tx_queue_info *qinfo);
void ath9k_htc_check_stop_queues(struct ath9k_htc_priv *priv);
+void __ath9k_htc_check_wake_queues(struct ath9k_htc_priv *priv, bool decrement);
void ath9k_htc_check_wake_queues(struct ath9k_htc_priv *priv);
int ath9k_htc_tx_get_slot(struct ath9k_htc_priv *priv);
void ath9k_htc_tx_clear_slot(struct ath9k_htc_priv *priv, int slot);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index b46be3682f21..3c52e66c79f4 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -888,17 +888,18 @@ 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:
+ __ath9k_htc_check_wake_queues(priv, true);
ath9k_htc_tx_clear_slot(priv, slot);
fail_tx:
dev_kfree_skb_any(skb);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index 95f48c7dca15..4369a17fb4d4 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -65,9 +65,11 @@ void ath9k_htc_check_stop_queues(struct ath9k_htc_priv *priv)
spin_unlock_bh(&priv->tx.tx_lock);
}
-void ath9k_htc_check_wake_queues(struct ath9k_htc_priv *priv)
+void __ath9k_htc_check_wake_queues(struct ath9k_htc_priv *priv, bool decrement)
{
spin_lock_bh(&priv->tx.tx_lock);
+ if (decrement)
+ priv->tx.queued_cnt--;
if ((priv->tx.queued_cnt < ATH9K_HTC_TX_THRESHOLD) &&
(priv->tx.flags & ATH9K_HTC_OP_TX_QUEUES_STOP)) {
priv->tx.flags &= ~ATH9K_HTC_OP_TX_QUEUES_STOP;
@@ -76,6 +78,11 @@ void ath9k_htc_check_wake_queues(struct ath9k_htc_priv *priv)
spin_unlock_bh(&priv->tx.tx_lock);
}
+void ath9k_htc_check_wake_queues(struct ath9k_htc_priv *priv)
+{
+ __ath9k_htc_check_wake_queues(priv, false);
+}
+
int ath9k_htc_tx_get_slot(struct ath9k_htc_priv *priv)
{
int slot;
base-commit: 465fcc982a221f774594aa7d7351fde8c03a3deb
--
2.56.0
reply other threads:[~2026-11-17 7:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117071620.1650281-1-mehmet.fide@gmail.com \
--to=mehmet.fide@gmail.com \
--cc=Sujith.Manoharan@atheros.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mehmet.fide@screeningeagle.com \
--cc=toke@toke.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®