2023-03-10 20:30:13

by Martin Blumenstingl

[permalink] [raw]
Subject: [PATCH v2 RFC 0/9] rtw88: Add SDIO support

Recently the rtw88 driver has gained locking support for the "slow" bus
types (USB, SDIO) as part of USB support. Thanks to everyone who helped
make this happen!

Based on the USB work (especially the locking part and various
bugfixes) this series adds support for SDIO based cards. It's the
result of a collaboration between Jernej and myself. Neither of us has
access to the rtw88 datasheets. All of our work is based on studying
the RTL8822BS and RTL8822CS vendor drivers and trial and error.

Jernej and myself have tested this with RTL8822BS and RTL8822CS cards.
Other users have confirmed that RTL8821CS support is working as well.
RTL8723DS may also work (we tried our best to handle rtw_chip_wcpu_11n
where needed) but has not been tested at this point.

Jernej's results with a RTL8822BS:
- Main functionality works
- Had a case where no traffic got across the link until he issued a
scan

My results with a RTL8822CS:
- 2.4GHz and 5GHz bands are both working
- TX throughput on a 5GHz network is between 50 Mbit/s and 90 Mbit/s
- RX throughput on a 5GHz network is at 19 Mbit/s (this seems to be
an combination of the location of my board and the cheap antenna
which are both hurting RX performance)

A user shared his results on his own RTL8822CS off-list with me:
- 50Mbit/s throughput in both directions

A user shared his results on RTL8821CS off-list with me:
- 50Mbps down and 25Mbps on a 5GHz network

Why is this an RFC?
- I think it's worth to get another round of feedback from the rtw88
maintainers
- As with most patches: testing is very welcome. If things are working
fine then a Tested-by is appreciated (with some details about the
card, throughput, ...). If something doesn't work for you: please
still report back so we can investigate that problem!

Changes since v1 at [0]:
- removed patches 1-8 as they have been submitted and separately (they
were indepdent and this helped cutting down the size of this series)
- dropped patch "rtw88: ps: Increase LEAVE_LPS_TRY_CNT for SDIO based
chipsets" as the underlying issue has been fixed - most likely with
upstream commit 823092a53556eb ("wifi: rtw88: fix race condition
when doing H2C command")
- rework the code so we don't need a new HCI specific power_switch
callback by utilizing the RTW_FLAG_POWERON flag which was recently
introduced
- various patches include the feedback from reviewers and build
testing robots (see the individual patches for details)


[0] https://lore.kernel.org/lkml/[email protected]/T/


Jernej Skrabec (1):
wifi: rtw88: Add support for the SDIO based RTL8822BS chipset

Martin Blumenstingl (8):
wifi: rtw88: Clear RTW_FLAG_POWERON early in rtw_mac_power_switch()
wifi: rtw88: sdio: Add HCI implementation for SDIO based chipsets
wifi: rtw88: mac: Support SDIO specific bits in the power on sequence
wifi: rtw88: main: Add the {cpwm,rpwm}_addr for SDIO based chipsets
wifi: rtw88: main: Reserve 8 bytes of extra TX headroom for SDIO cards
mmc: sdio: add Realtek SDIO vendor ID and various wifi device IDs
wifi: rtw88: Add support for the SDIO based RTL8822CS chipset
wifi: rtw88: Add support for the SDIO based RTL8821CS chipset

drivers/net/wireless/realtek/rtw88/Kconfig | 36 +
drivers/net/wireless/realtek/rtw88/Makefile | 12 +
drivers/net/wireless/realtek/rtw88/debug.h | 1 +
drivers/net/wireless/realtek/rtw88/mac.c | 51 +-
drivers/net/wireless/realtek/rtw88/mac.h | 1 -
drivers/net/wireless/realtek/rtw88/main.c | 9 +-
drivers/net/wireless/realtek/rtw88/reg.h | 12 +
.../net/wireless/realtek/rtw88/rtw8821cs.c | 35 +
.../net/wireless/realtek/rtw88/rtw8822bs.c | 35 +
.../net/wireless/realtek/rtw88/rtw8822cs.c | 35 +
drivers/net/wireless/realtek/rtw88/sdio.c | 1251 +++++++++++++++++
drivers/net/wireless/realtek/rtw88/sdio.h | 175 +++
include/linux/mmc/sdio_ids.h | 9 +
13 files changed, 1654 insertions(+), 8 deletions(-)
create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c
create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8822bs.c
create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8822cs.c
create mode 100644 drivers/net/wireless/realtek/rtw88/sdio.c
create mode 100644 drivers/net/wireless/realtek/rtw88/sdio.h

--
2.39.2



2023-03-10 20:30:13

by Martin Blumenstingl

[permalink] [raw]
Subject: [PATCH v2 RFC 9/9] wifi: rtw88: Add support for the SDIO based RTL8821CS chipset

Wire up RTL8821CS chipset support using the new rtw88 SDIO HCI code as
well as the existing RTL8821C chipset code.

Signed-off-by: Martin Blumenstingl <[email protected]>
---
Changes since v1:
- use /* ... */ style for copyright comments


drivers/net/wireless/realtek/rtw88/Kconfig | 11 ++++++
drivers/net/wireless/realtek/rtw88/Makefile | 3 ++
.../net/wireless/realtek/rtw88/rtw8821cs.c | 35 +++++++++++++++++++
3 files changed, 49 insertions(+)
create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c

diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
index 6b65da81127f..29eb2f8e0eb7 100644
--- a/drivers/net/wireless/realtek/rtw88/Kconfig
+++ b/drivers/net/wireless/realtek/rtw88/Kconfig
@@ -133,6 +133,17 @@ config RTW88_8821CE

802.11ac PCIe wireless network adapter

+config RTW88_8821CS
+ tristate "Realtek 8821CS SDIO wireless network adapter"
+ depends on MMC
+ select RTW88_CORE
+ select RTW88_SDIO
+ select RTW88_8821C
+ help
+ Select this option will enable support for 8821CS chipset
+
+ 802.11ac SDIO wireless network adapter
+
config RTW88_8821CU
tristate "Realtek 8821CU USB wireless network adapter"
depends on USB
diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
index 6105c2745bda..82979b30ae8d 100644
--- a/drivers/net/wireless/realtek/rtw88/Makefile
+++ b/drivers/net/wireless/realtek/rtw88/Makefile
@@ -59,6 +59,9 @@ rtw88_8821c-objs := rtw8821c.o rtw8821c_table.o
obj-$(CONFIG_RTW88_8821CE) += rtw88_8821ce.o
rtw88_8821ce-objs := rtw8821ce.o

+obj-$(CONFIG_RTW88_8821CS) += rtw88_8821cs.o
+rtw88_8821cs-objs := rtw8821cs.o
+
obj-$(CONFIG_RTW88_8821CU) += rtw88_8821cu.o
rtw88_8821cu-objs := rtw8821cu.o

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
new file mode 100644
index 000000000000..7ad7c13ac9e6
--- /dev/null
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/* Copyright(c) Martin Blumenstingl <[email protected]>
+ */
+
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/module.h>
+#include "sdio.h"
+#include "rtw8821c.h"
+
+static const struct sdio_device_id rtw_8821cs_id_table[] = {
+ {
+ SDIO_DEVICE(SDIO_VENDOR_ID_REALTEK,
+ SDIO_DEVICE_ID_REALTEK_RTW8821CS),
+ .driver_data = (kernel_ulong_t)&rtw8821c_hw_spec,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(sdio, rtw_8821cs_id_table);
+
+static struct sdio_driver rtw_8821cs_driver = {
+ .name = "rtw_8821cs",
+ .probe = rtw_sdio_probe,
+ .remove = rtw_sdio_remove,
+ .id_table = rtw_8821cs_id_table,
+ .drv = {
+ .pm = &rtw_sdio_pm_ops,
+ .shutdown = rtw_sdio_shutdown,
+ }
+};
+module_sdio_driver(rtw_8821cs_driver);
+
+MODULE_AUTHOR("Martin Blumenstingl <[email protected]>");
+MODULE_DESCRIPTION("Realtek 802.11ac wireless 8821cs driver");
+MODULE_LICENSE("Dual BSD/GPL");
--
2.39.2


2023-03-10 20:30:16

by Martin Blumenstingl

[permalink] [raw]
Subject: [PATCH v2 RFC 7/9] wifi: rtw88: Add support for the SDIO based RTL8822BS chipset

From: Jernej Skrabec <[email protected]>

Wire up RTL8822BS chipset support using the new rtw88 SDIO HCI code as
well as the existing RTL8822B chipset code.

Signed-off-by: Jernej Skrabec <[email protected]>
Signed-off-by: Martin Blumenstingl <[email protected]>
---
Changes since v1:
- use /* ... */ style for copyright comments


drivers/net/wireless/realtek/rtw88/Kconfig | 11 ++++++
drivers/net/wireless/realtek/rtw88/Makefile | 3 ++
.../net/wireless/realtek/rtw88/rtw8822bs.c | 35 +++++++++++++++++++
3 files changed, 49 insertions(+)
create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8822bs.c

diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
index cdf9cb478ee2..0cfc68dcc416 100644
--- a/drivers/net/wireless/realtek/rtw88/Kconfig
+++ b/drivers/net/wireless/realtek/rtw88/Kconfig
@@ -45,6 +45,17 @@ config RTW88_8822BE

802.11ac PCIe wireless network adapter

+config RTW88_8822BS
+ tristate "Realtek 8822BS SDIO wireless network adapter"
+ depends on MMC
+ select RTW88_CORE
+ select RTW88_SDIO
+ select RTW88_8822B
+ help
+ Select this option will enable support for 8822BS chipset
+
+ 802.11ac SDIO wireless network adapter
+
config RTW88_8822BU
tristate "Realtek 8822BU USB wireless network adapter"
depends on USB
diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
index 892cad60ba31..2b8f4dd9707f 100644
--- a/drivers/net/wireless/realtek/rtw88/Makefile
+++ b/drivers/net/wireless/realtek/rtw88/Makefile
@@ -26,6 +26,9 @@ rtw88_8822b-objs := rtw8822b.o rtw8822b_table.o
obj-$(CONFIG_RTW88_8822BE) += rtw88_8822be.o
rtw88_8822be-objs := rtw8822be.o

+obj-$(CONFIG_RTW88_8822BS) += rtw88_8822bs.o
+rtw88_8822bs-objs := rtw8822bs.o
+
obj-$(CONFIG_RTW88_8822BU) += rtw88_8822bu.o
rtw88_8822bu-objs := rtw8822bu.o

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822bs.c b/drivers/net/wireless/realtek/rtw88/rtw8822bs.c
new file mode 100644
index 000000000000..76645e7a6bc7
--- /dev/null
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822bs.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/* Copyright(c) Jernej Skrabec <[email protected]>
+ */
+
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/module.h>
+#include "sdio.h"
+#include "rtw8822b.h"
+
+static const struct sdio_device_id rtw_8822bs_id_table[] = {
+ {
+ SDIO_DEVICE(SDIO_VENDOR_ID_REALTEK,
+ SDIO_DEVICE_ID_REALTEK_RTW8822BS),
+ .driver_data = (kernel_ulong_t)&rtw8822b_hw_spec,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(sdio, rtw_8822bs_id_table);
+
+static struct sdio_driver rtw_8822bs_driver = {
+ .name = "rtw_8822bs",
+ .probe = rtw_sdio_probe,
+ .remove = rtw_sdio_remove,
+ .id_table = rtw_8822bs_id_table,
+ .drv = {
+ .pm = &rtw_sdio_pm_ops,
+ .shutdown = rtw_sdio_shutdown,
+ }
+};
+module_sdio_driver(rtw_8822bs_driver);
+
+MODULE_AUTHOR("Jernej Skrabec <[email protected]>");
+MODULE_DESCRIPTION("Realtek 802.11ac wireless 8822bs driver");
+MODULE_LICENSE("Dual BSD/GPL");
--
2.39.2


2023-03-10 20:30:17

by Martin Blumenstingl

[permalink] [raw]
Subject: [PATCH v2 RFC 8/9] wifi: rtw88: Add support for the SDIO based RTL8822CS chipset

Wire up RTL8822CS chipset support using the new rtw88 SDIO HCI code as
well as the existing RTL8822C chipset code.

Signed-off-by: Martin Blumenstingl <[email protected]>
---
Changes since v1:
- use /* ... */ style for copyright comments


drivers/net/wireless/realtek/rtw88/Kconfig | 11 ++++++
drivers/net/wireless/realtek/rtw88/Makefile | 3 ++
.../net/wireless/realtek/rtw88/rtw8822cs.c | 35 +++++++++++++++++++
3 files changed, 49 insertions(+)
create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8822cs.c

diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
index 0cfc68dcc416..6b65da81127f 100644
--- a/drivers/net/wireless/realtek/rtw88/Kconfig
+++ b/drivers/net/wireless/realtek/rtw88/Kconfig
@@ -78,6 +78,17 @@ config RTW88_8822CE

802.11ac PCIe wireless network adapter

+config RTW88_8822CS
+ tristate "Realtek 8822CS SDIO wireless network adapter"
+ depends on MMC
+ select RTW88_CORE
+ select RTW88_SDIO
+ select RTW88_8822C
+ help
+ Select this option will enable support for 8822CS chipset
+
+ 802.11ac SDIO wireless network adapter
+
config RTW88_8822CU
tristate "Realtek 8822CU USB wireless network adapter"
depends on USB
diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
index 2b8f4dd9707f..6105c2745bda 100644
--- a/drivers/net/wireless/realtek/rtw88/Makefile
+++ b/drivers/net/wireless/realtek/rtw88/Makefile
@@ -38,6 +38,9 @@ rtw88_8822c-objs := rtw8822c.o rtw8822c_table.o
obj-$(CONFIG_RTW88_8822CE) += rtw88_8822ce.o
rtw88_8822ce-objs := rtw8822ce.o

+obj-$(CONFIG_RTW88_8822CS) += rtw88_8822cs.o
+rtw88_8822cs-objs := rtw8822cs.o
+
obj-$(CONFIG_RTW88_8822CU) += rtw88_8822cu.o
rtw88_8822cu-objs := rtw8822cu.o

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822cs.c b/drivers/net/wireless/realtek/rtw88/rtw8822cs.c
new file mode 100644
index 000000000000..db8984b67f89
--- /dev/null
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822cs.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/* Copyright(c) Martin Blumenstingl <[email protected]>
+ */
+
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/module.h>
+#include "sdio.h"
+#include "rtw8822c.h"
+
+static const struct sdio_device_id rtw_8822cs_id_table[] = {
+ {
+ SDIO_DEVICE(SDIO_VENDOR_ID_REALTEK,
+ SDIO_DEVICE_ID_REALTEK_RTW8822CS),
+ .driver_data = (kernel_ulong_t)&rtw8822c_hw_spec,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(sdio, rtw_8822cs_id_table);
+
+static struct sdio_driver rtw_8822cs_driver = {
+ .name = "rtw_8822cs",
+ .probe = rtw_sdio_probe,
+ .remove = rtw_sdio_remove,
+ .id_table = rtw_8822cs_id_table,
+ .drv = {
+ .pm = &rtw_sdio_pm_ops,
+ .shutdown = rtw_sdio_shutdown,
+ }
+};
+module_sdio_driver(rtw_8822cs_driver);
+
+MODULE_AUTHOR("Martin Blumenstingl <[email protected]>");
+MODULE_DESCRIPTION("Realtek 802.11ac wireless 8822cs driver");
+MODULE_LICENSE("Dual BSD/GPL");
--
2.39.2


2023-03-11 02:16:13

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH v2 RFC 0/9] rtw88: Add SDIO support

On 3/10/23 14:29, Martin Blumenstingl wrote:
> Recently the rtw88 driver has gained locking support for the "slow" bus
> types (USB, SDIO) as part of USB support. Thanks to everyone who helped
> make this happen!
>
> Based on the USB work (especially the locking part and various
> bugfixes) this series adds support for SDIO based cards. It's the
> result of a collaboration between Jernej and myself. Neither of us has
> access to the rtw88 datasheets. All of our work is based on studying
> the RTL8822BS and RTL8822CS vendor drivers and trial and error.
>
> Jernej and myself have tested this with RTL8822BS and RTL8822CS cards.
> Other users have confirmed that RTL8821CS support is working as well.
> RTL8723DS may also work (we tried our best to handle rtw_chip_wcpu_11n
> where needed) but has not been tested at this point.
>
> Jernej's results with a RTL8822BS:
> - Main functionality works
> - Had a case where no traffic got across the link until he issued a
> scan
>
> My results with a RTL8822CS:
> - 2.4GHz and 5GHz bands are both working
> - TX throughput on a 5GHz network is between 50 Mbit/s and 90 Mbit/s
> - RX throughput on a 5GHz network is at 19 Mbit/s (this seems to be
> an combination of the location of my board and the cheap antenna
> which are both hurting RX performance)
>
> A user shared his results on his own RTL8822CS off-list with me:
> - 50Mbit/s throughput in both directions
>
> A user shared his results on RTL8821CS off-list with me:
> - 50Mbps down and 25Mbps on a 5GHz network
>
> Why is this an RFC?
> - I think it's worth to get another round of feedback from the rtw88
> maintainers
> - As with most patches: testing is very welcome. If things are working
> fine then a Tested-by is appreciated (with some details about the
> card, throughput, ...). If something doesn't work for you: please
> still report back so we can investigate that problem!
>
> Changes since v1 at [0]:
> - removed patches 1-8 as they have been submitted and separately (they
> were indepdent and this helped cutting down the size of this series)
> - dropped patch "rtw88: ps: Increase LEAVE_LPS_TRY_CNT for SDIO based
> chipsets" as the underlying issue has been fixed - most likely with
> upstream commit 823092a53556eb ("wifi: rtw88: fix race condition
> when doing H2C command")
> - rework the code so we don't need a new HCI specific power_switch
> callback by utilizing the RTW_FLAG_POWERON flag which was recently
> introduced
> - various patches include the feedback from reviewers and build
> testing robots (see the individual patches for details)
>
>
> [0] https://lore.kernel.org/lkml/[email protected]/T/
>
>
> Jernej Skrabec (1):
> wifi: rtw88: Add support for the SDIO based RTL8822BS chipset
>
> Martin Blumenstingl (8):
> wifi: rtw88: Clear RTW_FLAG_POWERON early in rtw_mac_power_switch()
> wifi: rtw88: sdio: Add HCI implementation for SDIO based chipsets
> wifi: rtw88: mac: Support SDIO specific bits in the power on sequence
> wifi: rtw88: main: Add the {cpwm,rpwm}_addr for SDIO based chipsets
> wifi: rtw88: main: Reserve 8 bytes of extra TX headroom for SDIO cards
> mmc: sdio: add Realtek SDIO vendor ID and various wifi device IDs
> wifi: rtw88: Add support for the SDIO based RTL8822CS chipset
> wifi: rtw88: Add support for the SDIO based RTL8821CS chipset
>
> drivers/net/wireless/realtek/rtw88/Kconfig | 36 +
> drivers/net/wireless/realtek/rtw88/Makefile | 12 +
> drivers/net/wireless/realtek/rtw88/debug.h | 1 +
> drivers/net/wireless/realtek/rtw88/mac.c | 51 +-
> drivers/net/wireless/realtek/rtw88/mac.h | 1 -
> drivers/net/wireless/realtek/rtw88/main.c | 9 +-
> drivers/net/wireless/realtek/rtw88/reg.h | 12 +
> .../net/wireless/realtek/rtw88/rtw8821cs.c | 35 +
> .../net/wireless/realtek/rtw88/rtw8822bs.c | 35 +
> .../net/wireless/realtek/rtw88/rtw8822cs.c | 35 +
> drivers/net/wireless/realtek/rtw88/sdio.c | 1251 +++++++++++++++++
> drivers/net/wireless/realtek/rtw88/sdio.h | 175 +++
> include/linux/mmc/sdio_ids.h | 9 +
> 13 files changed, 1654 insertions(+), 8 deletions(-)
> create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8822bs.c
> create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8822cs.c
> create mode 100644 drivers/net/wireless/realtek/rtw88/sdio.c
> create mode 100644 drivers/net/wireless/realtek/rtw88/sdio.h

Martin,

I am not qualified to review the code, but I am integrating this version into my
rtw88 repo at GitHub.com.

It is essential that a successful build is possible after every patch is applied
so that an arbitrary bisection will not fail to build. This patch series fails
after #2 is committed. File mac.c needs symbol SDIO_LOCAL_OFFSET, which was
moved from mac.h to sdio.h. I resolved this be including sdio.h in mac.c. This
breaks #3, where you add the include to mac.c. It needs to happen one patch earlier.

The other problem for my repo is that it cannot modify
include/linux/mmc/sdio_ids.h, thus I have to create a local sdio_ids.h to
contain the new definitions. Once your patches are in the kernel, I will be able
to eliminate this work around.

I do not have any rtw88 SDIO devices, thus I will not be able to test, but I
will pass any information that I get from my users.

Larry



2023-03-11 20:56:49

by Martin Blumenstingl

[permalink] [raw]
Subject: Re: [PATCH v2 RFC 0/9] rtw88: Add SDIO support

Hello Larry,

On Sat, Mar 11, 2023 at 3:16 AM Larry Finger <[email protected]> wrote:
[...]
> I am not qualified to review the code, but I am integrating this version into my
> rtw88 repo at GitHub.com.
>
> It is essential that a successful build is possible after every patch is applied
> so that an arbitrary bisection will not fail to build. This patch series fails
> after #2 is committed. File mac.c needs symbol SDIO_LOCAL_OFFSET, which was
> moved from mac.h to sdio.h. I resolved this be including sdio.h in mac.c. This
> breaks #3, where you add the include to mac.c. It needs to happen one patch earlier.
Thank you for spotting and reporting this issue! You are right with
this, I'll add the sdio.h include to mac.c with patch 2 to resolve
this issue as you suggested.

> The other problem for my repo is that it cannot modify
> include/linux/mmc/sdio_ids.h, thus I have to create a local sdio_ids.h to
> contain the new definitions. Once your patches are in the kernel, I will be able
> to eliminate this work around.
You can also modify the three SDIO driver files (rtw8821cs.c,
rtw8822bs.c, rtw8822cs.c) and use the literal IDs there if you have to
patch those files anyways.

> I do not have any rtw88 SDIO devices, thus I will not be able to test, but I
> will pass any information that I get from my users.
That sounds great - thank you!


Best regards,
Martin

2023-03-13 09:22:36

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH v2 RFC 9/9] wifi: rtw88: Add support for the SDIO based RTL8821CS chipset



> -----Original Message-----
> From: Martin Blumenstingl <[email protected]>
> Sent: Saturday, March 11, 2023 4:29 AM
> To: [email protected]
> Cc: Yan-Hsuan Chuang <[email protected]>; Kalle Valo <[email protected]>; Ulf Hansson
> <[email protected]>; [email protected]; [email protected];
> [email protected]; Chris Morgan <[email protected]>; Nitin Gupta <[email protected]>;
> Neo Jou <[email protected]>; Ping-Ke Shih <[email protected]>; Jernej Skrabec <[email protected]>;
> Martin Blumenstingl <[email protected]>
> Subject: [PATCH v2 RFC 9/9] wifi: rtw88: Add support for the SDIO based RTL8821CS chipset
>
> Wire up RTL8821CS chipset support using the new rtw88 SDIO HCI code as
> well as the existing RTL8821C chipset code.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> Changes since v1:
> - use /* ... */ style for copyright comments
>
>
> drivers/net/wireless/realtek/rtw88/Kconfig | 11 ++++++
> drivers/net/wireless/realtek/rtw88/Makefile | 3 ++
> .../net/wireless/realtek/rtw88/rtw8821cs.c | 35 +++++++++++++++++++
> 3 files changed, 49 insertions(+)
> create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c
>

[...]

> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> new file mode 100644
> index 000000000000..7ad7c13ac9e6
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> @@ -0,0 +1,35 @@
> +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
> +/* Copyright(c) Martin Blumenstingl <[email protected]>
> + */
> +
> +#include <linux/mmc/sdio_func.h>
> +#include <linux/mmc/sdio_ids.h>
> +#include <linux/module.h>
> +#include "sdio.h"
> +#include "rtw8821c.h"

nit: alphabetic order


I run sparse/smatch with this patchset, and smatch warns:

1. drivers/net/wireless/realtek/rtw88/mac.c:313 rtw_mac_power_switch() error: uninitialized symbol 'imr'.
This should be a false-alarm, but just initialize imr to 0 to avoid this.


2. drivers/net/wireless/realtek/rtw88/sdio.c:136 rtw_sdio_read_indirect_bytes() error: uninitialized symbol 'ret'.
This should be a false-alarm too. I guess it considers 'count = 0' is possible.

Ping-Ke


2023-03-16 20:00:01

by Chris Morgan

[permalink] [raw]
Subject: Re: [PATCH v2 RFC 9/9] wifi: rtw88: Add support for the SDIO based RTL8821CS chipset

On Fri, Mar 10, 2023 at 09:29:22PM +0100, Martin Blumenstingl wrote:
> Wire up RTL8821CS chipset support using the new rtw88 SDIO HCI code as
> well as the existing RTL8821C chipset code.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> Changes since v1:
> - use /* ... */ style for copyright comments
>
>
> drivers/net/wireless/realtek/rtw88/Kconfig | 11 ++++++
> drivers/net/wireless/realtek/rtw88/Makefile | 3 ++
> .../net/wireless/realtek/rtw88/rtw8821cs.c | 35 +++++++++++++++++++
> 3 files changed, 49 insertions(+)
> create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c
>
> diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
> index 6b65da81127f..29eb2f8e0eb7 100644
> --- a/drivers/net/wireless/realtek/rtw88/Kconfig
> +++ b/drivers/net/wireless/realtek/rtw88/Kconfig
> @@ -133,6 +133,17 @@ config RTW88_8821CE
>
> 802.11ac PCIe wireless network adapter
>
> +config RTW88_8821CS
> + tristate "Realtek 8821CS SDIO wireless network adapter"
> + depends on MMC
> + select RTW88_CORE
> + select RTW88_SDIO
> + select RTW88_8821C
> + help
> + Select this option will enable support for 8821CS chipset
> +
> + 802.11ac SDIO wireless network adapter
> +
> config RTW88_8821CU
> tristate "Realtek 8821CU USB wireless network adapter"
> depends on USB
> diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
> index 6105c2745bda..82979b30ae8d 100644
> --- a/drivers/net/wireless/realtek/rtw88/Makefile
> +++ b/drivers/net/wireless/realtek/rtw88/Makefile
> @@ -59,6 +59,9 @@ rtw88_8821c-objs := rtw8821c.o rtw8821c_table.o
> obj-$(CONFIG_RTW88_8821CE) += rtw88_8821ce.o
> rtw88_8821ce-objs := rtw8821ce.o
>
> +obj-$(CONFIG_RTW88_8821CS) += rtw88_8821cs.o
> +rtw88_8821cs-objs := rtw8821cs.o
> +
> obj-$(CONFIG_RTW88_8821CU) += rtw88_8821cu.o
> rtw88_8821cu-objs := rtw8821cu.o
>
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> new file mode 100644
> index 000000000000..7ad7c13ac9e6
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> @@ -0,0 +1,35 @@
> +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
> +/* Copyright(c) Martin Blumenstingl <[email protected]>
> + */
> +
> +#include <linux/mmc/sdio_func.h>
> +#include <linux/mmc/sdio_ids.h>
> +#include <linux/module.h>
> +#include "sdio.h"
> +#include "rtw8821c.h"
> +
> +static const struct sdio_device_id rtw_8821cs_id_table[] = {
> + {
> + SDIO_DEVICE(SDIO_VENDOR_ID_REALTEK,
> + SDIO_DEVICE_ID_REALTEK_RTW8821CS),
> + .driver_data = (kernel_ulong_t)&rtw8821c_hw_spec,
> + },
> + {}
> +};
> +MODULE_DEVICE_TABLE(sdio, rtw_8821cs_id_table);
> +
> +static struct sdio_driver rtw_8821cs_driver = {
> + .name = "rtw_8821cs",
> + .probe = rtw_sdio_probe,
> + .remove = rtw_sdio_remove,
> + .id_table = rtw_8821cs_id_table,
> + .drv = {
> + .pm = &rtw_sdio_pm_ops,
> + .shutdown = rtw_sdio_shutdown,
> + }
> +};
> +module_sdio_driver(rtw_8821cs_driver);
> +
> +MODULE_AUTHOR("Martin Blumenstingl <[email protected]>");
> +MODULE_DESCRIPTION("Realtek 802.11ac wireless 8821cs driver");
> +MODULE_LICENSE("Dual BSD/GPL");
> --
> 2.39.2
>

Overall it works well for me, but when I resume from suspend I get the
following filling up my dmesg:

rtw_8821cs mmc3:0001:1: sdio read8 failed (0x86): -110

So suspend/resume seems to be an issue, but otherwise it works well
for me.

Chris Morgan

2023-03-20 20:30:12

by Martin Blumenstingl

[permalink] [raw]
Subject: Re: [PATCH v2 RFC 9/9] wifi: rtw88: Add support for the SDIO based RTL8821CS chipset

Hi Chris,

On Thu, Mar 16, 2023 at 8:59 PM Chris Morgan <[email protected]> wrote:
[...]
> > +MODULE_AUTHOR("Martin Blumenstingl <[email protected]>");
> > +MODULE_DESCRIPTION("Realtek 802.11ac wireless 8821cs driver");
> > +MODULE_LICENSE("Dual BSD/GPL");
> > --
> > 2.39.2
> >
>
> Overall it works well for me, but when I resume from suspend I get the
> following filling up my dmesg:
>
> rtw_8821cs mmc3:0001:1: sdio read8 failed (0x86): -110
>
> So suspend/resume seems to be an issue, but otherwise it works well
> for me.
Thanks for reporting this issue! I have a fix in my local tree and I'm
testing it currently. If you want to try it for yourself (before I
send an updated series) you can just replace one function in sdio.c:
static int __maybe_unused rtw_sdio_suspend(struct device *dev)
{
struct sdio_func *func = dev_to_sdio_func(dev);
struct ieee80211_hw *hw = dev_get_drvdata(dev);
struct rtw_dev *rtwdev = hw->priv;
int ret;

ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
if (ret)
rtw_err(rtwdev, "Failed to host PM flag MMC_PM_KEEP_POWER");

return ret;
}


Best regards,
Martin