diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c index f1f69d09f48..dce26fa7ded 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -1552,10 +1552,12 @@ UfsDeviceDetection ( // Start UFS device detection. // Try up to 3 times for establishing data link with device. // + // MU_CHANGE [BEGIN] - Fix UFS device detection retry logic for (Retry = 0; Retry < 3; Retry++) { Status = UfsExecUicCommands (Private, UfsUicDmeLinkStartup, 0, 0, 0); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "[%a] UfsExecUicCommands failed with Status=%r\n", __func__, Status)); + continue; } // @@ -1567,13 +1569,15 @@ UfsDeviceDetection ( Address = Private->UfsHcBase + UFS_HC_IS_OFFSET; Status = UfsWaitMemSet (Address, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "[%a] UfsWaitMemSet failed with Status=%r\n", __func__, Status)); + continue; } } else { DEBUG ((DEBUG_INFO, "UfsblockioPei: found a attached UFS device\n")); return EFI_SUCCESS; } } + // MU_CHANGE [END] - Fix UFS device detection retry logic return EFI_NOT_FOUND; } diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 820b089cb57..6fe16a413cc 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -1950,6 +1950,7 @@ UfsDeviceDetection ( // Start UFS device detection. // Try up to 3 times for establishing data link with device. // + // MU_CHANGE [BEGIN] - Fix UFS device detection retry logic for (Retry = 0; Retry < 3; Retry++) { LinkStartupCommand.Opcode = UfsUicDmeLinkStartup; LinkStartupCommand.Arg1 = 0; @@ -1957,23 +1958,27 @@ UfsDeviceDetection ( LinkStartupCommand.Arg3 = 0; Status = UfsExecUicCommands (Private, &LinkStartupCommand); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "[%a] UfsExecUicCommands failed with Status=%r\n", __func__, Status)); + continue; } Status = UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "[%a] UfsMmioRead32 failed with Status=%r\n", __func__, Status)); + continue; } if ((Data & UFS_HC_HCS_DP) == 0) { Status = UfsWaitMemSet (Private, UFS_HC_IS_OFFSET, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "[%a] UfsWaitMemSet failed with Status=%r\n", __func__, Status)); + continue; } } else { return EFI_SUCCESS; } } + // MU_CHANGE [END] - Fix UFS device detection retry logic return EFI_NOT_FOUND; }