Skip to content
Permalink
Browse files

mmc: core: new discard feature support at Samsung eMMC v4.41+.

Support discard feature if MID field in the CID register is 0x15, EXT.CSD[192]
(device version) is 5 and Bit 0 in the EXT.CSD[64] is 1. Also removed REQ_SECURE flag
check to avoid kernel hang.

This patch is released from samsung.

Change-Id: I4023a900680e9bca10c40311b09ed077a22617db
  • Loading branch information...
singhome_lee Ramanan Rajeswaran
singhome_lee authored and Ramanan Rajeswaran committed Sep 20, 2012
1 parent 2562ea0 commit 3de09ec8e73b7352c37f50a40d696f20be454b8b
@@ -705,7 +705,9 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
from = blk_rq_pos(req);
nr = blk_rq_sectors(req);

if (mmc_can_trim(card))
if (mmc_can_discard(card))

This comment has been minimized.

@jakkawan

jakkawan Jun 18, 2016

I4023a900680e9bca10c40311b09ed077a22617db

This comment has been minimized.

@Anginwidarto

Anginwidarto Nov 21, 2016

I4023a900680e9bca10c40311b09ed077a22617db

arg = MMC_DISCARD_ARG;
else if (mmc_can_trim(card))
arg = MMC_TRIM_ARG;
else
arg = MMC_ERASE_ARG;
@@ -1216,10 +1218,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
/* complete ongoing async transfer before issuing discard */
if (card->host->areq)
mmc_blk_issue_rw_rq(mq, NULL);
if (req->cmd_flags & REQ_SECURE) {
/* FIXME: Bypass secdiscard, waiting eMMC vendor update new FW. */
ret = mmc_blk_issue_discard_rq(mq, req);
}
ret = mmc_blk_issue_discard_rq(mq, req);
} else if (req && req->cmd_flags & REQ_FLUSH) {
/* complete ongoing async transfer before issuing flush */
if (card->host->areq)
@@ -142,7 +142,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,

queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
q->limits.max_discard_sectors = max_discard;
if (card->erased_byte == 0)
if (card->erased_byte == 0 && !mmc_can_discard(card))
q->limits.discard_zeroes_data = 1;
q->limits.discard_granularity = card->pref_erase << 9;
/* granularity must not be greater than max. discard */
13 drivers/mmc/core/core.c 100644 → 100755
@@ -1482,7 +1482,10 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
{
unsigned int erase_timeout;

if (card->ext_csd.erase_group_def & 1) {
if (arg == MMC_DISCARD_ARG ||
(arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) {
erase_timeout = card->ext_csd.trim_timeout;
} else if (card->ext_csd.erase_group_def & 1) {
/* High Capacity Erase Group Size uses HC timeouts */
if (arg == MMC_TRIM_ARG)
erase_timeout = card->ext_csd.trim_timeout;
@@ -1758,6 +1761,14 @@ int mmc_can_trim(struct mmc_card *card)
}
EXPORT_SYMBOL(mmc_can_trim);

int mmc_can_discard(struct mmc_card *card)
{
if (card->ext_csd.feature_support & MMC_DISCARD_FEATURE)
return 1;
return 0;
}
EXPORT_SYMBOL( mmc_can_discard);

int mmc_can_secure_erase_trim(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)
3 drivers/mmc/core/mmc.c 100644 → 100755
@@ -439,6 +439,9 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
else
card->erased_byte = 0x0;

if ((card->cid.manfid == 0x15) && (ext_csd[64] & 0x01))
card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;

out:
return err;
}
@@ -85,6 +85,9 @@ struct mmc_ext_csd {
bool bk_ops; /* BK ops support bit */
bool bk_ops_en; /* BK ops enable bit */
unsigned int sec_count;

unsigned int feature_support;
#define MMC_DISCARD_FEATURE BIT(0)
};

struct sd_scr {
@@ -149,6 +149,7 @@ extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
#define MMC_ERASE_ARG 0x00000000
#define MMC_SECURE_ERASE_ARG 0x80000000
#define MMC_TRIM_ARG 0x00000001
#define MMC_DISCARD_ARG 0x00000003
#define MMC_SECURE_TRIM1_ARG 0x80000001
#define MMC_SECURE_TRIM2_ARG 0x80008000

@@ -159,6 +160,7 @@ extern int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
unsigned int arg);
extern int mmc_can_erase(struct mmc_card *card);
extern int mmc_can_trim(struct mmc_card *card);
extern int mmc_can_discard(struct mmc_card *card);
extern int mmc_can_secure_erase_trim(struct mmc_card *card);
extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
unsigned int nr);

2 comments on commit 3de09ec

@domrany

This comment has been minimized.

Copy link

domrany replied Mar 19, 2014

85

@Anginwidarto

This comment has been minimized.

Copy link

Anginwidarto replied Nov 21, 2016

[****](

  • 1. url

)

Please sign in to comment.
You can’t perform that action at this time.