public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/3] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop
@ 2021-02-22 17:02 Purna Chandra Rao Bandaru
  2021-02-22 17:02 ` [PATCH 2/3] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver Purna Chandra Rao Bandaru
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Purna Chandra Rao Bandaru @ 2021-02-22 17:02 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.

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>

Change-Id: I6cb063b43bdf37790db8e60c3919153cd2f3c086
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
index 9768c2e6fb..8859578af3 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;
+  UINT16 Timeout;
 
   DeviceInitStatus = 0xFF;
 
@@ -761,17 +761,23 @@ UfsFinishDeviceInitialization (
     return Status;
   }
 
-  Timeout = 5;
+  Timeout = 6000; //There are cards that can take upto 600ms.
   do {
+    MicroSecondDelay (100); //Give 100 us and then start polling.
     Status = UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus);
     if (EFI_ERROR (Status)) {
       return Status;
     }
-    MicroSecondDelay (1);
     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;
+  }
 }
 
 /**
-- 
2.16.2.windows.1


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

end of thread, other threads:[~2021-02-24  4:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-22 17:02 [PATCH 1/3] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Purna Chandra Rao Bandaru
2021-02-22 17:02 ` [PATCH 2/3] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver Purna Chandra Rao Bandaru
2021-02-22 17:02 ` [PATCH 3/3] MdeModulePkg/UfsPassThruDxe: Improve UFS device Readiness check Purna Chandra Rao Bandaru
2021-02-23 17:50 ` [edk2-devel] [PATCH 1/3] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Laszlo Ersek
2021-02-24  4:16   ` purna.chandra.rao.bandaru

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