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: Optimize time for secure erase/trim for some Kingston eMMCs

Kingston eMMC IY2964 and IB2932 takes a fixed ~2 seconds for each secure
erase/trim operation regardless of size - that is, a single secure
erase/trim operation of 1MB takes the same time as 1GB. With default
calculated 3.5MB max discard size, secure erase 1GB requires ~300 separate
operations taking ~10 minutes total.

Add a card quirk, MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME, to set maximum
secure erase size for those devices. This allows 1GB secure erase to
complete in a single operation, reducing time from 10 minutes to just 2
seconds.

Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Luke Wang and committed by
Ulf Hansson
d6bf2e64 f3b9683b

+22 -2
+5
drivers/mmc/core/card.h
··· 311 311 return c->quirks & MMC_QUIRK_BROKEN_MDT; 312 312 } 313 313 314 + static inline int mmc_card_fixed_secure_erase_trim_time(const struct mmc_card *c) 315 + { 316 + return c->quirks & MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME; 317 + } 318 + 314 319 #endif
+7 -2
drivers/mmc/core/queue.c
··· 184 184 return; 185 185 186 186 lim->max_hw_discard_sectors = max_discard; 187 - if (mmc_card_can_secure_erase_trim(card)) 188 - lim->max_secure_erase_sectors = max_discard; 187 + if (mmc_card_can_secure_erase_trim(card)) { 188 + if (mmc_card_fixed_secure_erase_trim_time(card)) 189 + lim->max_secure_erase_sectors = UINT_MAX >> card->erase_shift; 190 + else 191 + lim->max_secure_erase_sectors = max_discard; 192 + } 193 + 189 194 if (mmc_card_can_trim(card) && card->erased_byte == 0) 190 195 lim->max_write_zeroes_sectors = max_discard; 191 196
+9
drivers/mmc/core/quirks.h
··· 153 153 MMC_FIXUP("M62704", CID_MANFID_KINGSTON, 0x0100, add_quirk_mmc, 154 154 MMC_QUIRK_TRIM_BROKEN), 155 155 156 + /* 157 + * On Some Kingston eMMCs, secure erase/trim time is independent 158 + * of erase size, fixed at approximately 2 seconds. 159 + */ 160 + MMC_FIXUP("IY2964", CID_MANFID_KINGSTON, 0x0100, add_quirk_mmc, 161 + MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME), 162 + MMC_FIXUP("IB2932", CID_MANFID_KINGSTON, 0x0100, add_quirk_mmc, 163 + MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME), 164 + 156 165 END_FIXUP 157 166 }; 158 167
+1
include/linux/mmc/card.h
··· 330 330 #define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17) /* Disable broken SD poweroff notify support */ 331 331 #define MMC_QUIRK_NO_UHS_DDR50_TUNING (1<<18) /* Disable DDR50 tuning */ 332 332 #define MMC_QUIRK_BROKEN_MDT (1<<19) /* Wrong manufacturing year */ 333 + #define MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME (1<<20) /* Secure erase/trim time is fixed regardless of size */ 333 334 334 335 bool written_flag; /* Indicates eMMC has been written since power on */ 335 336 bool reenable_cmdq; /* Re-enable Command Queue */