Skip to content

Commit 7194efb

Browse files
ahunter6cjb
authored andcommitted
mmc: fixes for eMMC v4.5 discard operation
eMMC v4.5 discard operation is significantly different from the existing trim operation because it is not guaranteed to work with the new sanitize operation. Consequently mmc_can_trim() is separated from mmc_can_discard(). Also the new discard operation does not result in the sectors being set to all-zeros, so discard_zeroes_data must not be set. In addition, the new discard has the same timeout as trim, but from v4.5 trim is defined to use the hc timeout. The timeout calculation is adjusted accordingly. Fixes apply to linux 3.2 on. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: <stable@vger.kernel.org> Acked-by: Jaehoon Chung <jh80.chung@samsung.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent 3b422e9 commit 7194efb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/mmc/card/queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,
139139

140140
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
141141
q->limits.max_discard_sectors = max_discard;
142-
if (card->erased_byte == 0)
142+
if (card->erased_byte == 0 && !mmc_can_discard(card))
143143
q->limits.discard_zeroes_data = 1;
144144
q->limits.discard_granularity = card->pref_erase << 9;
145145
/* granularity must not be greater than max. discard */

drivers/mmc/core/core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,10 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
14091409
{
14101410
unsigned int erase_timeout;
14111411

1412-
if (card->ext_csd.erase_group_def & 1) {
1412+
if (arg == MMC_DISCARD_ARG ||
1413+
(arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) {
1414+
erase_timeout = card->ext_csd.trim_timeout;
1415+
} else if (card->ext_csd.erase_group_def & 1) {
14131416
/* High Capacity Erase Group Size uses HC timeouts */
14141417
if (arg == MMC_TRIM_ARG)
14151418
erase_timeout = card->ext_csd.trim_timeout;
@@ -1681,8 +1684,6 @@ int mmc_can_trim(struct mmc_card *card)
16811684
{
16821685
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
16831686
return 1;
1684-
if (mmc_can_discard(card))
1685-
return 1;
16861687
return 0;
16871688
}
16881689
EXPORT_SYMBOL(mmc_can_trim);

0 commit comments

Comments
 (0)