When a UHS card successfully negotiates 1.8V signaling during normal
initialization, the host voltage switch is performed as part of the
ACMD41 handshake. Without this fix, the warm-reboot recovery path
would fire again immediately after, switching the host voltage a
second time unnecessarily.

Add a check so the recovery path is only entered when the voltage
switch was not already performed during the current initialization
session.

Fixes: 906ee6785b1c ("mmc: sd: Handle UHS-I voltage signaling without power 
cycle")
Signed-off-by: Tanmay Kathpalia <[email protected]>
---
 drivers/mmc/mmc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 7dadff27abe..10d8a37d2a8 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2720,10 +2720,11 @@ static int mmc_startup(struct mmc *mmc)
 
 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
                /*
-                * If the card has already switched to 1.8V signaling, then
-                * set the signal voltage to 1.8V.
+                * If voltage switch was skipped during ACMD41 but the card is
+                * already at 1.8V (retained from a previous session, e.g. warm
+                * reboot), re-configure the host to match.
                 */
-               if (mmc_sd_card_using_v18(mmc)) {
+               if (!(mmc->ocr & OCR_S18R) && mmc_sd_card_using_v18(mmc)) {
                        /*
                         * During a signal voltage level switch, the clock must 
be gated
                         * for 5 ms according to the SD spec.
-- 
2.43.7

Reply via email to