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

mmc: cb710: 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
~2s timeout of the polling loop, implemented in cb710_wait_for_event(). 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 2s, like erase (CMD38) for example.

Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20200414161413.3036-7-ulf.hansson@linaro.org

+8
+8
drivers/mmc/host/cb710-mmc.c
··· 10 10 #include <linux/delay.h> 11 11 #include "cb710-mmc.h" 12 12 13 + #define CB710_MMC_REQ_TIMEOUT_MS 2000 14 + 13 15 static const u8 cb710_clock_divider_log2[8] = { 14 16 /* 1, 2, 4, 8, 16, 32, 128, 512 */ 15 17 0, 1, 2, 3, 4, 5, 7, 9 ··· 709 707 mmc->f_min = val >> cb710_clock_divider_log2[CB710_MAX_DIVIDER_IDX]; 710 708 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; 711 709 mmc->caps = MMC_CAP_4_BIT_DATA; 710 + /* 711 + * In cb710_wait_for_event() we use a fixed timeout of ~2s, hence let's 712 + * inform the core about it. A future improvement should instead make 713 + * use of the cmd->busy_timeout. 714 + */ 715 + mmc->max_busy_timeout = CB710_MMC_REQ_TIMEOUT_MS; 712 716 713 717 reader = mmc_priv(mmc); 714 718