[edk2-devel] [PATCH] MdeModulePkg: Replace with UfsUnitDesc to fix response timeout problem.

VincentX Ke posted 1 patch 2 years, 4 months ago
Failed in applying to current master (apply log)
.../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c     | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
[edk2-devel] [PATCH] MdeModulePkg: Replace with UfsUnitDesc to fix response timeout problem.
Posted by VincentX Ke 2 years, 4 months ago
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3714

Replace with UFS_UNIT_DESC to fix response timeout 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>
---
 .../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c     | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
index b331c0f3e3..3a55348cac 100644
--- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
@@ -1037,9 +1037,10 @@ InitializeUfsBlockIoPeim (
   UFS_PEIM_HC_PRIVATE_DATA       *Private;
   EDKII_UFS_HOST_CONTROLLER_PPI  *UfsHcPpi;
   UINT32                         Index;
-  UFS_CONFIG_DESC                Config;
   UINTN                          MmioBase;
   UINT8                          Controller;
+  UFS_UNIT_DESC                  UnitDescriptor;
+  UINT32                         UnitDescriptorSize;
 
   //
   // Shadow this PEIM to run from memory
@@ -1126,19 +1127,18 @@ InitializeUfsBlockIoPeim (
     }
 
     //
-    // Get Ufs Device's Lun Info by reading Configuration Descriptor.
+    // Check if 8 common luns are active and set corresponding bit mask.
     //
-    Status = UfsRwDeviceDesc (Private, TRUE, UfsConfigDesc, 0, 0, &Config, sizeof (UFS_CONFIG_DESC));
-    if (EFI_ERROR (Status)) {
-      DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status = %r\n", Status));
-      Controller++;
-      continue;
-    }
-
-    for (Index = 0; Index < UFS_PEIM_MAX_LUNS; Index++) {
-      if (Config.UnitDescConfParams[Index].LunEn != 0) {
+    UnitDescriptorSize = sizeof (UFS_UNIT_DESC);
+    for (Index = 0; Index < 8; Index++) {
+      Status = UfsRwDeviceDesc (Private, TRUE, UfsUnitDesc, (UINT8) Index, 0, &UnitDescriptor, UnitDescriptorSize);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "Failed to read unit descriptor, index = %X, status = %r\n", Index, Status));
+        continue;
+      }
+      if (UnitDescriptor.LunEn == 0x1) {
+        DEBUG ((DEBUG_INFO, "UFS LUN %X is enabled\n", Index));
         Private->Luns.BitMask |= (BIT0 << Index);
-        DEBUG ((DEBUG_INFO, "Ufs %d Lun %d is enabled\n", Controller, Index));
       }
     }
 
-- 
2.18.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84795): https://edk2.groups.io/g/devel/message/84795
Mute This Topic: https://groups.io/mt/87716515/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] MdeModulePkg: Replace with UfsUnitDesc to fix response timeout problem.
Posted by Wu, Hao A 2 years, 4 months ago
Thanks for the patch.
Generally, the change is good to me. A couple of minor inline comments below:


> -----Original Message-----
> From: Ke, VincentX <vincentx.ke@intel.com>
> Sent: Tuesday, December 14, 2021 2:50 PM
> To: devel@edk2.groups.io
> Cc: Ke, VincentX <vincentx.ke@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; Chiu, Ian
> <Ian.chiu@intel.com>; Chu, Maggie <maggie.chu@intel.com>
> Subject: [PATCH] MdeModulePkg: Replace with UfsUnitDesc to fix response
> timeout problem.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3714
> 
> Replace with UFS_UNIT_DESC to fix response timeout 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>
> ---
>  .../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c     | 24 +++++++++----------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
> b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
> index b331c0f3e3..3a55348cac 100644
> --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
> +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
> @@ -1037,9 +1037,10 @@ InitializeUfsBlockIoPeim (
>    UFS_PEIM_HC_PRIVATE_DATA       *Private;
>    EDKII_UFS_HOST_CONTROLLER_PPI  *UfsHcPpi;
>    UINT32                         Index;
> -  UFS_CONFIG_DESC                Config;
>    UINTN                          MmioBase;
>    UINT8                          Controller;
> +  UFS_UNIT_DESC                  UnitDescriptor;
> +  UINT32                         UnitDescriptorSize;
> 
>    //
>    // Shadow this PEIM to run from memory @@ -1126,19 +1127,18 @@
> InitializeUfsBlockIoPeim (
>      }
> 
>      //
> -    // Get Ufs Device's Lun Info by reading Configuration Descriptor.
> +    // Check if 8 common luns are active and set corresponding bit mask.
>      //
> -    Status = UfsRwDeviceDesc (Private, TRUE, UfsConfigDesc, 0, 0, &Config,
> sizeof (UFS_CONFIG_DESC));
> -    if (EFI_ERROR (Status)) {
> -      DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status
> = %r\n", Status));
> -      Controller++;
> -      continue;
> -    }
> -
> -    for (Index = 0; Index < UFS_PEIM_MAX_LUNS; Index++) {
> -      if (Config.UnitDescConfParams[Index].LunEn != 0) {
> +    UnitDescriptorSize = sizeof (UFS_UNIT_DESC);
> +    for (Index = 0; Index < 8; Index++) {


Please help to use the macro "UFS_PEIM_MAX_LUNS" instead of using hardcode value "8" in the above line.


> +      Status = UfsRwDeviceDesc (Private, TRUE, UfsUnitDesc, (UINT8) Index, 0,
> &UnitDescriptor, UnitDescriptorSize);


I think you can directly use "sizeof (UFS_UNIT_DESC)" in the above line and not introducing the local variable "UnitDescriptorSize".


> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "Failed to read unit descriptor, index = %X,


Failed to read unit descriptor -> Fail to read UFS Unit Descriptor


> status = %r\n", Index, Status));
> +        continue;
> +      }
> +      if (UnitDescriptor.LunEn == 0x1) {
> +        DEBUG ((DEBUG_INFO, "UFS LUN %X is enabled\n", Index));


Please help to keep the controller index information in the above debug message as before.

Best Regards,
Hao Wu


>          Private->Luns.BitMask |= (BIT0 << Index);
> -        DEBUG ((DEBUG_INFO, "Ufs %d Lun %d is enabled\n", Controller,
> Index));
>        }
>      }
> 
> --
> 2.18.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84797): https://edk2.groups.io/g/devel/message/84797
Mute This Topic: https://groups.io/mt/87716515/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-