From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796191623; b=dFkLv73TMDulzO+hXFqLEmJP0ThpP+NI1uiFufQiDRQDILqhX8409ZZotoiHbFQ+pvHE /nyzYQpsXMS/KWucYjBAHuqsO0rV1jBjvlTC7xrHR/lA7+pbLZGD0YpYiyQ4TLfyHwMke Xqq0Hw8QK+hxdyPlddQ1jYW1L9e04KeWYprgVL6K9Z+vNHeny38iSE46vjDAsdPlg8pW9 pwQPgj4UCg0Yhs07wBndEsM4x/KCQTRcQ1hkY2/V79+cRi24us8ON4G2AqM37U8fyAVfb yDFBCaS751IJ1rihzAJ2uV6OedMUziW6XPv2Rl+gEsfMzZ/0nHlHVUQOMaUyhbIjwBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796191623; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=bQt0VAep183rvNFyOIMILbV4nARwBAql9nHmAR0gqVs=; b=Rd6RhPckVuFBrX+QZepDI04/Q0VLKa11/8gbzCOcNP/qh7A92DzWkTX+z7tdbDoRsbMJ V61qU1cPLi1GHS1r2uMBeSmgucetvzuv7/V4JnFWjrh5k6NvGeQVriUeZHeN9nSK/awGP csC4DzU8dIPEXn9ObFBSGTaT5M+heECdTzBew/WB6VjawaIRduNg9lLNAYI0EzdeZMXsg QjTTFElFvRyDc0Z/W20eW/UymZBLcFCbtpn2IGkyXMCfnw0DoV1ldITdOVqNLjgAE22uw VOCjM3tSdVALrlVsuvIvsAxWdvwf9bb2e5VaOsAZlK6kpDVx4U7gOSiGijALYe6KrtA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xCfGDQKl; arc=none smtp.remote-ip=209.85.210.170 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CB02606A32E for ; Wed, 2 Dec 2026 06:07:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8CB02606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xCfGDQKl Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8b904d10882so5247219b3a.0 for ; Tue, 01 Dec 2026 22:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796191623; x=1796796423; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bQt0VAep183rvNFyOIMILbV4nARwBAql9nHmAR0gqVs=; b=xCfGDQKlUwLO2wc9aIDkq/n1CovHVqA2aJFX21dK2UQ8q1IO3MOdojuE5zzzvgiuSY hdxidp9zYrJyWO/1q7RbjgnuF7PFtIfR752vcAec79gBINrVQnJEYPTfLFyFSMPwk9G4 2hm8884gqgtH7sG8bexe6Q/MpauonqAzc4QdN34fJ17PuuRWBTaSFNR0GqZrHBq1PyiF SPfNnsZwgzfRBpPM7q+kSEJ4fKyf6Ykys4Y/nGaEgFIq+rYjE7U//WvjVGrCFw5r7u93 Vj2ND7x7jLrQtpwJ/2u+kIW8GPc49j4wBQZG1olFIBgt6yj3PPS4m5/0XUH777utwLqR xXOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796191623; x=1796796423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bQt0VAep183rvNFyOIMILbV4nARwBAql9nHmAR0gqVs=; b=Nnwz/wFChjNCSYwHgbdlVTwYeBrYUjnoYWgd3jEFmmei3YW7H/sg8JcdZWrhAMesrm zfu4KUM/MIL2kZu2bF/FqhMJYEsv0fWrvZboWxXpUR05ENna4+YydA18afQJ8j3DzZs1 T2tFnsPhoc5PcUZQMJcYnPYB8Uj7d0oWNGVgX3MmajRJxbPgckz08b2AJhc7cZxEP8pe 2pZ8YFP4gU/r2rnnCqgY9SsuJSHKXdgUIPvSIREGfVrAjOdkR5cANbVjhQRqGs5Unjba bzyJZ52ZfDt/lpPnpDe8gDwr2+hBmdcvYYKvcVjbWpmCYMJebUehd7z7KYlK4yXFhe11 h3OA== X-Gm-Message-State: APuU4Z9vtKBwpEu/naVidX3vCl8sYsCo4ibiqcotDxH9Jp98kkMY9Rz4 YmJckpweoKj3Ua8mL797adlv3TKmACoWm7djDc4d16XM108z1Q3+bwFp X-Gm-Gg: AZFdTZcH8vuUq5fY7TzUile2+/EtNiFvkxwQD1ALOyYABa3xooG2+87CidFqea9gYb6 1/Yi8lr4PSPtszZZfU9pqaa3EhBs+aC3X/iAmFULfwy/5LKgxRAFZYxMxV4uRHgpxVWbol6irju uhPvUkd3ETIIjAlKwM/j/evXkZcG9J4+9JiKjx+N8so10flBmhjiyeUYM/HEBFqXKLsY7Tdzkuu 5V3sSEDy1XLWqeLKT8QDhEM/rADy1Hy9tSKzNgJR2utrp3hN4vcCTyZSrpWyCdO6ePL2Je3H30u /p5htbBa30YbwVKRscA2J3ctC36kq97tzJ/XFS8+aEgX3eDE2ZXcECq3N/NhcGp+iTTDP1YQV+b xirbecKDDFruSlhcZ7NvPsXByekT+dP8Q+b9sQZ+rYPbek+yXijoUF3dZXSKdqsZsLIJWU2x0d9 JYz2I9OEkeLzgTnzK7n1jTS6vveB9SdCYXkb0+78nlES37jyOAh1MixtsYNYWtkeepVoVTK/+ER 4SAC5CtfGeV/cesgFEAOD50MNQPkXfdX0F7aLomugNttLhYFXJ6Qq0ahA8Kx0oo/terRoDFWJwm McFOKvPjvCxgaEw5uojIO2kPeuEcEOraCXoc1nG64rLUihEEen5JETqClZfVqXeERXxIvFnBtDd GtQg6xLdKwk6D/nx4wjaZaE7wLCy8BOGkmF64vMWExtjtWLeM+VtkP1B+GG3ZeMiZylt2wfbQCN xCWvqsqqL6bklWdC3BwtGL8g== X-Received: by 2002:a05:6a00:39a3:b0:8a0:59d2:7d41 with SMTP id d2e1a72fcca58-8c87dcdf45cmr40309577b3a.56.1796191622569; Tue, 01 Dec 2026 22:07:02 -0800 (PST) Received: from LAPTOP-3B99V33A ([240c:c983:10:3f3:204f:902a:c2ed:bb15]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8cc4eb26293sm17592371b3a.16.2026.12.01.22.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 22:07:02 -0800 (PST) From: "Bin Luo (University of Electronic Science and Technology of China)" To: stf_xl@wp.pl, johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] wifi: rt2x00: prevent txstatus_timer rearm during USB uninitialize Date: Wed, 2 Dec 2026 14:06:52 +0800 Message-ID: <20261202060652.976-1-luob87709@gmail.com> X-Mailer: git-send-email 2.51.0.windows.1 In-Reply-To: <20261126065132.971-1-luob87709@gmail.com> References: <20261126065132.971-1-luob87709@gmail.com> X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit (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 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 txdone_work/txstatus_timer, or would you also like rt2x00lib_disable_radio() / rt2800_txstatus_timeout() adjusted to flush pending TX entries faster? Best regards, Bin Luo