On Fri, Dec 14, 2018 at 9:29 PM Tony Lindgren <tony@xxxxxxxxxxx> wrote: > * Ricardo Salveti <rsalveti@xxxxxxxxxxxx> [181214 12:42]: > > Basically since commit 60f36637bbbd ("wlcore: sdio: allow pm to handle > > sdio power") PM is now handling the sdio power off/on process, and if > > wl12xx_sdio_power_on gets called right after wl12xx_sdio_power_off (if > > down/up), the device will not go to the required power off/on sequence > > (since PM will abort the suspend process), and the firmware loading > > process will fail. I would guess the problem only happens with > > autosuspend because of the extra delay it causes (pm_runtime_put > > always returns -EBUSY on wl12xx_sdio_power_off with autosuspend). > > OK thanks for the update, that's interesting. > > > Is there a way to force the suspend on wl12xx_sdio_power_off, or > > should we partially restore the old behavior? > > Well usually we could do pm_runtime_put_sync_suspend() but > here it won't help as the pm_runtime_put() is already in > progress by the SDIO subsystem and that's why we get -EBUSY. > > Does adding a little wait at the end of wl12xx_sdio_power_off() > before return? Maybe something like: > > /* Make sure the card gets powered off */ > while (error == -EBUSY && !pm_runtime_suspended(&card->dev) && > retries--) { > msleep(100); > } Yes, this is enough to force the power off process and fixes the hang I was having. Also tried playing a bit with the msleep value and can confirm it usually needs to wait between 30-40 milliseconds before powering the card off. Do you mind sending a patch with the above changes then? I can help testing with the boards I have. Thanks, -- Ricardo Salveti de Araujo