On Tue, 20 Jun 2023 at 03:40, Marek Vasut <marex@xxxxxxx> wrote: > > This microSD card never clears Flush Cache bit after cache flush has > been started in sd_flush_cache(). This leads e.g. to failure to mount > file system. Add a quirk which disables the SD cache for this specific > card from specific manufacturing date of 11/2019, since on newer dated > cards from 05/2023 the cache flush works correctly. > > Fixes: 08ebf903af57 ("mmc: core: Fixup support for writeback-cache for eMMC and SD") > Signed-off-by: Marek Vasut <marex@xxxxxxx> > --- > Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx> > Cc: Avri Altman <avri.altman@xxxxxxx> > Cc: Brian Norris <briannorris@xxxxxxxxxxxx> > Cc: ChanWoo Lee <cw9316.lee@xxxxxxxxxxx> > Cc: Liang He <windhl@xxxxxxx> > Cc: Seunghui Lee <sh043.lee@xxxxxxxxxxx> > Cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx> > Cc: Xander Li <xander_li@xxxxxxxxxxxxxxx> > Cc: Zhen Lei <thunder.leizhen@xxxxxxxxxx> > Cc: linux-mmc@xxxxxxxxxxxxxxx [...] > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c > index 72b664ed90cf6..99ff6e754017a 100644 > --- a/drivers/mmc/core/sd.c > +++ b/drivers/mmc/core/sd.c > @@ -1170,7 +1170,7 @@ static int sd_parse_ext_reg_perf(struct mmc_card *card, u8 fno, u8 page, > card->ext_perf.feature_support |= SD_EXT_PERF_HOST_MAINT; > > /* Cache support at bit 0. */ > - if (reg_buf[4] & BIT(0)) > + if ((reg_buf[4] & BIT(0)) && !mmc_card_broken_sd_cache(card)) > card->ext_perf.feature_support |= SD_EXT_PERF_CACHE; If the bit in card->ext_perf.feature_support doesn't get set, according to the above, the cache will never be used. In other words, there is no need for any of the additional bail-out-points below, so please drop them. > > /* Command queue support indicated via queue depth bits (0 to 4). */ > @@ -1306,6 +1306,8 @@ static int sd_read_ext_regs(struct mmc_card *card) > > static bool sd_cache_enabled(struct mmc_host *host) > { > + if (mmc_card_broken_sd_cache(host->card)) > + return 0; > return host->card->ext_perf.feature_enabled & SD_EXT_PERF_CACHE; > } > > @@ -1366,6 +1368,9 @@ static int sd_enable_cache(struct mmc_card *card) > u8 *reg_buf; > int err; > > + if (mmc_card_broken_sd_cache(card)) > + return 0; > + > card->ext_perf.feature_enabled &= ~SD_EXT_PERF_CACHE; > > reg_buf = kzalloc(512, GFP_KERNEL); > diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h > index c726ea7812552..daa2f40d9ce65 100644 > --- a/include/linux/mmc/card.h > +++ b/include/linux/mmc/card.h > @@ -294,6 +294,7 @@ struct mmc_card { > #define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */ > #define MMC_QUIRK_BROKEN_HPI (1<<13) /* Disable broken HPI support */ > #define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14) /* Disable broken SD discard support */ > +#define MMC_QUIRK_BROKEN_SD_CACHE (1<<15) /* Disable broken SD cache support */ > > bool reenable_cmdq; /* Re-enable Command Queue */ > Other than the minor thing above, this looks good to me! Kind regards Uffe