Skip to content

Commit

Permalink
mmc: Add MMC_QUIRK_ERASE_BROKEN for some cards
Browse files Browse the repository at this point in the history
Some SD cards have been found that corrupt data when small blocks
are erased. Add a quirk to indicate that ERASE should not be used,
and set it for cards of that type.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
  • Loading branch information
Phil Elwell committed May 13, 2016
1 parent c317a02 commit a48bbc5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -2551,6 +2551,13 @@ static const struct mmc_fixup blk_fixups[] =
MMC_FIXUP("V10016", CID_MANFID_KINGSTON, CID_OEMID_ANY, add_quirk_mmc,
MMC_QUIRK_TRIM_BROKEN),

/*
* On some Kingston SD cards, multiple erases of less than 64
* sectors can cause corruption.
*/
MMC_FIXUP("SD16G", 0x41, 0x3432, add_quirk_mmc,
MMC_QUIRK_ERASE_BROKEN),

END_FIXUP
};

Expand Down
3 changes: 2 additions & 1 deletion drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2253,7 +2253,8 @@ EXPORT_SYMBOL(mmc_erase);
int mmc_can_erase(struct mmc_card *card)
{
if ((card->host->caps & MMC_CAP_ERASE) &&
(card->csd.cmdclass & CCC_ERASE) && card->erase_size)
(card->csd.cmdclass & CCC_ERASE) && card->erase_size &&
!(card->quirks & MMC_QUIRK_ERASE_BROKEN))
return 1;
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions include/linux/mmc/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ struct mmc_card {
#define MMC_QUIRK_TRIM_BROKEN (1<<12) /* Skip trim */


#define MMC_QUIRK_ERASE_BROKEN (1<<31) /* Skip erase */


unsigned int erase_size; /* erase size in sectors */
unsigned int erase_shift; /* if erase unit is power 2 */
unsigned int pref_erase; /* in sectors */
Expand Down

0 comments on commit a48bbc5

Please sign in to comment.