public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v4] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop
@ 2021-03-02  5:18 Bandaru, Purna Chandra Rao
  2021-03-02  6:03 ` Wu, Hao A
  0 siblings, 1 reply; 3+ messages in thread
From: Bandaru, Purna Chandra Rao @ 2021-03-02  5:18 UTC (permalink / raw)
  To: devel; +Cc: Purna Chandra Rao Bandaru, Mateusz Albecki, Ray Ni, Hao A Wu

https://bugzilla.tianocore.org/show_bug.cgi?id=3217

Current Ufs Pass thru driver polls for 5us and return success even when
the timeout occurs.
There are cards that can take upto 600ms for Init and hence increased
the time out for fDeviceInit polling loop.

Change-Id: I7b38e6f6aa46d93f07621caf29ad7c43f57df021
Signed-off-by: Bandaru <purna.chandra.rao.bandaru@intel.com>
Cc: Mateusz Albecki <mateusz.albecki@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 17 +++++++++++++----
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h |  3 ++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
index 9768c2e6fb..92ff958f16 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
   Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -749,7 +749,7 @@ UfsFinishDeviceInitialization (
 {
   EFI_STATUS  Status;
   UINT8  DeviceInitStatus;
-  UINT8  Timeout;
+  UINT32 Timeout;
 
   DeviceInitStatus = 0xFF;
 
@@ -761,7 +761,10 @@ UfsFinishDeviceInitialization (
     return Status;
   }
 
-  Timeout = 5;
+  //
+  // There are cards that can take upto 600ms to clear fDeviceInit flag.
+  //
+  Timeout = UFS_INIT_COMPLETION_TIMEOUT;
   do {
     Status = UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus);
     if (EFI_ERROR (Status)) {
@@ -771,7 +774,13 @@ UfsFinishDeviceInitialization (
     Timeout--;
   } while (DeviceInitStatus != 0 && Timeout != 0);
 
-  return EFI_SUCCESS;
+  if (Timeout == 0) {
+    DEBUG ((DEBUG_ERROR, "UfsFinishDeviceInitialization DeviceInitStatus=%x EFI_TIMEOUT \n", DeviceInitStatus));
+    return EFI_TIMEOUT;
+  } else {
+    DEBUG ((DEBUG_INFO, "UfsFinishDeviceInitialization Timeout left=%x EFI_SUCCESS \n", Timeout));
+    return EFI_SUCCESS;
+  }
 }
 
 /**
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
index ef33250c89..79b86f7e6b 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
   Copyright (c) Microsoft Corporation.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -40,6 +40,7 @@
 //
 #define UFS_MAX_LUNS                12
 #define UFS_WLUN_PREFIX             0xC1
+#define UFS_INIT_COMPLETION_TIMEOUT 600000
 
 typedef struct {
   UINT8    Lun[UFS_MAX_LUNS];
-- 
2.16.2.windows.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop
  2021-03-02  5:18 [PATCH v4] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Bandaru, Purna Chandra Rao
@ 2021-03-02  6:03 ` Wu, Hao A
  2021-03-05  8:45   ` [edk2-devel] " Wu, Hao A
  0 siblings, 1 reply; 3+ messages in thread
From: Wu, Hao A @ 2021-03-02  6:03 UTC (permalink / raw)
  To: Bandaru, Purna Chandra Rao, devel@edk2.groups.io
  Cc: Albecki, Mateusz, Ni, Ray

> -----Original Message-----
> From: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com>
> Sent: Tuesday, March 2, 2021 1:18 PM
> To: devel@edk2.groups.io
> Cc: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com>;
> Albecki, Mateusz <mateusz.albecki@intel.com>; Ni, Ray <ray.ni@intel.com>;
> Wu, Hao A <hao.a.wu@intel.com>
> Subject: [PATCH v4] MdeModulePkg/UfsPassThruDxe: Improve Device
> initialization polling Loop
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=3217
> 
> Current Ufs Pass thru driver polls for 5us and return success even when the
> timeout occurs.
> There are cards that can take upto 600ms for Init and hence increased the
> time out for fDeviceInit polling loop.
> 
> Change-Id: I7b38e6f6aa46d93f07621caf29ad7c43f57df021


Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

I will remove the above 'Change-Id' information when pushing the patch.
I will hold this patch until the edk2-stable202102 is announced.

Best Regards,
Hao Wu


> Signed-off-by: Bandaru <purna.chandra.rao.bandaru@intel.com>
> Cc: Mateusz Albecki <mateusz.albecki@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> ---
>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 17
> +++++++++++++----
> MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h |  3 ++-
>  2 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> index 9768c2e6fb..92ff958f16 100644
> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> @@ -1,6 +1,6 @@
>  /** @file
> 
> -  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2014 - 2021, Intel Corporation. All rights
> + reserved.<BR>
>    Copyright (c) Microsoft Corporation.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -749,7 +749,7 @@ UfsFinishDeviceInitialization (  {
>    EFI_STATUS  Status;
>    UINT8  DeviceInitStatus;
> -  UINT8  Timeout;
> +  UINT32 Timeout;
> 
>    DeviceInitStatus = 0xFF;
> 
> @@ -761,7 +761,10 @@ UfsFinishDeviceInitialization (
>      return Status;
>    }
> 
> -  Timeout = 5;
> +  //
> +  // There are cards that can take upto 600ms to clear fDeviceInit flag.
> +  //
> +  Timeout = UFS_INIT_COMPLETION_TIMEOUT;
>    do {
>      Status = UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus);
>      if (EFI_ERROR (Status)) {
> @@ -771,7 +774,13 @@ UfsFinishDeviceInitialization (
>      Timeout--;
>    } while (DeviceInitStatus != 0 && Timeout != 0);
> 
> -  return EFI_SUCCESS;
> +  if (Timeout == 0) {
> +    DEBUG ((DEBUG_ERROR, "UfsFinishDeviceInitialization
> DeviceInitStatus=%x EFI_TIMEOUT \n", DeviceInitStatus));
> +    return EFI_TIMEOUT;
> +  } else {
> +    DEBUG ((DEBUG_INFO, "UfsFinishDeviceInitialization Timeout left=%x
> EFI_SUCCESS \n", Timeout));
> +    return EFI_SUCCESS;
> +  }
>  }
> 
>  /**
> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> index ef33250c89..79b86f7e6b 100644
> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> @@ -1,6 +1,6 @@
>  /** @file
> 
> -  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2014 - 2021, Intel Corporation. All rights
> + reserved.<BR>
>    Copyright (c) Microsoft Corporation.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -40,6 +40,7 @@
>  //
>  #define UFS_MAX_LUNS                12
>  #define UFS_WLUN_PREFIX             0xC1
> +#define UFS_INIT_COMPLETION_TIMEOUT 600000
> 
>  typedef struct {
>    UINT8    Lun[UFS_MAX_LUNS];
> --
> 2.16.2.windows.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH v4] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop
  2021-03-02  6:03 ` Wu, Hao A
@ 2021-03-05  8:45   ` Wu, Hao A
  0 siblings, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2021-03-05  8:45 UTC (permalink / raw)
  To: devel@edk2.groups.io, Wu, Hao A, Bandaru, Purna Chandra Rao
  Cc: Albecki, Mateusz, Ni, Ray

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao
> A
> Sent: Tuesday, March 2, 2021 2:04 PM
> To: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com>;
> devel@edk2.groups.io
> Cc: Albecki, Mateusz <mateusz.albecki@intel.com>; Ni, Ray
> <ray.ni@intel.com>
> Subject: Re: [edk2-devel] [PATCH v4] MdeModulePkg/UfsPassThruDxe:
> Improve Device initialization polling Loop
> 
> > -----Original Message-----
> > From: Bandaru, Purna Chandra Rao
> <purna.chandra.rao.bandaru@intel.com>
> > Sent: Tuesday, March 2, 2021 1:18 PM
> > To: devel@edk2.groups.io
> > Cc: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com>;
> > Albecki, Mateusz <mateusz.albecki@intel.com>; Ni, Ray
> > <ray.ni@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> > Subject: [PATCH v4] MdeModulePkg/UfsPassThruDxe: Improve Device
> > initialization polling Loop
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=3217
> >
> > Current Ufs Pass thru driver polls for 5us and return success even
> > when the timeout occurs.
> > There are cards that can take upto 600ms for Init and hence increased
> > the time out for fDeviceInit polling loop.
> >
> > Change-Id: I7b38e6f6aa46d93f07621caf29ad7c43f57df021
> 
> 
> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
> 
> I will remove the above 'Change-Id' information when pushing the patch.
> I will hold this patch until the edk2-stable202102 is announced.


Pushed via commit:
https://github.com/tianocore/edk2/commit/c5740f360636479fb91681093b1dee1cc366075c

Best Regards,
Hao Wu


> 
> Best Regards,
> Hao Wu
> 
> 
> > Signed-off-by: Bandaru <purna.chandra.rao.bandaru@intel.com>
> > Cc: Mateusz Albecki <mateusz.albecki@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > ---
> >  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 17
> > +++++++++++++----
> > MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h |  3 ++-
> >  2 files changed, 15 insertions(+), 5 deletions(-)
> >
> > diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> > b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> > index 9768c2e6fb..92ff958f16 100644
> > --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> > +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
> > @@ -1,6 +1,6 @@
> >  /** @file
> >
> > -  Copyright (c) 2014 - 2019, Intel Corporation. All rights
> > reserved.<BR>
> > +  Copyright (c) 2014 - 2021, Intel Corporation. All rights
> > + reserved.<BR>
> >    Copyright (c) Microsoft Corporation.<BR>
> >    SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > @@ -749,7 +749,7 @@ UfsFinishDeviceInitialization (  {
> >    EFI_STATUS  Status;
> >    UINT8  DeviceInitStatus;
> > -  UINT8  Timeout;
> > +  UINT32 Timeout;
> >
> >    DeviceInitStatus = 0xFF;
> >
> > @@ -761,7 +761,10 @@ UfsFinishDeviceInitialization (
> >      return Status;
> >    }
> >
> > -  Timeout = 5;
> > +  //
> > +  // There are cards that can take upto 600ms to clear fDeviceInit flag.
> > +  //
> > +  Timeout = UFS_INIT_COMPLETION_TIMEOUT;
> >    do {
> >      Status = UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus);
> >      if (EFI_ERROR (Status)) {
> > @@ -771,7 +774,13 @@ UfsFinishDeviceInitialization (
> >      Timeout--;
> >    } while (DeviceInitStatus != 0 && Timeout != 0);
> >
> > -  return EFI_SUCCESS;
> > +  if (Timeout == 0) {
> > +    DEBUG ((DEBUG_ERROR, "UfsFinishDeviceInitialization
> > DeviceInitStatus=%x EFI_TIMEOUT \n", DeviceInitStatus));
> > +    return EFI_TIMEOUT;
> > +  } else {
> > +    DEBUG ((DEBUG_INFO, "UfsFinishDeviceInitialization Timeout
> > + left=%x
> > EFI_SUCCESS \n", Timeout));
> > +    return EFI_SUCCESS;
> > +  }
> >  }
> >
> >  /**
> > diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> > b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> > index ef33250c89..79b86f7e6b 100644
> > --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> > +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
> > @@ -1,6 +1,6 @@
> >  /** @file
> >
> > -  Copyright (c) 2014 - 2019, Intel Corporation. All rights
> > reserved.<BR>
> > +  Copyright (c) 2014 - 2021, Intel Corporation. All rights
> > + reserved.<BR>
> >    Copyright (c) Microsoft Corporation.<BR>
> >    SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > @@ -40,6 +40,7 @@
> >  //
> >  #define UFS_MAX_LUNS                12
> >  #define UFS_WLUN_PREFIX             0xC1
> > +#define UFS_INIT_COMPLETION_TIMEOUT 600000
> >
> >  typedef struct {
> >    UINT8    Lun[UFS_MAX_LUNS];
> > --
> > 2.16.2.windows.1
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-05  8:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-02  5:18 [PATCH v4] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Bandaru, Purna Chandra Rao
2021-03-02  6:03 ` Wu, Hao A
2021-03-05  8:45   ` [edk2-devel] " Wu, Hao A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox