]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c
MdeModulePkg/SdMmc: Add break to avoid dead loop when polling OCR Reg
[mirror_edk2.git] / MdeModulePkg / Bus / Sd / EmmcBlockIoPei / EmmcHci.c
index 2c0baca3e34ef9de54505f87ca7c1ff3e1141a0c..7c40892da063ae6b66300e54f1d148d077eb3978 100644 (file)
@@ -2827,6 +2827,7 @@ EmmcPeimIdentification (
   EFI_STATUS                     Status;\r
   UINT32                         Ocr;\r
   UINT32                         Rca;\r
+  UINTN                          Retry;\r
 \r
   Status = EmmcPeimReset (Slot);\r
   if (EFI_ERROR (Status)) {\r
@@ -2834,13 +2835,20 @@ EmmcPeimIdentification (
     return Status;\r
   }\r
 \r
-  Ocr = 0;\r
+  Ocr   = 0;\r
+  Retry = 0;\r
   do {\r
     Status = EmmcPeimGetOcr (Slot, &Ocr);\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "EmmcPeimIdentification: EmmcPeimGetOcr fails with %r\n", Status));\r
       return Status;\r
     }\r
+\r
+    if (Retry++ == 100) {\r
+      DEBUG ((EFI_D_ERROR, "EmmcPeimIdentification: EmmcPeimGetOcr fails too many times\n"));\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+    MicroSecondDelay (10 * 1000);\r
   } while ((Ocr & BIT31) == 0);\r
 \r
   Status = EmmcPeimGetAllCid (Slot);\r