Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mmc: core: Add SD card quirk for broken poweroff notification

GIGASTONE Gaming Plus microSD cards manufactured on 02/2022 report that
they support poweroff notification and cache, but they are not working
correctly.

Flush Cache bit never gets cleared in sd_flush_cache() and Poweroff
Notification Ready bit also never gets set to 1 within 1 second from the
end of busy of CMD49 in sd_poweroff_notify().

This leads to I/O error and runtime PM error state.

I observed that the same card manufactured on 01/2024 works as expected.

This problem seems similar to the Kingston cards fixed with
commit c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston
Canvas Go Plus from 11/2019") and should be handled using quirks.

CID for the problematic card is here.
12345641535443002000000145016200

Manufacturer ID is 0x12 and defined as CID_MANFID_GIGASTONE as of now,
but would like comments on what naming is appropriate because MID list
is not public and not sure it's right.

Signed-off-by: Keita Aihara <keita.aihara@sony.com>
Link: https://lore.kernel.org/r/20240913094417.GA4191647@sony.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Keita Aihara and committed by
Ulf Hansson
cd068d51 8e929cb5

+18 -1
+7
drivers/mmc/core/card.h
··· 82 82 #define CID_MANFID_SANDISK_SD 0x3 83 83 #define CID_MANFID_ATP 0x9 84 84 #define CID_MANFID_TOSHIBA 0x11 85 + #define CID_MANFID_GIGASTONE 0x12 85 86 #define CID_MANFID_MICRON 0x13 86 87 #define CID_MANFID_SAMSUNG 0x15 87 88 #define CID_MANFID_APACER 0x27 ··· 285 284 { 286 285 return c->quirks & MMC_QUIRK_BROKEN_CACHE_FLUSH; 287 286 } 287 + 288 + static inline int mmc_card_broken_sd_poweroff_notify(const struct mmc_card *c) 289 + { 290 + return c->quirks & MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY; 291 + } 292 + 288 293 #endif
+9
drivers/mmc/core/quirks.h
··· 25 25 0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd, 26 26 MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY), 27 27 28 + /* 29 + * GIGASTONE Gaming Plus microSD cards manufactured on 02/2022 never 30 + * clear Flush Cache bit and set Poweroff Notification Ready bit. 31 + */ 32 + _FIXUP_EXT("ASTC", CID_MANFID_GIGASTONE, 0x3456, 2022, 2, 33 + 0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd, 34 + MMC_QUIRK_BROKEN_SD_CACHE | MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY, 35 + EXT_CSD_REV_ANY), 36 + 28 37 END_FIXUP 29 38 }; 30 39
+1 -1
drivers/mmc/core/sd.c
··· 1107 1107 card->ext_power.rev = reg_buf[0] & 0xf; 1108 1108 1109 1109 /* Power Off Notification support at bit 4. */ 1110 - if (reg_buf[1] & BIT(4)) 1110 + if ((reg_buf[1] & BIT(4)) && !mmc_card_broken_sd_poweroff_notify(card)) 1111 1111 card->ext_power.feature_support |= SD_EXT_POWER_OFF_NOTIFY; 1112 1112 1113 1113 /* Power Sustenance support at bit 5. */
+1
include/linux/mmc/card.h
··· 294 294 #define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14) /* Disable broken SD discard support */ 295 295 #define MMC_QUIRK_BROKEN_SD_CACHE (1<<15) /* Disable broken SD cache support */ 296 296 #define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16) /* Don't flush cache until the write has occurred */ 297 + #define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17) /* Disable broken SD poweroff notify support */ 297 298 298 299 bool written_flag; /* Indicates eMMC has been written since power on */ 299 300 bool reenable_cmdq; /* Re-enable Command Queue */