Skip to content

Commit da3c6d0

Browse files
ahunter6gregkh
authored andcommitted
mmc: core: Fix inconsistent sd3_bus_mode at UHS-I SD voltage switch failure
commit 63f1560930e4e1c4f6279b8ae715c9841fe1a6d3 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8bca229 commit da3c6d0

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
@@ -942,15 +942,16 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
942942

943943
/* Erase init depends on CSD and SSR */
944944
mmc_init_erase(card);
945-
946-
/*
947-
* Fetch switch information from card.
948-
*/
949-
err = mmc_read_switch(card);
950-
if (err)
951-
return err;
952945
}
953946

947+
/*
948+
* Fetch switch information from card. Note, sd3_bus_mode can change if
949+
* voltage switch outcome changes, so do this always.
950+
*/
951+
err = mmc_read_switch(card);
952+
if (err)
953+
return err;
954+
954955
/*
955956
* For SPI, enable CRC as appropriate.
956957
* This CRC enable is located AFTER the reading of the
@@ -1473,26 +1474,15 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
14731474
if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_uhs(host) &&
14741475
mmc_sd_card_using_v18(card) &&
14751476
host->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_180) {
1476-
/*
1477-
* Re-read switch information in case it has changed since
1478-
* oldcard was initialized.
1479-
*/
1480-
if (oldcard) {
1481-
err = mmc_read_switch(card);
1482-
if (err)
1483-
goto free_card;
1484-
}
1485-
if (mmc_sd_card_using_v18(card)) {
1486-
if (mmc_host_set_uhs_voltage(host) ||
1487-
mmc_sd_init_uhs_card(card)) {
1488-
v18_fixup_failed = true;
1489-
mmc_power_cycle(host, ocr);
1490-
if (!oldcard)
1491-
mmc_remove_card(card);
1492-
goto retry;
1493-
}
1494-
goto cont;
1477+
if (mmc_host_set_uhs_voltage(host) ||
1478+
mmc_sd_init_uhs_card(card)) {
1479+
v18_fixup_failed = true;
1480+
mmc_power_cycle(host, ocr);
1481+
if (!oldcard)
1482+
mmc_remove_card(card);
1483+
goto retry;
14951484
}
1485+
goto cont;
14961486
}
14971487

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

0 commit comments

Comments
 (0)