History

mmc: core: Add quirk for long data read time

Adds a quirk that sets the data read timeout to a fixed value instead of relying on the information in the CSD. The timeout value chosen is 300ms since that has proven enough for the problematic cards found, but could be increased if other cards require this. This patch also enables this quirk for certain Micron cards known to have this problem.

Stefan Nilsson XK committed 15 years ago

Commit 6de5fc91 parent 7833c663 files · +26 −0Browse files

Unified · Split

3 files
  1. drivers/mmc/card/block.c +8 −0
  2. drivers/mmc/core/core.c +12 −0
  3. include/linux/mmc/card.h +6 −0
drivers/mmc/card/block.c+8−0
@@ -1606,6 +1606,14 @@ static const struct mmc_fixup blk_fixups[] = · 1605 unmodified lines
16061606 MMC_QUIRK_BLK_NO_CMD23),
16071607 MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc,
16081608 MMC_QUIRK_BLK_NO_CMD23),
1609+
1610+ /*
1611+ * Some Micron MMC cards needs longer data read timeout than
1612+ * indicated in CSD.
1613+ */
1614+ MMC_FIXUP(CID_NAME_ANY, 0x13, 0x200, add_quirk_mmc,
1615+ MMC_QUIRK_LONG_READ_TIME),
1616+
16091617 END_FIXUP
16101618 };
16111619
drivers/mmc/core/core.c+12−0
@@ -529,6 +529,18 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) · 528 unmodified lines
529529 data->timeout_clks = 0;
530530 }
531531 }
532+
533+ /*
534+ * Some cards require longer data read timeout than indicated in CSD.
535+ * Address this by setting the read timeout to a "reasonably high"
536+ * value. For the cards tested, 300ms has proven enough. If necessary,
537+ * this value can be increased if other problematic cards require this.
538+ */
539+ if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) {
540+ data->timeout_ns = 300000000;
541+ data->timeout_clks = 0;
542+ }
543+
532544 /*
533545 * Some cards need very high timeouts if driven in SPI mode.
534546 * The worst observed timeout was 900ms after writing a
include/linux/mmc/card.h+6−0
@@ -218,6 +218,7 @@ struct mmc_card { · 217 unmodified lines
218218 #define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
219219 #define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
220220 #define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8) /* Avoid sending 512 bytes in */
221+#define MMC_QUIRK_LONG_READ_TIME (1<<9) /* Data read time > CSD says */
221222 /* byte mode */
222223 unsigned int poweroff_notify_state; /* eMMC4.5 notify feature */
223224 #define MMC_NO_POWER_NOTIFICATION 0
@@ -433,6 +434,11 @@ static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c) · 209 unmodified lines
433434 return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512;
434435 }
435436
437+static inline int mmc_card_long_read_time(const struct mmc_card *c)
438+{
439+ return c->quirks & MMC_QUIRK_LONG_READ_TIME;
440+}
441+
436442 #define mmc_card_name(c) ((c)->cid.prod_name)
437443 #define mmc_card_id(c) (dev_name(&(c)->dev))
438444