[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211022063920.2145-2-huijin.park@samsung.com>
Date: Fri, 22 Oct 2021 15:39:20 +0900
From: Huijin Park <huijin.park@...sung.com>
To: Ulf Hansson <ulf.hansson@...aro.org>
Cc: linux-mmc@...r.kernel.org, linux-kernel@...r.kernel.org,
Huijin Park <bbanghj.park@...il.com>,
Huijin Park <huijin.park@...sung.com>
Subject: [PATCH 2/2] mmc: core: use jiffies to checking timeout for CMD1
This patch uses jiffies for checking timeout instead of loop count.
Because the previous patch which is adjusting interval time changes
the timeout value. Besides using jiffies is more clearly for checking
timeout instead of counting loop.
Signed-off-by: Huijin Park <huijin.park@...sung.com>
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 61b4ffdc89ce..f48216d65d2c 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -176,14 +176,16 @@ int mmc_go_idle(struct mmc_host *host)
int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
{
struct mmc_command cmd = {};
- int i, err = 0;
+ int err = 0;
int interval = 1, interval_max = 10;
+ unsigned long timeout;
cmd.opcode = MMC_SEND_OP_COND;
cmd.arg = mmc_host_is_spi(host) ? 0 : ocr;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
- for (i = 100; i; i--) {
+ timeout = jiffies + msecs_to_jiffies(1000);
+ while (true) {
err = mmc_wait_for_cmd(host, &cmd, 0);
if (err)
break;
@@ -197,7 +199,12 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
break;
}
- err = -ETIMEDOUT;
+ if (time_after(jiffies, timeout)) {
+ pr_err("%s: Card stuck being busy! %s\n",
+ mmc_hostname(host), __func__);
+ err = -ETIMEDOUT;
+ break;
+ }
mmc_delay(interval);
if (interval < interval_max)
--
2.17.1
Powered by blists - more mailing lists