]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
MdeModulePkg/SdMmc: Add break to avoid dead loop when polling OCR Reg
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / SdMmcPciHcDxe / EmmcDevice.c
index 9dbec1016d52a125b33eaedb0ac513ddd33d4caf..c5fd214307ff5658bd80b17115c32fe67167372d 100755 (executable)
@@ -1109,6 +1109,7 @@ EmmcIdentification (
   EFI_SD_MMC_PASS_THRU_PROTOCOL  *PassThru;\r
   UINT32                         Ocr;\r
   UINT16                         Rca;\r
+  UINTN                          Retry;\r
 \r
   PciIo    = Private->PciIo;\r
   PassThru = &Private->PassThru;\r
@@ -1119,7 +1120,8 @@ EmmcIdentification (
     return Status;\r
   }\r
 \r
-  Ocr = 0;\r
+  Ocr   = 0;\r
+  Retry = 0;\r
   do {\r
     Status = EmmcGetOcr (PassThru, Slot, &Ocr);\r
     if (EFI_ERROR (Status)) {\r
@@ -1127,6 +1129,12 @@ EmmcIdentification (
       return Status;\r
     }\r
     Ocr |= BIT30;\r
+\r
+    if (Retry++ == 100) {\r
+      DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd1 fails too many times\n"));\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+    gBS->Stall(10 * 1000);\r
   } while ((Ocr & BIT31) == 0);\r
 \r
   Status = EmmcGetAllCid (PassThru, Slot);\r