From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web08.3708.1614042968308275132 for ; Mon, 22 Feb 2021 17:16:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=vsQ8Y39L; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: hao.a.wu@intel.com) IronPort-SDR: vPIKPc2iUHfInKseIWr7UK/vXGXcGMepzr/dCGY0rpcxB7I7MQijhWMfIClbzFM32JP2Ws5q6O UujSOUUfc30A== X-IronPort-AV: E=McAfee;i="6000,8403,9903"; a="269601424" X-IronPort-AV: E=Sophos;i="5.81,198,1610438400"; d="scan'208";a="269601424" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 17:16:07 -0800 IronPort-SDR: y/OAHnL9ZFq7mCGiklyZBVd+3mFxKKmnYxgov7WlkayLr+tTlbRF+2vMb6rFSn+yzkZU4nxbnq IIQ2offTgPcg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,198,1610438400"; d="scan'208";a="430467777" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by FMSMGA003.fm.intel.com with ESMTP; 22 Feb 2021 17:16:07 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 22 Feb 2021 17:16:06 -0800 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 22 Feb 2021 17:16:06 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Mon, 22 Feb 2021 17:16:06 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.106) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Mon, 22 Feb 2021 17:16:04 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NeEkrPX6aturFRQmR2gjmUBa6L5JuBInuPKi8jbtHcMg5N5HiJmhcrFyP655xf1SL534cszpMGPVd9No0L2Myj3F6P2VIdA9EZ1SV5z2cAobtiTiGSGQtS8HpLBWnbOLDLivj4jS4SmwyMHg3CeUrx7Z/pTKa5D8FvnIxuThNiSKeuR5o0J+19LCYdJZd3dmjpwafpOZWxkIxCRfiyhugDbfikf9eDLjRzmvjvzzOeC3Yj8FSHYcv2Su4D7rxUC71XhZG+ikCNqLTezVNKLvaoyechtEfzpLMeoaVlMqTaElYce81be6uLp8LWF6sWqySoTvPi3kdel+tC9CyXI9GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dpSOuMGz1BKlDHqIUoyUWzv6L9ch9VkWqsj/9KWlrIs=; b=D5LEODIo6ag0leEUQ3Xd9kEev5Rx+G6GMq0dRRgxueq0tIV4+Lro6+WePbdq3PG4NXJKfhZNT3AzixbUArj6jQuuUzbkRRz4PeplZij3pZ7cJAsjQiRVYhMm9ytAdKKL1TY2vlvV4GmdfkoiKUkyMnOayYs5PmyYXyXYbnLOn4mOhicxqM9KH2swKOS8kYS6r10meEBb3K8AORcg0OsCmm3djA48Pk9U930vtDcJBbTy+83JwGw3PzK4hQ4FeI3XmdO6dKZwFDQxFooXLn2eqyZo8ODpt3+tAVK+KhxkTEXTSAm/1WVPVgbjpJm1HVFWSLhC+PWjrAecnBWODGrgrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dpSOuMGz1BKlDHqIUoyUWzv6L9ch9VkWqsj/9KWlrIs=; b=vsQ8Y39LHitHWo+HDli+V7qFfUZi32/0mAKVxy4oApFH44GGtURPwinQX8vkM+UWyY9gFh4dpk0XyGljl9ENDTptDbLzd1a4ctPGh9ZjOyUnlQMcoloKV4OhTQTmAQ572niUE3qHXeJMiiZFTuTOuhgtc037zMxW9SZAGOr9ppc= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR11MB4082.namprd11.prod.outlook.com (2603:10b6:405:7d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.30; Tue, 23 Feb 2021 01:16:04 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::9d91:6348:53a9:cb20]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::9d91:6348:53a9:cb20%7]) with mapi id 15.20.3868.032; Tue, 23 Feb 2021 01:16:04 +0000 From: "Wu, Hao A" To: "Bandaru, Purna Chandra Rao" , "devel@edk2.groups.io" CC: "Albecki, Mateusz" , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver Thread-Topic: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver Thread-Index: AQHXBQuRLSwBS6euzEiT1FtH3mO6Vqpjs0AggAAu+GCAAI8NgIAAhV7w Date: Tue, 23 Feb 2021 01:16:03 +0000 Message-ID: References: <20210217090143.20032-1-purna.chandra.rao.bandaru@intel.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 036717f1-10f3-40cd-5441-08d8d79896f8 x-ms-traffictypediagnostic: BN6PR11MB4082: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: haBZC3qzuuNyjjDM1blIdZumtcuMI6AurAxR7JSwlTxryGK0q9N/bR87CFOBVGa/RN4kSPTqnzhhQn0tVhl+LCALIcgrQVhrOLbYEStqN3uJ0gOjlij4SsYZEE/QLCKLj72v32onN8lL2Uq80ZtPEpKph553GsWPnfd1ytJOuC0LA2i7rJuFcCqSOP9Eks8lAUkxI2i+5mrY0JXtoeJVDYfk/nqLOL6qZgXQc8l2A3smt4yXsFSvDbshV2MNohYXKK6ariL3PSB0XnGtDjXobsnWzb8GYvcsnmJZDED0iUZ7uaFLOyUy1QRUgHM3rcYSSy+JXw7OuXcWt9UIVzOr7yMlq/WWUL7RTdBtnCyitiIgiAUvKu+GnrLzuu4YMa/yN6VQTD3PIGLXjF3Fnk7ntoTg7A6GokFhHm+ZGJG43YD5jiVaw4h0Zy4Uxb6qxr9ZVE682CGJ1c2d0luWZO+gV/udXCllcOOpEVWDmaQjsLoX0fKzBGQI18fyQGQAHOfjgzxlY4e0a8IZeyBOayBeazknWOamDU4IXULqOQeesxo5xWsHpZJaZ1AZshjLe9sxWANxnuhwY5/5+vL/QPqBtEIjMm/Rv0An7CIQyW373C8= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(396003)(346002)(39860400002)(136003)(376002)(71200400001)(52536014)(186003)(45080400002)(7696005)(9686003)(5660300002)(4326008)(19627235002)(8676002)(6506007)(107886003)(66946007)(8936002)(33656002)(66476007)(26005)(64756008)(30864003)(86362001)(66446008)(66556008)(54906003)(83380400001)(2906002)(110136005)(316002)(55016002)(76116006)(53546011)(966005)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?2i/dRt40NYd8jQbOxTaA2DfyYdioi2MwLGzPOVgAvf3Oap/UPKK/zPoFhOcF?= =?us-ascii?Q?94IZsdtD+0knjKlLj0kCIKbQ3GwMHZVRAroMVKtdMGEd/ww8d1Ohhb5ZgfAa?= =?us-ascii?Q?JeEdGj9Xr61LA2sO+l/gCdNfmEZppLzIJOsGE8WjtCbZ1/SZ4mTh3Evsbuu+?= =?us-ascii?Q?23NlI3RbfEwJDB0N1mmHsOOluCq+6Q1rZFP1plhTI3FzLPd+yL69hwuga9mx?= =?us-ascii?Q?d+hF8f6W4hbIf6itgDaeggHYiuO5Gl482eJbnRhQb0l1polwhVXp3Vi6O8wZ?= =?us-ascii?Q?fO7aumiepK6HqAJu2cyWiwdz/hcW54BV0CoOqhVNb2IIkCWKace5qCkcxkma?= =?us-ascii?Q?0tThWgTgTRfWs22EPp9I5DcRxQmpsYCa9e2cCWZk7mqZs8ifI83xOb7woD+F?= =?us-ascii?Q?gw8E1ywTHtVaZ5LrVWZN63IKbYfo5ubFAtYoINLR9a6QPdsBAWQ7VxsybW3W?= =?us-ascii?Q?DMTIfpUwFvQTvuTtf9FfIUffvXjDRt+Kw+mrqoDMdVaqp1sdqABcTT4Raa0/?= =?us-ascii?Q?BKVpd6Z4wJ39ICGpQpCDCIbundqJFdQ/Innin2tAWw9UPOC83R2jNrG9JMWy?= =?us-ascii?Q?kJuiWnRgZ4/qKmpgrTRPbY7XoU9LN1RlhLqr8ic2SGwbPbZA+mau7TOeYTY3?= =?us-ascii?Q?nCT29QkXB0OXtnSDi5cMGcMPL8Qt1PrGacx+P5O+Q4MObU+XYTKVBuHuNKWV?= =?us-ascii?Q?N3HaeIxJttWXrQg4HssrihzRQcubMSZZOclqTqt1we+a7TpVREY8HoAvtM1f?= =?us-ascii?Q?MDMqCVQ+IXFp3x3q4PjDegwIketbr425YAqRcj5RfmFuApJKEwooDYewdGqj?= =?us-ascii?Q?OSV6WfPDC7tlIESmYvhz/yTZpy4HnYhLUaEZIO4+PUOoumX6hOy+F5pgTIST?= =?us-ascii?Q?PNCpNChkYSf0P3h/sPbxesNS90CJIEnG1/nwTPS0BezNhi6A7LyZZ/ugixsX?= =?us-ascii?Q?xsoXmAVeATfcm3T9/1tNYVqpPkh33i7OakfuClOQFXuMlCf67WmWrxFNQAqK?= =?us-ascii?Q?ido3yjG+jn6T8wu+d6gTgQ1+OqHsnI38EbbPfqSY//h/ROlN9PZ2vRuPLPF5?= =?us-ascii?Q?vCDr4tNcS4r5yOL78wjLF5F1cAm4AVazg4WhI0FlvLMD0XArY0g4H5BYj6hK?= =?us-ascii?Q?tOovs7XUx/sim+UuGzKiZZPxpGv4y7zaq1QeEmOURiom5nKblnzDZv3mKz6w?= =?us-ascii?Q?DcKy/TN+DhNqMY3aU2qqfLq9x+5OA6TMRBbXWQV3DKj0cVkkvR/XlSlXer6+?= =?us-ascii?Q?lcPlf7SOiU/ZApcwFeut2N6+Ab+89aa7TKSFkTIyEygHWxyUoMY9J+6rt+C6?= =?us-ascii?Q?Pb3AGKBas6hZWKe3bkqDHw16?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 036717f1-10f3-40cd-5441-08d8d79896f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 01:16:03.9813 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: C4C4Vw8nB1mdosWL8BslrK0GNvwSvPb6OgtGnNzaBLgIK1QqH/z4qEyJeQ9cOSRRWhraSi4XCu8HKa8Rl85mQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB4082 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Bandaru, Purna Chandra Rao > Sent: Tuesday, February 23, 2021 1:11 AM > To: Wu, Hao A ; devel@edk2.groups.io > Cc: Albecki, Mateusz ; Ni, Ray > > Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: > Improve Error handling of Ufs Pass Thru driver >=20 > Thank you Hai Bu for the response. >=20 > I have broken this into three separate patches. There were no specific > recommendation in the speciation for seen multiple issues on all the UFS > platforms like LKF, ADP-P and EHK. Hello, After quickly going through the new series sent, I do not see my previous inline comments and questions get addressed. Could you please help to provide your feedbacks and update the patches? > And these changes worked on all the three with various UFS cards. > Can you please review and help to get this changes at the earliest in ma= ster > as well as Downstream/master. Sorry, since there is an upcoming stable tag approaching, at this moment, = I prefer to hold this feature after the stable tag (March 6th). Best Regards, Hao Wu >=20 > Thanks > ~Purna >=20 > -----Original Message----- > From: Wu, Hao A > Sent: Monday, February 22, 2021 2:10 PM > To: devel@edk2.groups.io; Wu, Hao A ; Bandaru, > Purna Chandra Rao > Cc: Albecki, Mateusz ; Ni, Ray > > Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: > Improve Error handling of Ufs Pass Thru driver >=20 > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Wu, > Hao > > A > > Sent: Monday, February 22, 2021 4:38 PM > > To: Bandaru, Purna Chandra Rao ; > > devel@edk2.groups.io > > Cc: Albecki, Mateusz ; Ni, Ray > > > > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: > > Improve Error handling of Ufs Pass Thru driver > > > > > -----Original Message----- > > > From: Bandaru, Purna Chandra Rao > > > > > Sent: Wednesday, February 17, 2021 5:02 PM > > > To: devel@edk2.groups.io > > > Cc: Bandaru, Purna Chandra Rao > > > ; > > > Albecki, Mateusz ; Ni, Ray > > > ; Wu, Hao A > > > Subject: [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Error > handling > > > of Ufs Pass Thru driver > > > > > > 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 incr= ease > > > the time out for fDeviceInit polling loop. > > > 2) Add UFS host conctroller reset in the last retry of Link start u= p. > > > 3) Retry sending NOP OUT command upto 10 times > > > > > > Hello Bandaru, > > > > Could you help to break this patch into a 3-patch series in V2? > > With each patch handling just one of the above 3 improvements > mentioned. > > > > For improvement 2) above, I do not see such UFS host controller > > re-enabling process being mentioned in UFSHCI 3.0 spec section 7.1.1. > > Is this process being documented somewhere else in the spec or > > suggested by device vender? >=20 >=20 > Sorry for missing one comment. > Could you help to add the information on what kind of tests have been > performed for the code changes? >=20 > Thanks in advance. >=20 > Best Regards, > Hao Wu >=20 >=20 > > > > More inline comments below: > > > > > > > > > > Signed-off-by: Bandaru > > > Cc: Mateusz Albecki > > > Cc: Ray Ni > > > Cc: Hao A Wu > > > > > > 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/MdeModulePkg/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 > > > > > > - 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 =3D 0xFF; > > > > > > @@ -761,17 +761,23 @@ UfsFinishDeviceInitialization ( > > > return Status; > > > } > > > > > > - Timeout =3D 5; > > > + Timeout =3D 6000; //There are cards that can take upto 600ms. > > > > > > Please help to add a macro in file UfsPassThru.h: > > #define UFS_INIT_COMPLETION_TIMEOUT 6000 And use the macro here. > > > > Also a minor comment, could you help to use the below comment format? > > // > > // There are UFS devices that can take up to 600ms to clear the > > fDeviceInit flag // Timeout =3D UFS_INIT_COMPLETION_TIMEOUT; > > > > > > > do { > > > + MicroSecondDelay (100); //Give 100 us and then start polling. > > > > > > For the above delay movement, do you observe any side effect for the > > origin code? > > If not, I prefer to leave the origin behavior: > > do { > > UfsReadFlag(); > > ... > > MicroSecondDelay (1); > > } while (...) > > since doing so will have the least performance penalty for devices > > that respond fast. > > > > > > > Status =3D UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitSta= tus); > > > if (EFI_ERROR (Status)) { > > > return Status; > > > } > > > - MicroSecondDelay (1); > > > Timeout--; > > > } while (DeviceInitStatus !=3D 0 && Timeout !=3D 0); > > > > > > + 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 EFI_SUCCESS \n", Timeout)); > > > return EFI_SUCCESS; > > > > > > Please help to add two spaces for text alignment in the above line. > > > > > > > + } > > > } > > > > > > /** > > > @@ -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 Layer is ready. > > > // > > > > > > For the NOP OUT - NOP IN improvement, could you help to provide more > > information on what is the current issue for some devices? > > Is it a timeout happened for: > > Status =3D UfsWaitMemSet (Private, UFS_HC_UTRLDBR_OFFSET, BIT0 << > > Slot, 0, UFS_TIMEOUT); (If so, have you tried increasing the last > > parameter like > > '10*UFS_TIMEOUT'?) Or the case is that NopInUpiu->Resp has a non-zero > > value? > > > > I found that in the UFS 3.0 spec: > > |> For some implementations, the device UTP layer may not be > > |> initialized yet, therefore the device may not respond promptly to > > |> NOP OUT UPIU sending NOP IN UPIU. > > |> The host waits until it receives the NOP IN UPIU from the device... > > And there is no mention for the retry scheme. > > > > > > > + 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; > > > } > > > > > > diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c > > > b/MdeModulePkg/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. > > > > > > - 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 > > > > > > @@ -1929,17 +1929,15 @@ 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 =3D 0; Retry < 3; Retry++) { > > > + for (Retry =3D 0; Retry < 4; Retry++) { > > > > > > Please introduce a macro in file UfsPassThru.h: > > #define UFS_LINK_STARTUP_RETRIES 4 > > And use the macro here. > > > > Also, is it necessary to increase the retry number by 1? > > Or the device can be successfully brought up by adding a host > > controller re- enabling? > > > > > > > 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; > > > - } > > > > > > Will the DME_LINKSTARTUP command execution fail at first and then > > succeed after retry? > > If not, I prefer to keep the origin code logic to return error status = directly. > > > > > > > + if (!EFI_ERROR (Status)) { > > > > > > 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) { > > > > > > Please help to update to: > > if (Retry =3D=3D UFS_LINK_STARTUP_RETRIES - 1) { > > > > And add comments like: > > // > > // Try re-enabling the UFS host controller in the last retry attempt > > // > > > > > > Best Regards, > > Hao Wu > > > > > > > + Status =3D UfsEnableHostController (Private); > > > + if (EFI_ERROR (Status)) { > > > + DEBUG ((DEBUG_ERROR, "UfsDeviceDetection: Enable Host > > Controller > > > Fails, Status =3D %r\n", Status)); > > > + return Status; > > > + } > > > } > > > } > > > > > > -- > > > 2.16.2.windows.1 > > > > > > > >=20 > >