Skip to contentSkip to conversation

mmc: Do not advertise secure discard if it is blacklisted

PATCH Applied Lukas Czerner 3 participants 5 messages Jun 18, 2014 – Jul 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: Do not advertise secure discard if it is blacklisted

Currently when the device secure discard implementation is blacklisted (MMC_QUIRK_SEC_ERASE_TRIM_BROKEN quirk is set) instead of secure discard we're going to do normal discard, which is wrong.

When the secure discard is known to be broken we should just disallow it entirely and not advertise this functionality to the user. Fix it.

Also move mmc_fixup_device() in from of mmc_blk_alloc() so we can get quirks set before we attempt to set queue information.

---
 drivers/mmc/card/block.c | 6 +++---
 drivers/mmc/core/core.c  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/card/block.c +3 -3
index 452782b..ede41f0 100644
@@ -2028,8 +2028,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 &&
-			!(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
+		if (req->cmd_flags & REQ_SECURE)
 			ret = mmc_blk_issue_secdiscard_rq(mq, req);
 		else
 			ret = mmc_blk_issue_discard_rq(mq, req);
@@ -2432,6 +2431,8 @@ static int mmc_blk_probe(struct mmc_card *card)
 	if (!(card->csd.cmdclass & CCC_BLOCK_READ))
 		return -ENODEV;
 
+	mmc_fixup_device(card, blk_fixups);
+
 	md = mmc_blk_alloc(card);
 	if (IS_ERR(md))
 		return PTR_ERR(md);
@@ -2446,7 +2447,6 @@ static int mmc_blk_probe(struct mmc_card *card)
 		goto out;
 
 	mmc_set_drvdata(card, md);
-	mmc_fixup_device(card, blk_fixups);
 
 	if (mmc_add_disk(md))
 		goto out;
drivers/mmc/core/core.c +2 -1
index 7dc0c85..d03a080 100644
@@ -2102,7 +2102,8 @@ 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)
+	if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) &&
+	    !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
 		return 1;
 	return 0;
 }
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 12 lines · Lukas Czerner

Date: Wed, 18 Jun 2014 13:18:07 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Lukas Czerner <[email protected]>
Subject: [PATCH] mmc: Do not advertise secure discard if it is blacklisted

Currently when the device secure discard implementation is blacklisted (MMC_QUIRK_SEC_ERASE_TRIM_BROKEN quirk is set) instead of secure discard we're going to do normal discard, which is wrong.

Quoted 6 lines

When the secure discard is known to be broken we should just disallow it entirely and not advertise this functionality to the user. Fix it.

Also move mmc_fixup_device() in from of mmc_blk_alloc() so we can get quirks set before we attempt to set queue information.

I forgot to mention that I do not have such hardware so anyone who does, could you please test this patch ?

Thanks!
-Lukas

Quoted 53 lines
---
 drivers/mmc/card/block.c | 6 +++---
 drivers/mmc/core/core.c  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/card/block.c +3 -3
index 452782b..ede41f0 100644
@@ -2028,8 +2028,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 &&
-			!(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
+		if (req->cmd_flags & REQ_SECURE)
 			ret = mmc_blk_issue_secdiscard_rq(mq, req);
 		else
 			ret = mmc_blk_issue_discard_rq(mq, req);
@@ -2432,6 +2431,8 @@ static int mmc_blk_probe(struct mmc_card *card)
 	if (!(card->csd.cmdclass & CCC_BLOCK_READ))
 		return -ENODEV;
 
+	mmc_fixup_device(card, blk_fixups);
+
 	md = mmc_blk_alloc(card);
 	if (IS_ERR(md))
 		return PTR_ERR(md);
@@ -2446,7 +2447,6 @@ static int mmc_blk_probe(struct mmc_card *card)
 		goto out;
 
 	mmc_set_drvdata(card, md);
-	mmc_fixup_device(card, blk_fixups);
 
 	if (mmc_add_disk(md))
 		goto out;
drivers/mmc/core/core.c +2 -1
index 7dc0c85..d03a080 100644
@@ -2102,7 +2102,8 @@ 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)
+	if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) &&
+	    !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
 		return 1;
 	return 0;
 }
#2 lore raw
In reply to Lukas Czerner
Quoted 12 lines · Lukas Czerner

Date: Wed, 18 Jun 2014 13:18:07 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Lukas Czerner <[email protected]>
Subject: [PATCH] mmc: Do not advertise secure discard if it is blacklisted

Currently when the device secure discard implementation is blacklisted (MMC_QUIRK_SEC_ERASE_TRIM_BROKEN quirk is set) instead of secure discard we're going to do normal discard, which is wrong.

Quoted 6 lines

When the secure discard is known to be broken we should just disallow it entirely and not advertise this functionality to the user. Fix it.

Also move mmc_fixup_device() in from of mmc_blk_alloc() so we can get quirks set before we attempt to set queue information.

Where should I send it to get noticed ? It's sitting here for a month now.

Thanks!
-Lukas

Quoted 53 lines
---
 drivers/mmc/card/block.c | 6 +++---
 drivers/mmc/core/core.c  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/card/block.c +3 -3
index 452782b..ede41f0 100644
@@ -2028,8 +2028,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 &&
-			!(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
+		if (req->cmd_flags & REQ_SECURE)
 			ret = mmc_blk_issue_secdiscard_rq(mq, req);
 		else
 			ret = mmc_blk_issue_discard_rq(mq, req);
@@ -2432,6 +2431,8 @@ static int mmc_blk_probe(struct mmc_card *card)
 	if (!(card->csd.cmdclass & CCC_BLOCK_READ))
 		return -ENODEV;
 
+	mmc_fixup_device(card, blk_fixups);
+
 	md = mmc_blk_alloc(card);
 	if (IS_ERR(md))
 		return PTR_ERR(md);
@@ -2446,7 +2447,6 @@ static int mmc_blk_probe(struct mmc_card *card)
 		goto out;
 
 	mmc_set_drvdata(card, md);
-	mmc_fixup_device(card, blk_fixups);
 
 	if (mmc_add_disk(md))
 		goto out;
drivers/mmc/core/core.c +2 -1
index 7dc0c85..d03a080 100644
@@ -2102,7 +2102,8 @@ 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)
+	if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) &&
+	    !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
 		return 1;
 	return 0;
 }
Acked-by
#3 lore raw

Hi, Lukas.

I think it's reasonable. And CC'd Ulf.

Best Regards,
Jaehoon Chung

Quoted 71 lines · Lukáš Czerner
Quoted 12 lines · Lukas Czerner

Date: Wed, 18 Jun 2014 13:18:07 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Lukas Czerner <[email protected]>
Subject: [PATCH] mmc: Do not advertise secure discard if it is blacklisted

Currently when the device secure discard implementation is blacklisted (MMC_QUIRK_SEC_ERASE_TRIM_BROKEN quirk is set) instead of secure discard we're going to do normal discard, which is wrong.

Quoted 6 lines

When the secure discard is known to be broken we should just disallow it entirely and not advertise this functionality to the user. Fix it.

Also move mmc_fixup_device() in from of mmc_blk_alloc() so we can get quirks set before we attempt to set queue information.

Where should I send it to get noticed ? It's sitting here for a month now.

Thanks!
-Lukas

Quoted 44 lines
---
 drivers/mmc/card/block.c | 6 +++---
 drivers/mmc/core/core.c  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/card/block.c +3 -3
index 452782b..ede41f0 100644
@@ -2028,8 +2028,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 &&
-			!(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
+		if (req->cmd_flags & REQ_SECURE)
 			ret = mmc_blk_issue_secdiscard_rq(mq, req);
 		else
 			ret = mmc_blk_issue_discard_rq(mq, req);
@@ -2432,6 +2431,8 @@ static int mmc_blk_probe(struct mmc_card *card)
 	if (!(card->csd.cmdclass & CCC_BLOCK_READ))
 		return -ENODEV;
 
+	mmc_fixup_device(card, blk_fixups);
+
 	md = mmc_blk_alloc(card);
 	if (IS_ERR(md))
 		return PTR_ERR(md);
@@ -2446,7 +2447,6 @@ static int mmc_blk_probe(struct mmc_card *card)
 		goto out;
 
 	mmc_set_drvdata(card, md);
-	mmc_fixup_device(card, blk_fixups);
 
 	if (mmc_add_disk(md))
 		goto out;
drivers/mmc/core/core.c +0 -0
index 7dc0c85..d03a080 100644
@@ -2102,7 +2102,8 @@ EXPORT_SYMBOL(mmc_can_sanitize);
 
Quoted 14 lines

drivers/mmc/core/core.c EXPORT_SYMBOL(mmc_can_sanitize); · line 2109

Quoted 9 lines
drivers/mmc/core/core.c +2 -1
 int mmc_can_secure_erase_trim(struct mmc_card *card)
 {
-	if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)
+	if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) &&
+	    !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
 		return 1;
 	return 0;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#4 lore raw
Quoted 39 lines · Jaehoon Chung

Hi, Lukas.

I think it's reasonable. And CC'd Ulf.

Best Regards,
Jaehoon Chung

Quoted 29 lines · Lukáš Czerner
Quoted 12 lines · Lukas Czerner

Date: Wed, 18 Jun 2014 13:18:07 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Lukas Czerner <[email protected]>
Subject: [PATCH] mmc: Do not advertise secure discard if it is blacklisted

Currently when the device secure discard implementation is blacklisted (MMC_QUIRK_SEC_ERASE_TRIM_BROKEN quirk is set) instead of secure discard we're going to do normal discard, which is wrong.

Quoted 6 lines

When the secure discard is known to be broken we should just disallow it entirely and not advertise this functionality to the user. Fix it.

Also move mmc_fixup_device() in from of mmc_blk_alloc() so we can get quirks set before we attempt to set queue information.

Where should I send it to get noticed ? It's sitting here for a month now.

Thanks!
-Lukas

Quoted 2 lines

Sorry for the delay.

Thanks, applied for next!

Kind regards
Uffe

Quoted 57 lines
Quoted 56 lines
Quoted 42 lines
---
 drivers/mmc/card/block.c | 6 +++---
 drivers/mmc/core/core.c  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/card/block.c +3 -3
index 452782b..ede41f0 100644
@@ -2028,8 +2028,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 &&
-                    !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
+            if (req->cmd_flags & REQ_SECURE)
                     ret = mmc_blk_issue_secdiscard_rq(mq, req);
             else
                     ret = mmc_blk_issue_discard_rq(mq, req);
@@ -2432,6 +2431,8 @@ static int mmc_blk_probe(struct mmc_card *card)
     if (!(card->csd.cmdclass & CCC_BLOCK_READ))
             return -ENODEV;
 
+    mmc_fixup_device(card, blk_fixups);
+
     md = mmc_blk_alloc(card);
     if (IS_ERR(md))
             return PTR_ERR(md);
@@ -2446,7 +2447,6 @@ static int mmc_blk_probe(struct mmc_card *card)
             goto out;
 
     mmc_set_drvdata(card, md);
-    mmc_fixup_device(card, blk_fixups);
 
     if (mmc_add_disk(md))
             goto out;
drivers/mmc/core/core.c +0 -0
index 7dc0c85..d03a080 100644

drivers/mmc/core/core.c EXPORT_SYMBOL(mmc_can_sanitize); · line 2109

Quoted 9 lines
drivers/mmc/core/core.c +2 -1
@@ -2102,7 +2102,8 @@ 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)
+    if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) &&
+        !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN))
             return 1;
     return 0;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html