]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
MdeModulePkg: Replace with UFS_UNIT_DESC to fix timeout problem
[mirror_edk2.git] / MdeModulePkg / Bus / Ufs / UfsBlockIoPei / UfsBlockIoPei.c
index b331c0f3e34842297ec20af2941e4fbf730c0cba..b8651ff998465b5a336abaac67f894410f5ff1f7 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -1037,9 +1037,9 @@ InitializeUfsBlockIoPeim (
   UFS_PEIM_HC_PRIVATE_DATA       *Private;\r
   EDKII_UFS_HOST_CONTROLLER_PPI  *UfsHcPpi;\r
   UINT32                         Index;\r
-  UFS_CONFIG_DESC                Config;\r
   UINTN                          MmioBase;\r
   UINT8                          Controller;\r
+  UFS_UNIT_DESC                  UnitDescriptor;\r
 \r
   //\r
   // Shadow this PEIM to run from memory\r
@@ -1126,19 +1126,18 @@ InitializeUfsBlockIoPeim (
     }\r
 \r
     //\r
-    // Get Ufs Device's Lun Info by reading Configuration Descriptor.\r
+    // Check if 8 common luns are active and set corresponding bit mask.\r
     //\r
-    Status = UfsRwDeviceDesc (Private, TRUE, UfsConfigDesc, 0, 0, &Config, sizeof (UFS_CONFIG_DESC));\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status = %r\n", Status));\r
-      Controller++;\r
-      continue;\r
-    }\r
-\r
     for (Index = 0; Index < UFS_PEIM_MAX_LUNS; Index++) {\r
-      if (Config.UnitDescConfParams[Index].LunEn != 0) {\r
-        Private->Luns.BitMask |= (BIT0 << Index);\r
+      Status = UfsRwDeviceDesc (Private, TRUE, UfsUnitDesc, (UINT8)Index, 0, &UnitDescriptor, sizeof (UFS_UNIT_DESC));\r
+      if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_ERROR, "Fail to read UFS Unit Descriptor, Index = %X, Status = %r\n", Index, Status));\r
+        continue;\r
+      }\r
+\r
+      if (UnitDescriptor.LunEn == 0x1) {\r
         DEBUG ((DEBUG_INFO, "Ufs %d Lun %d is enabled\n", Controller, Index));\r
+        Private->Luns.BitMask |= (BIT0 << Index);\r
       }\r
     }\r
 \r