MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 17 +++++++++++++---- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-)
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 | 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..275351cf8e 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72119): https://edk2.groups.io/g/devel/message/72119
Mute This Topic: https://groups.io/mt/80864767/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
> -----Original Message----- > From: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com> > Sent: Tuesday, February 23, 2021 10:32 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] 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. > > 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 | 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..275351cf8e 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 I will help to remove the tailing space in the above line before pushing the patch. (Not sure if the tailing space is generated when I extract the patch from my mailing agent.) Anyway, Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Best Regards, Hao Wu > > typedef struct { > UINT8 Lun[UFS_MAX_LUNS]; > -- > 2.16.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#72121): https://edk2.groups.io/g/devel/message/72121 Mute This Topic: https://groups.io/mt/80864767/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.