Skip to content

Commit e3ae340

Browse files
committed
mmc: core: Use a minimum 1600ms timeout when enabling CACHE ctrl
Some eMMCs from Micron have been reported to need ~800 ms timeout, while enabling the CACHE ctrl after running sudden power failure tests. The needed timeout is greater than what the card specifies as its generic CMD6 timeout, through the EXT_CSD register, hence the problem. Normally we would introduce a card quirk to extend the timeout for these specific Micron cards. However, due to the rather complicated debug process needed to find out the error, let's simply use a minimum timeout of 1600ms, the double of what has been reported, for all cards when enabling CACHE ctrl. Reported-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Reported-by: Andreas Dannenberg <dannenberg@ti.com> Reported-by: Faiz Abbas <faiz_abbas@ti.com> Cc: <stable@vger.kernel.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent ba9f39a commit e3ae340

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/mmc/core/mmc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "pwrseq.h"
3131

3232
#define DEFAULT_CMD6_TIMEOUT_MS 500
33+
#define MIN_CACHE_EN_TIMEOUT_MS 1600
3334

3435
static const unsigned int tran_exp[] = {
3536
10000, 100000, 1000000, 10000000,
@@ -1789,13 +1790,18 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
17891790
}
17901791

17911792
/*
1792-
* If cache size is higher than 0, this indicates
1793-
* the existence of cache and it can be turned on.
1793+
* If cache size is higher than 0, this indicates the existence of cache
1794+
* and it can be turned on. Note that some eMMCs from Micron has been
1795+
* reported to need ~800 ms timeout, while enabling the cache after
1796+
* sudden power failure tests. Let's extend the timeout to a minimum of
1797+
* DEFAULT_CACHE_EN_TIMEOUT_MS and do it for all cards.
17941798
*/
17951799
if (card->ext_csd.cache_size > 0) {
1800+
unsigned int timeout_ms = MIN_CACHE_EN_TIMEOUT_MS;
1801+
1802+
timeout_ms = max(card->ext_csd.generic_cmd6_time, timeout_ms);
17961803
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1797-
EXT_CSD_CACHE_CTRL, 1,
1798-
card->ext_csd.generic_cmd6_time);
1804+
EXT_CSD_CACHE_CTRL, 1, timeout_ms);
17991805
if (err && err != -EBADMSG)
18001806
goto free_card;
18011807

0 commit comments

Comments
 (0)