Skip to content

Commit 63f1560

Browse files
ahunter6storulf
authored andcommitted
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: Seunghui Lee <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Seunghui Lee <[email protected]> Tested-by: Seunghui Lee <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 15c5620 commit 63f1560

File tree

1 file changed

+16
-26
lines changed
  • drivers/mmc/core

1 file changed

+16
-26
lines changed

drivers/mmc/core/sd.c

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -949,15 +949,16 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
949949

950950
/* Erase init depends on CSD and SSR */
951951
mmc_init_erase(card);
952-
953-
/*
954-
* Fetch switch information from card.
955-
*/
956-
err = mmc_read_switch(card);
957-
if (err)
958-
return err;
959952
}
960953

954+
/*
955+
* Fetch switch information from card. Note, sd3_bus_mode can change if
956+
* voltage switch outcome changes, so do this always.
957+
*/
958+
err = mmc_read_switch(card);
959+
if (err)
960+
return err;
961+
961962
/*
962963
* For SPI, enable CRC as appropriate.
963964
* This CRC enable is located AFTER the reading of the
@@ -1480,26 +1481,15 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
14801481
if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_uhs(host) &&
14811482
mmc_sd_card_using_v18(card) &&
14821483
host->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_180) {
1483-
/*
1484-
* Re-read switch information in case it has changed since
1485-
* oldcard was initialized.
1486-
*/
1487-
if (oldcard) {
1488-
err = mmc_read_switch(card);
1489-
if (err)
1490-
goto free_card;
1491-
}
1492-
if (mmc_sd_card_using_v18(card)) {
1493-
if (mmc_host_set_uhs_voltage(host) ||
1494-
mmc_sd_init_uhs_card(card)) {
1495-
v18_fixup_failed = true;
1496-
mmc_power_cycle(host, ocr);
1497-
if (!oldcard)
1498-
mmc_remove_card(card);
1499-
goto retry;
1500-
}
1501-
goto cont;
1484+
if (mmc_host_set_uhs_voltage(host) ||
1485+
mmc_sd_init_uhs_card(card)) {
1486+
v18_fixup_failed = true;
1487+
mmc_power_cycle(host, ocr);
1488+
if (!oldcard)
1489+
mmc_remove_card(card);
1490+
goto retry;
15021491
}
1492+
goto cont;
15031493
}
15041494

15051495
/* Initialization sequence for UHS-I cards */

0 commit comments

Comments
 (0)