diff mbox series

wlcore/wl12xx: Fix wl12xx get_mac error if device is in ELP

Message ID 20210603062814.19464-1-tony@atomide.com
State Accepted
Commit 11ef6bc846dcdce838f0b00c5f6a562c57e5d43b
Delegated to: Kalle Valo
Headers show
Series wlcore/wl12xx: Fix wl12xx get_mac error if device is in ELP | expand

Commit Message

Tony Lindgren June 3, 2021, 6:28 a.m. UTC
At least on wl12xx, reading the MAC after boot can fail with a warning
at drivers/net/wireless/ti/wlcore/sdio.c:78 wl12xx_sdio_raw_read.
The failed call comes from wl12xx_get_mac() that wlcore_nvs_cb() calls
after request_firmware_work_func().

After the error, no wireless interface is created. Reloading the wl12xx
module makes the interface work.

Turns out the wlan controller can be in a low-power ELP state after the
boot from the bootloader or kexec, and needs to be woken up first.

Let's wake the hardware and add a sleep after that similar to
wl12xx_pre_boot() is already doing.

Note that a similar issue could exist for wl18xx, but I have not seen it
so far. And a search for wl18xx_get_mac and wl12xx_sdio_raw_read did not
produce similar errors.

Cc: Carl Philipp Klemm <philipp@uvos.xyz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/net/wireless/ti/wl12xx/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Kalle Valo June 14, 2021, 3:47 p.m. UTC | #1
Tony Lindgren <tony@atomide.com> wrote:

> At least on wl12xx, reading the MAC after boot can fail with a warning
> at drivers/net/wireless/ti/wlcore/sdio.c:78 wl12xx_sdio_raw_read.
> The failed call comes from wl12xx_get_mac() that wlcore_nvs_cb() calls
> after request_firmware_work_func().
> 
> After the error, no wireless interface is created. Reloading the wl12xx
> module makes the interface work.
> 
> Turns out the wlan controller can be in a low-power ELP state after the
> boot from the bootloader or kexec, and needs to be woken up first.
> 
> Let's wake the hardware and add a sleep after that similar to
> wl12xx_pre_boot() is already doing.
> 
> Note that a similar issue could exist for wl18xx, but I have not seen it
> so far. And a search for wl18xx_get_mac and wl12xx_sdio_raw_read did not
> produce similar errors.
> 
> Cc: Carl Philipp Klemm <philipp@uvos.xyz>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

Patch applied to wireless-drivers-next.git, thanks.

11ef6bc846dc wlcore/wl12xx: Fix wl12xx get_mac error if device is in ELP
diff mbox series

Patch

diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
--- a/drivers/net/wireless/ti/wl12xx/main.c
+++ b/drivers/net/wireless/ti/wl12xx/main.c
@@ -1503,6 +1503,13 @@  static int wl12xx_get_fuse_mac(struct wl1271 *wl)
 	u32 mac1, mac2;
 	int ret;
 
+	/* Device may be in ELP from the bootloader or kexec */
+	ret = wlcore_write32(wl, WL12XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
+	if (ret < 0)
+		goto out;
+
+	usleep_range(500000, 700000);
+
 	ret = wlcore_set_partition(wl, &wl->ptable[PART_DRPW]);
 	if (ret < 0)
 		goto out;