[PATCH rtw-next v6 4/4] wifi: rtw88: sdio: Split rtw_sdio_rx_isr into 8051 and 3081 variants
From: Alastair D'Silva
Date: Wed Oct 14 2026 - 03:55:09 EST
Split rtw_sdio_rx_isr() into separate 8051 and 3081 variants to be
clear. The two differences between the architectures are:
- Register size: REG_SDIO_RX0_REQ_LEN is 16-bit on 8051, 32-bit on 3081.
- HISR behavior: 8051 re-reads REG_SDIO_HISR on each iteration, while
3081 drains based on rx_len without re-reading HISR.
This is a refactoring without any logic changes.
Assisted-by: LLM
Acked-by: Ping-Ke Shih <pkshih@xxxxxxxxxxx>
Reviewed-by: Luka Gejak <luka.gejak@xxxxxxxxx>
Signed-off-by: Alastair D'Silva <alastair@xxxxxxxxxxx>
---
drivers/net/wireless/realtek/rtw88/sdio.c | 58 +++++++++++++----------
1 file changed, 33 insertions(+), 25 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c
index e459541b7678..3569aae0f2f0 100644
--- a/drivers/net/wireless/realtek/rtw88/sdio.c
+++ b/drivers/net/wireless/realtek/rtw88/sdio.c
@@ -1439,17 +1439,13 @@ static int rtw_sdio_rxfifo_recv(struct rtw_dev *rtwdev, u32 rx_len)
return 0;
}
-static void rtw_sdio_rx_isr(struct rtw_dev *rtwdev)
+static void rtw_sdio_rx_isr_8051(struct rtw_dev *rtwdev)
{
u32 rx_len, hisr, total_rx_bytes = 0;
int ret;
do {
- if (rtw_chip_wcpu_8051(rtwdev))
- rx_len = rtw_read16(rtwdev, REG_SDIO_RX0_REQ_LEN);
- else
- rx_len = rtw_read32(rtwdev, REG_SDIO_RX0_REQ_LEN);
-
+ rx_len = rtw_read16(rtwdev, REG_SDIO_RX0_REQ_LEN);
if (!rx_len)
break;
@@ -1459,33 +1455,45 @@ static void rtw_sdio_rx_isr(struct rtw_dev *rtwdev)
total_rx_bytes += rx_len;
- if (rtw_chip_wcpu_8051(rtwdev)) {
- /* Stop if no more RX requests are pending, even if
- * rx_len could be greater than zero in the next
- * iteration. This is needed because the RX buffer may
- * already contain data while either HW or FW are not
- * done filling that buffer yet. Still reading the
- * buffer can result in packets where
- * rtw_rx_pkt_stat.pkt_len is zero or points beyond the
- * end of the buffer.
- */
- hisr = rtw_read32(rtwdev, REG_SDIO_HISR);
- } else {
- /* RTW_WCPU_3081 chips have improved hardware or
- * firmware and can use rx_len unconditionally.
- */
- hisr = REG_SDIO_HISR_RX_REQUEST;
- }
+ /*
+ * Stop if no more RX requests are pending, even if
+ * rx_len could be greater than zero in the next
+ * iteration. This is needed because the RX buffer may
+ * already contain data while either HW or FW are not
+ * done filling that buffer yet. Still reading the
+ * buffer can result in packets where
+ * rtw_rx_pkt_stat.pkt_len is zero or points beyond the
+ * end of the buffer.
+ */
+ hisr = rtw_read32(rtwdev, REG_SDIO_HISR);
} while (total_rx_bytes < SZ_64K && hisr & REG_SDIO_HISR_RX_REQUEST);
}
+static void rtw_sdio_rx_isr_3081(struct rtw_dev *rtwdev)
+{
+ u32 rx_len, total_rx_bytes = 0;
+ int ret;
+
+ do {
+ rx_len = rtw_read32(rtwdev, REG_SDIO_RX0_REQ_LEN);
+ if (!rx_len)
+ break;
+
+ ret = rtw_sdio_rxfifo_recv(rtwdev, rx_len);
+ if (ret)
+ break;
+
+ total_rx_bytes += rx_len;
+ } while (total_rx_bytes < SZ_64K);
+}
+
static void rtw_sdio_handle_interrupt_8051(struct rtw_dev *rtwdev, u32 hisr)
{
if (hisr & REG_SDIO_HISR_TXERR)
rtw_sdio_tx_err_isr(rtwdev);
if (hisr & REG_SDIO_HISR_RX_REQUEST) {
hisr &= ~REG_SDIO_HISR_RX_REQUEST;
- rtw_sdio_rx_isr(rtwdev);
+ rtw_sdio_rx_isr_8051(rtwdev);
}
/*
@@ -1515,7 +1523,7 @@ static void rtw_sdio_handle_interrupt_3081(struct rtw_dev *rtwdev, u32 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);
+ rtw_sdio_rx_isr_3081(rtwdev);
/*
* Unmasking HIMR re-asserts the IRQ line if new packets arrived or if
--
2.53.0