2023-10-29 11:19:29

by Karel Balej

[permalink] [raw]
Subject: [PATCH 0/2] net: mwifiex: add support for the SD8777 chipset

This series introduces simple modifications to the Marvell mwifiex
wireless driver to make it support the SD8777 chipset which can be found
in mobile devices using the PXA1908 SoC (the support for which is being
upstreamed here [1]), among others, such as samsung,coreprimevelte or
samsung,xcover3lte. The changes are based on the Samsung downstream code
for coreprimevelte [2].

The driver requires proprietary firmware which is not yet part of
linux-firmware, but it is packaged in postmarketOS.

The Marvell repository for PXA1908 [3] contains some information in the
form of release notes (in a PDF under drivers/marvell/sd8777).

This series was sucessfully tested with the aforementioned smartphone,
samsung,coreprimevelte. However it has a caveat: the driver is not
always able to load the firmware onto the device and even when it
succeeds, it emits some errors and eventually breaks irrecoverably after
some time, seemingly after heavier usage. dmesg outputs with description
are below. The suspicion, supported by the fact that the eMMC on the
smartphone does not work at the moment (it reports as busy and the
initialization fails with -ETIMEDOUT, see [4] for dmesg output), is that
the problem is either with the MMC driver (sdhci-pxav3) or the clocks
driver which according to the author is currently missing some parts
present in the downstream version. In particular, the lack of tuning in
the mainline sdhci-pxav3 was considered a possible cause (specifically
the dvfs tuning which the downstream driver performs), however disabling
of this tuning in the downstream kernel doesn't seem to have any effect
on it's ability to use either eMMC or the wireless.

Here are the relevant dmesg outputs for several situations (debug
messages are enabled in the first, not so in the others):

This is the usual output when the firmware loading fails. The device has
to be rebooted before the next attempt to load the firmware because the
driver seems to think that it's already loaded.

[ 68.335394] mwifiex_sdio mmc2:0001:1: info: SDIO FUNC1 IO port: 0x10000
[ 68.485552] mwifiex_sdio mmc2:0001:1: info: downloading FW image (418332 bytes)
[ 68.698674] mwifiex_sdio mmc2:0001:1: FW download, write iomem (0) failed @ 208016
[ 68.698711] mwifiex_sdio mmc2:0001:1: prog_fw failed ret=0xffffffff
[ 68.698724] mwifiex_sdio mmc2:0001:1: info: _mwifiex_fw_dpc: unregister device

The return value of mwifiex_write_data_sync which is invoked during the
firmware loading is -EILSEQ.

Here, the download succeeds but the driver still emits some errors.
Eventually after some (short in this case) time the wireless stops
working and the below errors are printed repeatedly (here the failure
occurred while page loading was in progress in Mozilla Firefox). A
restart seems to be necessary to get the adapter to work again.

[ 61.876547] mwifiex_sdio mmc2:0001:1: info: FW download over, size 418332 bytes
[ 61.981497] mwifiex_sdio mmc2:0001:1: WLAN FW is active
[ 62.278898] mwifiex_sdio mmc2:0001:1: CMD_RESP: cmd 0x242 error, result=0x2
[ 62.278919] mwifiex_sdio mmc2:0001:1: mwifiex_process_cmdresp: cmd 0x242 failed during initialization
[ 62.661327] mwifiex_sdio mmc2:0001:1: info: MWIFIEX VERSION: mwifiex 1.0 (14.75.33.p119)
[ 62.661349] mwifiex_sdio mmc2:0001:1: driver_version = mwifiex 1.0 (14.75.33.p119)
[ 63.886186] mwifiex_sdio mmc2:0001:1: info: trying to associate to bssid CENSORED
[ 63.898581] mwifiex_sdio mmc2:0001:1: info: associated to bssid CENSORED successfully
[ 64.011982] mwifiex_sdio mmc2:0001:1: CMD_RESP: cmd 0x23f error, result=0x2
[ 145.926392] mwifiex_sdio mmc2:0001:1: host_to_card, write iomem (1) failed: -110
[ 146.643323] mwifiex_sdio mmc2:0001:1: write CFG reg failed
[ 147.342918] mwifiex_sdio mmc2:0001:1: host_to_card, write iomem (2) failed: -16
[ 148.041929] mwifiex_sdio mmc2:0001:1: write CFG reg failed
[ 148.727401] mwifiex_sdio mmc2:0001:1: host_to_card, write iomem (3) failed: -16
[ 149.418479] mwifiex_sdio mmc2:0001:1: write CFG reg failed
[ 149.418508] mwifiex_sdio mmc2:0001:1: mwifiex_write_data_async failed: 0xFFFFFFFF
[ 150.108002] mwifiex_sdio mmc2:0001:1: host_to_card, write iomem (1) failed: -16
[ 150.788011] mwifiex_sdio mmc2:0001:1: write CFG reg failed
[ 151.452231] mwifiex_sdio mmc2:0001:1: host_to_card, write iomem (2) failed: -16
[ 152.136966] mwifiex_sdio mmc2:0001:1: write CFG reg failed
[ 152.836739] mwifiex_sdio mmc2:0001:1: host_to_card, write iomem (3) failed: -16
[ 153.545571] mwifiex_sdio mmc2:0001:1: write CFG reg failed
[ 153.545611] mwifiex_sdio mmc2:0001:1: mwifiex_write_data_async failed: 0xFFFFFFFF
[ 154.083665] mwifiex_sdio mmc2:0001:1: cmd_wait_q terminated: -110
[ 154.083707] mwifiex_sdio mmc2:0001:1: failed to get signal information
[...]

Last observed scenario is again a failure occuring some time after
firmware loading succeeds. This also seems to be irrecoverable without
device reboot.

[ 2101.209913] mwifiex_sdio mmc2:0001:1: mwifiex_cmd_timeout_func: Timeout cmd id = 0xa4, act = 0x0
[ 2101.209941] mwifiex_sdio mmc2:0001:1: num_data_h2c_failure = 0
[ 2101.209949] mwifiex_sdio mmc2:0001:1: num_cmd_h2c_failure = 0
[ 2101.209957] mwifiex_sdio mmc2:0001:1: is_cmd_timedout = 1
[ 2101.209964] mwifiex_sdio mmc2:0001:1: num_tx_timeout = 0
[ 2101.209971] mwifiex_sdio mmc2:0001:1: last_cmd_index = 1
[ 2101.209978] mwifiex_sdio mmc2:0001:1: last_cmd_id: 16 00 a4 00 75 00 a4 00 7f 00
[ 2101.209988] mwifiex_sdio mmc2:0001:1: last_cmd_act: 00 00 00 00 02 00 00 00 00 00
[ 2101.209995] mwifiex_sdio mmc2:0001:1: last_cmd_resp_index = 0
[ 2101.210003] mwifiex_sdio mmc2:0001:1: last_cmd_resp_id: 16 80 a4 80 75 80 a4 80 7f 80
[ 2101.210010] mwifiex_sdio mmc2:0001:1: last_event_index = 4
[ 2101.210018] mwifiex_sdio mmc2:0001:1: last_event: 0b 00 0a 00 0b 00 0a 00 1c 00
[ 2101.210025] mwifiex_sdio mmc2:0001:1: data_sent=1 cmd_sent=1
[ 2101.210033] mwifiex_sdio mmc2:0001:1: ps_mode=1 ps_state=0
[ 2101.210089] mwifiex_sdio mmc2:0001:1: failed to get signal information
[ 2101.210761] mwifiex_sdio mmc2:0001:1: PREP_CMD: FW is in bad state
[ 2101.210786] mwifiex_sdio mmc2:0001:1: failed to get signal information
[ 2101.211162] mwifiex_sdio mmc2:0001:1: ===mwifiex driverinfo dump start===
[ 2101.211178] mwifiex_sdio mmc2:0001:1: info: MWIFIEX VERSION: mwifiex 1.0 (14.75.33.p119)
[ 2101.211202] mwifiex_sdio mmc2:0001:1: SDIO register dump start
[ 2101.211482] mwifiex_sdio mmc2:0001:1: SDIO Func0 (0x0-0x9): 32 02 02 02 03 00 00 02 03 00
[ 2101.211649] mwifiex_sdio mmc2:0001:1: SDIO Func1 (0x0-0x9): 02 3f 03 00 00 00 00 00 92 00
[ 2101.211740] mwifiex_sdio mmc2:0001:1: SDIO Func1: (0x28) 00 (0x30) 08 (0x34) 07 (0x38) 11 (0x3c) 00
[ 2101.211921] mwifiex_sdio mmc2:0001:1: SDIO Func1 (0x60-0x6a): dc fe 5f 81 ca 04 00 79 79 00 30
[ 2101.314135] mwifiex_sdio mmc2:0001:1: SDIO Func1 (0x60-0x6a): dc fe 5f 81 ca 04 00 79 79 00 30
[ 2101.314168] mwifiex_sdio mmc2:0001:1: SDIO register dump end
[ 2101.314300] mwifiex_sdio mmc2:0001:1: ===mwifiex driverinfo dump end===
[ 2101.314313] mwifiex_sdio mmc2:0001:1: == mwifiex dump information to /sys/class/devcoredump start
[ 2101.314586] mwifiex_sdio mmc2:0001:1: == mwifiex dump information to /sys/class/devcoredump end
[ 2101.314610] mwifiex_sdio mmc2:0001:1: PREP_CMD: FW is in bad state
[ 2101.314638] mwifiex_sdio mmc2:0001:1: PREP_CMD: FW is in bad state
[ 2101.317997] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.318029] mwifiex_sdio mmc2:0001:1: deleting the crypto keys
[ 2101.318037] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.318044] mwifiex_sdio mmc2:0001:1: deleting the crypto keys
[ 2101.318051] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.318057] mwifiex_sdio mmc2:0001:1: deleting the crypto keys
[ 2101.318064] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.318071] mwifiex_sdio mmc2:0001:1: deleting the crypto keys
[ 2101.318078] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.318084] mwifiex_sdio mmc2:0001:1: deleting the crypto keys
[ 2101.318091] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.318098] mwifiex_sdio mmc2:0001:1: deleting the crypto keys
[ 2101.321278] mwifiex_sdio mmc2:0001:1: info: shutdown mwifiex...
[ 2101.323214] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.323250] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.324427] mwifiex_sdio mmc2:0001:1: PREP_CMD: card is removed
[ 2101.419786] mmc2: queuing unknown CIS tuple 0x50 [40 1e fd d1 c0 46 70 47 00 b5 23 48 24 49 01 60 24 48 24 49 01 60 24 49 08 47 1f 48 24 49 01 60] (32 bytes)
[ 2101.460850] mmc2: queuing unknown CIS tuple 0x70 [53 f0 21 e3 1e ff 2f e1 10 1f 11 ee 00 00 50 e3 02 2a a0 e3 02 10 c1 01 02 10 81 11 10 1f 01 ee 1e ff 2f e1 01 00 a0 e3 f6 ff ff eb ea ff ff fa 48 00 9f e5 54 10 9f e5 54 20 9f e5 ef ff ff eb] (71 bytes)
[ 2101.532495] mmc2: queuing unknown CIS tuple 0xe8 [2f 07 ee 1e ff 2f e1 0e 30 a0 e1 00 00 a0 e3 ea ff ff eb e5 ff ff fa 03 e0 a0 e1 2c 30 9f e5 13 ff 2f e1 00 10 80 e5 1a 9f 00 ee 12 ff 2f e1 04 21 00 80 c0 00 10 80 04 22 00 80 06 0a 46 02 48] (144 bytes)
[ 2101.598922] mmc2: queuing unknown CIS tuple 0x9d [29 15 1d 01 00 4d 61 72 76 65 6c 6c 20 42 6c 75 65 74 6f 6f 74 68 20 44 65 76 69 63 65 00 00 ff 20 04 df 02 32 91 21 02 0c 00 22 2a 01 01 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00] (162 bytes)
[ 2101.599647] mmc2: tried to HW reset card, got error -2
[ 2101.599699] mwifiex_sdio mmc2:0001:1: SDIO HW reset failed: -2

Despite these problems, the wireless is overall usable on the phone,
once the firmware loading succeeds, even for intensive transfers, until
one of the other failures occurs, for which no rule seems to exist - it
can happen soon after starting some transfer or it can work for several
hours under normal load, although some CMD_RESP errors (as above) are
printed frequently.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://github.com/CoderCharmander/g361f-kernel
[3] https://github.com/acorn-marvell/brillo_pxa_kernel
[4] https://wiki.postmarketos.org/wiki/Marvell_PXA1908

Karel Balej (2):
dt-bindings: mwifiex: document use with the SD8777 chipset
net: mwifiex: add support for the SD8777 chipset

.../bindings/net/wireless/marvell-8xxx.txt | 3 ++-
drivers/net/wireless/marvell/mwifiex/Kconfig | 4 ++--
drivers/net/wireless/marvell/mwifiex/sdio.c | 19 +++++++++++++++++++
drivers/net/wireless/marvell/mwifiex/sdio.h | 1 +
include/linux/mmc/sdio_ids.h | 1 +
5 files changed, 25 insertions(+), 3 deletions(-)

--
2.42.0


2023-10-29 11:19:33

by Karel Balej

[permalink] [raw]
Subject: [PATCH 2/2] net: mwifiex: add support for the SD8777 chipset

Marvell SD8777 is a wireless chipset used for instance in the PXA1908
SoC found for example in the samsung,coreprimevelte smartphone, with
which this was tested. The driver seems to be compatible with this
chipset so enable this support by adding the necessary information based
on the downstream code.

Signed-off-by: Karel Balej <[email protected]>
---
drivers/net/wireless/marvell/mwifiex/Kconfig | 4 ++--
drivers/net/wireless/marvell/mwifiex/sdio.c | 19 +++++++++++++++++++
drivers/net/wireless/marvell/mwifiex/sdio.h | 1 +
include/linux/mmc/sdio_ids.h | 1 +
4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/Kconfig b/drivers/net/wireless/marvell/mwifiex/Kconfig
index b182f7155d66..a7bd2c5735f6 100644
--- a/drivers/net/wireless/marvell/mwifiex/Kconfig
+++ b/drivers/net/wireless/marvell/mwifiex/Kconfig
@@ -10,13 +10,13 @@ config MWIFIEX
mwifiex.

config MWIFIEX_SDIO
- tristate "Marvell WiFi-Ex Driver for SD8786/SD8787/SD8797/SD8887/SD8897/SD8977/SD8978/SD8987/SD8997"
+ tristate "Marvell WiFi-Ex Driver for SD8777/SD8786/SD8787/SD8797/SD8887/SD8897/SD8977/SD8978/SD8987/SD8997"
depends on MWIFIEX && MMC
select FW_LOADER
select WANT_DEV_COREDUMP
help
This adds support for wireless adapters based on Marvell
- 8786/8787/8797/8887/8897/8977/8978/8987/8997 chipsets with
+ 8777/8786/8787/8797/8887/8897/8977/8978/8987/8997 chipsets with
SDIO interface. SD8978 is also known as NXP IW416.

If you choose to build it as a module, it will be called
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index 774858cfe86f..c55f1f5669cb 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -318,6 +318,21 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd89xx = {
0x68, 0x69, 0x6a},
};

+static const struct mwifiex_sdio_device mwifiex_sdio_sd8777 = {
+ .firmware = SD8777_DEFAULT_FW_NAME,
+ .reg = &mwifiex_reg_sd87xx,
+ .max_ports = 16,
+ .mp_agg_pkt_limit = 8,
+ .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K,
+ .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
+ .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
+ .supports_sdio_new_mode = false,
+ .has_control_mask = true,
+ .can_dump_fw = false,
+ .can_auto_tdls = false,
+ .can_ext_scan = true,
+};
+
static const struct mwifiex_sdio_device mwifiex_sdio_sd8786 = {
.firmware = SD8786_DEFAULT_FW_NAME,
.reg = &mwifiex_reg_sd87xx,
@@ -496,6 +511,7 @@ static struct memory_type_mapping mem_type_mapping_tbl[] = {
};

static const struct of_device_id mwifiex_sdio_of_match_table[] __maybe_unused = {
+ { .compatible = "marvell,sd8777" },
{ .compatible = "marvell,sd8787" },
{ .compatible = "marvell,sd8897" },
{ .compatible = "marvell,sd8978" },
@@ -924,6 +940,8 @@ static void mwifiex_sdio_coredump(struct device *dev)

/* WLAN IDs */
static const struct sdio_device_id mwifiex_ids[] = {
+ {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8777_WLAN),
+ .driver_data = (unsigned long)&mwifiex_sdio_sd8777},
{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8786_WLAN),
.driver_data = (unsigned long) &mwifiex_sdio_sd8786},
{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8787_WLAN),
@@ -3180,6 +3198,7 @@ MODULE_AUTHOR("Marvell International Ltd.");
MODULE_DESCRIPTION("Marvell WiFi-Ex SDIO Driver version " SDIO_VERSION);
MODULE_VERSION(SDIO_VERSION);
MODULE_LICENSE("GPL v2");
+MODULE_FIRMWARE(SD8777_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8786_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8787_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8797_DEFAULT_FW_NAME);
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.h b/drivers/net/wireless/marvell/mwifiex/sdio.h
index ae94c172310f..ed92256b2302 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.h
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.h
@@ -18,6 +18,7 @@

#include "main.h"

+#define SD8777_DEFAULT_FW_NAME "mrvl/sd8777_uapsta.bin"
#define SD8786_DEFAULT_FW_NAME "mrvl/sd8786_uapsta.bin"
#define SD8787_DEFAULT_FW_NAME "mrvl/sd8787_uapsta.bin"
#define SD8797_DEFAULT_FW_NAME "mrvl/sd8797_uapsta.bin"
diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
index 7fada7a714fe..c46ab35ceb20 100644
--- a/include/linux/mmc/sdio_ids.h
+++ b/include/linux/mmc/sdio_ids.h
@@ -94,6 +94,7 @@
#define SDIO_DEVICE_ID_MARVELL_8797_BT 0x912a
#define SDIO_DEVICE_ID_MARVELL_8897_WLAN 0x912d
#define SDIO_DEVICE_ID_MARVELL_8897_BT 0x912e
+#define SDIO_DEVICE_ID_MARVELL_8777_WLAN 0x9131
#define SDIO_DEVICE_ID_MARVELL_8887_F0 0x9134
#define SDIO_DEVICE_ID_MARVELL_8887_WLAN 0x9135
#define SDIO_DEVICE_ID_MARVELL_8887_BT 0x9136
--
2.42.0

2023-10-29 11:19:36

by Karel Balej

[permalink] [raw]
Subject: [PATCH 1/2] dt-bindings: mwifiex: document use with the SD8777 chipset

Document the corresponding compatible string for the use of this driver
with the Marvell SD8777 wireless chipset.

Signed-off-by: Karel Balej <[email protected]>
---
.../devicetree/bindings/net/wireless/marvell-8xxx.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
index cdc303caf5f4..4f374ea029ed 100644
--- a/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
+++ b/Documentation/devicetree/bindings/net/wireless/marvell-8xxx.txt
@@ -1,4 +1,4 @@
-Marvell 8787/8897/8978/8997 (sd8787/sd8897/sd8978/sd8997/pcie8997) SDIO/PCIE devices
+Marvell 8777/8787/8897/8978/8997 (sd8777/sd8787/sd8897/sd8978/sd8997/pcie8997) SDIO/PCIE devices
------

This node provides properties for controlling the Marvell SDIO/PCIE wireless device.
@@ -8,6 +8,7 @@ connects the device to the system.
Required properties:

- compatible : should be one of the following:
+ * "marvell,sd8777"
* "marvell,sd8787"
* "marvell,sd8897"
* "marvell,sd8978"
--
2.42.0

2023-10-29 11:26:59

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: mwifiex: document use with the SD8777 chipset

On 29/10/2023 12:08, Karel Balej wrote:
> Document the corresponding compatible string for the use of this driver
> with the Marvell SD8777 wireless chipset.
>
> Signed-off-by: Karel Balej <[email protected]>
> ---


Acked-by: Krzysztof Kozlowski <[email protected]>


---

This is an automated instruction, just in case, because many review tags
are being ignored. If you know the process, you can skip it (please do
not feel offended by me posting it here - no bad intentions intended).
If you do not know the process, here is a short explanation:

Please add Acked-by/Reviewed-by/Tested-by tags when posting new
versions, under or above your Signed-off-by tag. Tag is "received", when
provided in a message replied to you on the mailing list. Tools like b4
can help here. However, there's no need to repost patches *only* to add
the tags. The upstream maintainer will do that for tags received on the
version they apply.

https://elixir.bootlin.com/linux/v6.5-rc3/source/Documentation/process/submitting-patches.rst#L577


Best regards,
Krzysztof