diff options
author | Kyungmin Park <kyungmin.park@samsung.com> | 2011-10-14 01:15:48 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2011-10-26 16:32:26 -0400 |
commit | d9ddd62943ee07a75d0428ffcf52f1a747a28c39 (patch) | |
tree | e4fb8b0b2ba2fe39bf725762b2c04441f1adf3b8 | |
parent | 4e0a5adf46ee7810af2e1b7e4e8c2a298652618e (diff) |
mmc: core: mmc sanitize feature support for v4.5
In the v4.5, there's no secure erase & trim support.
Instead it supports the sanitize feature.
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/card/block.c | 9 | ||||
-rw-r--r-- | drivers/mmc/card/queue.c | 2 | ||||
-rw-r--r-- | drivers/mmc/core/core.c | 8 | ||||
-rw-r--r-- | include/linux/mmc/core.h | 1 | ||||
-rw-r--r-- | include/linux/mmc/mmc.h | 2 |
5 files changed, 20 insertions, 2 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 049445eb4f74..e85816e1634a 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -792,11 +792,18 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, | |||
792 | unsigned int from, nr, arg; | 792 | unsigned int from, nr, arg; |
793 | int err = 0, type = MMC_BLK_SECDISCARD; | 793 | int err = 0, type = MMC_BLK_SECDISCARD; |
794 | 794 | ||
795 | if (!mmc_can_secure_erase_trim(card)) { | 795 | if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) { |
796 | err = -EOPNOTSUPP; | 796 | err = -EOPNOTSUPP; |
797 | goto out; | 797 | goto out; |
798 | } | 798 | } |
799 | 799 | ||
800 | /* The sanitize operation is supported at v4.5 only */ | ||
801 | if (mmc_can_sanitize(card)) { | ||
802 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
803 | EXT_CSD_SANITIZE_START, 1, 0); | ||
804 | goto out; | ||
805 | } | ||
806 | |||
800 | from = blk_rq_pos(req); | 807 | from = blk_rq_pos(req); |
801 | nr = blk_rq_sectors(req); | 808 | nr = blk_rq_sectors(req); |
802 | 809 | ||
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index fed290ecc242..dcad59cbfef1 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
@@ -140,7 +140,7 @@ static void mmc_queue_setup_discard(struct request_queue *q, | |||
140 | /* granularity must not be greater than max. discard */ | 140 | /* granularity must not be greater than max. discard */ |
141 | if (card->pref_erase > max_discard) | 141 | if (card->pref_erase > max_discard) |
142 | q->limits.discard_granularity = 0; | 142 | q->limits.discard_granularity = 0; |
143 | if (mmc_can_secure_erase_trim(card)) | 143 | if (mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card)) |
144 | queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q); | 144 | queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q); |
145 | } | 145 | } |
146 | 146 | ||
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a3c4e0fe9434..d9836e5a4e59 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1713,6 +1713,14 @@ int mmc_can_trim(struct mmc_card *card) | |||
1713 | } | 1713 | } |
1714 | EXPORT_SYMBOL(mmc_can_trim); | 1714 | EXPORT_SYMBOL(mmc_can_trim); |
1715 | 1715 | ||
1716 | int mmc_can_sanitize(struct mmc_card *card) | ||
1717 | { | ||
1718 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) | ||
1719 | return 1; | ||
1720 | return 0; | ||
1721 | } | ||
1722 | EXPORT_SYMBOL(mmc_can_sanitize); | ||
1723 | |||
1716 | int mmc_can_secure_erase_trim(struct mmc_card *card) | 1724 | int mmc_can_secure_erase_trim(struct mmc_card *card) |
1717 | { | 1725 | { |
1718 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) | 1726 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) |
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 56e5625b6f41..9585835cbc42 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h | |||
@@ -156,6 +156,7 @@ extern int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, | |||
156 | unsigned int arg); | 156 | unsigned int arg); |
157 | extern int mmc_can_erase(struct mmc_card *card); | 157 | extern int mmc_can_erase(struct mmc_card *card); |
158 | extern int mmc_can_trim(struct mmc_card *card); | 158 | extern int mmc_can_trim(struct mmc_card *card); |
159 | extern int mmc_can_sanitize(struct mmc_card *card); | ||
159 | extern int mmc_can_secure_erase_trim(struct mmc_card *card); | 160 | extern int mmc_can_secure_erase_trim(struct mmc_card *card); |
160 | extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, | 161 | extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, |
161 | unsigned int nr); | 162 | unsigned int nr); |
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 02e9e3de9609..8a05a21fc7c3 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h | |||
@@ -275,6 +275,7 @@ struct _mmc_csd { | |||
275 | #define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ | 275 | #define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ |
276 | #define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ | 276 | #define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ |
277 | #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ | 277 | #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ |
278 | #define EXT_CSD_SANITIZE_START 165 /* W */ | ||
278 | #define EXT_CSD_WR_REL_PARAM 166 /* RO */ | 279 | #define EXT_CSD_WR_REL_PARAM 166 /* RO */ |
279 | #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ | 280 | #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ |
280 | #define EXT_CSD_PART_CONFIG 179 /* R/W */ | 281 | #define EXT_CSD_PART_CONFIG 179 /* R/W */ |
@@ -343,6 +344,7 @@ struct _mmc_csd { | |||
343 | #define EXT_CSD_SEC_ER_EN BIT(0) | 344 | #define EXT_CSD_SEC_ER_EN BIT(0) |
344 | #define EXT_CSD_SEC_BD_BLK_EN BIT(2) | 345 | #define EXT_CSD_SEC_BD_BLK_EN BIT(2) |
345 | #define EXT_CSD_SEC_GB_CL_EN BIT(4) | 346 | #define EXT_CSD_SEC_GB_CL_EN BIT(4) |
347 | #define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */ | ||
346 | 348 | ||
347 | #define EXT_CSD_RST_N_EN_MASK 0x3 | 349 | #define EXT_CSD_RST_N_EN_MASK 0x3 |
348 | #define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */ | 350 | #define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */ |