mmc: core: sdio: move mmc_sdio_init_card to a separate function
RFC PATCH 1/2 mmc: core: sdio: move mmc_sdio_init_card to a separate function
No functional change. Move mmc_sdio_init_card to a separate function (_mmc_sdio_power_restore) and invoke it from mmc_sdio_power_restore. This is in preparation to invoke _mmc_sdio_power_restore from mmc_sdio_runtime_resume so that mmc_claim_host can be invoked before mmc_power_up.
--- drivers/mmc/core/sdio.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/mmc/core/sdio.c +14 -8
@@ -970,15 +970,10 @@ static int mmc_sdio_resume(struct mmc_host *host)return err; } -static int mmc_sdio_power_restore (struct mmc_host *host) +static int _mmc_sdio_power_restore (struct mmc_host *host) {int ret; -BUG_ON (!host); -BUG_ON (!host->card); - -mmc_claim_host (host); -/* * Reset the card by performing the same steps that are taken by * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe.
@@ -1002,14 +997,25 @@ static int mmc_sdio_power_restore(struct mmc_host *host) ret =mmc_send_io_op_cond (host,0 ,NULL );if (ret) - goto out; +return ret; ret =mmc_sdio_init_card (host, host->card->ocr, host->card,mmc_card_keep_power (host));if (!ret && host->sdio_irqs)mmc_signal_sdio_irq (host); -out: +return 0 ; +} + +static int mmc_sdio_power_restore (struct mmc_host *host) +{ +int ret; + +BUG_ON (!host); +BUG_ON (!host->card); + +mmc_claim_host (host); + ret =_mmc_sdio_power_restore (host);mmc_release_host (host);return ret;
Signature · 1 line
1.7.9.5
RFC PATCH 2/2 mmc: core: sdio: claim host before power up or power off
mmc_sdio_runtime_resume and mmc_sdio_runtime_suspend does power up and power off respectively but does so without claiming the host. Among other things mmc_claim_host inovkes pm_runtime_get_sync to enable the clocks. Invoke mmc_claim_host before mmc_power_up and mmc_power_off in mmc_sdio_runtime_resume and mmc_sdio_runtime_suspend respectively.
This is required since certain platforms (like TI SoCs) access the controller registers during power up.
--- drivers/mmc/core/sdio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/mmc/core/sdio.c +9 -1
@@ -1023,16 +1023,24 @@ static int mmc_sdio_power_restore(struct mmc_host *host)static int mmc_sdio_runtime_suspend (struct mmc_host *host) { +mmc_claim_host (host);/* No references to the card, cut the power to it. */ mmc_power_off (host); +mmc_release_host (host);return 0 ; }static int mmc_sdio_runtime_resume (struct mmc_host *host) { +int ret; + +mmc_claim_host (host);/* Restore power and re-initialize. */ mmc_power_up (host, host->card->ocr); -return mmc_sdio_power_restore (host); + ret =_mmc_sdio_power_restore (host); +mmc_release_host (host); + +return ret; }static int mmc_sdio_reset (struct mmc_host *host)
Signature · 1 line
1.7.9.5
Re: [RFC PATCH 2/2] mmc: core: sdio: claim host before power up or power off
Quoted 8 lines · Kishon Vijay Abraham I
mmc_sdio_runtime_resumeandmmc_sdio_runtime_suspenddoes power up and power off respectively but does so without claiming the host. Among other thingsmmc_claim_hostinovkespm_runtime_get_syncto enable the clocks. Invokemmc_claim_hostbeforemmc_power_upandmmc_power_offinmmc_sdio_runtime_resumeandmmc_sdio_runtime_suspendrespectively.This is required since certain platforms (like TI SoCs) access the controller registers during power up.
I realize the issue. Actually I have been working on similar patch which take a bit wider approach. That's because there are more cases where the host needs to be claimed, when it isn't.
I just posted a patch, please have a look and see if it makes sense to you, you are on cc.
"[PATCH] mmc: core: Keep host claimed while invoking mmc_power_off|up()"
Kind regards
Uffe
Quoted 39 lines
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/mmc/core/sdio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/mmc/core/sdio.c +9
-2@@ -1023,16 +1023,24 @@ static int mmc_sdio_power_restore(struct mmc_host *host)static int mmc_sdio_runtime_suspend (struct mmc_host *host) { +mmc_claim_host (host);/* No references to the card, cut the power to it. */ mmc_power_off (host); +mmc_release_host (host);return 0 ; }static int mmc_sdio_runtime_resume (struct mmc_host *host) { +int ret; + +mmc_claim_host (host);/* Restore power and re-initialize. */ mmc_power_up (host, host->card->ocr); -return mmc_sdio_power_restore (host); + ret =_mmc_sdio_power_restore (host); +mmc_release_host (host); + +return ret; }static int mmc_sdio_reset (struct mmc_host *host) --1.7.9.5
Re: [RFC PATCH 2/2] mmc: core: sdio: claim host before power up or power off
Hi,
Quoted 10 lines · Ulf Hansson
Quoted 8 lines · Kishon Vijay Abraham I
mmc_sdio_runtime_resumeandmmc_sdio_runtime_suspenddoes power up and power off respectively but does so without claiming the host. Among other thingsmmc_claim_hostinovkespm_runtime_get_syncto enable the clocks. Invokemmc_claim_hostbeforemmc_power_upandmmc_power_offinmmc_sdio_runtime_resumeandmmc_sdio_runtime_suspendrespectively.This is required since certain platforms (like TI SoCs) access the controller registers during power up.
Quoted 7 lines
I realize the issue. Actually I have been working on similar patch which take a bit wider approach. That's because there are more cases where the host needs to be claimed, when it isn't.
I just posted a patch, please have a look and see if it makes sense to you, you are on cc.
"[PATCH] mmc: core: Keep host claimed while invoking mmc_power_off|up()"
Sure Uffe.
-Kishon
Quoted 43 lines
Kind regards
UffeQuoted 39 lines
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/mmc/core/sdio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/mmc/core/sdio.c +9
-2@@ -1023,16 +1023,24 @@ static int mmc_sdio_power_restore(struct mmc_host *host)static int mmc_sdio_runtime_suspend (struct mmc_host *host) { +mmc_claim_host (host);/* No references to the card, cut the power to it. */ mmc_power_off (host); +mmc_release_host (host);return 0 ; }static int mmc_sdio_runtime_resume (struct mmc_host *host) { +int ret; + +mmc_claim_host (host);/* Restore power and re-initialize. */ mmc_power_up (host, host->card->ocr); -return mmc_sdio_power_restore (host); + ret =_mmc_sdio_power_restore (host); +mmc_release_host (host); + +return ret; }static int mmc_sdio_reset (struct mmc_host *host) --1.7.9.5