mmc: core: mmc sanitize feature support for v4.5
authorKyungmin Park <kyungmin.park@samsung.com>
Fri, 14 Oct 2011 05:15:48 +0000 (14:15 +0900)
committerChris Ball <cjb@laptop.org>
Wed, 26 Oct 2011 20:32:26 +0000 (16:32 -0400)
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>
drivers/mmc/card/block.c
drivers/mmc/card/queue.c
drivers/mmc/core/core.c
include/linux/mmc/core.h
include/linux/mmc/mmc.h

index 049445eb4f74c69bda3a7b061c669e3cc3ab6135..e85816e1634ab80546bb0d87eabfdc585612feee 100644 (file)
@@ -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);
 
index fed290ecc2426a39ec90cb91dca9f13ccbc860c6..dcad59cbfef11a873b0dfa49ef9dcd4e8fcf1d83 100644 (file)
@@ -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);
 }
 
index a3c4e0fe94344c360bea4cbb3af08960797812bc..d9836e5a4e5917a6a4f300ad8e113822aff923d9 100644 (file)
@@ -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)
index 56e5625b6f4121b39609024cee93bd08bcd3daf2..9585835cbc427ea2343660c1a9238f9e5585ffb7 100644 (file)
@@ -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);
index 02e9e3de96093139b97d47babd38557bfd07cc67..8a05a21fc7c33be4cfbcc25cb67fc86b5052fec1 100644 (file)
@@ -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 */
@@ -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 */