Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: jz4740: Inform the mmc core about the maximum busy timeout

Some commands uses R1B responses, which means the card may assert the DAT0
line to signal busy for a period of time, after it has received the
command. The mmc core normally specifies the busy period for the command in
the cmd->busy_timeout. Ideally the driver should respect it, but that
requires quite some update of the code, so let's defer that to someone with
the HW at hand.

Instead, let's inform the mmc core about the maximum supported busy timeout
in ->max_busy_timeout during ->probe(). This value corresponds to the fixed
5s timeout used by jz4740. In this way, we let the mmc core validate the
needed timeout, which may lead to that it converts from a R1B into a R1
response and then use CMD13 to poll for busy completion.

In other words, this change enables support for commands with longer busy
periods than 5s, like erase (CMD38) for example.

Cc: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20200414161413.3036-5-ulf.hansson@linaro.org

+11 -2
+11 -2
drivers/mmc/host/jz4740_mmc.c
··· 108 108 #define JZ_MMC_LPM_LOW_POWER_MODE_EN BIT(0) 109 109 110 110 #define JZ_MMC_CLK_RATE 24000000 111 + #define JZ_MMC_REQ_TIMEOUT_MS 5000 111 112 112 113 enum jz4740_mmc_version { 113 114 JZ_MMC_JZ4740, ··· 441 440 442 441 if (timeout == 0) { 443 442 set_bit(0, &host->waiting); 444 - mod_timer(&host->timeout_timer, jiffies + 5*HZ); 443 + mod_timer(&host->timeout_timer, 444 + jiffies + msecs_to_jiffies(JZ_MMC_REQ_TIMEOUT_MS)); 445 445 jz4740_mmc_set_irq_enabled(host, irq, true); 446 446 return true; 447 447 } ··· 895 893 896 894 host->state = JZ4740_MMC_STATE_READ_RESPONSE; 897 895 set_bit(0, &host->waiting); 898 - mod_timer(&host->timeout_timer, jiffies + 5*HZ); 896 + mod_timer(&host->timeout_timer, 897 + jiffies + msecs_to_jiffies(JZ_MMC_REQ_TIMEOUT_MS)); 899 898 jz4740_mmc_send_command(host, req->cmd); 900 899 } 901 900 ··· 1025 1022 mmc->f_max = JZ_MMC_CLK_RATE; 1026 1023 mmc->f_min = mmc->f_max / 128; 1027 1024 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 1025 + 1026 + /* 1027 + * We use a fixed timeout of 5s, hence inform the core about it. A 1028 + * future improvement should instead respect the cmd->busy_timeout. 1029 + */ 1030 + mmc->max_busy_timeout = JZ_MMC_REQ_TIMEOUT_MS; 1028 1031 1029 1032 mmc->max_blk_size = (1 << 10) - 1; 1030 1033 mmc->max_blk_count = (1 << 15) - 1;