linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: Do not advertise secure discard if it is blacklisted
@ 2014-06-18 11:18 Lukas Czerner
  2014-06-18 11:24 ` Lukáš Czerner
  2014-07-14  8:10 ` Lukáš Czerner
  0 siblings, 2 replies; 5+ messages in thread
From: Lukas Czerner @ 2014-06-18 11:18 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-fsdevel, chris, Lukas Czerner

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.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 drivers/mmc/card/block.c | 6 +++---
 drivers/mmc/core/core.c  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 452782b..ede41f0 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -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;
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 7dc0c85..d03a080 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -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;
 }
-- 
1.8.3.1


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

* Re: [PATCH] mmc: Do not advertise secure discard if it is blacklisted
  2014-06-18 11:18 [PATCH] mmc: Do not advertise secure discard if it is blacklisted Lukas Czerner
@ 2014-06-18 11:24 ` Lukáš Czerner
  2014-07-14  8:10 ` Lukáš Czerner
  1 sibling, 0 replies; 5+ messages in thread
From: Lukáš Czerner @ 2014-06-18 11:24 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-fsdevel, chris

On Wed, 18 Jun 2014, Lukas Czerner wrote:

> Date: Wed, 18 Jun 2014 13:18:07 +0200
> From: Lukas Czerner <lczerner@redhat.com>
> To: linux-mmc@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org, chris@printf.net,
>     Lukas Czerner <lczerner@redhat.com>
> 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.
> 
> 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

> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
>  drivers/mmc/card/block.c | 6 +++---
>  drivers/mmc/core/core.c  | 3 ++-
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 452782b..ede41f0 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -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;
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 7dc0c85..d03a080 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -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;
>  }
> 

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

* Re: [PATCH] mmc: Do not advertise secure discard if it is blacklisted
  2014-06-18 11:18 [PATCH] mmc: Do not advertise secure discard if it is blacklisted Lukas Czerner
  2014-06-18 11:24 ` Lukáš Czerner
@ 2014-07-14  8:10 ` Lukáš Czerner
  2014-07-14 22:48   ` Jaehoon Chung
  1 sibling, 1 reply; 5+ messages in thread
From: Lukáš Czerner @ 2014-07-14  8:10 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-fsdevel, linux-kernel, chris

On Wed, 18 Jun 2014, Lukas Czerner wrote:

> Date: Wed, 18 Jun 2014 13:18:07 +0200
> From: Lukas Czerner <lczerner@redhat.com>
> To: linux-mmc@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org, chris@printf.net,
>     Lukas Czerner <lczerner@redhat.com>
> 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.
> 
> 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

> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
>  drivers/mmc/card/block.c | 6 +++---
>  drivers/mmc/core/core.c  | 3 ++-
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 452782b..ede41f0 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -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;
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 7dc0c85..d03a080 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -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;
>  }
> 

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

* Re: [PATCH] mmc: Do not advertise secure discard if it is blacklisted
  2014-07-14  8:10 ` Lukáš Czerner
@ 2014-07-14 22:48   ` Jaehoon Chung
  2014-07-26  9:17     ` Ulf Hansson
  0 siblings, 1 reply; 5+ messages in thread
From: Jaehoon Chung @ 2014-07-14 22:48 UTC (permalink / raw)
  To: Lukáš Czerner, linux-mmc
  Cc: linux-fsdevel, linux-kernel, chris, Ulf Hansson

Hi, Lukas.

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

Acked-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

On 07/14/2014 05:10 PM, Lukáš Czerner wrote:
> On Wed, 18 Jun 2014, Lukas Czerner wrote:
> 
>> Date: Wed, 18 Jun 2014 13:18:07 +0200
>> From: Lukas Czerner <lczerner@redhat.com>
>> To: linux-mmc@vger.kernel.org
>> Cc: linux-fsdevel@vger.kernel.org, chris@printf.net,
>>     Lukas Czerner <lczerner@redhat.com>
>> 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.
>>
>> 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
> 
>>
>> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
>> ---
>>  drivers/mmc/card/block.c | 6 +++---
>>  drivers/mmc/core/core.c  | 3 ++-
>>  2 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 452782b..ede41f0 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -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;
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index 7dc0c85..d03a080 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -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 majordomo@vger.kernel.org
> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] mmc: Do not advertise secure discard if it is blacklisted
  2014-07-14 22:48   ` Jaehoon Chung
@ 2014-07-26  9:17     ` Ulf Hansson
  0 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2014-07-26  9:17 UTC (permalink / raw)
  To: Jaehoon Chung, Lukáš Czerner
  Cc: linux-mmc, linux-fsdevel, linux-kernel@vger.kernel.org,
	Chris Ball

On 15 July 2014 00:48, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> Hi, Lukas.
>
> I think it's reasonable. And CC'd Ulf.
>
> Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
>
> Best Regards,
> Jaehoon Chung
>
> On 07/14/2014 05:10 PM, Lukáš Czerner wrote:
>> On Wed, 18 Jun 2014, Lukas Czerner wrote:
>>
>>> Date: Wed, 18 Jun 2014 13:18:07 +0200
>>> From: Lukas Czerner <lczerner@redhat.com>
>>> To: linux-mmc@vger.kernel.org
>>> Cc: linux-fsdevel@vger.kernel.org, chris@printf.net,
>>>     Lukas Czerner <lczerner@redhat.com>
>>> 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.
>>>
>>> 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
>>
>>>
>>> Signed-off-by: Lukas Czerner <lczerner@redhat.com>

Sorry for the delay.

Thanks, applied for next!

Kind regards
Uffe

>>> ---
>>>  drivers/mmc/card/block.c | 6 +++---
>>>  drivers/mmc/core/core.c  | 3 ++-
>>>  2 files changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>> index 452782b..ede41f0 100644
>>> --- a/drivers/mmc/card/block.c
>>> +++ b/drivers/mmc/card/block.c
>>> @@ -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;
>>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>>> index 7dc0c85..d03a080 100644
>>> --- a/drivers/mmc/core/core.c
>>> +++ b/drivers/mmc/core/core.c
>>> @@ -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 majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

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

end of thread, other threads:[~2014-07-26  9:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18 11:18 [PATCH] mmc: Do not advertise secure discard if it is blacklisted Lukas Czerner
2014-06-18 11:24 ` Lukáš Czerner
2014-07-14  8:10 ` Lukáš Czerner
2014-07-14 22:48   ` Jaehoon Chung
2014-07-26  9:17     ` Ulf Hansson

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).