From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web12.38163.1614013859796351907 for ; Mon, 22 Feb 2021 09:10:59 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=WANGX0s1; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: purna.chandra.rao.bandaru@intel.com) IronPort-SDR: QvpcNCi00YclNjem7rSIEun5K9kDETk7A27lL089O4q8zsNJZ43O7PE480KLSCMHNYtJ50E2wq UxWP49DhNyGA== X-IronPort-AV: E=McAfee;i="6000,8403,9903"; a="203921597" X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="203921597" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 09:10:58 -0800 IronPort-SDR: fpzZuaAaFS8dLVxEYpCQ56U36a8CUfcQcfN2svQB9U48sYHgXtfCk72ts7zF0IdEG4SMCVdNqh PEN7t7n362Qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="380086139" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga002.jf.intel.com with ESMTP; 22 Feb 2021 09:10:58 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx604.amr.corp.intel.com (10.18.126.84) 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 09:10:57 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 09:10:57 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 09:10:57 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.45) by edgegateway.intel.com (192.55.55.70) 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 09:10:56 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LaytdGgZoeBxvaGKR6+2lpRZqtaoklRRUnURyyWBNrh9+i9xnn0j8yKcm7t57rjjYh3e4VIMLngTbLLXvB3N6v7K/cF+8s5ho1plP7cU7Sg1xNjvEbmgxXtXQFX0kXMhv9qZqjDBCsjPaz7aQMYJ2ePkCvj+fvCys5QEKXc8psRi25jQbgYCvunV7adn2/JdJLPWDQT11bEuS55ugktAjzac5xBSyzw5vqNImViyu/KIUPwxyA6Tt39z4rziWMoXfkFgSnmIxQ1+OFOahtTZvy01VFPRZT+KhAfjNLUbtx9+yomDOBc7/YtsYsFsNsWu4OoCgObEazMTSsZ3UGvp5g== 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=RiK580h3x5m+5SanjEGKAWckACX5/XbsuBas95SoNGM=; b=nJao6QkOqaxVEsmcNcs/jBxkMJIp25COfP+/Y2yFySg6cDGJTFQI3Mi1Dmrmc6yuevSTEKOhnfdO2KDvPgOBX6lwjoqeSrnri3V/uBnrrElx4kosjPcqVPxuHnsLYKVhcqsDDplPo3PaJ+tkjqnNA8/OcLjsLXz6LHdeyszEED/qGapMjkMd91zBR4fNHzkYk+CIg6PGWBJxGc5gpXhxzxmrmeuf+t7Jq2z43/9e5+J5OwvGyyU7Mq2ywQcXHi2EoOAiAU6vh0ecRmQkMSND8ND5cFJPe2hN1VupWP9qOvJ60Qh9nHUmn/D08SAMD2jKNkNV93dNYFhXO1Rd/mcGTA== 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=RiK580h3x5m+5SanjEGKAWckACX5/XbsuBas95SoNGM=; b=WANGX0s1XCvU/hTpj/oIqgBNuGZuS063+3tIHTf5i9tJoqbUseIa8qPFh+7NRmADVXWVcTiNyXh1gs9HP4B+RwJ1VrpDKwDZfPZ+GNgRVbXnqs/vpS6lfUzaF77iYpi2FhHAMaMEs7ee5AdSOCrQIVfbR55YNcT3a01kiatSZCw= Received: from CO1PR11MB5171.namprd11.prod.outlook.com (2603:10b6:303:95::11) by MWHPR11MB1440.namprd11.prod.outlook.com (2603:10b6:301:7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.33; Mon, 22 Feb 2021 17:10:56 +0000 Received: from CO1PR11MB5171.namprd11.prod.outlook.com ([fe80::3076:f392:fb2:c728]) by CO1PR11MB5171.namprd11.prod.outlook.com ([fe80::3076:f392:fb2:c728%3]) with mapi id 15.20.3868.030; Mon, 22 Feb 2021 17:10:56 +0000 From: "Bandaru, Purna Chandra Rao" 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 Thread-Topic: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver Thread-Index: AQHXBQuR9lktG5ylfE6UQnPDDV38xKpj4gGAgAAAeYCAAIz+0A== Date: Mon, 22 Feb 2021 17:10:55 +0000 Message-ID: References: <20210217090143.20032-1-purna.chandra.rao.bandaru@intel.com> In-Reply-To: Accept-Language: en-IN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows 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: [106.200.197.239] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 14a0c0f7-c3b2-4086-27bb-08d8d754d13b x-ms-traffictypediagnostic: MWHPR11MB1440: 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: FoWonHiEMa5NCwuq/vwUQMT3YTtp6G/JxRHwG2hWqRkfZ/oHB/yyx758QcQCM9RhorAoCeSMIy1eLU9Pd4QlylfkT+/wqFQbpDFDl050rvtYqj6ecBA3PLB9xlS1tw6FgcdK45bbNw4MZSOWYE0UvNQBR1RN4UTyVtklKyqrKbWTRxovWGQcelcMqOlxOy1GXEx+ZzM7OzvyWGSKxZ76RcswZQ2aPHjZTxPMhnabA7jtCcw9aJtpXO7sg6k/aLBQoC5cvbxmAHCo0QFfXI3MS9oR1fZRpeJRQAivT+ZnsLeNOIzrXgMfv+mDxAGAuLbl7VnV4ehJPLMAyQa1+AIeoRZxvFiH0kSCollJwQ2Hhwl5fXCvILvobV1s+opIchUkV4skzuJefhpfi1Jnn/bYVQlqo+ZfrcPZ543OmJAzPXBNxfkmS11dYC3ml4H1nx+Rg4vwHurc4yp2RuYViq33AOVOPoo8it8vU+myr0v7EIPTvIKtmSi7TBlCGMA2MGHXDp88f82cb6PHAeG3MPLxk0bDfk8NPM/HN7HMBas4162yFf6cUcvlD5Zl7VL0pWO7Pzs9G/5Kn7OpQNEMtFTKAD8XbqRglMzmIEyDkB0H0HQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB5171.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(366004)(396003)(376002)(39860400002)(136003)(55016002)(54906003)(186003)(71200400001)(66476007)(33656002)(76116006)(66946007)(110136005)(66556008)(26005)(64756008)(66446008)(316002)(53546011)(6506007)(52536014)(8936002)(7696005)(2906002)(83380400001)(8676002)(5660300002)(45080400002)(107886003)(86362001)(9686003)(478600001)(4326008)(966005)(19627235002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?Qe4VCApzmb8RWUZC2x9/zqIFquG8rwnLQeUqmXeJ2hPaFsVgH9MXlsgSQTZy?= =?us-ascii?Q?aZMB5mXW6hVydwJVjeF3025Wm9u8BH6zshdx3B0u1f17GJ8mtOoGL8S8EvG+?= =?us-ascii?Q?Hx4dfzTjw8NfQWpC7bpTlKd50lvuoy3H8i9AmD3O0pQuvCP8mgagoCq6bR1n?= =?us-ascii?Q?ydY2pJTMMC1a6QEnLx+FyFHUED/2kQL91ljAGhSE9dYIBnKQf/20Eoq3Gi1e?= =?us-ascii?Q?BzzSKdLCQVxLSifgTAtxH7CQZWf3PC3TJ6gF4minNbNO9r0nMNE2T8e24SyH?= =?us-ascii?Q?NtRIXRErTl4ygbS2SeRZ7wih8jAYyLAQu4rAfN1hMc7V6GxhP423GUG7IU+t?= =?us-ascii?Q?rsxWqsyGm15yK13ckJwb1EZky4aJhhCWGo/Zr1ekjFnUBtHweg2+oiZKhoDb?= =?us-ascii?Q?/aXNeHzvpb7hves4aChz+4sveEwaA+vuRQDFPNd3+WZH7Z9y1YWfTuMODnp9?= =?us-ascii?Q?7a28Az466/MVhikPNXQYh7CsF3vzDS6SApH0AJCAoY20WONgoem2ejNgFOoU?= =?us-ascii?Q?7ZRXqiouSuSUyppprdK0EUntIxt0C+tYiDnI5o5jpXBnxuIOxH8J+exS9Lo1?= =?us-ascii?Q?iHgzpE5eGeKd+1icnnNtkzADs+3HIJCsetEvIlaDnMP8eVwamyRLabsyS6Io?= =?us-ascii?Q?fD+ARkLUQCypGXqznIl89ZJA7Hu5k5mme32/4vKeQ+xFctvDNIohxhXO1Ew3?= =?us-ascii?Q?xwlCMh7EpglWOKQ2gsSNbU1bejYFRHaBK7psA9ti8z2POsa5oLNvJpzsqDqB?= =?us-ascii?Q?WQTlp1jiR8hgWhmLuM5BF+B/6iN7eQz1dSmcoZNZGIjHTt8xPWhjSsyMPdc1?= =?us-ascii?Q?yH6jU3G6lfOjXuskxqNTGCdQrBRuU3slpczvZ6UpeFPI/6OafgEdfGgCqqqP?= =?us-ascii?Q?boYdfh8Iye+6JoY7JIOF8jdvWFDCv1xrs/xYvbyuVoB9rNhgGeVrRcJYoshf?= =?us-ascii?Q?y6B+mno5iIvQg6VYFtFiSq0mAHkGnmPDlKHzmFBiEjtGvKqSyo5r4HAjoCM1?= =?us-ascii?Q?WL7xi9wch8BhdfEUbxPyAH6xO9P2aV4po55Q1Qo/mO1TZ8CWo3fQPFZNHGs3?= =?us-ascii?Q?dVieEHOZe8C1bRXN+DXhgCQ+TvvTB2Y5z5zDawdB9MbHIID7zWh2vLtpRbZm?= =?us-ascii?Q?P7fCr/Tl4gmuYRI3eXScC9nyHPmEkVgPGsWjgIcxFTGc2m/pOu1ucXqJbme+?= =?us-ascii?Q?7Aj/A7jhPHaN+zgYYyWD7onpmfOaLgBQFh1sQazZOaYQlhqiqNU0QPQVEuff?= =?us-ascii?Q?NZ34mB5kVTMDLxhS6u41PF3fNP6dFkSC9Xd7RM+FytWBBL9hToYYRf8Y1yF9?= =?us-ascii?Q?nTv3geuCgmvfVfay4i/f9mU+?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5171.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14a0c0f7-c3b2-4086-27bb-08d8d754d13b X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Feb 2021 17:10:55.9369 (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: ifGbF9DEp/zK+GxXy11duk6aJvMdbSyqiADgv63YB1pjAQhwlIFsHhmKsPZP8TtZzSa2hzJ9+NkP0nVFJjtZ+iM3CoTKOU4R2XNuHgwuwnmC729/4VLZmcfcWkXekGO2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1440 Return-Path: purna.chandra.rao.bandaru@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thank you Hai Bu for the response. I have broken this into three separate patches. There were no specific rec= ommendation in the speciation for seen multiple issues on all the UFS platf= orms like LKF, ADP-P and EHK. 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 mast= er as well as Downstream/master. Thanks=20 ~Purna -----Original Message----- From: Wu, Hao A =20 Sent: Monday, February 22, 2021 2:10 PM To: devel@edk2.groups.io; Wu, Hao A ; Bandaru, Purna C= handra Rao Cc: Albecki, Mateusz ; Ni, Ray Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Err= or handling of Ufs Pass Thru driver > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wu, Hao= =20 > A > Sent: Monday, February 22, 2021 4:38 PM > To: Bandaru, Purna Chandra Rao ; > devel@edk2.groups.io > Cc: Albecki, Mateusz ; Ni, Ray=20 > > Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: > Improve Error handling of Ufs Pass Thru driver >=20 > > -----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=20 > > ; > > Albecki, Mateusz ; Ni, Ray=20 > > ; Wu, Hao A > > Subject: [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Error handling= =20 > > 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 increa= se > > 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 >=20 >=20 > Hello Bandaru, >=20 > 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. >=20 > For improvement 2) above, I do not see such UFS host controller=20 > 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=20 > suggested by device vender? Sorry for missing one comment. Could you help to add the information on what kind of tests have been perf= ormed for the code changes? Thanks in advance. Best Regards, Hao Wu >=20 > More inline comments below: >=20 >=20 > > > > 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=20 > > reserved.
> > + Copyright (c) 2014 - 2021, Intel Corporation. All rights=20 > > + 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. >=20 >=20 > Please help to add a macro in file UfsPassThru.h: > #define UFS_INIT_COMPLETION_TIMEOUT 6000 And use the macro here. >=20 > 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=20 > fDeviceInit flag // Timeout =3D UFS_INIT_COMPLETION_TIMEOUT; >=20 >=20 > > do { > > + MicroSecondDelay (100); //Give 100 us and then start polling. >=20 >=20 > For the above delay movement, do you observe any side effect for the=20 > 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=20 > that respond fast. >=20 >=20 > > Status =3D UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatu= s); > > 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=20 > > + left=3D%x EFI_SUCCESS \n", Timeout)); > > return EFI_SUCCESS; >=20 >=20 > Please help to add two spaces for text alignment in the above line. >=20 >=20 > > + } > > } > > > > /** > > @@ -905,9 +911,19 @@ UfsPassThruDriverBindingStart ( > > // At the end of the UFS Interconnect Layer initialization on=20 > > both host and device side, > > // the host shall send a NOP OUT UPIU to verify that the device=20 > > UTP Layer is ready. > > // >=20 >=20 > For the NOP OUT - NOP IN improvement, could you help to provide more=20 > 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 <<=20 > Slot, 0, UFS_TIMEOUT); (If so, have you tried increasing the last=20 > parameter like > '10*UFS_TIMEOUT'?) Or the case is that NopInUpiu->Resp has a non-zero=20 > value? >=20 > I found that in the UFS 3.0 spec: > |> For some implementations, the device UTP layer may not be=20 > |> initialized yet, therefore the device may not respond promptly to=20 > |> 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. >=20 >=20 > > + 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=20 > > + received > > NOP IN, Status =3D %r\n", Status)); > > + break; > > + } > > + } > > + if (!Index) { > > + DEBUG ((DEBUG_INFO, "NOP OUT failed all the 10 times Status =3D= =20 > > + %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=20 > > protocol interface > > for upper layer application to execute UFS-supported SCSI cmds. > > > > - Copyright (c) 2014 - 2019, Intel Corporation. All rights=20 > > reserved.
> > + Copyright (c) 2014 - 2021, Intel Corporation. All rights=20 > > + 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++) { >=20 >=20 > Please introduce a macro in file UfsPassThru.h: > #define UFS_LINK_STARTUP_RETRIES 4 > And use the macro here. >=20 > Also, is it necessary to increase the retry number by 1? > Or the device can be successfully brought up by adding a host=20 > controller re- enabling? >=20 >=20 > > 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; > > - } >=20 >=20 > Will the DME_LINKSTARTUP command execution fail at first and then=20 > succeed after retry? > If not, I prefer to keep the origin code logic to return error status di= rectly. >=20 >=20 > > + 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) { >=20 >=20 > Please help to update to: > if (Retry =3D=3D UFS_LINK_STARTUP_RETRIES - 1) { >=20 > And add comments like: > // > // Try re-enabling the UFS host controller in the last retry attempt=20 > // >=20 >=20 > Best Regards, > Hao Wu >=20 >=20 > > + 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 >=20 >=20 >=20 >=20