Skip to content

Commit 9b597e7

Browse files
P33Mpopcornmix
authored andcommitted
mmc: sd: filter card CQ support based on an allow-list
We have found that many SD cards in the field, even of the same make and model, have latent bugs in their CQ implementation. Some product lines have fewer bugs with newer manufacture dates, but this is not a guarantee that a particular card is at a particular firmware revision level. Many of these bugs lead to card hangs or data corruption. Add a quirk to mark a card as having a tested, working CQ implementation and ignore the capability if absent. Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
1 parent fe79220 commit 9b597e7

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

drivers/mmc/core/card.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,9 @@ static inline int mmc_card_broken_sd_poweroff_notify(const struct mmc_card *c)
295295
return c->quirks & MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY;
296296
}
297297

298+
static inline int mmc_card_working_sd_cq(const struct mmc_card *c)
299+
{
300+
return c->quirks & MMC_QUIRK_WORKING_SD_CQ;
301+
}
302+
298303
#endif

drivers/mmc/core/sd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,10 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
15011501
goto free_card;
15021502
}
15031503

1504+
/* Disallow command queueing on unvetted cards */
1505+
if (!mmc_card_working_sd_cq(card))
1506+
card->ext_csd.cmdq_support = false;
1507+
15041508
/* Enable command queueing if supported */
15051509
if (card->ext_csd.cmdq_support && host->caps2 & MMC_CAP2_CQE) {
15061510
/*

include/linux/mmc/card.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ struct mmc_card {
295295
#define MMC_QUIRK_BROKEN_SD_CACHE (1<<15) /* Disable broken SD cache support */
296296
#define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16) /* Don't flush cache until the write has occurred */
297297
#define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17) /* Disable broken SD poweroff notify support */
298+
#define MMC_QUIRK_WORKING_SD_CQ (1<<30) /* SD card has known-good CQ implementation */
298299
#define MMC_QUIRK_ERASE_BROKEN (1<<31) /* Skip erase */
299300

300301
bool written_flag; /* Indicates eMMC has been written since power on */

0 commit comments

Comments
 (0)