MdeModulePkg/SdMmc: Add break to avoid dead loop when polling OCR Reg

At worst case, OCR register may always not set BIT31. It will cause
original code enter to dead loop. Adding a break for such case.

Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
This commit is contained in:
Feng Tian
2017-03-13 11:20:41 +08:00
parent 1c3ac4b91e
commit ec86d28558
4 changed files with 36 additions and 3 deletions

View File

@@ -1109,6 +1109,7 @@ EmmcIdentification (
EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;
UINT32 Ocr;
UINT16 Rca;
UINTN Retry;
PciIo = Private->PciIo;
PassThru = &Private->PassThru;
@@ -1119,7 +1120,8 @@ EmmcIdentification (
return Status;
}
Ocr = 0;
Ocr = 0;
Retry = 0;
do {
Status = EmmcGetOcr (PassThru, Slot, &Ocr);
if (EFI_ERROR (Status)) {
@@ -1127,6 +1129,12 @@ EmmcIdentification (
return Status;
}
Ocr |= BIT30;
if (Retry++ == 100) {
DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd1 fails too many times\n"));
return EFI_DEVICE_ERROR;
}
gBS->Stall(10 * 1000);
} while ((Ocr & BIT31) == 0);
Status = EmmcGetAllCid (PassThru, Slot);