* [PATCH] mmc: core: allow detection of locked cards
@ 2024-05-21 21:04 linux-mmc
2024-05-23 3:41 ` Avri Altman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: linux-mmc @ 2024-05-21 21:04 UTC (permalink / raw)
To: linux-mmc, ulf.hansson; +Cc: Daniel Kucera
From: Daniel Kucera <linux-mmc@danman.eu>
Signed-off-by: Daniel Kucera <linux-mmc@danman.eu>
---
drivers/mmc/core/sd.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 1c8148cdd..b22c30348 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1475,9 +1475,22 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
goto free_card;
}
- err = mmc_sd_setup_card(host, card, oldcard != NULL);
- if (err)
- goto free_card;
+ u32 card_status;
+
+ err = mmc_send_status(card, &card_status);
+ if (err){
+ pr_err("%s: unable to get card status\n",
+ mmc_hostname(host));
+ goto free_card;
+ }
+
+ if (card_status & R1_CARD_IS_LOCKED){
+ pr_warn("%s: card is locked\n", mmc_hostname(host));
+ } else {
+ err = mmc_sd_setup_card(host, card, oldcard != NULL);
+ if (err)
+ goto free_card;
+ }
/*
* If the card has not been power cycled, it may still be using 1.8V
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH] mmc: core: allow detection of locked cards
2024-05-21 21:04 [PATCH] mmc: core: allow detection of locked cards linux-mmc
@ 2024-05-23 3:41 ` Avri Altman
2024-05-23 8:29 ` Christian Loehle
2024-05-23 8:30 ` Christian Loehle
2 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2024-05-23 3:41 UTC (permalink / raw)
To: linux-mmc@danman.eu, linux-mmc@vger.kernel.org,
ulf.hansson@linaro.org
>
> From: Daniel Kucera <linux-mmc@danman.eu>
Please don't leave the commit log empty.
>
> Signed-off-by: Daniel Kucera <linux-mmc@danman.eu>
> ---
> drivers/mmc/core/sd.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index
> 1c8148cdd..b22c30348 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -1475,9 +1475,22 @@ static int mmc_sd_init_card(struct mmc_host
> *host, u32 ocr,
Aren't you be needing a similar handling for the eMMC side as well?
Thanks,
Avri
> goto free_card;
> }
>
> - err = mmc_sd_setup_card(host, card, oldcard != NULL);
> - if (err)
> - goto free_card;
> + u32 card_status;
> +
> + err = mmc_send_status(card, &card_status);
> + if (err){
> + pr_err("%s: unable to get card status\n",
> + mmc_hostname(host));
> + goto free_card;
> + }
> +
> + if (card_status & R1_CARD_IS_LOCKED){
> + pr_warn("%s: card is locked\n", mmc_hostname(host));
> + } else {
> + err = mmc_sd_setup_card(host, card, oldcard != NULL);
> + if (err)
> + goto free_card;
> + }
>
> /*
> * If the card has not been power cycled, it may still be using 1.8V
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: core: allow detection of locked cards
2024-05-21 21:04 [PATCH] mmc: core: allow detection of locked cards linux-mmc
2024-05-23 3:41 ` Avri Altman
@ 2024-05-23 8:29 ` Christian Loehle
2024-05-23 13:17 ` Daniel Kucera
2024-05-23 8:30 ` Christian Loehle
2 siblings, 1 reply; 5+ messages in thread
From: Christian Loehle @ 2024-05-23 8:29 UTC (permalink / raw)
To: linux-mmc, linux-mmc, ulf.hansson
On 5/21/24 22:04, linux-mmc@danman.eu wrote:
> From: Daniel Kucera <linux-mmc@danman.eu>
>
> Signed-off-by: Daniel Kucera <linux-mmc@danman.eu>
> ---
> drivers/mmc/core/sd.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 1c8148cdd..b22c30348 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -1475,9 +1475,22 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
> goto free_card;
> }
>
> - err = mmc_sd_setup_card(host, card, oldcard != NULL);
> - if (err)
> - goto free_card;
> + u32 card_status;
> +
> + err = mmc_send_status(card, &card_status);
> + if (err){
> + pr_err("%s: unable to get card status\n",
> + mmc_hostname(host));
> + goto free_card;
> + }
> +
> + if (card_status & R1_CARD_IS_LOCKED){
> + pr_warn("%s: card is locked\n", mmc_hostname(host));
> + } else {
> + err = mmc_sd_setup_card(host, card, oldcard != NULL);
> + if (err)
> + goto free_card;
> + }
>
> /*
> * If the card has not been power cycled, it may still be using 1.8V
Does that work for you?
I vaguely remember adding some checks before the block device setup and some
recovery as well since the partition scan (will fail) already triggered resets.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: core: allow detection of locked cards
2024-05-21 21:04 [PATCH] mmc: core: allow detection of locked cards linux-mmc
2024-05-23 3:41 ` Avri Altman
2024-05-23 8:29 ` Christian Loehle
@ 2024-05-23 8:30 ` Christian Loehle
2 siblings, 0 replies; 5+ messages in thread
From: Christian Loehle @ 2024-05-23 8:30 UTC (permalink / raw)
To: linux-mmc, linux-mmc, ulf.hansson
On 5/21/24 22:04, linux-mmc@danman.eu wrote:
> From: Daniel Kucera <linux-mmc@danman.eu>
>
> Signed-off-by: Daniel Kucera <linux-mmc@danman.eu>
> ---
> drivers/mmc/core/sd.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 1c8148cdd..b22c30348 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -1475,9 +1475,22 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
> goto free_card;
> }
>
> - err = mmc_sd_setup_card(host, card, oldcard != NULL);
> - if (err)
> - goto free_card;
> + u32 card_status;
> +
> + err = mmc_send_status(card, &card_status);
> + if (err){
> + pr_err("%s: unable to get card status\n",
> + mmc_hostname(host));
> + goto free_card;
> + }
> +
> + if (card_status & R1_CARD_IS_LOCKED){
> + pr_warn("%s: card is locked\n", mmc_hostname(host));
> + } else {
> + err = mmc_sd_setup_card(host, card, oldcard != NULL);
> + if (err)
> + goto free_card;
> + }
>
> /*
> * If the card has not been power cycled, it may still be using 1.8V
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: core: allow detection of locked cards
2024-05-23 8:29 ` Christian Loehle
@ 2024-05-23 13:17 ` Daniel Kucera
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Kucera @ 2024-05-23 13:17 UTC (permalink / raw)
To: Christian Loehle; +Cc: linux-mmc, ulf.hansson
On 2024-05-23 10:29, Christian Loehle wrote:
> On 5/21/24 22:04, linux-mmc@danman.eu wrote:
>> From: Daniel Kucera <linux-mmc@danman.eu>
>>
>> Signed-off-by: Daniel Kucera <linux-mmc@danman.eu>
>> ---
>> drivers/mmc/core/sd.c | 19 ++++++++++++++++---
>> 1 file changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
>> index 1c8148cdd..b22c30348 100644
>> --- a/drivers/mmc/core/sd.c
>> +++ b/drivers/mmc/core/sd.c
>> @@ -1475,9 +1475,22 @@ static int mmc_sd_init_card(struct mmc_host
>> *host, u32 ocr,
>> goto free_card;
>> }
>>
>> - err = mmc_sd_setup_card(host, card, oldcard != NULL);
>> - if (err)
>> - goto free_card;
>> + u32 card_status;
>> +
>> + err = mmc_send_status(card, &card_status);
>> + if (err){
>> + pr_err("%s: unable to get card status\n",
>> + mmc_hostname(host));
>> + goto free_card;
>> + }
>> +
>> + if (card_status & R1_CARD_IS_LOCKED){
>> + pr_warn("%s: card is locked\n", mmc_hostname(host));
>> + } else {
>> + err = mmc_sd_setup_card(host, card, oldcard != NULL);
>> + if (err)
>> + goto free_card;
>> + }
>>
>> /*
>> * If the card has not been power cycled, it may still be using 1.8V
>
> Does that work for you?
> I vaguely remember adding some checks before the block device setup and
> some
> recovery as well since the partition scan (will fail) already triggered
> resets.
Yes, it does, it shows a few read errors but then I run the unlock and
mount without problems.
See:
[819348.273781] mmc1: card is locked
[819348.275379] mmc1: new SD card at address 0001
[819348.276149] mmcblk1: mmc1:0001 00000 1.89 GiB
[819351.379473] mmc1: card is locked
[819351.983845] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819351.983861] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819355.631723] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819355.631734] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819359.279802] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819359.279813] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819359.279827] ldm_validate_partition_table(): Disk read failed.
[819362.927837] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819362.927863] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819366.575712] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819366.575724] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819370.223933] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819370.223958] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819373.875932] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819373.875952] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819373.875978] Dev mmcblk1: unable to read RDB block 0
[819377.520037] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819377.520062] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819381.167907] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819381.167933] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819384.815750] I/O error, dev mmcblk1, sector 24 op 0x0:(READ) flags
0x0 phys_seg 1 prio class 2
[819384.815776] Buffer I/O error on dev mmcblk1, logical block 3, async
page read
[819388.463981] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819388.464007] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819392.111760] I/O error, dev mmcblk1, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 2
[819392.111770] Buffer I/O error on dev mmcblk1, logical block 0, async
page read
[819392.111786] mmcblk1: unable to read partition table
[819395.759713] I/O error, dev mmcblk1, sector 3964800 op 0x0:(READ)
flags 0x80700 phys_seg 1 prio class 2
[819399.408666] I/O error, dev mmcblk1, sector 3964800 op 0x0:(READ)
flags 0x0 phys_seg 1 prio class 2
[819399.408691] Buffer I/O error on dev mmcblk1, logical block 495600,
async page read
I waited several minutes and then I run the unlock and the partition is
detected automatically:
[820514.276616] mmcblk1: p1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-05-23 13:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 21:04 [PATCH] mmc: core: allow detection of locked cards linux-mmc
2024-05-23 3:41 ` Avri Altman
2024-05-23 8:29 ` Christian Loehle
2024-05-23 13:17 ` Daniel Kucera
2024-05-23 8:30 ` Christian Loehle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox