mmc: mmc: Improve reliability of mmc_select_hs200()
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 28 Oct 2015 12:25:40 +0000 (14:25 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 9 Nov 2015 12:12:08 +0000 (13:12 +0100)
commit1815e61b1a7efe81017a883e817292daf7d2f922
tree71bdab46ad5549d57472af8f5259100d4ebfb4b8
parent26d49fe7195385f2f1e406feddb01c16b53e77b6
mmc: mmc: Improve reliability of mmc_select_hs200()

Currently mmc_select_hs200() uses __mmc_switch() which checks the
success of the switch to HS200 mode using CMD13 (SEND_STATUS).
The problem is that it does that using the timing settings of legacy
mode.  That is prone to error, not least because the timing parameters
for legacy mode are tighter than the timing parameters for HS200 mode.

In the case when CMD13 polling is used (i.e. not MMC_CAP_WAIT_WHILE_BUSY)
with the switch command, it must be assumed that using different modes on
the card and host must work.

However in the case when CMD13 polling is not used
(i.e. MMC_CAP_WAIT_WHILE_BUSY) mmc_select_hs200() can be made more
reliable by setting the host to the correct timing before sending CMD13.

This patch does that.

A complication is that the caller, mmc_select_timing(), will ignore a
switch error (indicated by -EBADMSG), assume the old mode is valid
and continue, so the old timing must be restored in that case.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: <stable@vger.kernel.org> # 4.2+
Tested-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/mmc.c