mmc: core: Do regular power cycle when lacking eMMC HW reset support
authorGwendal Grignou <gwendal@chromium.org>
Fri, 1 Apr 2016 23:04:22 +0000 (16:04 -0700)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 2 May 2016 08:33:24 +0000 (10:33 +0200)
The eMMC HW reset may be implemented either via the host ops ->hw_reset()
callback or through DT and the eMMC pwrseq. Additionally some eMMC cards
don't support HW reset.

To allow a reset to be done for the different combinations of mmc hosts
and eMMC/MMC cards, let's implement a fallback via trying a regular power
cycle. This improves the mmc block layer retry mechanism of failing I/O
requests.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
[Ulf: Rewrote changelog]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/core.c
drivers/mmc/core/mmc.c

index f80b3ab3266ad74a3d070f4cbee8bf93f729ecd2..99275e40bf2fb7f61083d6bcf2b867d76d6b25ca 100644 (file)
@@ -2456,8 +2456,9 @@ int mmc_hw_reset(struct mmc_host *host)
        ret = host->bus_ops->reset(host);
        mmc_bus_put(host);
 
-       if (ret != -EOPNOTSUPP)
-               pr_warn("%s: tried to reset card\n", mmc_hostname(host));
+       if (ret)
+               pr_warn("%s: tried to reset card, got error %d\n",
+                       mmc_hostname(host), ret);
 
        return ret;
 }
index 4dbe3df8024b2cf3ed9206f8d76cff1ba660dc7e..b8aa12ced45f94d850d20af56e788b6cb3028e43 100644 (file)
@@ -1957,19 +1957,17 @@ static int mmc_reset(struct mmc_host *host)
 {
        struct mmc_card *card = host->card;
 
-       if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
-               return -EOPNOTSUPP;
-
-       if (!mmc_can_reset(card))
-               return -EOPNOTSUPP;
-
-       mmc_set_clock(host, host->f_init);
-
-       host->ops->hw_reset(host);
-
-       /* Set initial state and call mmc_set_ios */
-       mmc_set_initial_state(host);
-
+       if ((host->caps & MMC_CAP_HW_RESET) && host->ops->hw_reset &&
+            mmc_can_reset(card)) {
+               /* If the card accept RST_n signal, send it. */
+               mmc_set_clock(host, host->f_init);
+               host->ops->hw_reset(host);
+               /* Set initial state and call mmc_set_ios */
+               mmc_set_initial_state(host);
+       } else {
+               /* Do a brute force power cycle */
+               mmc_power_cycle(host, card->ocr);
+       }
        return mmc_init_card(host, card->ocr, card);
 }