]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mmc: mmc: Introduce mmc_abort_tuning()
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 2 Dec 2016 13:14:23 +0000 (15:14 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 5 Dec 2016 13:16:22 +0000 (14:16 +0100)
If a tuning command times out, the card could still be processing it, which
will cause problems for recovery. The eMMC specification says that CMD12
can be used to stop CMD21, so add a function that does that.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/mmc_ops.c
include/linux/mmc/core.h

index 81ce63bb07735953787b24ae4d590e8c0c271acd..b11c3455b040c5b03e8083e9b8e4f234b0752537 100644 (file)
@@ -678,6 +678,31 @@ out:
 }
 EXPORT_SYMBOL_GPL(mmc_send_tuning);
 
+int mmc_abort_tuning(struct mmc_host *host, u32 opcode)
+{
+       struct mmc_command cmd = {0};
+
+       /*
+        * eMMC specification specifies that CMD12 can be used to stop a tuning
+        * command, but SD specification does not, so do nothing unless it is
+        * eMMC.
+        */
+       if (opcode != MMC_SEND_TUNING_BLOCK_HS200)
+               return 0;
+
+       cmd.opcode = MMC_STOP_TRANSMISSION;
+       cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
+
+       /*
+        * For drivers that override R1 to R1b, set an arbitrary timeout based
+        * on the tuning timeout i.e. 150ms.
+        */
+       cmd.busy_timeout = 150;
+
+       return mmc_wait_for_cmd(host, &cmd, 0);
+}
+EXPORT_SYMBOL_GPL(mmc_abort_tuning);
+
 static int
 mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
                  u8 len)
index 0ce928b3ce90eeb72d2df2f0d996cec6e25ec688..e33cc748dcfe16e65d20ea6f815ca365deb0b2db 100644 (file)
@@ -176,6 +176,7 @@ extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
 extern void mmc_start_bkops(struct mmc_card *card, bool from_exception);
 extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
 extern int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
+extern int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
 extern int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);
 
 #define MMC_ERASE_ARG          0x00000000