Commit f37ac1ae authored by Ulf Hansson's avatar Ulf Hansson
Browse files

mmc: owl-mmc: Respect the cmd->busy_timeout from the mmc core



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: default avatarUlf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20200414161413.3036-8-ulf.hansson@linaro.org
parent d422f8b9
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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;