linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: core: set read only with permanent write protect
       [not found] <CGME20210222081517epcas1p37fef998684dc9eae0bcd2764a3f82fb1@epcas1p3.samsung.com>
@ 2021-02-22  8:31 ` Seunghui Lee
  2021-02-25  7:17   ` 이승희
  2021-03-02 10:39   ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Seunghui Lee @ 2021-02-22  8:31 UTC (permalink / raw)
  To: ulf.hansson, pali, huyue2, tiantao6, linux-mmc, linux-kernel
  Cc: grant.jung, jt77.jang, dh0421.hwang, junwoo80.lee, jangsub.yi,
	cw9316.lee, sh8267.baek, wkon.kim, Seunghui Lee

Some of SD cards sets permanent write protection
due to lifespan or internal problem.
Host can find out it's protected permanantly during initialization.
Once set read only during initialization,
it could prevent unnecessary write operation in it.

Signed-off-by: Seunghui Lee <sh043.lee@samsung.com>
---
 drivers/mmc/core/sd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 6fa51a6ed058..2c48d6504101 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -135,6 +135,9 @@ static int mmc_decode_csd(struct mmc_card *card)
 			csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;
 			csd->erase_size <<= csd->write_blkbits - 9;
 		}
+
+		if (UNSTUFF_BITS(resp, 13, 1))
+			mmc_card_set_readonly(card);
 		break;
 	case 1:
 		/*
@@ -169,6 +172,9 @@ static int mmc_decode_csd(struct mmc_card *card)
 		csd->write_blkbits = 9;
 		csd->write_partial = 0;
 		csd->erase_size = 1;
+
+		if (UNSTUFF_BITS(resp, 13, 1))
+			mmc_card_set_readonly(card);
 		break;
 	default:
 		pr_err("%s: unrecognised CSD structure version %d\n",
-- 
2.29.0


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

* RE: [PATCH] mmc: core: set read only with permanent write protect
  2021-02-22  8:31 ` [PATCH] mmc: core: set read only with permanent write protect Seunghui Lee
@ 2021-02-25  7:17   ` 이승희
  2021-03-02 10:39   ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: 이승희 @ 2021-02-25  7:17 UTC (permalink / raw)
  To: ulf.hansson, pali, huyue2, tiantao6, linux-mmc, linux-kernel
  Cc: grant.jung, jt77.jang, dh0421.hwang, junwoo80.lee, jangsub.yi,
	cw9316.lee, sh8267.baek, wkon.kim

Dear Maintainer & commiters,

Please review the patch for updating.
I'm not sure if it's reviewed or not.

As you know, there are lots of defect SD cards in the market.
It's one of solution that reduces the system load.
The CSD register shows that it's permanent write protected
due to lifespan or internal problem.

Once host sets read only field, the upper layer doesn't issue
unnecessary write operation in it.

Thanks and regards,
Seunghui Lee.

> -----Original Message-----
> From: Seunghui Lee <sh043.lee@samsung.com>
> Sent: Monday, February 22, 2021 5:32 PM
> To: ulf.hansson@linaro.org; pali@kernel.org; huyue2@yulong.com;
> tiantao6@hisilicon.com; linux-mmc@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: grant.jung@samsung.com; jt77.jang@samsung.com;
> dh0421.hwang@samsung.com; junwoo80.lee@samsung.com; jangsub.yi@samsung.com;
> cw9316.lee@samsung.com; sh8267.baek@samsung.com; wkon.kim@samsung.com;
> Seunghui Lee <sh043.lee@samsung.com>
> Subject: [PATCH] mmc: core: set read only with permanent write protect
> 
> Some of SD cards sets permanent write protection due to lifespan or
> internal problem.
> Host can find out it's protected permanantly during initialization.
> Once set read only during initialization, it could prevent unnecessary
> write operation in it.
> 
> Signed-off-by: Seunghui Lee <sh043.lee@samsung.com>
> ---
>  drivers/mmc/core/sd.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index
> 6fa51a6ed058..2c48d6504101 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -135,6 +135,9 @@ static int mmc_decode_csd(struct mmc_card *card)
>  			csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;
>  			csd->erase_size <<= csd->write_blkbits - 9;
>  		}
> +
> +		if (UNSTUFF_BITS(resp, 13, 1))
> +			mmc_card_set_readonly(card);
>  		break;
>  	case 1:
>  		/*
> @@ -169,6 +172,9 @@ static int mmc_decode_csd(struct mmc_card *card)
>  		csd->write_blkbits = 9;
>  		csd->write_partial = 0;
>  		csd->erase_size = 1;
> +
> +		if (UNSTUFF_BITS(resp, 13, 1))
> +			mmc_card_set_readonly(card);
>  		break;
>  	default:
>  		pr_err("%s: unrecognised CSD structure version %d\n",
> --
> 2.29.0



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

* Re: [PATCH] mmc: core: set read only with permanent write protect
  2021-02-22  8:31 ` [PATCH] mmc: core: set read only with permanent write protect Seunghui Lee
  2021-02-25  7:17   ` 이승희
@ 2021-03-02 10:39   ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2021-03-02 10:39 UTC (permalink / raw)
  To: Seunghui Lee
  Cc: Pali Rohár, Yue Hu, Tian Tao, linux-mmc,
	Linux Kernel Mailing List, grant.jung, jt77.jang, DooHyun Hwang,
	junwoo80.lee, jangsub.yi, Chanwoo Lee, sh8267.baek, wkon.kim

On Mon, 22 Feb 2021 at 09:15, Seunghui Lee <sh043.lee@samsung.com> wrote:
>
> Some of SD cards sets permanent write protection
> due to lifespan or internal problem.
> Host can find out it's protected permanantly during initialization.
> Once set read only during initialization,
> it could prevent unnecessary write operation in it.
>
> Signed-off-by: Seunghui Lee <sh043.lee@samsung.com>

Applied for next and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/sd.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 6fa51a6ed058..2c48d6504101 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -135,6 +135,9 @@ static int mmc_decode_csd(struct mmc_card *card)
>                         csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;
>                         csd->erase_size <<= csd->write_blkbits - 9;
>                 }
> +
> +               if (UNSTUFF_BITS(resp, 13, 1))
> +                       mmc_card_set_readonly(card);
>                 break;
>         case 1:
>                 /*
> @@ -169,6 +172,9 @@ static int mmc_decode_csd(struct mmc_card *card)
>                 csd->write_blkbits = 9;
>                 csd->write_partial = 0;
>                 csd->erase_size = 1;
> +
> +               if (UNSTUFF_BITS(resp, 13, 1))
> +                       mmc_card_set_readonly(card);
>                 break;
>         default:
>                 pr_err("%s: unrecognised CSD structure version %d\n",
> --
> 2.29.0
>

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

end of thread, other threads:[~2021-03-02 11:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210222081517epcas1p37fef998684dc9eae0bcd2764a3f82fb1@epcas1p3.samsung.com>
2021-02-22  8:31 ` [PATCH] mmc: core: set read only with permanent write protect Seunghui Lee
2021-02-25  7:17   ` 이승희
2021-03-02 10:39   ` 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).