From: Purna Chandra Rao Bandaru <purna.chandra.rao.bandaru@intel.com>
To: devel@edk2.groups.io
Cc: Purna Chandra Rao Bandaru <purna.chandra.rao.bandaru@intel.com>,
Mateusz Albecki <mateusz.albecki@intel.com>,
Ray Ni <ray.ni@intel.com>, Hao A Wu <hao.a.wu@intel.com>
Subject: [PATCH 2/3] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver
Date: Mon, 22 Feb 2021 22:32:35 +0530 [thread overview]
Message-ID: <20210222170236.6312-2-purna.chandra.rao.bandaru@intel.com> (raw)
In-Reply-To: <20210222170236.6312-1-purna.chandra.rao.bandaru@intel.com>
https://bugzilla.tianocore.org/show_bug.cgi?id=3217
Add UFS host conctroller reset in the last retry of the Link start up
to allow scope for recovery of the Link.
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: Iecc87be51c557ec07890e2d700d6912ddf16adbd
---
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 45 +++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 0b1030ab47..e1416696d4 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -2,7 +2,7 @@
UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface
for upper layer application to execute UFS-supported SCSI cmds.
- 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
@@ -1929,37 +1929,42 @@ UfsDeviceDetection (
//
// Start UFS device detection.
- // Try up to 3 times for establishing data link with device.
+ // Try up to 4 times for establishing data link with device.
//
- for (Retry = 0; Retry < 3; Retry++) {
+ for (Retry = 0; Retry < 4; Retry++) {
LinkStartupCommand.Opcode = UfsUicDmeLinkStartup;
LinkStartupCommand.Arg1 = 0;
LinkStartupCommand.Arg2 = 0;
LinkStartupCommand.Arg3 = 0;
Status = UfsExecUicCommands (Private, &LinkStartupCommand);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- if ((Data & UFS_HC_HCS_DP) == 0) {
- Status = UfsWaitMemSet (Private, UFS_HC_IS_OFFSET, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT);
+ if (!EFI_ERROR (Status)) {
+ Status = UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- } else {
- if (mUfsHcPlatform != NULL && mUfsHcPlatform->Callback != NULL) {
- Status = mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostLinkStartup, &Private->UfsHcDriverInterface);
+
+ if ((Data & UFS_HC_HCS_DP) == 0) {
+ Status = UfsWaitMemSet (Private, UFS_HC_IS_OFFSET, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHcPostLinkStartup, Status = %r\n", Status));
- return Status;
+ return EFI_DEVICE_ERROR;
+ }
+ } else {
+ if (mUfsHcPlatform != NULL && mUfsHcPlatform->Callback != NULL) {
+ Status = mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostLinkStartup, &Private->UfsHcDriverInterface);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHcPostLinkStartup, Status = %r\n", Status));
+ return Status;
+ }
}
+ return EFI_SUCCESS;
+ }
+ }
+ if (Retry == 2) {
+ Status = UfsEnableHostController (Private);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "UfsDeviceDetection: Enable Host Controller Fails, Status = %r\n", Status));
+ return Status;
}
- return EFI_SUCCESS;
}
}
--
2.16.2.windows.1
next prev parent reply other threads:[~2021-02-22 17:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 17:02 [PATCH 1/3] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Purna Chandra Rao Bandaru
2021-02-22 17:02 ` Purna Chandra Rao Bandaru [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210222170236.6312-2-purna.chandra.rao.bandaru@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox