diff mbox

mmc: mmc: Use 500ms as the default generic CMD6 timeout

Message ID 1478280753-2482-1-git-send-email-ulf.hansson@linaro.org
State New
Headers show

Commit Message

Ulf Hansson Nov. 4, 2016, 5:32 p.m. UTC
In the eMMC 4.51 version of the spec, an EXT_CSD field called
GENERIC_CMD6_TIME[248] was added. This allows cards to specify the maximum
time it may need to move out from its busy state, when a CMD6 command has
been sent.

In cases when the card is compliant to versions < 4.51 of the eMMC spec,
obviously the core needs to use a fall-back value for this timeout, which
currently is set to 10 minutes. This value is completely in the wrong range
and importantly in some cases it causes a card initialization to take more
than 10 minute to complete.

Earlier this scenario was avoided as the mmc core used CMD13 to poll the
card, to find out when it stopped signaling busy. Commit 08573eaf1a70
("mmc: mmc: do not use CMD13 to get status after speed mode switch")
changed this behavior.

Instead of reverting that commit, which would cause other issues, let's
instead start by picking a simple solution for the problem, by using a
500ms default generic CMD6 timeout.

The reason for using exactly 500ms, comes from observations that shows it's
quite common for cards to specify 250ms. 500ms is two times that value so
likely it should be enough for most cards.

Cc: <stable@vger.kernel.org> # v4.8+
Fixes: 08573eaf1a70 ("mmc: mmc: do not use CMD13 to get status after speed
mode switch")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---
 drivers/mmc/core/mmc.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
1.9.1

Comments

Stephen Boyd Nov. 4, 2016, 8:13 p.m. UTC | #1
On 11/04, Ulf Hansson wrote:
> In the eMMC 4.51 version of the spec, an EXT_CSD field called

> GENERIC_CMD6_TIME[248] was added. This allows cards to specify the maximum

> time it may need to move out from its busy state, when a CMD6 command has

> been sent.

> 

> In cases when the card is compliant to versions < 4.51 of the eMMC spec,

> obviously the core needs to use a fall-back value for this timeout, which

> currently is set to 10 minutes. This value is completely in the wrong range

> and importantly in some cases it causes a card initialization to take more

> than 10 minute to complete.

> 

> Earlier this scenario was avoided as the mmc core used CMD13 to poll the

> card, to find out when it stopped signaling busy. Commit 08573eaf1a70

> ("mmc: mmc: do not use CMD13 to get status after speed mode switch")

> changed this behavior.

> 

> Instead of reverting that commit, which would cause other issues, let's

> instead start by picking a simple solution for the problem, by using a

> 500ms default generic CMD6 timeout.

> 

> The reason for using exactly 500ms, comes from observations that shows it's

> quite common for cards to specify 250ms. 500ms is two times that value so

> likely it should be enough for most cards.

> 

> Cc: <stable@vger.kernel.org> # v4.8+

> Fixes: 08573eaf1a70 ("mmc: mmc: do not use CMD13 to get status after speed

> mode switch")

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


The 10 minute delay goes away and I see the card almost instantly
on my msm8960-cdp. I smoke tested on a couple other platforms
that weren't experiencing the problem and they seems fine too.

Tested-by: Stephen Boyd <sboyd@codeaurora.org>


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
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
Ulf Hansson Nov. 7, 2016, 10:50 a.m. UTC | #2
On 7 November 2016 at 11:03, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Nov 4, 2016 at 6:32 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

>

>> In the eMMC 4.51 version of the spec, an EXT_CSD field called

>> GENERIC_CMD6_TIME[248] was added. This allows cards to specify the maximum

>> time it may need to move out from its busy state, when a CMD6 command has

>> been sent.

>>

>> In cases when the card is compliant to versions < 4.51 of the eMMC spec,

>> obviously the core needs to use a fall-back value for this timeout, which

>> currently is set to 10 minutes. This value is completely in the wrong range

>> and importantly in some cases it causes a card initialization to take more

>> than 10 minute to complete.

>>

>> Earlier this scenario was avoided as the mmc core used CMD13 to poll the

>> card, to find out when it stopped signaling busy. Commit 08573eaf1a70

>> ("mmc: mmc: do not use CMD13 to get status after speed mode switch")

>> changed this behavior.

>>

>> Instead of reverting that commit, which would cause other issues, let's

>> instead start by picking a simple solution for the problem, by using a

>> 500ms default generic CMD6 timeout.

>>

>> The reason for using exactly 500ms, comes from observations that shows it's

>> quite common for cards to specify 250ms. 500ms is two times that value so

>> likely it should be enough for most cards.

>>

>> Cc: <stable@vger.kernel.org> # v4.8+

>> Fixes: 08573eaf1a70 ("mmc: mmc: do not use CMD13 to get status after speed

>> mode switch")

>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

>

> This fixes my rootfs issue. It still doesn't appear immediately as it did

> before, but maybe before was wrong then. (Or we should hammer

> a bit with  CMD13 and wait for a correct CRC?)


Yes, I see this as a quick fix for stable/rc.

So, I intend to submit a new series which builds on top of this and
which hopefully will improves the behaviour.

>

> Anyways: things are a lot better now, so:

> Tested-by: Linus Walleij <linus.walleij@linaro.org>


Thanks for testing!

Kind regards
Uffe
--
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
diff mbox

Patch

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e811bd9..9355366 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -26,6 +26,8 @@ 
 #include "mmc_ops.h"
 #include "sd_ops.h"
 
+#define DEFAULT_CMD6_TIMEOUT_MS	500
+
 static const unsigned int tran_exp[] = {
 	10000,		100000,		1000000,	10000000,
 	0,		0,		0,		0
@@ -571,6 +573,7 @@  static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 		card->erased_byte = 0x0;
 
 	/* eMMC v4.5 or later */
+	card->ext_csd.generic_cmd6_time = DEFAULT_CMD6_TIMEOUT_MS;
 	if (card->ext_csd.rev >= 6) {
 		card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;