summaryrefslogtreecommitdiff
path: root/drivers/mmc/core/sd.c
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2013-10-02 17:37:09 +0200
committerChris Ball <cjb@laptop.org>2013-10-30 20:28:40 -0400
commit9ec775f7efd6d17084b4f361804d2030d50fca0e (patch)
tree96e83ec6405aa185bbb7cf8f1fa819ffaafd76ad /drivers/mmc/core/sd.c
parent0c04c6274fbc56c40649472e0076e949ecbc75ce (diff)
mmc: Don't force card to active state when entering suspend/shutdown
By adding a card state that records if it is suspended or resumed, we can accept asyncronus suspend/resume requests for the mmc and sd bus_ops. MMC_CAP_AGGRESSIVE_PM, will at request inactivity through the runtime bus_ops callbacks, execute a suspend of the the card. In the state were this has been done, we can receive a suspend request for the mmc bus, which for sd and mmc forced the card to active state by a pm_runtime_get_sync. In other words, the card was resumed and then immediately suspended again, completely unnecessary. Since the suspend/resume bus_ops callbacks for sd and mmc are now capable of handling asynchronous requests, we no longer need to force the card to active state before executing suspend. Evidently preventing the above sequence for MMC_CAP_AGGRESSIVE_PM. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/core/sd.c')
-rw-r--r--drivers/mmc/core/sd.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 6ef84d0ca178..685796560f8b 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1078,13 +1078,20 @@ static int mmc_sd_suspend(struct mmc_host *host)
BUG_ON(!host->card);
mmc_claim_host(host);
+
+ if (mmc_card_suspended(host->card))
+ goto out;
+
if (!mmc_host_is_spi(host))
err = mmc_deselect_cards(host);
host->card->state &= ~MMC_STATE_HIGHSPEED;
- if (!err)
+ if (!err) {
mmc_power_off(host);
- mmc_release_host(host);
+ mmc_card_set_suspended(host->card);
+ }
+out:
+ mmc_release_host(host);
return err;
}
@@ -1096,16 +1103,22 @@ static int mmc_sd_suspend(struct mmc_host *host)
*/
static int mmc_sd_resume(struct mmc_host *host)
{
- int err;
+ int err = 0;
BUG_ON(!host);
BUG_ON(!host->card);
mmc_claim_host(host);
+
+ if (!mmc_card_suspended(host->card))
+ goto out;
+
mmc_power_up(host, host->card->ocr);
err = mmc_sd_init_card(host, host->card->ocr, host->card);
- mmc_release_host(host);
+ mmc_card_clr_suspended(host->card);
+out:
+ mmc_release_host(host);
return err;
}