]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/mmc/core/sd.c
mmc: core: Fixup signal voltage switch
[mirror_ubuntu-jammy-kernel.git] / drivers / mmc / core / sd.c
index 9a59fcd55a75f636ce103f9dd6f9b5cb4b67027e..03134b1e563cc81d1ee300305ad60e07b08dc0c3 100644 (file)
@@ -712,6 +712,14 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
 {
        int err;
        u32 max_current;
+       int retries = 10;
+
+try_again:
+       if (!retries) {
+               ocr &= ~SD_OCR_S18R;
+               pr_warning("%s: Skipping voltage switch\n",
+                       mmc_hostname(host));
+       }
 
        /*
         * Since we're changing the OCR value, we seem to
@@ -733,9 +741,10 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
 
        /*
         * If the host supports one of UHS-I modes, request the card
-        * to switch to 1.8V signaling level.
+        * to switch to 1.8V signaling level. If the card has failed
+        * repeatedly to switch however, skip this.
         */
-       if (mmc_host_uhs(host))
+       if (retries && mmc_host_uhs(host))
                ocr |= SD_OCR_S18R;
 
        /*
@@ -746,7 +755,6 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
        if (max_current > 150)
                ocr |= SD_OCR_XPC;
 
-try_again:
        err = mmc_send_app_op_cond(host, ocr, rocr);
        if (err)
                return err;
@@ -758,8 +766,11 @@ try_again:
        if (!mmc_host_is_spi(host) && rocr &&
           ((*rocr & 0x41000000) == 0x41000000)) {
                err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180);
-               if (err) {
-                       ocr &= ~SD_OCR_S18R;
+               if (err == -EAGAIN) {
+                       retries--;
+                       goto try_again;
+               } else if (err) {
+                       retries = 0;
                        goto try_again;
                }
        }