mmc: card: quirk: disable cache for Hynix card

This change prevents enabling cache during card init for Hynix cards.
This change is workaround the problem of Hynix cards behavior for
adb reboot flow, when as a result of power cycle with cache enabled,
ext4 journal get aborted, because of meta data corruption.

Change-Id: I3198c940a334c8e5fbc3e68e0fea638e76467a75
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
This commit is contained in:
Konstantin Dorfman 2014-01-27 11:46:25 +02:00
parent a18f488cdf
commit 6932a01cda
4 changed files with 15 additions and 4 deletions

View File

@ -3158,6 +3158,9 @@ static const struct mmc_fixup blk_fixups[] =
MMC_FIXUP("SEM04G", 0x45, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_INAND_DATA_TIMEOUT),
/* Disable cache for this cards */
MMC_FIXUP("H8G2d", CID_MANFID_HYNIX, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_CACHE_DISABLE),
END_FIXUP
};

View File

@ -3541,7 +3541,8 @@ int mmc_flush_cache(struct mmc_card *card)
struct mmc_host *host = card->host;
int err = 0, rc;
if (!(host->caps2 & MMC_CAP2_CACHE_CTRL))
if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) ||
(card->quirks & MMC_QUIRK_CACHE_DISABLE))
return err;
if (mmc_card_mmc(card) &&
@ -3580,7 +3581,8 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
int err = 0, rc;
if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) ||
mmc_card_is_removable(host))
mmc_card_is_removable(host) ||
(card->quirks & MMC_QUIRK_CACHE_DISABLE))
return err;
if (card && mmc_card_mmc(card) &&

View File

@ -1555,7 +1555,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
* If HPI is not supported then cache shouldn't be enabled.
*/
if ((host->caps2 & MMC_CAP2_CACHE_CTRL) &&
(card->ext_csd.cache_size > 0) && card->ext_csd.hpi_en) {
(card->ext_csd.cache_size > 0) && card->ext_csd.hpi_en &&
((card->quirks & MMC_QUIRK_CACHE_DISABLE) == 0)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_CACHE_CTRL, 1,
card->ext_csd.generic_cmd6_time);
@ -1575,6 +1576,11 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
card->ext_csd.cache_ctrl = 1;
}
}
if (card->quirks & MMC_QUIRK_CACHE_DISABLE) {
pr_warn("%s: This is Hynix card, cache disabled!\n",
mmc_hostname(card->host));
card->ext_csd.cache_ctrl = 0;
}
/*
* The mandatory minimum values are defined for packed command.

View File

@ -356,7 +356,7 @@ struct mmc_card {
#define MMC_QUIRK_BROKEN_HPI (1 << 12)
/* Skip data-timeout advertised by card */
#define MMC_QUIRK_BROKEN_DATA_TIMEOUT (1<<13)
#define MMC_QUIRK_CACHE_DISABLE (1 << 14) /* prevent cache enable */
unsigned int erase_size; /* erase size in sectors */
unsigned int erase_shift; /* if erase unit is power 2 */