Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

//
Expand All @@ -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;
}
Expand Down
11 changes: 8 additions & 3 deletions MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1950,30 +1950,35 @@ 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;
LinkStartupCommand.Arg2 = 0;
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;
}
Expand Down
Loading