Skip to content

Commit e4f6da2

Browse files
Stefan Nilsson XKgrigorig
Stefan Nilsson XK
authored andcommitted
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. Signed-off-by: Stefan Nilsson XK <[email protected]> Signed-off-by: Ulf Hansson <[email protected]> Acked-by: Linus Walleij <[email protected]> Cc: <[email protected]> Signed-off-by: Chris Ball <[email protected]>
1 parent f3320b7 commit e4f6da2

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

drivers/mmc/card/block.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,14 @@ static const struct mmc_fixup blk_fixups[] =
14921492
MMC_QUIRK_BLK_NO_CMD23),
14931493
MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc,
14941494
MMC_QUIRK_BLK_NO_CMD23),
1495+
1496+
/*
1497+
* Some Micron MMC cards needs longer data read timeout than
1498+
* indicated in CSD.
1499+
*/
1500+
MMC_FIXUP(CID_NAME_ANY, 0x13, 0x200, add_quirk_mmc,
1501+
MMC_QUIRK_LONG_READ_TIME),
1502+
14951503
END_FIXUP
14961504
};
14971505

drivers/mmc/core/core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,18 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
415415
data->timeout_clks = 0;
416416
}
417417
}
418+
419+
/*
420+
* Some cards require longer data read timeout than indicated in CSD.
421+
* Address this by setting the read timeout to a "reasonably high"
422+
* value. For the cards tested, 300ms has proven enough. If necessary,
423+
* this value can be increased if other problematic cards require this.
424+
*/
425+
if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) {
426+
data->timeout_ns = 300000000;
427+
data->timeout_clks = 0;
428+
}
429+
418430
/*
419431
* Some cards need very high timeouts if driven in SPI mode.
420432
* The worst observed timeout was 900ms after writing a

include/linux/mmc/card.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ struct mmc_card {
188188
#define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
189189
#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
190190
#define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
191+
#define MMC_QUIRK_LONG_READ_TIME (1<<9) /* Data read time > CSD says */
191192

192193
unsigned int erase_size; /* erase size in sectors */
193194
unsigned int erase_shift; /* if erase unit is power 2 */
@@ -377,6 +378,11 @@ static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c)
377378
return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF;
378379
}
379380

381+
static inline int mmc_card_long_read_time(const struct mmc_card *c)
382+
{
383+
return c->quirks & MMC_QUIRK_LONG_READ_TIME;
384+
}
385+
380386
#define mmc_card_name(c) ((c)->cid.prod_name)
381387
#define mmc_card_id(c) (dev_name(&(c)->dev))
382388

0 commit comments

Comments
 (0)