mmc: core: disable the cache before suspend only after stopping BKOPS

mmc_cache_ctrl was called in runtime suspend before MMC interrupted
BKOPS in case it is still running on the card. This caused the cache
disable to timeout.
Therefore, mmc_cache_ctrl has to move to mmc_suspend where we are sure
that the card can go into suspend and there is no pending activity.

CRs-Fixed: 436805
Change-Id: I76281a766f48ccacc24685a64067df4e60cfe1d8
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit 67a51386fd99be62e5e68f4bc76ee00c19099cd6)
This commit is contained in:
Maya Erez 2012-12-31 16:17:58 +02:00 committed by Iliyan Malchev
parent 7cfc02ad99
commit c32f990a39
2 changed files with 8 additions and 10 deletions

View file

@ -2576,6 +2576,7 @@ EXPORT_SYMBOL(mmc_flush_cache);
* Turn the cache ON/OFF.
* Turning the cache OFF shall trigger flushing of the data
* to the non-volatile storage.
* This function should be called with host claimed
*/
int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
{
@ -2587,9 +2588,6 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
mmc_card_is_removable(host))
return err;
if (!mmc_try_claim_host(host))
return -EBUSY;
if (card && mmc_card_mmc(card) &&
(card->ext_csd.cache_size > 0)) {
enable = !!enable;
@ -2607,7 +2605,6 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
card->ext_csd.cache_ctrl = enable;
}
}
mmc_release_host(host);
return err;
}
@ -2630,10 +2627,6 @@ int mmc_suspend_host(struct mmc_host *host)
wake_unlock(&host->detect_wake_lock);
mmc_flush_scheduled_work();
err = mmc_cache_ctrl(host, 0);
if (err)
goto out;
mmc_bus_get(host);
if (host->bus_ops && !host->bus_dead) {
/*
@ -2685,7 +2678,6 @@ int mmc_suspend_host(struct mmc_host *host)
if (!err && !mmc_card_keep_power(host))
mmc_power_off(host);
out:
return err;
stop_bkops_err:
if (!(host->card && mmc_card_sdio(host->card)))

View file

@ -1447,6 +1447,11 @@ static int mmc_suspend(struct mmc_host *host)
BUG_ON(!host->card);
mmc_claim_host(host);
err = mmc_cache_ctrl(host, 0);
if (err)
goto out;
if (mmc_can_poweroff_notify(host->card))
err = mmc_poweroff_notify(host->card, EXT_CSD_POWER_OFF_SHORT);
else if (mmc_card_can_sleep(host))
@ -1454,8 +1459,9 @@ static int mmc_suspend(struct mmc_host *host)
else if (!mmc_host_is_spi(host))
mmc_deselect_cards(host);
host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);
mmc_release_host(host);
out:
mmc_release_host(host);
return err;
}