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

mmc: atmel-mci: Respect the cmd->busy_timeout from the mmc core

Using a fixed 2s timeout for all commands is a bit problematic.

For some commands it means waiting longer than needed for the timer to
expire, which may not a big issue, but still. For other commands, like for
an erase (CMD38) that uses a R1B response, may require longer timeouts than
2s. In these cases, we may end up treating the command as it failed, while
it just needed some more time to complete successfully.

Fix the problem by respecting the cmd->busy_timeout, which is provided by
the mmc core.

Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Link: https://lore.kernel.org/r/20200414161413.3036-4-ulf.hansson@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

+4 -2
+4 -2
drivers/mmc/host/atmel-mci.c
··· 809 809 static void atmci_send_command(struct atmel_mci *host, 810 810 struct mmc_command *cmd, u32 cmd_flags) 811 811 { 812 + unsigned int timeout_ms = cmd->busy_timeout ? cmd->busy_timeout : 813 + ATMCI_CMD_TIMEOUT_MS; 814 + 812 815 WARN_ON(host->cmd); 813 816 host->cmd = cmd; 814 817 ··· 822 819 atmci_writel(host, ATMCI_ARGR, cmd->arg); 823 820 atmci_writel(host, ATMCI_CMDR, cmd_flags); 824 821 825 - mod_timer(&host->timer, 826 - jiffies + msecs_to_jiffies(ATMCI_CMD_TIMEOUT_MS)); 822 + mod_timer(&host->timer, jiffies + msecs_to_jiffies(timeout_ms)); 827 823 } 828 824 829 825 static void atmci_send_stop_cmd(struct atmel_mci *host, struct mmc_data *data)