linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Do not require secure trim for discard
@ 2022-11-14 13:26 Christian Löhle
  2022-11-17  8:19 ` Adrian Hunter
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Löhle @ 2022-11-14 13:26 UTC (permalink / raw)
  To: adrian.hunter, linux-mmc, linux-kernel; +Cc: ulf.hansson

Discard feature is independent of security features.
The support check for all trims and discard falsely checked
for secure trim/discard, but in the discard case this is not
mandated by the spec.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/core/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 95fa8fb1d45f..507005211529 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1761,7 +1761,8 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
 		return -EOPNOTSUPP;
 
 	if (mmc_card_mmc(card) && (arg & MMC_TRIM_ARGS) &&
-	    !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN))
+	    !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) &&
+	    arg != MMC_DISCARD_ARG)
 		return -EOPNOTSUPP;
 
 	if (arg == MMC_SECURE_ERASE_ARG) {
-- 
2.37.3

Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: core: Do not require secure trim for discard
  2022-11-14 13:26 [PATCH] mmc: core: Do not require secure trim for discard Christian Löhle
@ 2022-11-17  8:19 ` Adrian Hunter
  0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2022-11-17  8:19 UTC (permalink / raw)
  To: Christian Löhle, linux-mmc, linux-kernel; +Cc: ulf.hansson

On 14/11/22 15:26, Christian Löhle wrote:
> Discard feature is independent of security features.
> The support check for all trims and discard falsely checked
> for secure trim/discard, but in the discard case this is not
> mandated by the spec.
> 

"Discard" was added after "Trim", so while MMC_TRIM_ARGS made
sense originally, that stopped with:

commit b3bf915308ca ("mmc: core: new discard feature support at eMMC v4.5")

So this could have that as a fixes tag.

Also MMC_TRIM_ARGS is a bit of a misleading name since it covers
one of the bits of MMC_DISCARD_ARG, so I suggest a second patch to
tidy things up.

Perhaps rename it and change the value to 8003 e.g.

#define MMC_TRIM_OR_DISCARD_ARGS	0x00008003

and make a wrapper for the Trim case:

static bool is_trim_arg(unsigned int arg)
{
	return (arg & MMC_TRIM_OR_DISCARD_ARGS) && arg != MMC_DISCARD_ARG;
}

> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
> ---
>  drivers/mmc/core/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 95fa8fb1d45f..507005211529 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1761,7 +1761,8 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
>  		return -EOPNOTSUPP;
>  
>  	if (mmc_card_mmc(card) && (arg & MMC_TRIM_ARGS) &&
> -	    !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN))
> +	    !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) &&
> +	    arg != MMC_DISCARD_ARG)
>  		return -EOPNOTSUPP;
>  
>  	if (arg == MMC_SECURE_ERASE_ARG) {


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-17  8:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 13:26 [PATCH] mmc: core: Do not require secure trim for discard Christian Löhle
2022-11-17  8:19 ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).