mmc: core: Use userland specified timeout value for eMMC sanitize
authorBean Huo <beanhuo@micron.com>
Fri, 2 Apr 2021 09:24:31 +0000 (11:24 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 12 Apr 2021 06:50:44 +0000 (08:50 +0200)
As the density increases, the 4-minute timeout value for sanitize is no
longer feasible. At the same time, devices of different densities have
different timeout values, which makes it difficult to use a common timeout
value. Therefore, let's pass down the userland-specified sanitize timeout
value so it can be used.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Link: https://lore.kernel.org/r/20210402092432.25069-2-huobean@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/block.c
drivers/mmc/core/mmc_ops.c
drivers/mmc/core/mmc_ops.h

index fe5892d..8bfd4d9 100644 (file)
@@ -539,7 +539,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
 
        if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
            (cmd.opcode == MMC_SWITCH))
-               return mmc_sanitize(card);
+               return mmc_sanitize(card, idata->ic.cmd_timeout_ms);
 
        mmc_wait_for_req(card->host, &mrq);
 
index f413474..ccca067 100644 (file)
@@ -1010,7 +1010,7 @@ int mmc_cmdq_disable(struct mmc_card *card)
 }
 EXPORT_SYMBOL_GPL(mmc_cmdq_disable);
 
-int mmc_sanitize(struct mmc_card *card)
+int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms)
 {
        struct mmc_host *host = card->host;
        int err;
@@ -1020,12 +1020,15 @@ int mmc_sanitize(struct mmc_card *card)
                return -EOPNOTSUPP;
        }
 
+       if (!timeout_ms)
+               timeout_ms = MMC_SANITIZE_TIMEOUT_MS;
+
        pr_debug("%s: Sanitize in progress...\n", mmc_hostname(host));
 
        mmc_retune_hold(host);
 
        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START,
-                        1, MMC_SANITIZE_TIMEOUT_MS);
+                        1, timeout_ms);
        if (err)
                pr_err("%s: Sanitize failed err=%d\n", mmc_hostname(host), err);
 
index 6320092..1ed0d03 100644 (file)
@@ -46,7 +46,7 @@ void mmc_run_bkops(struct mmc_card *card);
 int mmc_flush_cache(struct mmc_card *card);
 int mmc_cmdq_enable(struct mmc_card *card);
 int mmc_cmdq_disable(struct mmc_card *card);
-int mmc_sanitize(struct mmc_card *card);
+int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms);
 
 #endif