From nobody Sat May 4 18:26:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+71609+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+71609+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1613058494; cv=none; d=zohomail.com; s=zohoarc; b=YrBpGyWNFmYHgzmNgYVBnH8hr/KgRzyMkYwYNa2YzFfonKDER3QwtsWD3ZD4kDH3Wb5Gnu0FZO8SAvrKsHTRELfQ3Vtm9Ew3hLfRnx0zZz+RayalgsBKMwxCwKA7FdkXyTsKWgkPMQKh8egMn6MTIcfaeXtpiSxk7O/SK0UVhsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613058494; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=rFhw0D9lWFXeWz96JxbW5pUoCud7K/AvS36nd29HQWU=; b=DCah1HbPsqlwhRsHUuwygT+rIOTUP/aEt+auuSWJA/ZPXL5dX6uvhxgoC76wn7V2aDFURaBXH7P64h28m138GTaE0bR50NI5CRkWLVtc3QdlrE9bI3fLf7tdsTX8NN857+x2XDsQ1H4u/wTs8kLXzQsjAI/L3auRPZ8IPUPuy3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+71609+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1613058493856994.2008487298071; Thu, 11 Feb 2021 07:48:13 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 02UgYY1788612xkmyPqwrVl7; Thu, 11 Feb 2021 07:48:13 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.8159.1613048436906490549 for ; Thu, 11 Feb 2021 05:00:36 -0800 IronPort-SDR: RtIyf5Tw+5wopch2aPQGs0JBAsynjxLQm15eJAkauhvGanGbczPemKQdmZxdX0mGbO4u+0OpPU TOgZXkIyKY3A== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="161378466" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="161378466" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 05:00:16 -0800 IronPort-SDR: eiZZBJNXIAI/lM4QibR7D0tiOeKCP80S+N1V75xJNP6/0B76wABV28mSHNpaE+ZoZy020mRX2+ 9h+UtYClu3FQ== X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="362496541" X-Received: from pbandaru-mobl1.gar.corp.intel.com ([10.215.134.96]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 05:00:14 -0800 From: Purna Chandra Rao Bandaru To: devel@edk2.groups.io Cc: Bandaru Subject: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver Date: Thu, 11 Feb 2021 18:29:34 +0530 Message-Id: <20210211125934.11024-1-purna.chandra.rao.bandaru@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,purna.chandra.rao.bandaru@intel.com X-Gm-Message-State: MBkpGQKy0JerArgisAiQYwywx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1613058493; bh=g+8StC2LRM4zeRmVKIk6gBm8f975hp1E5Id1bzOSoxI=; h=Cc:Date:From:Reply-To:Subject:To; b=VyxxC1hnG6mhkYpiVH7OlsLl8XcthhOm6QPzojuUr/ZIRzBCPZ8E1w0HaERY+FCam6M Mf/yNzYZQxHj1gAJL/OfFSNuOSCkI1/jr1Ao+P/xbWRt10khaG+yOAelRJb22nywNumGO PfOIXcy0MsZEAjN6C2563rxgrDrYKBZkMTY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Bandaru https://bugzilla.tianocore.org/show_bug.cgi?id=3D3217 Following is the brief description of the changes 1) There are cards that can take upto 600ms for Init and hence increase the time out for fDeviceInit polling loop. 2) Add UFS host conctroller reset in the last retry of Link start up. 3) Retry sending NOP OUT command upto 10 times Signed-off-by: Bandaru Change-Id: I6c0dbc1c147487e51f0ed5f2425957ae089b0160 --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 26 ++++++++++++++++= +++++----- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 18 ++++++++++++----= -- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 9768c2e6fb..89048745be 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -1,6 +1,6 @@ /** @file =20 - 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 =20 @@ -749,7 +749,7 @@ UfsFinishDeviceInitialization ( { EFI_STATUS Status; UINT8 DeviceInitStatus; - UINT8 Timeout; + UINT16 Timeout; =20 DeviceInitStatus =3D 0xFF; =20 @@ -761,17 +761,23 @@ UfsFinishDeviceInitialization ( return Status; } =20 - Timeout =3D 5; + Timeout =3D 6000; //There are cards that can take upto 600ms. do { + MicroSecondDelay (100); //Give 100 us and then start polling. Status =3D UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus); if (EFI_ERROR (Status)) { return Status; } - MicroSecondDelay (1); Timeout--; } while (DeviceInitStatus !=3D 0 && Timeout !=3D 0); =20 + if (Timeout =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "UfsFinishDeviceInitialization DeviceInitStatus= =3D%x EFI_TIMEOUT \n", DeviceInitStatus)); + return EFI_TIMEOUT; + } else { + DEBUG ((DEBUG_INFO, "UfsFinishDeviceInitialization Timeout left=3D%x E= FI_SUCCESS \n", Timeout)); return EFI_SUCCESS; + } } =20 /** @@ -905,9 +911,19 @@ UfsPassThruDriverBindingStart ( // At the end of the UFS Interconnect Layer initialization on both host = and device side, // the host shall send a NOP OUT UPIU to verify that the device UTP Laye= r is ready. // + for (Index =3D 10; Index > 0; Index--) { Status =3D UfsExecNopCmds (Private); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Ufs Sending NOP IN command Error, Status =3D %r\= n", Status)); + DEBUG ((DEBUG_ERROR, "Ufs Sending NOP IN command Error, Index =3D %x= Status =3D %r\n", Index, Status)); + MicroSecondDelay (100); //100 us + continue; + } else { + DEBUG ((DEBUG_INFO, "Ufs Sent NOP OUT successfully and received NOP = IN, Status =3D %r\n", Status)); + break; + } + } + if (!Index) { + DEBUG ((DEBUG_INFO, "NOP OUT failed all the 10 times Status =3D %r\n",= Status)); goto Error; } =20 diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 0b1030ab47..4fa5689196 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. =20 - 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 =20 @@ -1929,17 +1929,15 @@ UfsDeviceDetection ( =20 // // 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 =3D 0; Retry < 3; Retry++) { + for (Retry =3D 0; Retry < 4; Retry++) { LinkStartupCommand.Opcode =3D UfsUicDmeLinkStartup; LinkStartupCommand.Arg1 =3D 0; LinkStartupCommand.Arg2 =3D 0; LinkStartupCommand.Arg3 =3D 0; Status =3D UfsExecUicCommands (Private, &LinkStartupCommand); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; - } + if (!EFI_ERROR (Status)) { =20 Status =3D UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data); if (EFI_ERROR (Status)) { @@ -1960,6 +1958,14 @@ UfsDeviceDetection ( } } return EFI_SUCCESS; + } + } + if (Retry =3D=3D 2) { + Status =3D UfsEnableHostController (Private); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "UfsDeviceDetection: Enable Host Controller F= ails, Status =3D %r\n", Status)); + return Status; + } } } =20 --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#71609): https://edk2.groups.io/g/devel/message/71609 Mute This Topic: https://groups.io/mt/80560328/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-