From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=212.77.101.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796198748; b=LPp+Vhh7qTwRlmv+e1wfInTb0GvxSX4/oeGPpB2ZcVD0Sr2gmCDIywFQYchwIC8CF/Q0 MNI1IwyqvfspDenHym/YIKnR4e4UeJcOHkojU//ZeEv9+qAY8xhi3J0rWuOq+UqLC5+fI Xc+rR7Y5TuNyc5X01KUQ6ux9SzsQkL3UXR0etDSIAZWV9IssqMIFx5KjkBTf+fMZRq0Xn L1FY6rnIXBIYjk0U7BOSq0S/PUz/R+tjjMkTKF4xJcUGInqGuH09+cccq+oB7OxDpxcCJ pVIbRU+YXkplA2LRZHKMyZwx3KsDG7jqQpAvKlvBgGdaYGpZcCZ2H0hCuPdD+jrWkLg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796198748; h=DMARC-Filter:Received:DKIM-Signature:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-WP-MailID:X-WP-AV:X-WP-SPAM; bh=uTq87lTXvfEV2ekY9lStWb8GOHJRpIuOJ3w3K+rRDfw=; b=mxw6y8qFgdrgPB04RTWDD6G2+xJp0PO7OM7n8kjTrIXiYQ2dvXmUpNdkC90QkMVPfmqz CzneqR9TORRyldbL0BPQMF0J3//aVHbdnGauzJlhTwSbVwNVMQDcZZVus0sh09S79BY+8 F6uA6F1AUmgsKu09Pr/iDE49jHFD9XUALn/9ub7RTVnaTi9MMPsM9q/A0BHNWV1GCi8bx GAZfsLPHZciaFL837MA1qBmTAE6JaAu9KjLrvLUJTtRiylMZfyiALn+OV7M5Bg5VB/ZEW nriM92ep8iZk3l/1G7vjFlTRYEhQoK1IGhDaqMclAXosdnDdDgIYLVmDsyDy17g88EA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass header.d=wp.pl header.i=@wp.pl header.a=rsa-sha256 header.s=s20261130 header.b=FdyrJP7z; arc=none smtp.remote-ip=212.77.101.11 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09E41606A31A for ; Wed, 2 Dec 2026 08:05:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 09E41606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=wp.pl header.i=@wp.pl header.a=rsa-sha256 header.s=s20261130 header.b=FdyrJP7z Received: (wp-smtpd smtp.wp.pl 29669 invoked from network); 2 Dec 2026 09:05:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=s20261130; t=1796198740; bh=uTq87lTXvfEV2ekY9lStWb8GOHJRpIuOJ3w3K+rRDfw=; h=From:To:Cc:Subject; b=FdyrJP7z9MEw/M/qxlsmP7ywcKUBtUcJEubkGG1NtRgZg9sUwapmjo/+cZxDzSmNo iK7iJ7cnGWwnZiSDM1QHr8+Kpiru/knfMdefLgN+qdknG+W83oDBW+IlkhUfAHuY0o wENemVhGoLlOYpdTYr9NvRPmiCMfTo6dkSCFCQGqg5F14Go7v64Cz7aiSy+pFCD2J6 7SaqhZ1fpO8XF7QJU7pSsfSiEJHFc7uhgV1kmbSJc5Wc0xg/e6qcPVH55iJv6dLuDz retb8XiojbYAIQutbLuIG1zA1sjLXpIKZr29xc2tUHvFwwNiOS+sdY6hzYr4+BVvZ/ vN8uIBic2ilcA== Received: from localhost (77-236-5-223.static.play.pl [77.236.5.223]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with TLS_AES_256_GCM_SHA384 encrypted SMTP for ; 2 Dec 2026 09:05:39 +0100 Date: Wed, 2 Dec 2026 09:05:39 +0100 From: Stanislaw Gruszka To: "Bin Luo (University of Electronic Science and Technology of China)" Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] wifi: rt2x00: prevent txstatus_timer rearm during USB uninitialize Message-ID: References: <20261126065132.971-1-luob87709@gmail.com> <20261202060652.976-1-luob87709@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202060652.976-1-luob87709@gmail.com> X-WP-MailID: aa2dba5c6740315581614bc0af791f45 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [MaP0] On Wed, Dec 02, 2026 at 02:06:52PM +0800, Bin Luo (University of Electronic Science and Technology of China) wrote: > (Resending in plain text so it reaches the mailing lists.) > > Hi Stanislaw, > > On Wed, Dec 2, 2026 at 12:39 AM, Stanislaw Gruszka wrote: > > On Thu, Nov 26, 2026 at 02:51:32PM +0800, Bin Luo (University of Electronic Science and Technology of China) wrote: > > > rt2x00usb_uninitialize() cancels rt2x00dev->txstatus_timer before > > > calling cancel_work_sync(&rt2x00dev->txdone_work). Because > > > rt2800usb_work_txdone() calls rt2800usb_async_read_tx_status() and > > > > This is under condition: > > > > if (rt2800_txstatus_pending(rt2x00dev)) > > > > which should be false at this point, or I missed something? > > Thanks for the review! > > I tested this on an unmodified v7.4-rc4 kernel in QEMU using dummy_hcd + > raw_gadget emulating an RT2872 USB device (with kprobe tracing), and Could you provide link to the qemu driver and tests ? > rt2800_txstatus_pending(rt2x00dev) does indeed remain true when > rt2x00usb_uninitialize() runs. > > Here is why it stays true on both sysfs unbind and physical USB disconnect: > > 1. rt2x00lib_remove_dev() clears DEVICE_STATE_PRESENT and calls > rt2x00lib_disable_radio() -> rt2x00queue_flush_queues(rt2x00dev, true) -> > rt2x00usb_flush_queue(queue, true). > 2. Unlike rt2x00mac_flush(), rt2x00lib_disable_radio() does not set > DEVICE_STATE_FLUSHING (and rt2x00mac_flush() returns early once > DEVICE_STATE_PRESENT is cleared). > 3. Without DEVICE_STATE_FLUSHING, rt2800_entry_txstatus_timeout() uses the > 2000 ms timeout, whereas rt2x00usb_flush_queue() only loops > 10 * msleep(50) = 500 ms before returning with "Queue 0 failed to flush". > 4. Any TX entry whose bulk-OUT URB already completed within ~1.5 s without > a TX_STA_FIFO report (or even a bulk-OUT URB cancelled by > rt2x00usb_flush_entry() with ENTRY_DATA_IO_FAILED set, since > rt2800_txstatus_timeout() does not check ENTRY_DATA_IO_FAILED) is not > drained during the 500 ms flush, leaving Q_INDEX_DMA_DONE != Q_INDEX_DONE > (rt2800_txstatus_pending() == true) when rt2x00usb_uninitialize() runs. > > Here is the observed trace on unmodified v7.4-rc4 during sysfs unbind right > after a TX bulk-OUT URB completes without a TX_STA_FIFO entry: > > [ 31.778597] ieee80211 phy0: rt2x00queue_flush_queue: Warning - Queue 0 failed to flush > [ 31.780458] ieee80211 phy0: rt2800usb_tx_sta_fifo_read_completed: Warning - TX status read failed -2 > > rt2800usb_repro-84 [003] ... 31.778300: rt_flush_out: (rt2x00queue_flush_queue <- rt2x00usb_flush_queue) > pr/ttyS0-42 [000] ... 31.779332: rt_timer_cb: (rt2800usb_tx_sta_fifo_timeout) > pr/ttyS0-42 [000] ... 31.779341: rt_read_async: (rt2x00usb_register_read_async) > rt2800usb_repro-84 [003] ... 31.779845: rt_uninit_in: (rt2x00usb_uninitialize) > rt2800usb_repro-84 [003] ... 31.779913: rt_kill_urbs: (usb_kill_anchored_urbs) > rt2800usb_repro-85 [000] ... 31.780198: rt_fifo_cb_in: (rt2800usb_tx_sta_fifo_read_completed) urb_status=-2 > rt2800usb_repro-85 [000] ... 31.780531: rt_pending_ret: (rt2800usb_tx_sta_fifo_read_completed+0x171 <- rt2800_txstatus_pending) ret=0x1 > rt2800usb_repro-85 [000] ... 31.780567: rt_fifo_cb_out: (rt2x00usb_register_read_async_cb <- rt2800usb_tx_sta_fifo_read_completed) ret=0x1 > rt2800usb_repro-84 [003] ... 31.781440: rt_kill_urbs_out: (rt2x00usb_uninitialize <- usb_kill_anchored_urbs) > > Runtime testing also highlighted two additional details worth addressing in v2: > - At stop_reading: in rt2800usb_tx_sta_fifo_read_completed(), when > usb_kill_anchored_urbs() cancels the URB with -ENOENT, stop_reading: sees > rt2800_txstatus_pending() == true, re-sets TX_STATUS_READING, and returns > true to resubmit the killed URB (which fails with -EPERM and leaves > TX_STATUS_READING stuck set, e.g. across suspend/resume). > - In rt2x00usb_uninitialize(), usb_kill_anchored_urbs() runs before > hrtimer_cancel(&rt2x00dev->txstatus_timer), so a timer firing in between > can submit a fresh async TX_STA_FIFO URB after usb_kill_anchored_urbs() > has returned. > > Would you prefer that I send a v2 that also guards stop_reading: with > DEVICE_STATE_INITIALIZED and kills anchored URBs after stopping No, while related, this looks like different issue, I would prefer a separate patch with own description for it. > txdone_work/txstatus_timer, or would you also like rt2x00lib_disable_radio() / >rt2800_txstatus_timeout() adjusted to flush pending TX entries faster? I think assuring that tx queues are drained at the point we are canceling work would be better fix for original problem presented. Regards Stanislaw