]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Put off UFS HCS.DP checking to fix timing problem
authorKe, VincentX <vincentx.ke@intel.com>
Thu, 23 Dec 2021 07:07:54 +0000 (15:07 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 4 Jan 2022 02:23:14 +0000 (02:23 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3776

Put off UFS HCS.DP (Device Attached) checking
until UfsDeviceDetection() to fix timing problem.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ian Chiu <Ian.chiu@intel.com>
Cc: Maggie Chu <maggie.chu@intel.com>
Signed-off-by: VincentX Ke <vincentx.ke@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c

index 409ea283f5131316b6541596641c11ad9cac28a7..d19a7fed6eb6d8ad2126a972ecd7b65c1e725da5 100644 (file)
@@ -1355,23 +1355,6 @@ UfsExecUicCommands (
     }\r
   }\r
 \r
-  //\r
-  // Check value of HCS.DP and make sure that there is a device attached to the Link.\r
-  //\r
-  Address = UfsHcBase + UFS_HC_STATUS_OFFSET;\r
-  Data    = MmioRead32 (Address);\r
-  if ((Data & UFS_HC_HCS_DP) == 0) {\r
-    Address = UfsHcBase + UFS_HC_IS_OFFSET;\r
-    Status  = UfsWaitMemSet (Address, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  DEBUG ((DEBUG_INFO, "UfsblockioPei: found a attached UFS device\n"));\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1445,6 +1428,8 @@ UfsDeviceDetection (
   )\r
 {\r
   UINTN       Retry;\r
+  UINTN       Address;\r
+  UINT32      Data;\r
   EFI_STATUS  Status;\r
 \r
   //\r
@@ -1453,22 +1438,28 @@ UfsDeviceDetection (
   //\r
   for (Retry = 0; Retry < 3; Retry++) {\r
     Status = UfsExecUicCommands (Private, UfsUicDmeLinkStartup, 0, 0, 0);\r
-    if (!EFI_ERROR (Status)) {\r
-      break;\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_DEVICE_ERROR;\r
     }\r
 \r
-    if (Status == EFI_NOT_FOUND) {\r
-      continue;\r
+    //\r
+    // Check value of HCS.DP and make sure that there is a device attached to the Link\r
+    //\r
+    Address = Private->UfsHcBase + UFS_HC_STATUS_OFFSET;\r
+    Data    = MmioRead32 (Address);\r
+    if ((Data & UFS_HC_HCS_DP) == 0) {\r
+      Address = Private->UfsHcBase + UFS_HC_IS_OFFSET;\r
+      Status  = UfsWaitMemSet (Address, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT);\r
+      if (EFI_ERROR (Status)) {\r
+        return EFI_DEVICE_ERROR;\r
+      }\r
+    } else {\r
+      DEBUG ((DEBUG_INFO, "UfsblockioPei: found a attached UFS device\n"));\r
+      return EFI_SUCCESS;\r
     }\r
-\r
-    return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  if (Retry == 3) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
+  return EFI_NOT_FOUND;\r
 }\r
 \r
 /**\r