Skip to content

Commit 774514b

Browse files
Yann-lmsstorulf
authored andcommitted
mmc: mmci: Add MMC_CAP_NEED_RSP_BUSY for the stm32 variants
An issue has been observed on STM32MP157C-EV1 board, with an erase command with secure erase argument, ending up waiting for ~4 hours before timeout. The requested busy timeout from the mmc core ends up with 14784000ms (~4 hours), but the supported host->max_busy_timeout is 86767ms, which leads to that the core switch to use an R1 response in favor of the R1B and polls for busy with the host->card_busy() ops. In this case the polling doesn't work as expected, as we never detects that the card stops signaling busy, which leads to the following message: mmc1: Card stuck being busy! __mmc_poll_for_busy The problem boils done to that the stm32 variants can't use R1 responses in favor of R1B responses, as it leads to an internal state machine in the controller to get stuck. To continue to process requests, it would need to be reset. To fix this problem, let's set MMC_CAP_NEED_RSP_BUSY for the stm32 variant, which prevent the mmc core from switching to R1 responses. Additionally, let's cap the cmd->busy_timeout to the host->max_busy_timeout, thus rely on 86767ms to be sufficient (~66 seconds was need for this test case). Fixes: 94fe258 ("mmc: core: Enable erase/discard/trim support for all mmc hosts") Signed-off-by: Yann Gautier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] [Ulf: Simplified the code and extended the commit message] Signed-off-by: Ulf Hansson <[email protected]>
1 parent a38fd87 commit 774514b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/mmc/host/mmci.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,11 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
12421242
if (!cmd->busy_timeout)
12431243
cmd->busy_timeout = 10 * MSEC_PER_SEC;
12441244

1245-
clks = (unsigned long long)cmd->busy_timeout * host->cclk;
1245+
if (cmd->busy_timeout > host->mmc->max_busy_timeout)
1246+
clks = (unsigned long long)host->mmc->max_busy_timeout * host->cclk;
1247+
else
1248+
clks = (unsigned long long)cmd->busy_timeout * host->cclk;
1249+
12461250
do_div(clks, MSEC_PER_SEC);
12471251
writel_relaxed(clks, host->base + MMCIDATATIMER);
12481252
}
@@ -2151,6 +2155,10 @@ static int mmci_probe(struct amba_device *dev,
21512155
mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
21522156
}
21532157

2158+
/* Variants with mandatory busy timeout in HW needs R1B responses. */
2159+
if (variant->busy_timeout)
2160+
mmc->caps |= MMC_CAP_NEED_RSP_BUSY;
2161+
21542162
/* Prepare a CMD12 - needed to clear the DPSM on some variants. */
21552163
host->stop_abort.opcode = MMC_STOP_TRANSMISSION;
21562164
host->stop_abort.arg = 0;

0 commit comments

Comments
 (0)