Commit 63f15609 authored by Adrian Hunter's avatar Adrian Hunter Committed by Ulf Hansson

mmc: core: Fix inconsistent sd3_bus_mode at UHS-I SD voltage switch failure

If re-initialization results is a different signal voltage, because the
voltage switch failed previously, but not this time (or vice versa), then
sd3_bus_mode will be inconsistent with the card because the SD_SWITCH
command is done only upon first initialization.

Fix by always reading SD_SWITCH information during re-initialization, which
also means it does not need to be re-read later for the 1.8V fixup
workaround.

Note, brief testing showed SD_SWITCH took about 1.8ms to 2ms which added
about 1% to 1.5% to the re-initialization time, so it's not particularly
significant.
Reported-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Reviewed-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
Tested-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220815073321.63382-3-adrian.hunter@intel.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 15c56208
...@@ -949,14 +949,15 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card, ...@@ -949,14 +949,15 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
/* Erase init depends on CSD and SSR */ /* Erase init depends on CSD and SSR */
mmc_init_erase(card); mmc_init_erase(card);
}
/* /*
* Fetch switch information from card. * Fetch switch information from card. Note, sd3_bus_mode can change if
* voltage switch outcome changes, so do this always.
*/ */
err = mmc_read_switch(card); err = mmc_read_switch(card);
if (err) if (err)
return err; return err;
}
/* /*
* For SPI, enable CRC as appropriate. * For SPI, enable CRC as appropriate.
...@@ -1480,16 +1481,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, ...@@ -1480,16 +1481,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_uhs(host) && if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_uhs(host) &&
mmc_sd_card_using_v18(card) && mmc_sd_card_using_v18(card) &&
host->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_180) { host->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_180) {
/*
* Re-read switch information in case it has changed since
* oldcard was initialized.
*/
if (oldcard) {
err = mmc_read_switch(card);
if (err)
goto free_card;
}
if (mmc_sd_card_using_v18(card)) {
if (mmc_host_set_uhs_voltage(host) || if (mmc_host_set_uhs_voltage(host) ||
mmc_sd_init_uhs_card(card)) { mmc_sd_init_uhs_card(card)) {
v18_fixup_failed = true; v18_fixup_failed = true;
...@@ -1500,7 +1491,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, ...@@ -1500,7 +1491,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
} }
goto cont; goto cont;
} }
}
/* Initialization sequence for UHS-I cards */ /* Initialization sequence for UHS-I cards */
if (rocr & SD_ROCR_S18A && mmc_host_uhs(host)) { if (rocr & SD_ROCR_S18A && mmc_host_uhs(host)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment