wlcore: sdio: Fix flakey SDIO runtime PM handling
authorTony Lindgren <tony@atomide.com>
Thu, 17 May 2018 18:29:50 +0000 (11:29 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 29 May 2018 07:14:45 +0000 (10:14 +0300)
We can have pm_runtime_get_sync() return 1, and we can have
pm_runtime_put_sync() return -EBUSY. See rpm_suspend() and
rpm_resume() for more information.

Fix the issue by returning 0 from wl12xx_sdio_power_on() on success.
And use pm_runtime_put() instead of pm_runtime_put_sync() for
wl12xx_sdio_power_off(), then the MMC subsystem will idle the bus
when suitable.

Otherwise wlcore can sometimes get confused and may report bogus
errors and WLAN connection can fail.

Note that while wlcore checks the return value for wl1271_power_on(),
the return value is ignored for wl1271_power_off(). Let's fix them
both though to avoid further confusion in the future.

Fixes: 60f36637bbbd ("wlcore: sdio: allow pm to handle sdio power")
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ti/wlcore/sdio.c

index 6dbe61d47dc35a504cec8045b5626c7d2a5791b8..15d5ac1260616812d23baf3017b7b94b964b54da 100644 (file)
@@ -159,28 +159,36 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue)
                pm_runtime_put_noidle(&card->dev);
                dev_err(glue->dev, "%s: failed to get_sync(%d)\n",
                        __func__, ret);
-               goto out;
+
+               return ret;
        }
 
        sdio_claim_host(func);
        sdio_enable_func(func);
        sdio_release_host(func);
 
-out:
-       return ret;
+       return 0;
 }
 
 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;
 
        sdio_claim_host(func);
        sdio_disable_func(func);
        sdio_release_host(func);
 
        /* Let runtime PM know the card is powered off */
-       return pm_runtime_put_sync(&card->dev);
+       error = pm_runtime_put(&card->dev);
+       if (error < 0 && error != -EBUSY) {
+               dev_err(&card->dev, "%s failed: %i\n", __func__, error);
+
+               return error;
+       }
+
+       return 0;
 }
 
 static int wl12xx_sdio_set_power(struct device *child, bool enable)