Re: Driver for rtw8723ds

Martin Blumenstingl
2023-05-08T20:16:45Z

[-- Attachment #1: Type: text/plain, Size: 2788 bytes --]

Hi Larry,

On Mon, May 8, 2023 at 8:55 PM Larry Finger <Larry.Finger@lwfinger.net> wrote:
>
> Martin and Jernej,
>
> It took a bit of working through some problems, but the user now has the
> rtw8723ds loading and starting. The first problem other than the mechanics of
> building and installing the driver on his SoC was that there is a second SDIO
> vendor ID/device ID for his device, namely 0x024c:0xd724. As I am carrying a
> local copy of sdio_ids.h, that was relatively easy to fix.
Thanks for this hint - I guess we need to find out how to name that
0xd724 device and add it's ID to sdio_ids.h when I upstream the
patches then.
But let's look at the other problem first.

> At the moment, when the device starts, the log shows the following:
> [ 3.640866] rtw_8723ds mmc1:0001:1: Firmware version 48.0.0, H2C version 0
> [ 3.645302] sunxi-mmc 4021000.mmc: unaligned scatterlist: os b00 length 2
> [ 3.654556] sunxi-mmc 4021000.mmc: map DMA failed
> [ 3.659268] rtw_8723ds mmc1:0001:1: sdio read16 failed (0x10040): -22
> [ 3.665710] sunxi-mmc 4021000.mmc: unaligned scatterlist: os b00 length 2
> [ 3.672499] sunxi-mmc 4021000.mmc: map DMA failed
> [ 3.677208] rtw_8723ds mmc1:0001:1: sdio write16 failed (0x10040): -22
> [ 3.683739] sunxi-mmc 4021000.mmc: unaligned scatterlist: os b00 length 2
> [ 3.690528] sunxi-mmc 4021000.mmc: map DMA failed
> [ 3.695236] rtw_8723ds mmc1:0001:1: sdio write16 failed (0x10100): -22
> [ 3.873173] sunxi-mmc 4021000.mmc: unaligned scatterlist: os b00 length 2
> [ 3.879978] sunxi-mmc 4021000.mmc: map DMA failed
> [ 3.884690] rtw_8723ds mmc1:0001:1: sdio read16 failed (0x10002): -22
> [ 3.891141] sunxi-mmc 4021000.mmc: unaligned scatterlist: os b00 length 2
> [ 3.897931] sunxi-mmc 4021000.mmc: map DMA failed
> [ 3.902640] rtw_8723ds mmc1:0001:1: sdio write16 failed (0x10002): -22
> [ 3.909172] sunxi-mmc 4021000.mmc: unaligned scatterlist: os b00 length 2
> [ 3.915962] sunxi-mmc 4021000.mmc: map DMA failed
> [ 3.920672] rtw_8723ds mmc1:0001:1: sdio read16 failed (0x10008): -22
> [ 3.927116] sunxi-mmc 4021000.mmc: unaligned scatterlist: os b00 length 2
> [ 3.933906] sunxi-mmc 4021000.mmc: map DMA failed
> [ 3.938616] rtw_8723ds mmc1:0001:1: sdio write16 failed (0x10008): -22
This looks like an issue with the Allwinner SDIO controller. We can
try to work around this with the attached patch.
Please note that I've only compile-tested that patch.
In theory it can hurt 16-bit register access (read/write) performance
a bit (since we now require two MMC commands instead of one). Whether
this can be measured in the real world is unknown to me. Let's see if
it fixes the observed issue first.

Best regards,
Martin

[-- Attachment #2: rtw88-byte-wise-word-io.diff --]
[-- Type: text/x-patch, Size: 870 bytes --]

diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c
index af0459a79899..06fce7c3adda 100644
--- a/drivers/net/wireless/realtek/rtw88/sdio.c
+++ b/drivers/net/wireless/realtek/rtw88/sdio.c
@@ -87,11 +87,6 @@ static void rtw_sdio_writew(struct rtw_dev *rtwdev, u16 val, u32 addr,
u8 buf[2];
int i;

- if (rtw_sdio_use_memcpy_io(rtwdev, addr, 2)) {
- sdio_writew(rtwsdio->sdio_func, val, addr, err_ret);
- return;
- }
-
*(__le16 *)buf = cpu_to_le16(val);

for (i = 0; i < 2; i++) {
@@ -125,9 +120,6 @@ static u16 rtw_sdio_readw(struct rtw_dev *rtwdev, u32 addr, int *err_ret)
u8 buf[2];
int i;

- if (rtw_sdio_use_memcpy_io(rtwdev, addr, 2))
- return sdio_readw(rtwsdio->sdio_func, addr, err_ret);
-
for (i = 0; i < 2; i++) {
buf[i] = sdio_readb(rtwsdio->sdio_func, addr + i, err_ret);
if (*err_ret)