BACKPORT: FROMGIT: mmc: core: SD: Add BROKEN-SD-DISCARD quirk
v1 -> v2: - Address Ulf's suggestions Some SD-cards that are SDA-6.0 compliant reports they supports discard while they actually don't. This might cause mk2fs to fail while trying to format the card and revert it to a read-only mode. While at it, add SD MID for SANDISK. This is because eMMC MID is assign by JEDEC and SD MID is assigned by SD 3c-LLC. Signed-off-by: Avri Altman <avri.altman@wdc.com> Bug: 249507619 (cherry picked from commit 07d2872bf4c864eb83d034263c155746a2fb7a3b git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git) Change-Id: I43db47edbffc83dd680bad42ae691cef38edbf12 Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
@@ -1111,6 +1111,11 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
|
|||||||
nr = blk_rq_sectors(req);
|
nr = blk_rq_sectors(req);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
unsigned int erase_arg = card->erase_arg;
|
||||||
|
|
||||||
|
if (mmc_card_broken_sd_discard(card))
|
||||||
|
erase_arg = SD_ERASE_ARG;
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
|
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
|
||||||
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
|
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
|
||||||
@@ -1121,7 +1126,7 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
|
|||||||
card->ext_csd.generic_cmd6_time);
|
card->ext_csd.generic_cmd6_time);
|
||||||
}
|
}
|
||||||
if (!err)
|
if (!err)
|
||||||
err = mmc_erase(card, from, nr, card->erase_arg);
|
err = mmc_erase(card, from, nr, erase_arg);
|
||||||
} while (err == -EIO && !mmc_blk_reset(md, card->host, type));
|
} while (err == -EIO && !mmc_blk_reset(md, card->host, type));
|
||||||
if (err)
|
if (err)
|
||||||
status = BLK_STS_IOERR;
|
status = BLK_STS_IOERR;
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ struct mmc_fixup {
|
|||||||
#define EXT_CSD_REV_ANY (-1u)
|
#define EXT_CSD_REV_ANY (-1u)
|
||||||
|
|
||||||
#define CID_MANFID_SANDISK 0x2
|
#define CID_MANFID_SANDISK 0x2
|
||||||
|
#define CID_MANFID_SANDISK_SD 0x3
|
||||||
#define CID_MANFID_ATP 0x9
|
#define CID_MANFID_ATP 0x9
|
||||||
#define CID_MANFID_TOSHIBA 0x11
|
#define CID_MANFID_TOSHIBA 0x11
|
||||||
#define CID_MANFID_MICRON 0x13
|
#define CID_MANFID_MICRON 0x13
|
||||||
@@ -222,4 +223,9 @@ static inline int mmc_card_broken_hpi(const struct mmc_card *c)
|
|||||||
return c->quirks & MMC_QUIRK_BROKEN_HPI;
|
return c->quirks & MMC_QUIRK_BROKEN_HPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int mmc_card_broken_sd_discard(const struct mmc_card *c)
|
||||||
|
{
|
||||||
|
return c->quirks & MMC_QUIRK_BROKEN_SD_DISCARD;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
|
|||||||
MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc,
|
MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc,
|
||||||
MMC_QUIRK_TRIM_BROKEN),
|
MMC_QUIRK_TRIM_BROKEN),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some SD cards reports discard support while they don't
|
||||||
|
*/
|
||||||
|
MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
|
||||||
|
MMC_QUIRK_BROKEN_SD_DISCARD),
|
||||||
|
|
||||||
END_FIXUP
|
END_FIXUP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ struct mmc_card {
|
|||||||
#define MMC_QUIRK_BROKEN_IRQ_POLLING (1<<11) /* Polling SDIO_CCCR_INTx could create a fake interrupt */
|
#define MMC_QUIRK_BROKEN_IRQ_POLLING (1<<11) /* Polling SDIO_CCCR_INTx could create a fake interrupt */
|
||||||
#define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */
|
#define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */
|
||||||
#define MMC_QUIRK_BROKEN_HPI (1<<13) /* Disable broken HPI support */
|
#define MMC_QUIRK_BROKEN_HPI (1<<13) /* Disable broken HPI support */
|
||||||
|
#define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14) /* Disable broken SD discard support */
|
||||||
|
|
||||||
bool reenable_cmdq; /* Re-enable Command Queue */
|
bool reenable_cmdq; /* Re-enable Command Queue */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user