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.web10.32156.1613983224476675378 for ; Mon, 22 Feb 2021 00:40:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=dEQjqcoP; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: hao.a.wu@intel.com) IronPort-SDR: GVt0ld65ObNWgcNFmg8BQqH9sx4HfmgLofYMOFnDbuUHEHr+hKl3PqC+sf6MatsFDTUN/XqBjJ qGNYwiKkBvLQ== X-IronPort-AV: E=McAfee;i="6000,8403,9902"; a="203766193" X-IronPort-AV: E=Sophos;i="5.81,196,1610438400"; d="scan'208";a="203766193" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 00:40:23 -0800 IronPort-SDR: eHzDiwE45d+mH6GWp7HRAYh6ng73KLpzSBlnoHjnoLafCMBCfB6SRLqncGewo4pc3QsrVsIn1a iczeBV7mR9RA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,196,1610438400"; d="scan'208";a="430053866" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by FMSMGA003.fm.intel.com with ESMTP; 22 Feb 2021 00:40:23 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX606.amr.corp.intel.com (10.22.229.19) 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 00:40:23 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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 00:40:22 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) 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 00:40:22 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.109) by edgegateway.intel.com (134.134.137.100) 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 00:39:53 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PKPfm1WTLVkRDxTdLSmboUWwPOq+2I4Xebs7EIN7sPHh3v7v/dtQ1aHF5S+Cd+atIFRNF0zDoowtEtsGL7SlkFZwX9hH7PrtCAVhSBuj7Q2evgm9EGFd4g3543lmzf8YoqRVLL9Ux8K83ANSgM5hmAk4N+wsCQ3/20U/KAZ/s1NUSImJdgL6WI5PsyV6LcitEvNDDoCxBcGUZCiz+LhTBg0b9SqZUALbC5h8m+m3oVWwm+ukHlreDss1CDV58CfgAbWGV4Pvt868dll9bNQeXCpUeW7lTMENzLilNxmwhdFrjnvHEL3d6v2oFM5IFmGVYVAG7ZTvBOAnhLqytqlhVg== 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=wQhZP7KjEoMfXVYfS0DSGwaqBuoZHXYyoQOA0p4MsM4=; b=X6lRbW9j9gGsGt5NEJ9FCK54PNBvVHFUNiKWPQL0UJwZ07ejIlzWopH4tywAg9T2cCIzNUfJY0a7FJ1oC/xPbiHRK9uC222SvQeHjKSmPSP0uMaj7LCZWnTIP504ojaMbiBVhsLr8t/IbO7azkQVhJTZ87DB8oaXOtG37XhfU4VAWjMDD+nMg4D31RwEFpObRKTW874T2eJ25dJCC1FDc1GZds23str/+y9T0bt2nquJn+jwglKffbvHABHwJI/50DB1YPMTXJYLMPfY5OACzwBmIXkExxcYxBV0xxyLbgkjp1MXk/epPETGPGl41H57Ss+c5bS7lYi4b7MxT4DUug== 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=wQhZP7KjEoMfXVYfS0DSGwaqBuoZHXYyoQOA0p4MsM4=; b=dEQjqcoPxoLlXaeYdAhg0Ro7dRroJ6JtNRhrMTvvdDEqKeCUPilOqcQ5LPETCoPAp37FHDHvTyZ6703f0jkP+WL+WjVaWgTN74BUQ/mE/KhZsMiCmR8NLw16lQ2pJwz4RzT3T73sxkevlZtuV5kW8Pi/IhMXbS5SnHX8m7C3RHc= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR11MB1953.namprd11.prod.outlook.com (2603:10b6:404:105::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.36; Mon, 22 Feb 2021 08:39:51 +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; Mon, 22 Feb 2021 08:39:51 +0000 From: "Wu, Hao A" 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 Thread-Topic: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Error handling of Ufs Pass Thru driver Thread-Index: AQHXBQuRLSwBS6euzEiT1FtH3mO6Vqpjs0AggAAu+GA= Date: Mon, 22 Feb 2021 08:39:51 +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: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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: c4bf1879-3d23-44cf-c277-08d8d70d6b95 x-ms-traffictypediagnostic: BN6PR11MB1953: 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: +AOtLZky1nmpbIeJq0qu3PgdFeFrzKkCRidWDW66FpQflVukPEfXMaxfNhggFyTnN3eg6dYr5tNdcUTiZFsYUgm0MfLmvUx0v50ogUzb261bcNno/+VMKGHYNW3bvKveymSBCcgK4FuYvNFwqfZHKqgdh3qErzeoQ9lRV3HfYb0K9MzTRJv12/pjVL6YVLA1n7ISLlbIQ9LyZ4e4AjnZHyhLYzr2oCY+CWdATPf0+tFS6JwAWizzUDvNssB/rGS0WPLMl4gTpZYML7wy15zEyyqC6N6YunN8nmlhCMzi23bnsv9eNkP/ugznIewYHiQ+AI15x7p51un4G3mGK4Ktuh0P7MG2jRsSTgoAQxZ3praNN3UVYG+cjzyYseyoFVwsRRKfXfwWF2mq5GxevcbBFoa2QE+gGIKbmq17QEBcgMej3ekeb7nsG20/FpVkNAwp2sEpG13WWyLw2gr6jl4ooO9rVFrbVuNqOvfDGhhuBoXQS4cv2PUi7D/Uc5emcTT4uT42Zhqfu4g3cCuzroeXmGHi3MFgJBlJORllHegavj66JF9b7jwfDnPdlDKxrIBY0ah96ZT/7fS1PuHWGoOFIRNyN7HpoaZO8RhJjx45Glc= 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:(396003)(39860400002)(346002)(366004)(136003)(376002)(66446008)(110136005)(86362001)(8676002)(54906003)(45080400002)(66476007)(76116006)(7696005)(53546011)(66946007)(9686003)(2906002)(5660300002)(66556008)(316002)(6636002)(83380400001)(71200400001)(478600001)(52536014)(6506007)(186003)(26005)(8936002)(33656002)(19627235002)(64756008)(4326008)(966005)(2940100002)(55016002)(107886003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?zS8jswhKYH5Vu601UkhQRq0+0/bXZhOtHg2BRvUkYLw3IaKfL4nbZ2AeJY5j?= =?us-ascii?Q?WiL/6O03pgKkuQ2ls3UIK8sl2xO8JC6xThlSEQWwlxvJSDKijekWTilIeAUD?= =?us-ascii?Q?VJVwg/mlqlbaJ3QIcpsfKb6Ux786MASCVqJYyRYznQDqDi0sx/qslnLNLDzL?= =?us-ascii?Q?R/In4sha3LFEbUHhpNJAjSLtIexYpNdKZLIDgaA/fAItZGGccAv1KS88iDLQ?= =?us-ascii?Q?7dYr71iaQUF5fdrsdroXeHkArauiYp35M44uriJerxo70nTJJG7ulMjtAs2R?= =?us-ascii?Q?QyMOJFv88NXzED6Br1miEhXli/9DJaoF4ugBAPJYMcCbfN56kDSUPj3rzZEw?= =?us-ascii?Q?GfNzSnA0RlMjjjr0HLdfVSOJzBmABA3Z/JUOQIXsvV1FjlImzY7HgWdr0AEr?= =?us-ascii?Q?sYK+H7RScUIez0oX/dDE40kEZKQtAIyAQIWOJuRvmUmkqM/XnhNdarSB7Z+H?= =?us-ascii?Q?PKEFU4xXlrKMLviUrHXfbITyuduaV2wrI9Z+aNJSZZXwBmm2oL5NoWuylRgp?= =?us-ascii?Q?lJxI8+SyKNzrTSK3owgXSH+bw1+FrMv9kF/L/pN3x/NXjo6ku0qqZJ2iUVjo?= =?us-ascii?Q?iJlUVXHXGlbcEvYgAOjdk99hjqE6FvHgoc105I/ao0Pt5kcvavTdtperYpEE?= =?us-ascii?Q?rFGN97X7VmJJbVqK2+3pcreXqS2K/A52HzEVUX2YOje1eBnBYPKWaTFIi/gO?= =?us-ascii?Q?LUcNx8aZusuD5DSEg9Xyp24FuqTF2eqrCwvou1o4MtPqac151Jn86unTQWxV?= =?us-ascii?Q?G0kFlviYEh8eaRTIXON/Q4BKKiLVxIQAXdqD/kxEMsbd2mN1Hn7Jv1HyTlYj?= =?us-ascii?Q?w54XySBL5xIV1UZKQM/qXs2pCa/lL6u0HPmY8xKv/6iEu/zYOVPFXn3bfmZ1?= =?us-ascii?Q?nPrAxqDzq/5MK/PavOl/Dv5PuhTsWF/JSlTU4ZdP2vJVMsQmDbSNR+FtfVAm?= =?us-ascii?Q?+TxPnZYVn41M72zy28S08ySaS+du8jBZW2Mehlo48+CqDiC55Y9HuBHNPxCf?= =?us-ascii?Q?fV552XdEwdU5KA8GVTA47eSA/RuBYLMP8lgbAlRKx0SMzIW7pafgiFm/I8GW?= =?us-ascii?Q?kLpvcU5ytGAIzhhCNLr+kEGDUq7lrO+cIWXiXqwa+Kx16ch0pawh44lfsPH6?= =?us-ascii?Q?SSQDfcaioySqFF2F9KCqo1sPOTpoGxdIFdoVCb4qZtxiV5yOsmIkZCVN7KvE?= =?us-ascii?Q?d1YdAeJhN4AJ5KoxJouQw7Dt3SV5TRtwDgCPfHkM4Rq17ZkcO7uJHoK0VPE/?= =?us-ascii?Q?MuSKT45p3rwWw7Ks6pUda0NJWwGa6sYwU0R+aBr1IILR85CadK5pO/8B6yNf?= =?us-ascii?Q?qUfSlkpek5wzUVaMWOj9szUM?= 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: c4bf1879-3d23-44cf-c277-08d8d70d6b95 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Feb 2021 08:39:51.1789 (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: z65WU9hedi5ZwBVjg0MrTLwTzV0/vhSr+y+BrTcCMf3sTM7zjpiDKqJLwy7Zt3T1HEXXB2l6NZftXCBDFeNApA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1953 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: 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 >=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 ; > > 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 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 re-enabl= ing > 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? 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 > > 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. >=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 fDeviceI= nit > 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 ori= gin > 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. >=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 > > + 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 both > > host and device side, > > // the host shall send a NOP OUT UPIU to verify that the device UTP > > Layer is ready. > > // >=20 >=20 > 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 li= ke > '10*UFS_TIMEOUT'?) Or the case is that NopInUpiu->Resp has a non-zero > value? >=20 > 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. >=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 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++) { >=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 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 > 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 > 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