mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Alastair D'Silva <alastair@d-silva.org>,
	Kalle Valo <kvalo@kernel.org>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] wifi: rtw88: sdio: Fix unhandled RX request interrupt storm
Date: Tue, 29 Sep 2026 09:20:20 +0000	[thread overview]
Message-ID: <a90352f8a1e74c538b605ac4eed64675@realtek.com> (raw)
In-Reply-To: <242775cb0b45938c0138ae256073bbd9088c02c2.camel@d-silva.org>

Alastair D'Silva <alastair@d-silva.org> wrote:
> Instead of overhauling the driver for NAPI, this race condition can be solved
> cleanly and robustly using the IMR masking suggestion from your internal team:
> In rtw_sdio_handle_interrupt():
>     hisr = rtw_read32(rtwdev, REG_SDIO_HISR);
>     if (!hisr)
>         return;
>     /* Mask interrupts and acknowledge pending status bits */
>     rtw_sdio_disable_interrupt(rtwdev);
>     rtw_write32(rtwdev, REG_SDIO_HISR, hisr);
>     if (hisr & REG_SDIO_HISR_TXERR)
>         rtw_sdio_tx_err_isr(rtwdev);
>     if (hisr & REG_SDIO_HISR_RX_REQUEST)
>         rtw_sdio_rx_isr(rtwdev);
>     /* Re-enable interrupts: if new packets arrived during rx_isr,
>      * REG_SDIO_HISR_RX_REQUEST was asserted in hardware; unmasking HIMR
>      * immediately asserts SDIO DAT[1], causing ksdioirqd to run another pass.
>      */
>     rtw_sdio_enable_interrupt(rtwdev);

Yes, I prefer this kind of flow as well. It looks very similar to what PCI does.

> 
> I prefer this approach as:
> 1. It completely closes the race window: any packet arriving during FIFO drainage
>    latches REG_SDIO_HISR_RX_REQUEST in hardware. When rtw_sdio_enable_interrupt()
>    restores HIMR, the interrupt line is asserted and ksdioirqd immediately
>    services the new packet.

Please do the same experiments to ensure it doesn't get stuck in FIFO.


> 2. The overhead of toggling HIMR is just two 4-byte CMD52/CMD53 writes
>    (~1-2 microseconds total per interrupt burst), which is negligible (<0.1%)
>    compared to transferring payload data over SDIO.

I have lack knowledge of SDIO, so I can't judge this.
Can you design experiments as evidence?


> 3. It uses the existing rtw_sdio_disable_interrupt() and rtw_sdio_enable_interrupt()
>    helpers and requires only ~4 lines of code changes without touching rx_isr.

Make sense. Only IMR is affected. 

> 
> Alternatively, if we prefer not to touch HIMR, we can perform a drain-and-recheck
> inside rtw_sdio_rx_isr():
>   when rx_len reads 0, issue W1C to REG_SDIO_HISR_RX_REQUEST and immediately re-read
> REG_SDIO_RX0_REQ_LEN.
>   If it reads > 0, continue draining, otherwise break.

Honestly I don't read and think this in detail, but I can't understand it can
avoid racing. As you are not a fan of this approach, just ignore this.

> 
> Toggling HIMR as outlined above is the cleanest and most standard pattern.
> Please let me know if this approach is acceptable to you, and I will prepare
> and submit v2.

I'm okay this the proposal. 

I heard from internal that some weak platforms might want this kind of 
"busy polling" to yield performance. Maybe, we can design another alternative
ways if sometime people encounter problem. Or you have another thought now?

Ping-Ke


      reply	other threads:[~2026-09-29  9:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16  4:06 Alastair D'Silva
2026-09-17  7:59 ` Ping-Ke Shih
2026-09-17  9:09   ` Ping-Ke Shih
2026-09-17 10:04     ` Alastair D'Silva
2026-09-21  2:44       ` Ping-Ke Shih
2026-09-21  9:17         ` Alastair D'Silva
2026-09-22  1:25           ` Ping-Ke Shih
2026-09-29  4:03             ` Alastair D'Silva
2026-09-29  9:20               ` Ping-Ke Shih [this message]

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=a90352f8a1e74c538b605ac4eed64675@realtek.com \
    --to=pkshih@realtek.com \
    --cc=alastair@d-silva.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=stable@vger.kernel.org \
    /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®