linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations
@ 2023-05-14 20:03 Martin Blumenstingl
  2023-05-15  0:36 ` Ping-Ke Shih
  2023-05-15 12:18 ` Julian Calaby
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2023-05-14 20:03 UTC (permalink / raw)
  To: linux-wireless
  Cc: linux-kernel, pkshih, tony0620emma, kvalo, Martin Blumenstingl,
	Larry Finger, Rudi Heitbaum

The Allwinner sunxi-mmc controller cannot handle word (16 bit)
transfers. So and sdio_{read,write}w fails with messages like the
following example using an RTL8822BS (but the same problems were also
observed with RTL8822CS and RTL8723DS chips):
  rtw_8822bs mmc1:0001:1: Firmware version 27.2.0, H2C version 13
  sunxi-mmc 4021000.mmc: unaligned scatterlist: os f80 length 2
  sunxi-mmc 4021000.mmc: map DMA failed
  rtw_8822bs mmc1:0001:1: sdio read16 failed (0x10230): -22

Use two consecutive single byte accesses for word operations instead. It
turns out that upon closer inspection this is also what the vendor
driver does, even though it does have support for sdio_{read,write}w. So
we can conclude that the rtw88 chips do support word access but only on
SDIO controllers that also support it. Since there's no way to detect if
the controller supports word access or not the rtw88 sdio driver
switches to the easiest approach: avoiding word access.

Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Closes: https://lore.kernel.org/linux-wireless/527585e5-9cdd-66ed-c3af-6da162f4b720@lwfinger.net/
Reported-by: Rudi Heitbaum <rudi@heitbaum.com>
Fixes: 65371a3f14e7 ("wifi: rtw88: sdio: Add HCI implementation for SDIO based chipsets")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/net/wireless/realtek/rtw88/sdio.c | 8 --------
 1 file changed, 8 deletions(-)

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)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations
  2023-05-14 20:03 [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations Martin Blumenstingl
@ 2023-05-15  0:36 ` Ping-Ke Shih
  2023-05-15 10:59   ` Kalle Valo
  2023-05-15 12:18 ` Julian Calaby
  1 sibling, 1 reply; 5+ messages in thread
From: Ping-Ke Shih @ 2023-05-15  0:36 UTC (permalink / raw)
  To: Martin Blumenstingl, linux-wireless
  Cc: linux-kernel, tony0620emma, kvalo, Larry Finger, Rudi Heitbaum



> -----Original Message-----
> From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Sent: Monday, May 15, 2023 4:04 AM
> To: linux-wireless@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; Ping-Ke Shih <pkshih@realtek.com>; tony0620emma@gmail.com;
> kvalo@kernel.org; Martin Blumenstingl <martin.blumenstingl@googlemail.com>; Larry Finger
> <Larry.Finger@lwfinger.net>; Rudi Heitbaum <rudi@heitbaum.com>
> Subject: [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations
> 
> The Allwinner sunxi-mmc controller cannot handle word (16 bit)
> transfers. So and sdio_{read,write}w fails with messages like the
> following example using an RTL8822BS (but the same problems were also
> observed with RTL8822CS and RTL8723DS chips):
>   rtw_8822bs mmc1:0001:1: Firmware version 27.2.0, H2C version 13
>   sunxi-mmc 4021000.mmc: unaligned scatterlist: os f80 length 2
>   sunxi-mmc 4021000.mmc: map DMA failed
>   rtw_8822bs mmc1:0001:1: sdio read16 failed (0x10230): -22
> 
> Use two consecutive single byte accesses for word operations instead. It
> turns out that upon closer inspection this is also what the vendor
> driver does, even though it does have support for sdio_{read,write}w. So
> we can conclude that the rtw88 chips do support word access but only on
> SDIO controllers that also support it. Since there's no way to detect if
> the controller supports word access or not the rtw88 sdio driver
> switches to the easiest approach: avoiding word access.
> 
> Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
> Closes: https://lore.kernel.org/linux-wireless/527585e5-9cdd-66ed-c3af-6da162f4b720@lwfinger.net/

"Closes:" seems not a regular tag. Use "Link: " instead.

> Reported-by: Rudi Heitbaum <rudi@heitbaum.com>

Followed by a "Link: " if you have another one.

> Fixes: 65371a3f14e7 ("wifi: rtw88: sdio: Add HCI implementation for SDIO based chipsets")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
>  drivers/net/wireless/realtek/rtw88/sdio.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> 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)
> --
> 2.40.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations
  2023-05-15  0:36 ` Ping-Ke Shih
@ 2023-05-15 10:59   ` Kalle Valo
  2023-05-15 11:40     ` Ping-Ke Shih
  0 siblings, 1 reply; 5+ messages in thread
From: Kalle Valo @ 2023-05-15 10:59 UTC (permalink / raw)
  To: Ping-Ke Shih
  Cc: Martin Blumenstingl, linux-wireless, linux-kernel, tony0620emma,
	Larry Finger, Rudi Heitbaum

Ping-Ke Shih <pkshih@realtek.com> writes:

>> -----Original Message-----
>> From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>> Sent: Monday, May 15, 2023 4:04 AM
>> To: linux-wireless@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org; Ping-Ke Shih <pkshih@realtek.com>; tony0620emma@gmail.com;
>> kvalo@kernel.org; Martin Blumenstingl <martin.blumenstingl@googlemail.com>; Larry Finger
>> <Larry.Finger@lwfinger.net>; Rudi Heitbaum <rudi@heitbaum.com>
>> Subject: [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations
>> 
>> The Allwinner sunxi-mmc controller cannot handle word (16 bit)
>> transfers. So and sdio_{read,write}w fails with messages like the
>> following example using an RTL8822BS (but the same problems were also
>> observed with RTL8822CS and RTL8723DS chips):
>>   rtw_8822bs mmc1:0001:1: Firmware version 27.2.0, H2C version 13
>>   sunxi-mmc 4021000.mmc: unaligned scatterlist: os f80 length 2
>>   sunxi-mmc 4021000.mmc: map DMA failed
>>   rtw_8822bs mmc1:0001:1: sdio read16 failed (0x10230): -22
>> 
>> Use two consecutive single byte accesses for word operations instead. It
>> turns out that upon closer inspection this is also what the vendor
>> driver does, even though it does have support for sdio_{read,write}w. So
>> we can conclude that the rtw88 chips do support word access but only on
>> SDIO controllers that also support it. Since there's no way to detect if
>> the controller supports word access or not the rtw88 sdio driver
>> switches to the easiest approach: avoiding word access.
>> 
>> Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
>> Closes: https://lore.kernel.org/linux-wireless/527585e5-9cdd-66ed-c3af-6da162f4b720@lwfinger.net/
>
> "Closes:" seems not a regular tag. Use "Link: " instead.

Actually the documentation now talks about Closes tag:

https://docs.kernel.org/process/5.Posting.html#patch-formatting-and-changelogs

I guess this tag is a recent addition?

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations
  2023-05-15 10:59   ` Kalle Valo
@ 2023-05-15 11:40     ` Ping-Ke Shih
  0 siblings, 0 replies; 5+ messages in thread
From: Ping-Ke Shih @ 2023-05-15 11:40 UTC (permalink / raw)
  To: kvalo
  Cc: martin.blumenstingl, linux-wireless, Larry.Finger, linux-kernel,
	tony0620emma, rudi

On Mon, 2023-05-15 at 13:59 +0300, Kalle Valo wrote:
> 
> Ping-Ke Shih <pkshih@realtek.com> writes:
> 
> > > -----Original Message-----
> > > From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> > > Sent: Monday, May 15, 2023 4:04 AM
> > > To: linux-wireless@vger.kernel.org
> > > Cc: linux-kernel@vger.kernel.org; Ping-Ke Shih <pkshih@realtek.com>; tony0620emma@gmail.com;
> > > kvalo@kernel.org; Martin Blumenstingl <martin.blumenstingl@googlemail.com>; Larry Finger
> > > <Larry.Finger@lwfinger.net>; Rudi Heitbaum <rudi@heitbaum.com>
> > > Subject: [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word
> > > operations
> > > 
> > > The Allwinner sunxi-mmc controller cannot handle word (16 bit)
> > > transfers. So and sdio_{read,write}w fails with messages like the
> > > following example using an RTL8822BS (but the same problems were also
> > > observed with RTL8822CS and RTL8723DS chips):
> > >   rtw_8822bs mmc1:0001:1: Firmware version 27.2.0, H2C version 13
> > >   sunxi-mmc 4021000.mmc: unaligned scatterlist: os f80 length 2
> > >   sunxi-mmc 4021000.mmc: map DMA failed
> > >   rtw_8822bs mmc1:0001:1: sdio read16 failed (0x10230): -22
> > > 
> > > Use two consecutive single byte accesses for word operations instead. It
> > > turns out that upon closer inspection this is also what the vendor
> > > driver does, even though it does have support for sdio_{read,write}w. So
> > > we can conclude that the rtw88 chips do support word access but only on
> > > SDIO controllers that also support it. Since there's no way to detect if
> > > the controller supports word access or not the rtw88 sdio driver
> > > switches to the easiest approach: avoiding word access.
> > > 
> > > Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
> > > Closes: 
> > > https://lore.kernel.org/linux-wireless/527585e5-9cdd-66ed-c3af-6da162f4b720@lwfinger.net/
> > 
> > "Closes:" seems not a regular tag. Use "Link: " instead.
> 
> Actually the documentation now talks about Closes tag:
> 
> https://docs.kernel.org/process/5.Posting.html#patch-formatting-and-changelogs
> 
> I guess this tag is a recent addition?
> 

Thanks for information. 

Then, this patch looks good to me.

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations
  2023-05-14 20:03 [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations Martin Blumenstingl
  2023-05-15  0:36 ` Ping-Ke Shih
@ 2023-05-15 12:18 ` Julian Calaby
  1 sibling, 0 replies; 5+ messages in thread
From: Julian Calaby @ 2023-05-15 12:18 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: linux-wireless, linux-kernel, pkshih, tony0620emma, kvalo,
	Larry Finger, Rudi Heitbaum, linux-sunxi

Hi Martin,

On Mon, May 15, 2023 at 6:12 AM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
>
> The Allwinner sunxi-mmc controller cannot handle word (16 bit)
> transfers. So and sdio_{read,write}w fails with messages like the
> following example using an RTL8822BS (but the same problems were also
> observed with RTL8822CS and RTL8723DS chips):
>   rtw_8822bs mmc1:0001:1: Firmware version 27.2.0, H2C version 13
>   sunxi-mmc 4021000.mmc: unaligned scatterlist: os f80 length 2
>   sunxi-mmc 4021000.mmc: map DMA failed
>   rtw_8822bs mmc1:0001:1: sdio read16 failed (0x10230): -22
>
> Use two consecutive single byte accesses for word operations instead. It
> turns out that upon closer inspection this is also what the vendor
> driver does, even though it does have support for sdio_{read,write}w. So
> we can conclude that the rtw88 chips do support word access but only on
> SDIO controllers that also support it. Since there's no way to detect if
> the controller supports word access or not the rtw88 sdio driver
> switches to the easiest approach: avoiding word access.
>
> Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
> Closes: https://lore.kernel.org/linux-wireless/527585e5-9cdd-66ed-c3af-6da162f4b720@lwfinger.net/
> Reported-by: Rudi Heitbaum <rudi@heitbaum.com>
> Fixes: 65371a3f14e7 ("wifi: rtw88: sdio: Add HCI implementation for SDIO based chipsets")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

The linux-sunxi folks might have comments, so I've added them to CC.

> ---
>  drivers/net/wireless/realtek/rtw88/sdio.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> 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)
> --
> 2.40.1
>

Thanks,

--
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-15 12:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-14 20:03 [PATCH wireless v1] wifi: rtw88: sdio: Always use two consecutive bytes for word operations Martin Blumenstingl
2023-05-15  0:36 ` Ping-Ke Shih
2023-05-15 10:59   ` Kalle Valo
2023-05-15 11:40     ` Ping-Ke Shih
2023-05-15 12:18 ` Julian Calaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).