]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mmc: owl-mmc: Respect the cmd->busy_timeout from the mmc core
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 14 Apr 2020 16:14:01 +0000 (18:14 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 28 May 2020 09:21:01 +0000 (11:21 +0200)
For commands that doesn't involve to prepare a data transfer, owl-mmc is
using a fixed 30s response timeout. This is a bit problematic.

For some commands it means waiting longer than needed for the completion 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
30s. 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: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20200414161413.3036-8-ulf.hansson@linaro.org
drivers/mmc/host/owl-mmc.c

index 01ffe51f413df8556a1731ab02ec3a9ce1721007..5e20c099fe03a8d538dd3305fecbfd1136fc42cd 100644 (file)
@@ -92,6 +92,8 @@
 #define OWL_SD_STATE_RC16ER            BIT(1)
 #define OWL_SD_STATE_CRC7ER            BIT(0)
 
+#define OWL_CMD_TIMEOUT_MS             30000
+
 struct owl_mmc_host {
        struct device *dev;
        struct reset_control *reset;
@@ -172,6 +174,7 @@ static void owl_mmc_send_cmd(struct owl_mmc_host *owl_host,
                             struct mmc_command *cmd,
                             struct mmc_data *data)
 {
+       unsigned long timeout;
        u32 mode, state, resp[2];
        u32 cmd_rsp_mask = 0;
 
@@ -239,7 +242,10 @@ static void owl_mmc_send_cmd(struct owl_mmc_host *owl_host,
        if (data)
                return;
 
-       if (!wait_for_completion_timeout(&owl_host->sdc_complete, 30 * HZ)) {
+       timeout = msecs_to_jiffies(cmd->busy_timeout ? cmd->busy_timeout :
+               OWL_CMD_TIMEOUT_MS);
+
+       if (!wait_for_completion_timeout(&owl_host->sdc_complete, timeout)) {
                dev_err(owl_host->dev, "CMD interrupt timeout\n");
                cmd->error = -ETIMEDOUT;
                return;