Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 270298
b: refs/heads/master
c: d9ddd62
h: refs/heads/master
v: v3
  • Loading branch information
Kyungmin Park authored and Chris Ball committed Oct 26, 2011
1 parent 5da3989 commit b96a5ec
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4e0a5adf46ee7810af2e1b7e4e8c2a298652618e
refs/heads/master: d9ddd62943ee07a75d0428ffcf52f1a747a28c39
9 changes: 8 additions & 1 deletion trunk/drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,18 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
unsigned int from, nr, arg;
int err = 0, type = MMC_BLK_SECDISCARD;

if (!mmc_can_secure_erase_trim(card)) {
if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
err = -EOPNOTSUPP;
goto out;
}

/* The sanitize operation is supported at v4.5 only */
if (mmc_can_sanitize(card)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_SANITIZE_START, 1, 0);
goto out;
}

from = blk_rq_pos(req);
nr = blk_rq_sectors(req);

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/mmc/card/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,
/* granularity must not be greater than max. discard */
if (card->pref_erase > max_discard)
q->limits.discard_granularity = 0;
if (mmc_can_secure_erase_trim(card))
if (mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))
queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q);
}

Expand Down
8 changes: 8 additions & 0 deletions trunk/drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,14 @@ int mmc_can_trim(struct mmc_card *card)
}
EXPORT_SYMBOL(mmc_can_trim);

int mmc_can_sanitize(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_sanitize);

int mmc_can_secure_erase_trim(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/mmc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,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_sanitize(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);
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/mmc/mmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ struct _mmc_csd {
#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */
#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */
#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
#define EXT_CSD_SANITIZE_START 165 /* W */
#define EXT_CSD_WR_REL_PARAM 166 /* RO */
#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
#define EXT_CSD_PART_CONFIG 179 /* R/W */
Expand Down Expand Up @@ -343,6 +344,7 @@ struct _mmc_csd {
#define EXT_CSD_SEC_ER_EN BIT(0)
#define EXT_CSD_SEC_BD_BLK_EN BIT(2)
#define EXT_CSD_SEC_GB_CL_EN BIT(4)
#define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */

#define EXT_CSD_RST_N_EN_MASK 0x3
#define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */
Expand Down

0 comments on commit b96a5ec

Please sign in to comment.