Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: mmc: Introduce mmc_abort_tuning()

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>

authored by

Adrian Hunter and committed by
Ulf Hansson
e711f030 0760c355

+26
+25
drivers/mmc/core/mmc_ops.c
··· 678 678 } 679 679 EXPORT_SYMBOL_GPL(mmc_send_tuning); 680 680 681 + int mmc_abort_tuning(struct mmc_host *host, u32 opcode) 682 + { 683 + struct mmc_command cmd = {0}; 684 + 685 + /* 686 + * eMMC specification specifies that CMD12 can be used to stop a tuning 687 + * command, but SD specification does not, so do nothing unless it is 688 + * eMMC. 689 + */ 690 + if (opcode != MMC_SEND_TUNING_BLOCK_HS200) 691 + return 0; 692 + 693 + cmd.opcode = MMC_STOP_TRANSMISSION; 694 + cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; 695 + 696 + /* 697 + * For drivers that override R1 to R1b, set an arbitrary timeout based 698 + * on the tuning timeout i.e. 150ms. 699 + */ 700 + cmd.busy_timeout = 150; 701 + 702 + return mmc_wait_for_cmd(host, &cmd, 0); 703 + } 704 + EXPORT_SYMBOL_GPL(mmc_abort_tuning); 705 + 681 706 static int 682 707 mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, 683 708 u8 len)
+1
include/linux/mmc/core.h
··· 176 176 extern void mmc_start_bkops(struct mmc_card *card, bool from_exception); 177 177 extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int); 178 178 extern int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error); 179 + extern int mmc_abort_tuning(struct mmc_host *host, u32 opcode); 179 180 extern int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd); 180 181 181 182 #define MMC_ERASE_ARG 0x00000000