mmc: block: skip trim for some kingston eMMCs
authorShawn Lin <shawn.lin@rock-chips.com>
Wed, 12 Aug 2015 05:08:32 +0000 (13:08 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 27 Aug 2015 12:50:52 +0000 (14:50 +0200)
For some mass production of kingston eMMCs which adopt Phison's
firmware will meet an unrecoverable data conrruption occasionally
if performing trim due to a firmware bug confirmed by vendor. We
found it on Intel-C3230RK platform. So we add fixup of broken trim
for it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/card/block.c
drivers/mmc/core/core.c
include/linux/mmc/card.h

index a58287e574cc81ff21f63be0876cd2edeedc18cf..c742cfd7674e0eb699b2e656cff1eba288932b6f 100644 (file)
@@ -2389,6 +2389,7 @@ force_ro_fail:
 #define CID_MANFID_TOSHIBA     0x11
 #define CID_MANFID_MICRON      0x13
 #define CID_MANFID_SAMSUNG     0x15
+#define CID_MANFID_KINGSTON    0x70
 
 static const struct mmc_fixup blk_fixups[] =
 {
@@ -2451,6 +2452,15 @@ static const struct mmc_fixup blk_fixups[] =
        MMC_FIXUP("VZL00M", CID_MANFID_SAMSUNG, CID_OEMID_ANY, add_quirk_mmc,
                  MMC_QUIRK_SEC_ERASE_TRIM_BROKEN),
 
+       /*
+        *  On Some Kingston eMMCs, performing trim can result in
+        *  unrecoverable data conrruption occasionally due to a firmware bug.
+        */
+       MMC_FIXUP("V10008", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc,
+                 MMC_QUIRK_TRIM_BROKEN),
+       MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc,
+                 MMC_QUIRK_TRIM_BROKEN),
+
        END_FIXUP
 };
 
index 57edb2a9bb04bbf52daa9286e90d26ca1341d9b7..664b61729fa963b50b154f6c8e67bbfba007e423 100644 (file)
@@ -2250,7 +2250,8 @@ EXPORT_SYMBOL(mmc_can_erase);
 
 int mmc_can_trim(struct mmc_card *card)
 {
-       if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
+       if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) &&
+           (!(card->quirks & MMC_QUIRK_TRIM_BROKEN)))
                return 1;
        return 0;
 }
index 8fcbcd13218f5f1b1a0e1990b888c0d5e28aadfb..fdd0779ccdfa52309f5e99aeeadd84b356c1a472 100644 (file)
@@ -279,6 +279,8 @@ struct mmc_card {
 #define MMC_QUIRK_LONG_READ_TIME (1<<9)                /* Data read time > CSD says */
 #define MMC_QUIRK_SEC_ERASE_TRIM_BROKEN (1<<10)        /* Skip secure for erase/trim */
 #define MMC_QUIRK_BROKEN_IRQ_POLLING   (1<<11) /* Polling SDIO_CCCR_INTx could create a fake interrupt */
+#define MMC_QUIRK_TRIM_BROKEN  (1<<12)         /* Skip trim */
+
 
        unsigned int            erase_size;     /* erase size in sectors */
        unsigned int            erase_shift;    /* if erase unit is power 2 */