mmc: core: allow detection of locked cards
PATCH v3 1/1 mmc: core: allow detection of locked cards
From: Daniel Kucera <[email protected]>
Locked card will not reply to SEND_SCR or SD_STATUS commands so it was failing to initialize previously. When skipped, the card will get initialized and CMD42 can be sent using ioctl to unlock the card or remove password protection. Until unlocked, all read/write calls will timeout.
--- drivers/mmc/core/sd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mmc/core/sd.c +12 -1
@@ -928,8 +928,19 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card, bool reinit) {int err; +u32 card_status; -if (!reinit) { + err =mmc_send_status (card, &card_status); +if (err){ +pr_err ("%s: unable to get card status\n" ,mmc_hostname (host)); +return err; + } + +if (card_status &R1_CARD_IS_LOCKED ){ +pr_warn ("%s: card is locked\n" ,mmc_hostname (host)); + } + +if (!reinit && !(card_status &R1_CARD_IS_LOCKED )) {/* * Fetch SCR from card. */
Signature · 1 line
2.34.1
Quoted 38 lines · On 2024-05-23 15:20, [email protected] wrote:
From: Daniel Kucera <[email protected]>
Locked card will not reply to
SEND_SCRorSD_STATUScommands so it was failing to initialize previously. When skipped, the card will get initialized and CMD42 can be sent using ioctl to unlock the card or remove password protection. Until unlocked, all read/write calls will timeout.Signed-off-by Daniel Kucera <[email protected]>--- drivers/mmc/core/sd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/mmc/core/sd.c +12
-1@@ -928,8 +928,19 @@ int mmc_sd_setup_card(struct mmc_host *host,struct mmc_card *card, bool reinit) { int err; +u32 card_status; -if (!reinit) { + err =mmc_send_status (card, &card_status); +if (err){ +pr_err ("%s: unable to get card status\n" ,mmc_hostname (host)); +return err; + } + +if (card_status &R1_CARD_IS_LOCKED ){ +pr_warn ("%s: card is locked\n" ,mmc_hostname (host)); + } + +if (!reinit && !(card_status &R1_CARD_IS_LOCKED )) {/* * Fetch SCR from card.
Quoted 1 line
*/
Any feedback please?
D.
Quoted 34 lines · On 2024-05-23 15:20, [email protected] wrote:
Quoted 33 lines
From: Daniel Kucera <[email protected]>
Locked card will not reply to
SEND_SCRorSD_STATUScommands so it was failing to initialize previously. When skipped, the card will get initialized and CMD42 can be sent using ioctl to unlock the card or remove password protection.
Until unlocked, all read/write calls will timeout.Signed-off-by Daniel Kucera <[email protected]>--- drivers/mmc/core/sd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0
-0
1c8148cdd..ae821df7d100644drivers/mmc/core/sd.c +9
-1@@ -928,8 +928,19 @@ int mmc_sd_setup_card(struct mmc_host *host,struct mmc_card *card, bool reinit) { int err; +u32 card_status; -if (!reinit) { + err =mmc_send_status (card, &card_status); +if (err){ +pr_err ("%s: unable to get card status\n" ,mmc_hostname (host)); +return err; + } + +if (card_status &R1_CARD_IS_LOCKED ){ +pr_warn ("%s: card is locked\n" ,mmc_hostname (host));
Quoted 8 lines
Quoted 6 lines
drivers/mmc/core/sd.c +3
-0+ } + +if (!reinit && !(card_status &R1_CARD_IS_LOCKED )) {/* * Fetch SCR from card. */Any feedback please?
You didn't address my comment from your v1 -
Since eMMC & SD shares the very same locking feature (non-COP SD that is) - You should at least explain in your commit log why it isn't an issue for eMMC, If indeed it is not.
Thanks,
Avri
Quoted 2 lines
D.
Hello Avri,
Quoted 42 lines · Avri Altman
Quoted 34 lines · On 2024-05-23 15:20, [email protected] wrote:
Quoted 33 lines
From: Daniel Kucera <[email protected]>
Locked card will not reply to
SEND_SCRorSD_STATUScommands so it was failing to initialize previously. When skipped, the card will get initialized and CMD42 can be sent using ioctl to unlock the card or remove password protection.
Until unlocked, all read/write calls will timeout.Signed-off-by Daniel Kucera <[email protected]>--- drivers/mmc/core/sd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0
-0
1c8148cdd..ae821df7d100644drivers/mmc/core/sd.c +9
-1@@ -928,8 +928,19 @@ int mmc_sd_setup_card(struct mmc_host *host,struct mmc_card *card, bool reinit) { int err; +u32 card_status; -if (!reinit) { + err =mmc_send_status (card, &card_status); +if (err){ +pr_err ("%s: unable to get card status\n" ,mmc_hostname (host)); +return err; + } + +if (card_status &R1_CARD_IS_LOCKED ){ +pr_warn ("%s: card is locked\n" ,mmc_hostname (host));Quoted 8 lines
Quoted 6 lines
drivers/mmc/core/sd.c +3
-0+ } + +if (!reinit && !(card_status &R1_CARD_IS_LOCKED )) {/* * Fetch SCR from card. */Any feedback please?
Quoted 4 lines
You didn't address my comment from your v1 -
Since eMMC & SD shares the very same locking feature (non-COP SD that is) - You should at least explain in your commit log why it isn't an issue for eMMC, If indeed it is not.
I'm sorry, I didn't get what you mean by that. I am touching only the sd.c code, not the mmc.c (where eMMC is initialized, am I correct?). How should I address this?
Should I test with eMMC to SD adaptor? I don't have any currently.
I am sorry if these are stupid questions, I am a layman.
Quoted 6 lines
Thanks,
AvriQuoted 2 lines
D.
Thank you.
Daniel.
Quoted 51 lines
Hello Avri,
Quoted 42 lines · Avri Altman
Quoted 34 lines · On 2024-05-23 15:20, [email protected] wrote:
Quoted 33 lines
From: Daniel Kucera <[email protected]>
Locked card will not reply to
SEND_SCRorSD_STATUScommands so it was failing to initialize previously. When skipped, the card will get initialized and CMD42 can be sent using ioctl to unlock the card or remove password protection.
Until unlocked, all read/write calls will timeout.Signed-off-by Daniel Kucera <[email protected]>--- drivers/mmc/core/sd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0
-0
1c8148cdd..ae821df7d100644drivers/mmc/core/sd.c +9
-1@@ -928,8 +928,19 @@ int mmc_sd_setup_card(struct mmc_host *host,struct mmc_card *card, bool reinit) { int err; +u32 card_status; -if (!reinit) { + err =mmc_send_status (card, &card_status); +if (err){ +pr_err ("%s: unable to get card status\n" ,mmc_hostname (host)); +return err; + } + +if (card_status &R1_CARD_IS_LOCKED ){ +pr_warn ("%s: card is locked\n" ,mmc_hostname (host));Quoted 8 lines
Quoted 6 lines
drivers/mmc/core/sd.c +3
-0+ } + +if (!reinit && !(card_status &R1_CARD_IS_LOCKED )) {/* * Fetch SCR from card. */Any feedback please?
Quoted 5 lines
You didn't address my comment from your v1 - Since eMMC & SD shares the very same locking feature (non-COP SD that
is) -
You should at least explain in your commit log why it isn't an issue for eMMC, If indeed it is not.
Quoted 4 lines
I'm sorry, I didn't get what you mean by that. I am touching only the
sd.ccode, not themmc.c(where eMMC is initialized, am I correct?).
How should I address this?
Should I test with eMMC to SD adaptor? I don't have any currently.
Theoretically, looking in the eMMC spec, a locked eMMC device shouldn't have any issue returning from power down.
The only flow that is affected is that its not allowed to switch to hs200 in a locked state until unlocked - not to say that it is a problem. If you can't verify that via code review, can you test your mmc-utils code on an eMMC platform?
Thanks,
Avri
Quoted 12 lines
I am sorry if these are stupid questions, I am a layman.
Quoted 6 lines
Thanks,
AvriQuoted 2 lines
D.
Thank you.
Daniel.
Hi Avri,
Quoted 55 lines · Avri Altman
Quoted 51 lines
Hello Avri,
Quoted 42 lines · Avri Altman
Quoted 34 lines · On 2024-05-23 15:20, [email protected] wrote:
Quoted 33 lines
From: Daniel Kucera <[email protected]>
Locked card will not reply to
SEND_SCRorSD_STATUScommands so it was failing to initialize previously. When skipped, the card will get initialized and CMD42 can be sent using ioctl to unlock the card or remove password protection.
Until unlocked, all read/write calls will timeout.Signed-off-by Daniel Kucera <[email protected]>--- drivers/mmc/core/sd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0
-0
1c8148cdd..ae821df7d100644drivers/mmc/core/sd.c +9
-1@@ -928,8 +928,19 @@ int mmc_sd_setup_card(struct mmc_host *host,struct mmc_card *card, bool reinit) { int err; +u32 card_status; -if (!reinit) { + err =mmc_send_status (card, &card_status); +if (err){ +pr_err ("%s: unable to get card status\n" ,mmc_hostname (host)); +return err; + } + +if (card_status &R1_CARD_IS_LOCKED ){ +pr_warn ("%s: card is locked\n" ,mmc_hostname (host));Quoted 8 lines
Quoted 6 lines
drivers/mmc/core/sd.c +3
-0+ } + +if (!reinit && !(card_status &R1_CARD_IS_LOCKED )) {/* * Fetch SCR from card. */Any feedback please?
Quoted 5 lines
You didn't address my comment from your v1 - Since eMMC & SD shares the very same locking feature (non-COP SD that
is) -
You should at least explain in your commit log why it isn't an issue for eMMC, If indeed it is not.Quoted 4 lines
I'm sorry, I didn't get what you mean by that. I am touching only the
sd.ccode, not themmc.c(where eMMC is initialized, am I correct?).
How should I address this?
Should I test with eMMC to SD adaptor? I don't have any currently.
Quoted 7 lines
Theoretically, looking in the eMMC spec, a locked eMMC device shouldn't have any issue returning from power down.
The only flow that is affected is that its not allowed to switch to hs200 in a locked state until unlocked - not to say that it is a problem.
If you can't verify that via code review, can you test your mmc-utils code on an eMMC platform?
I've just tested with an eMMC to SD adapter in my reader and it is detected correctly:
[1463181.072006] mmc1: unexpected status 0x2000900 after switch [1463181.074560] mmc1: unexpected status 0x2000900 after switch [1463181.077038] mmc1: unexpected status 0x2000900 after switch [1463181.079709] mmc1: unexpected status 0x2000900 after switch [1463181.081972] mmc1: unexpected status 0x2000900 after switch [1463181.083412] mmc1: unexpected status 0x2000900 after switch [1463181.084831] mmc1: unexpected status 0x2000900 after switch [1463181.084836] mmc1: new high speed MMC card at address 0001 [1463181.085195] mmcblk1: mmc1:0001 004GA0 2.59 GiB
Do I need to do some changes to the patch?
Quoted 15 lines
Thanks,
AvriQuoted 12 lines
I am sorry if these are stupid questions, I am a layman.
Quoted 6 lines
Thanks,
AvriQuoted 2 lines
D.
Thank you.
Daniel.
Thank you,
Daniel
Quoted 80 lines
Hi Avri,
Quoted 55 lines · Avri Altman
Quoted 51 lines
Hello Avri,
Quoted 42 lines · Avri Altman
Quoted 34 lines · On 2024-05-23 15:20, [email protected] wrote:
Quoted 33 lines
From: Daniel Kucera <[email protected]>
Locked card will not reply to
SEND_SCRorSD_STATUScommands so it was failing to initialize previously. When skipped, the card will get initialized and CMD42 can be sent using ioctl to unlock the card or remove password protection.
Until unlocked, all read/write calls will timeout.Signed-off-by Daniel Kucera <[email protected]>--- drivers/mmc/core/sd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0
-0
1c8148cdd..ae821df7d100644drivers/mmc/core/sd.c +9
-1@@ -928,8 +928,19 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card, bool reinit) {int err; +u32 card_status; -if (!reinit) { + err =mmc_send_status (card, &card_status); +if (err){ +pr_err ("%s: unable to get card status\n" ,mmc_hostname (host)); +return err; + } + +if (card_status &R1_CARD_IS_LOCKED ){ +pr_warn ("%s: card is locked\n" ,mmc_hostname (host));Quoted 8 lines
Quoted 6 lines
drivers/mmc/core/sd.c +3
-0+ } + +if (!reinit && !(card_status &R1_CARD_IS_LOCKED )) {/* * Fetch SCR from card. */Any feedback please?
Quoted 5 lines
You didn't address my comment from your v1 - Since eMMC & SD shares the very same locking feature (non-COP SD that
is) -
You should at least explain in your commit log why it isn't an issue for eMMC, If indeed it is not.Quoted 4 lines
I'm sorry, I didn't get what you mean by that. I am touching only the
sd.ccode, not themmc.c(where eMMC is initialized, am I correct?). How should I address this?
Should I test with eMMC to SD adaptor? I don't have any currently.Quoted 7 lines
Theoretically, looking in the eMMC spec, a locked eMMC device shouldn't have any issue returning from power down.
The only flow that is affected is that its not allowed to switch to hs200 in a locked state until unlocked - not to say that it is a problem.
If you can't verify that via code review, can you test your mmc-utils code on an eMMC platform?I've just tested with an eMMC to SD adapter in my reader and it is detected correctly:
[1463181.072006] mmc1: unexpected status 0x2000900 after switch [1463181.074560] mmc1: unexpected status 0x2000900 after switch [1463181.077038] mmc1: unexpected status 0x2000900 after switch [1463181.079709] mmc1: unexpected status 0x2000900 after switch [1463181.081972] mmc1: unexpected status 0x2000900 after switch [1463181.083412] mmc1: unexpected status 0x2000900 after switch [1463181.084831] mmc1: unexpected status 0x2000900 after switch [1463181.084836] mmc1: new high speed MMC card at address 0001 [1463181.085195] mmcblk1: mmc1:0001 004GA0 2.59 GiB
Quoted 1 line
Do I need to do some changes to the patch?
Just add one more line to your commit log saying that no similar attention is needed for eMMC because....
Thanks,
Avri
Quoted 19 lines
Quoted 16 lines
Thanks,
AvriQuoted 12 lines
I am sorry if these are stupid questions, I am a layman.
Quoted 6 lines
Thanks,
AvriQuoted 2 lines
D.
Thank you.
Daniel.Thank you,
Daniel