From: "David Härdeman" <david@hardeman.nu>
To: Ping-Ke Shih <pkshih@realtek.com>, linux-wireless@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
"Leonard Lausen" <leonard@lausen.nl>,
"Alastair D'Silva" <alastair@d-silva.org>,
"Luka Gejak" <luka.gejak@linux.dev>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Bitterblue Smith" <rtl8821cerfe2@gmail.com>,
"David Härdeman" <david@hardeman.nu>
Subject: [PATCH rtw-next 4/5] wifi: rtw88: sdio: let TX in while receiving on the 88xx chips
Date: Mon, 16 Nov 2026 20:01:44 +0100 [thread overview]
Message-ID: <20261116190145.2736364-5-david@hardeman.nu> (raw)
In-Reply-To: <20261116190145.2736364-1-david@hardeman.nu>
The interrupt handler reads RX data for up to 64 KiB per interrupt while
it holds the host, and the TX work waits for the host meanwhile. At
SDR104 speeds an RTL8822CS spends most of the bus time on the per
transfer overhead, so when a client sends at full rate, the RX path
takes about 80% of the bus and leaves too little for TX. On a NanoPi
R76S acting as an AP, with TCP traffic in both directions, the AP sends
at only 20-35 Mbit/s while it receives at 165-220 Mbit/s.
When frames are waiting to be sent, stop reading after 8 KiB, about one
RX aggregate, so the TX work gets the host between reads; the handler
runs again for the rest. Without TX frames waiting, it still reads up
to 64 KiB. The 8051 chips keep their behaviour.
With traffic in both directions, the R76S now sends at 70-85 Mbit/s
while receiving at 100-120 Mbit/s, steadily over each run. The sum is
somewhat lower, as sending costs more bus time than receiving, and
one-way throughput doesn't change. Realtek's driver shows the same
imbalance as before (about 40 + 180 Mbit/s on the same setup).
Signed-off-by: David Härdeman <david@hardeman.nu>
---
drivers/net/wireless/realtek/rtw88/sdio.c | 39 ++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c
index cced6fdfa6d..a7664486613 100644
--- a/drivers/net/wireless/realtek/rtw88/sdio.c
+++ b/drivers/net/wireless/realtek/rtw88/sdio.c
@@ -34,6 +34,14 @@
#define RTW_SDIO_88XX_TX_FIFO_LOWATER 32
#define RTW_SDIO_TX_RETRY_DELAY msecs_to_jiffies(1)
+/*
+ * The interrupt handler holds the host while it reads RX data. Bound how much
+ * it reads per interrupt, and with frames waiting to be sent, let the TX path
+ * have the host after a smaller amount.
+ */
+#define RTW_SDIO_RX_BUDGET SZ_64K
+#define RTW_SDIO_RX_BUDGET_TX_PENDING SZ_8K
+
static bool rtw_sdio_is_bus_addr(u32 addr)
{
return !!(addr & RTW_SDIO_BUS_MSK);
@@ -1597,6 +1605,34 @@ static void rtw_sdio_rxfifo_recv(struct rtw_dev *rtwdev, u32 rx_len)
}
}
+static bool rtw_sdio_tx_pending(struct rtw_dev *rtwdev)
+{
+ struct rtw_sdio *rtwsdio = (struct rtw_sdio *)rtwdev->priv;
+ int queue;
+
+ for (queue = 0; queue <= RTW_TX_QUEUE_VO; queue++)
+ if (!skb_queue_empty(&rtwsdio->tx_queue[queue]))
+ return true;
+
+ return false;
+}
+
+static bool rtw_sdio_rx_budget_left(struct rtw_dev *rtwdev, u32 rx_bytes)
+{
+ if (rx_bytes >= RTW_SDIO_RX_BUDGET)
+ return false;
+
+ /*
+ * The 8051 chips send one frame per transfer and are not limited by
+ * the bus in the same way, keep their behaviour.
+ */
+ if (rtw_chip_wcpu_8051(rtwdev))
+ return true;
+
+ return rx_bytes < RTW_SDIO_RX_BUDGET_TX_PENDING ||
+ !rtw_sdio_tx_pending(rtwdev);
+}
+
static void rtw_sdio_rx_isr(struct rtw_dev *rtwdev)
{
u32 rx_len, hisr, total_rx_bytes = 0;
@@ -1631,7 +1667,8 @@ static void rtw_sdio_rx_isr(struct rtw_dev *rtwdev)
*/
hisr = REG_SDIO_HISR_RX_REQUEST;
}
- } while (total_rx_bytes < SZ_64K && hisr & REG_SDIO_HISR_RX_REQUEST);
+ } while (rtw_sdio_rx_budget_left(rtwdev, total_rx_bytes) &&
+ hisr & REG_SDIO_HISR_RX_REQUEST);
}
static void rtw_sdio_handle_interrupt(struct sdio_func *sdio_func)
--
2.47.3
next prev parent reply other threads:[~2026-11-16 19:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 19:01 [PATCH rtw-next 0/5] wifi: rtw88: sdio: faster and fairer TX for the 88xx chips David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 1/5] wifi: rtw88: sdio: cache the free TX page counts of " David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 2/5] wifi: rtw88: sdio: aggregate TX frames " David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 3/5] wifi: rtw88: sdio: limit the TX queue length " David Härdeman
2026-11-16 19:01 ` David Härdeman [this message]
2026-11-16 19:01 ` [PATCH rtw-next 5/5] wifi: rtw88: sdio: read neighbouring registers of the 88xx chips at once David Härdeman
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=20261116190145.2736364-5-david@hardeman.nu \
--to=david@hardeman.nu \
--cc=alastair@d-silva.org \
--cc=jernej.skrabec@gmail.com \
--cc=leonard@lausen.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=luka.gejak@linux.dev \
--cc=martin.blumenstingl@googlemail.com \
--cc=pkshih@realtek.com \
--cc=rtl8821cerfe2@gmail.com \
/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