The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Bin Luo via B4 Relay <devnull+luob87709.gmail.com@kernel.org>
To: Stanislaw Gruszka <stf_xl@wp.pl>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	 linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH wireless v3 1/2] wifi: rt2x00: set DEVICE_STATE_FLUSHING in rt2x00queue_flush_queues()
Date: Fri, 04 Dec 2026 14:06:48 +0800	[thread overview]
Message-ID: <20261204060647.476-2-luob87709@gmail.com> (raw)
In-Reply-To: <20261204060647.476-1-luob87709@gmail.com>

From: "Bin Luo (University of Electronic Science and Technology of China)" <luob87709@gmail.com>

rt2x00lib_disable_radio() flushes all queues via rt2x00queue_flush_queues()
before teardown and uninitialization, but unlike rt2x00mac_flush() it does
not set DEVICE_STATE_FLUSHING.

Without DEVICE_STATE_FLUSHING, rt2800_entry_txstatus_timeout() uses the
2000 ms timeout while rt2x00usb_flush_queue() only waits 10 * 50 ms
(500 ms).  As a result, any TX entry whose bulk-OUT URB completed without
a TX_STA_FIFO report (or was cancelled by rt2x00usb_flush_entry(), since
rt2800_txstatus_timeout() gates entry into rt2800_txdone_nostatus()) is
not drained during disable_radio(), printing "Queue 0 failed to flush"
and leaving rt2800_txstatus_pending() true when rt2x00usb_uninitialize()
runs.

Set DEVICE_STATE_FLUSHING around the TX queue flush loop in
rt2x00queue_flush_queues() so pending TX entries time out after 50 ms and
are drained before work and timers are cancelled.

Fixes: adf26a356f13 ("rt2x00: use different txstatus timeouts when flushing")
Signed-off-by: Bin Luo (University of Electronic Science and Technology of China) <luob87709@gmail.com>
---
Changes in v3:
- Resend cleanly via b4 web relay (v2 was line-wrapped by Gmail);
  no code changes from v2.

Changes in v2:
- Per Stanislaw Gruszka's review, fix the original issue by setting
  DEVICE_STATE_FLUSHING in rt2x00queue_flush_queues() so TX queues drain
  before teardown cancels work/timers, and move the separate TX_STA_FIFO
  URB error/teardown handling fix into patch 2/2.

Validation:
- scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks
- W=1 KASAN+LOCKDEP build of rt2x00queue.o: 0 warnings, 0 errors
- QEMU KVM (v7.4-rc4, KASAN+LOCKDEP) with dummy_hcd + raw_gadget
  emulating an RT2872 USB device: both sysfs unbind and physical USB
  disconnect drain Queue 0 within ~50 ms (rt2800_txstatus_pending() == 0)
  with 0 "Queue 0 failed to flush" warnings.

 drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
index 4b84249..3900ef3 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
@@ -1058,9 +1058,13 @@ void rt2x00queue_flush_queues(struct rt2x00_dev *rt2x00dev, bool drop)
 {
 	struct data_queue *queue;
 
+	set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
+
 	tx_queue_for_each(rt2x00dev, queue)
 		rt2x00queue_flush_queue(queue, drop);
 
+	clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
+
 	rt2x00queue_flush_queue(rt2x00dev->rx, drop);
 }
 EXPORT_SYMBOL_GPL(rt2x00queue_flush_queues);
-- 
2.43.0




  reply	other threads:[~2026-12-04  6:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  6:06 [PATCH wireless v3 0/2] wifi: rt2x00: fix TX queue flush and TX_STA_FIFO teardown Bin Luo via B4 Relay
2026-12-04  6:06 ` Bin Luo via B4 Relay [this message]
2026-12-04  6:06 ` [PATCH wireless v3 2/2] wifi: rt2x00: prevent TX_STA_FIFO URB resubmission on error and teardown Bin Luo via B4 Relay

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=20261204060647.476-2-luob87709@gmail.com \
    --to=devnull+luob87709.gmail.com@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luob87709@gmail.com \
    --cc=stf_xl@wp.pl \
    /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