Skip to content

Commit e923391

Browse files
computersforpeacestorulf
authored andcommitted
mmc: core: Terminate infinite loop in SD-UHS voltage switch
This loop intends to retry a max of 10 times, with some implicit termination based on the SD_{R,}OCR_S18A bit. Unfortunately, the termination condition depends on the value reported by the SD card (*rocr), which may or may not correctly reflect what we asked it to do. Needless to say, it's not wise to rely on the card doing what we expect; we should at least terminate the loop regardless. So, check both the input and output values, so we ensure we will terminate regardless of the SD card behavior. Note that SDIO learned a similar retry loop in commit 0797e5f ("mmc: core: Fixup signal voltage switch"), but that used the 'ocr' result, and so the current pre-terminating condition looks like: rocr & ocr & R4_18V_PRESENT (i.e., it doesn't have the same bug.) This addresses a number of crash reports seen on ChromeOS that look like the following: ... // lots of repeated: ... <4>[13142.846061] mmc1: Skipping voltage switch <4>[13143.406087] mmc1: Skipping voltage switch <4>[13143.964724] mmc1: Skipping voltage switch <4>[13144.526089] mmc1: Skipping voltage switch <4>[13145.086088] mmc1: Skipping voltage switch <4>[13145.645941] mmc1: Skipping voltage switch <3>[13146.153969] INFO: task halt:30352 blocked for more than 122 seconds. ... Fixes: f2119df ("mmc: sd: add support for signal voltage switch procedure") Cc: <[email protected]> Signed-off-by: Brian Norris <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 35ca91d commit e923391

File tree

1 file changed

+2
-1
lines changed
  • drivers/mmc/core

1 file changed

+2
-1
lines changed

drivers/mmc/core/sd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
870870
* the CCS bit is set as well. We deliberately deviate from the spec in
871871
* regards to this, which allows UHS-I to be supported for SDSC cards.
872872
*/
873-
if (!mmc_host_is_spi(host) && rocr && (*rocr & SD_ROCR_S18A)) {
873+
if (!mmc_host_is_spi(host) && (ocr & SD_OCR_S18R) &&
874+
rocr && (*rocr & SD_ROCR_S18A)) {
874875
err = mmc_set_uhs_voltage(host, pocr);
875876
if (err == -EAGAIN) {
876877
retries--;

0 commit comments

Comments
 (0)