linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wlcore: Fix bringing up wlan0 again if powered down briefly
@ 2018-12-17 16:42 Tony Lindgren
  2018-12-18  1:06 ` Ricardo Salveti
  2018-12-18 12:34 ` Ulf Hansson
  0 siblings, 2 replies; 15+ messages in thread
From: Tony Lindgren @ 2018-12-17 16:42 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Eyal Reizer, Kishon Vijay Abraham I, Guy Mishol, linux-wireless,
	linux-omap, Anders Roxell, John Stultz, Ricardo Salveti,
	Ulf Hansson

At least HiKey board can fail to bring up wireless interface again
if the interface is brought down and up with no delay inbetween.

This can be done tested with:

# while true; do ifconfig wlan0 down; ifconfig wlan0 up; done

According to Ricardo Salveti <rsalveti@rsalveti.net>, we need to
wait between 30 - 40 ms on HiKey. This seems to happen when we
get -EBUSY returned by pm_runtime_put() basedon the check in
rpm_check_suspend_allowed(). But as it still unclear if part of
the delay needed is because of capacitance, let's always do a
at least 50 ms msleep even if no -EBUSY is returned.

Cc: Anders Roxell <anders.roxell@linaro.org>
Cc: Eyal Reizer <eyalr@ti.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Ricardo Salveti <rsalveti@rsalveti.net>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Reported-by: Ricardo Salveti <rsalveti@rsalveti.net>
Fixes: 60f36637bbbd ("wlcore: sdio: allow pm to handle sdio power")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---

Uffe, do you have some better ideas on how to fix this issue?

---
 drivers/net/wireless/ti/wlcore/sdio.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c
--- a/drivers/net/wireless/ti/wlcore/sdio.c
+++ b/drivers/net/wireless/ti/wlcore/sdio.c
@@ -174,7 +174,7 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue)
 {
 	struct sdio_func *func = dev_to_sdio_func(glue->dev);
 	struct mmc_card *card = func->card;
-	int error;
+	int error, retries = 5;
 
 	sdio_claim_host(func);
 	sdio_disable_func(func);
@@ -188,6 +188,17 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue)
 		return error;
 	}
 
+	/* Wait a bit to ensure the card gets power off. Otherwise
+	 * bringing interface down and up again may not power off the
+	 * card inbetween. And then firmware load will fail on trying
+	 * to bring the card up again. We need to wait between 30 - 40
+	 * ms for this based on measurements on HiKey board.
+	 */
+	do {
+		msleep(50);
+	} while (error == -EBUSY && !pm_runtime_suspended(&card->dev) &&
+		 retries--);
+
 	return 0;
 }
 
-- 
2.19.2

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

end of thread, other threads:[~2019-01-14 13:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 16:42 [PATCH] wlcore: Fix bringing up wlan0 again if powered down briefly Tony Lindgren
2018-12-18  1:06 ` Ricardo Salveti
2018-12-18 12:34 ` Ulf Hansson
2018-12-18 15:54   ` Tony Lindgren
2018-12-20 10:14     ` Ulf Hansson
2018-12-20 23:14       ` Tony Lindgren
2018-12-23  7:38         ` [EXTERNAL] " Reizer, Eyal
2018-12-23 16:02           ` Tony Lindgren
2018-12-28 11:01             ` Ulf Hansson
2018-12-28 19:59               ` Tony Lindgren
2019-01-02 12:01                 ` Ulf Hansson
2019-01-07 15:18                   ` Tony Lindgren
2019-01-07 16:12                     ` Kalle Valo
2019-01-14 13:47                       ` Ulf Hansson
2018-12-28  9:48           ` Ulf Hansson

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