* [PATCH 1/2] mmc: lock: skip regular block io operations for locked cards
@ 2013-12-20 0:43 Abbas Raza
2013-12-20 0:43 ` [PATCH 2/2] mmc: lock: don't perform lock/unlock commands when in DDR mode Abbas Raza
0 siblings, 1 reply; 2+ messages in thread
From: Abbas Raza @ 2013-12-20 0:43 UTC (permalink / raw)
To: linux-mmc; +Cc: Abbas Raza, Al Cooper, Chris Ball
From: Abbas Raza <Abbas_Raza@mentor.com>
According to SD Physical Layer Specifications:
Locked cards respond to (and execute) all commands in the "basic"
command class (class 0), ACMD41, CMD16 and "lock card" command class.
Thus, the host is allowed to reset, initialize, select, query for status,
etc., but not to access data on the card.
But when a locked card is inserted into system having no key added for
this card, following errors are observed untill the card is removed
[ 36.955193] mmc0: card is locked.
[ 36.959746] mmc (null): Error, request_key -2
[ 36.964622] mmc0: Cannot find matching key
[ 36.968765] mmc0: Card unlock failed.
[ 36.972717] mmc0: new SDHC card at address 0002
[ 36.977747] mmcblk0: mmc0:0002 00000 7.41 GiB
[ 36.989596] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 36.999630] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 37.009604] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 37.019574] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 37.029548] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 37.039514] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 37.046729] end_request: I/O error, dev mmcblk0, sector 15556480
[ 37.052813] Buffer I/O error on device mmcblk0, logical block 1944560
[ 37.062139] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 37.072106] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 37.082072] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
.............
[ 46.249273] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 46.259247] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 46.269215] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 46.279183] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
[ 46.289151] mmcblk0: timed out sending r/w cmd command, card status 0x2400900
As a workaround, skip all the regular block io operations if the card is locked.
One can unlock the card after system boot by following below steps
1) Add key for this card.
2) Unlock the card using sysfs attribute 'unlock_retry' for this card.
Cc: Al Cooper <alcooperx@gmail.com>
Cc: Chris Ball <cjb@laptop.org>
Signed-off-by: Abbas Raza <Abbas_Raza@mentor.com>
---
drivers/mmc/card/block.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index bda7291..ac58224 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1477,6 +1477,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
/* claim host only for the first request */
mmc_claim_host(card->host);
+ if (mmc_card_locked(card)) {
+ if (req)
+ blk_end_request_all(req, 0);
+ ret = 0;
+ goto out;
+ }
+
ret = mmc_blk_part_switch(card, md);
if (ret) {
if (req) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] mmc: lock: don't perform lock/unlock commands when in DDR mode
2013-12-20 0:43 [PATCH 1/2] mmc: lock: skip regular block io operations for locked cards Abbas Raza
@ 2013-12-20 0:43 ` Abbas Raza
0 siblings, 0 replies; 2+ messages in thread
From: Abbas Raza @ 2013-12-20 0:43 UTC (permalink / raw)
To: linux-mmc; +Cc: Abbas Raza, Al Cooper, Chris Ball
From: Abbas Raza <Abbas_Raza@mentor.com>
According to JEDEC Standard No. 84-A441:
The card lock/unlock command (CMD42) can only be performed when the
card operates in single data rate mode. CMD42 is an illegal command in
dual data rate mode.
So if the card is in DDR mode, don't perform lock/unlock commands.
Otherwise following errors will be seen:
echo setpw > /sys/class/mmc_host/mmc2/mmc2\:0001/lock
-sh: echo: write error: Connection timed out
Timeout occurs because SET_BLOCK_LEN (CMD16) fails in dual data rate mode as
mentioned in JEDEC Standard No. 84-A441:
The following commands: bus testing (CMD19, CMD14), lock-unlock (CMD42),
set block-length (CMD16) and stream transfer (CMD11,CMD20) are not allowed
once the card is configured to operate in dual data rate mode and shall not
be executed but regarded as illegal commands.
Cc: Al Cooper <alcooperx@gmail.com>
Cc: Chris Ball <cjb@laptop.org>
Signed-off-by: Abbas Raza <Abbas_Raza@mentor.com>
---
drivers/mmc/core/mmc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 24d2010..f34d237 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -664,6 +664,12 @@ ssize_t mmc_lock_store(struct device *dev, struct device_attribute *att,
struct mmc_password password;
mmc_claim_host(card->host);
+
+ if (mmc_card_ddr_mode(card)) {
+ dev_warn(dev, "Illegal operation in DDR mode\n");
+ goto out;
+ }
+
if (!mmc_card_lockable(card))
goto out;
for (x = 0; x < ARRAY_SIZE(lock_cmds); x++) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-20 0:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-20 0:43 [PATCH 1/2] mmc: lock: skip regular block io operations for locked cards Abbas Raza
2013-12-20 0:43 ` [PATCH 2/2] mmc: lock: don't perform lock/unlock commands when in DDR mode Abbas Raza
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).