From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.37768.1614013377169342673 for ; Mon, 22 Feb 2021 09:02:57 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: purna.chandra.rao.bandaru@intel.com) IronPort-SDR: I0DCFPuBvoo6YFCfX+R+8+h8T2xfPnTOQwHZxVL9w8RqHisSHPQtDgF2/kmSG60jKmhCHtaaMO 0Pgjl/OCUISQ== X-IronPort-AV: E=McAfee;i="6000,8403,9903"; a="181072095" X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="181072095" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 09:02:45 -0800 IronPort-SDR: ldn6yu/AoaUv8v1oaczmRqiKM0hU2Xe4Dm0DsDPnJ70k/mjy/XyGBp+CgRoDfvTgLuhRrt1PdL +QPNLFNWemRA== X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="432152628" Received: from pbandaru-mobl1.gar.corp.intel.com ([10.213.95.147]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 09:02:43 -0800 From: Purna Chandra Rao Bandaru To: devel@edk2.groups.io Cc: Purna Chandra Rao Bandaru , Mateusz Albecki , Ray Ni , Hao A Wu Subject: [PATCH 1/3] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Date: Mon, 22 Feb 2021 22:32:34 +0530 Message-Id: <20210222170236.6312-1-purna.chandra.rao.bandaru@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Mateusz Albecki Cc: Ray Ni Cc: Hao A Wu 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.
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
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