From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.10492.1614090953816451698 for ; Tue, 23 Feb 2021 06:35:53 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=kg7PGKNq; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: purna.chandra.rao.bandaru@intel.com) IronPort-SDR: +Ofn+hvZUx7ys1/0eOk/aaE2M1SsBArCezjA/+eFg9rOioPBFbO+oSUhkUxwyvIOgRrHTUVtEr KhRGSjbjwkTg== X-IronPort-AV: E=McAfee;i="6000,8403,9903"; a="182336038" X-IronPort-AV: E=Sophos;i="5.81,200,1610438400"; d="scan'208";a="182336038" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2021 06:35:52 -0800 IronPort-SDR: Ct8j+5y5JF0oLPpRhE4ONcOaxuaKT6Y4hhu7yXUbqp4j9o0Ztje4Fus1Cd+1NYkgVNmevg9rdH OkIoYIpUv8yA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,200,1610438400"; d="scan'208";a="390911812" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga008.fm.intel.com with ESMTP; 23 Feb 2021 06:35:52 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 23 Feb 2021 06:35:52 -0800 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 23 Feb 2021 06:35:51 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Tue, 23 Feb 2021 06:35:51 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.100) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Tue, 23 Feb 2021 06:35:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YnTJZ945ITi7NYuHa160XkwWuIh5JQmsRxJ5UCaSdhSuhOXqRXT08tGiqAx4TFPtdclEWZEOU11r9w7B6F9AwvGebpdbw8SvkvJQpwlRyyyjXdMGpn7kXTNdGw9wAZaSHx0MOLzhqpWOEpWkIhP8vyeMafMSS0JigqjUWEAGe/soTrzd4HAB2CdQj73lcyCCu/NO8aY0Tm+nvpCl9N3mbOIAlw5jtPQnOiED7AqCso5oC+S4kS7oqpW8lGb3d7tjks33NOHeFljsLB0HKM8g8yPeTwonNvaEEGzUNyN6zf4RNHyUdRTU1tfzFeYa6eK2AGuCHWNiuBhSqHUFp7Q1XA== 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=MS3Dk0/WsVZ9QAx6eDQFOAdb33B86Gro72r1fTj1AvY=; b=PslT5Q03OUF2mODpvoE/UsJ6Hq1hAqUGdJr+hH5NF9pcgoCT5RZVOHyd3Pb2gam3PGgUGsBKAEQsURzziR1lt8Pvr4bopDCTG7PZeRyvFMTWAm0JMV+gv8ZOyU1DqfvC3H6cl5mH5Ae3xjTXiwQ4jvB+x5oQ7Rgj35ppoQ5F/Xc13euTN6bZTlow7FnvhTbZ5iRb9OJCLNvMnp7cvOqGOw/JCbCgenKfGqXbic4kSo7sMtmWEI9tbqmZ/Vq9VURQfC7tbSe1eezm62yueX0LoUiPJ7Icxzzn/WOUstjKE/tuRzyvmkjvQzzlN5DojTh92ZyovDuP/XSU1QNcst+lOw== 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=MS3Dk0/WsVZ9QAx6eDQFOAdb33B86Gro72r1fTj1AvY=; b=kg7PGKNq/HEcciHH3Sw7HJ9SloVrSdht+1B9ffFyoY+4qTOiNrpYOEgWbUkghRVg3gIsQHxnJDfpicNFsepWK1gTH08TzqjB3LVP2K/8nKvB5S11AI3s8i9n0/tAljfBJzMWQI0BlSb4avBuN9Q4hNC4Atf85T+SF6KLBwLFBiQ= Received: from CO1PR11MB5171.namprd11.prod.outlook.com (2603:10b6:303:95::11) by MWHPR11MB1854.namprd11.prod.outlook.com (2603:10b6:300:10c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.31; Tue, 23 Feb 2021 14:35:47 +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.033; Tue, 23 Feb 2021 14:35:47 +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+0IAAiViAgAC7YpA= Date: Tue, 23 Feb 2021 14:35:47 +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: yes 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: ed2f831c-c293-420a-5a6e-08d8d8084f98 x-ms-traffictypediagnostic: MWHPR11MB1854: 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: C4YPlesOWOP5HTEhhKGpZ6PyJY4tZ6Ygma9+rlGuKlTVDuZa3WdTEH+iHtU6ovDG6i1P6BpX8Kpzt3ccj30g2G6hi2nZb9/Chb9Ulxj5fI2vJPQgI1DRNopoRYw5QpDMstzrap8WXQ5I3pdNqdS7Q203YQZfZezw6H0YYD5RgIJnaSxNwM9/TNQ1Lhu7vEYD8vGQDjSHvY+A/iGZ0mBpYWUZeSuLqNvk5wK5cED1FJS19YRgtSKp8tR+lwF2F5K3XX7HFIDH4qciQsTRJ5ZQgA0Nucd14vDEh0w75gJqiSiHW/oef6Kg/RSzRnhJXQlXA0UpVNQrpNV7esRMLO35hdb0HYiK82LqhyEu+FzTLww2m5CZEM86OMLhftWos9mMV0pmWsa9jGc3j/TcJyNxO2ERzKGu9R8Q9F/zh6X8/0OYFOCFgGUtybANqg+qgdxOXK4FaIp3itus8S6FA0M6OfhhU1VyDtqa8z0CQwS1FviBs19J8Z3nC3h53dUG1KfEAnGWc8t0irdDnTa7Kr2DsMAxOYT49ryzXbegEhTL4sxVf2+HbpITwCoAiGLigzlSRHKJhlYhQQ91Jp/ED+e+EaDqoXaV+Y+nJgSP6TZ5vlo= 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:(39860400002)(376002)(396003)(346002)(366004)(136003)(316002)(186003)(66556008)(66616009)(110136005)(66446008)(5660300002)(8936002)(6506007)(99936003)(86362001)(54906003)(64756008)(966005)(76116006)(66946007)(66476007)(33656002)(478600001)(2906002)(4326008)(30864003)(7696005)(19627235002)(52536014)(9686003)(53546011)(83380400001)(107886003)(45080400002)(8676002)(26005)(55016002)(71200400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?OVfjgixba9cNX4vTPEvessK17mmyZimkONxwn2c18OI4B6RJJpexlReKCWed?= =?us-ascii?Q?ySG30lmRxRPyhEyXnFbCYTDIV1yYsERLmYX0lesDhU1j23dQ5BgIUC5IOTiu?= =?us-ascii?Q?unObjiKN1qzV1R3f6wbMun1Z0dJ2mKoqGxrXJcYflZsh+AmIACBodoZ8rH+j?= =?us-ascii?Q?pfL7Gu5tSC9K4DAIHowJc4ZcWmhzUfn6ftedbKPziSsXlwFky5i9uePofIw+?= =?us-ascii?Q?SgwxXXRKkHsXVNuwV7x+nRWansZLZvR9dcd2TADlsY4vrlO6mZ4pVdRbG4Cw?= =?us-ascii?Q?xF+4k1a6R/BIZjwmOn2P31pndlYZo+lUQhl0Qjwwpiq4hLpOcFPYbhi9nsxR?= =?us-ascii?Q?42cQC8B6bKc3RNOWvBESO0nIcCHf9Rasb3G20hBxYvJlYH5ygLLkcZk+21vv?= =?us-ascii?Q?hkTyeegk9MunaRc87ZHKxY+W0zPKcrunNOendcM8S8l6E03xHI25uv3UELs6?= =?us-ascii?Q?73rfVf3xW7iFJG649jbeLSv17lpufapGxLlHvdyKM/5Vzk771Hi0QY2RWaV6?= =?us-ascii?Q?sbtvqDYrkQ4Rbc+FvspbnO35oKqaDIJaTjpOtl85WEnX74IAsfuKWy0I/WJj?= =?us-ascii?Q?LQqfEdyEDVITsi5K/bzJFeabfHjxDMBPHYQ0TpnQhlawGBwW/+CutHa1S0aS?= =?us-ascii?Q?FOjgdRAiCOmsXvNschF5urfjlLiO+7DjyuFfzJMgOkUKMRZKIrtuo2Af2C2b?= =?us-ascii?Q?HI6q7cKNLs5/2D2Xk3H4zpfDRtJOW7evmDfGr5LW7pLqq8WfQ8J3YenuoV9U?= =?us-ascii?Q?PF2srPB+hDTlDEBdHKqbZF/8N2XghjYeFug+aQAIm/dcHFFIBXMSMyqsT77T?= =?us-ascii?Q?vVaz9F/ZgLlWINyzkfRiCHMPcR6w8PLUXg75M+9IBI1oIFwY/XOesHGpnWgf?= =?us-ascii?Q?kCgbFXlBYpFn/vqRlFo4pkpxGouLT7xB6lIfrUuNmCOnsXhBpxOnYOq8g9Nj?= =?us-ascii?Q?IPnxQW3s0ywaRhagA3D93dxhdcW3d9EESyomTW5cBgHMa7F+X5Y1ib5AUAD0?= =?us-ascii?Q?34GBUQfBgmAvfa8qhNUYx6IVHiEss6KKbsLAi9oy4MRwwHg+p9taoG57RdRf?= =?us-ascii?Q?AuXoHeC9AtlIqC6n0IjlRp5xxclw4geVfzDi/mjW0gqDaPD04M4mk027zNE2?= =?us-ascii?Q?635NuvPE2WQd85+GQPqk4EdGktmHEVP6xfkFu//NxZrtLiD0PIZLy/sRpnEY?= =?us-ascii?Q?MrP1dV71Z1s2dxaL5CAmLyvDV/70eO/ARBwe8hKi9OB3JKAceuE18mzpWiMY?= =?us-ascii?Q?I2nmd3ZiP+0rB6srkvqYZCebqvCc8udrmA2p6MxW24twnVmf4sZ4/79KyI6o?= =?us-ascii?Q?b1RSNJnDppFm5GD29UO34r93?= 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: ed2f831c-c293-420a-5a6e-08d8d8084f98 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 14:35:47.8602 (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: z9h4W2zanIxy4PlZvd1FYQWb+MevPja+w2TAkDlcc56gE8KWaD7S5ipjiApiuAargatX3JifmARcZhhuuSM0S6QAEoYPjgzOnljyxsn0uw7bVZ6SaVEHG671+/pVew60 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1854 Return-Path: purna.chandra.rao.bandaru@intel.com X-OriginatorOrg: intel.com X-Groupsio-MsgNum: 72120 Content-Language: en-US Content-Type: multipart/mixed; boundary="_002_CO1PR11MB51712B30907FB3540E36711AF9809CO1PR11MB5171namp_" --_002_CO1PR11MB51712B30907FB3540E36711AF9809CO1PR11MB5171namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Wu, Hao A I am trying to focus on merging patch#1 for now to unblock boot issues. Ma= rch 6th might be too late, May I request you to expedite any other alternat= ives like exceptions/overrides? For the remaining two patches I will get back to you with the plan after d= iscussing with WSIV and MVE teams on the protocol analyzer tools etc.=20 Thanks=20 ~Purna -----Original Message----- From: Wu, Hao A =20 Sent: Tuesday, February 23, 2021 6:46 AM To: Bandaru, Purna Chandra Rao ; deve= l@edk2.groups.io Cc: Albecki, Mateusz ; Ni, Ray Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Err= or handling of Ufs Pass Thru driver > -----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=20 > > 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= =20 > recommendation in the speciation for seen multiple issues on all the=20 > 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=20 > master 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,=20 > Purna Chandra Rao > 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: devel@edk2.groups.io On Behalf Of Wu, > Hao > > A > > Sent: Monday, February 22, 2021 4:38 PM > > To: Bandaru, Purna Chandra Rao=20 > > ; > > 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 > > > > > -----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=20 > > > ; 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=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? >=20 >=20 > Sorry for missing one comment. > Could you help to add the information on what kind of tests have been=20 > 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=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. > > > > > > 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=20 > > 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= =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. > > > > > > > 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=20 > > > + 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=20 > > > both host and device side, > > > // the host shall send a NOP OUT UPIU to verify that the device= =20 > > > UTP Layer is ready. > > > // > > > > > > 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=20 > > non-zero value? > > > > 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. > > > > > > > + 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++) { > > > > > > 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=20 > > 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=20 > > 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= =20 > > // > > > > > > 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 > > --_002_CO1PR11MB51712B30907FB3540E36711AF9809CO1PR11MB5171namp_ Content-Type: message/rfc822 Content-Disposition: attachment; creation-date="Tue, 23 Feb 2021 14:35:44 GMT"; modification-date="Tue, 23 Feb 2021 14:35:44 GMT" Received: from BYAPR11MB2743.namprd11.prod.outlook.com (2603:10b6:a02:c7::33) by CO1PR11MB5171.namprd11.prod.outlook.com with HTTPS; Tue, 23 Feb 2021 14:32:46 +0000 Received: from BL0PR1501CA0015.namprd15.prod.outlook.com (2603:10b6:207:17::28) by BYAPR11MB2743.namprd11.prod.outlook.com (2603:10b6:a02:c7::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27; Tue, 23 Feb 2021 14:32:45 +0000 Received: from BL2NAM02FT062.eop-nam02.prod.protection.outlook.com (2603:10b6:207:17:cafe::35) by BL0PR1501CA0015.outlook.office365.com (2603:10b6:207:17::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Tue, 23 Feb 2021 14:32:45 +0000 Received: from edgegateway.intel.com (192.55.55.68) by BL2NAM02FT062.mail.protection.outlook.com (10.152.77.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Tue, 23 Feb 2021 14:32:45 +0000 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by edgegateway.intel.com (10.1.192.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 23 Feb 2021 06:32:29 -0800 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 23 Feb 2021 06:32:28 -0800 Received: from orsmga008.jf.intel.com (10.7.209.65) by fmsmsx606.amr.corp.intel.com (10.18.84.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Tue, 23 Feb 2021 06:32:28 -0800 Received: from pbandaru-mobl1.gar.corp.intel.com ([10.213.97.20]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2021 06:32:25 -0800 From: "Bandaru, Purna Chandra Rao" To: "devel@edk2.groups.io" CC: "Bandaru, Purna Chandra Rao" , "Albecki, Mateusz" , "Ni, Ray" , "Wu, Hao A" Subject: [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Thread-Topic: [PATCH] MdeModulePkg/UfsPassThruDxe: Improve Device initialization polling Loop Thread-Index: AQHXCfDBfDeN04sYYUagdEvcj/LaxQ== Date: Tue, 23 Feb 2021 14:32:15 +0000 Message-ID: <20210223143215.26752-1-purna.chandra.rao.bandaru@intel.com> Content-Language: en-IN X-MS-Exchange-Organization-AuthMechanism: 10 X-MS-Exchange-Organization-AuthSource: fmsmsx606.amr.corp.intel.com X-MS-Has-Attach: X-MS-Exchange-Organization-Network-Message-Id: 4dfeea90-d39e-4c5e-3090-08d8d807e2d5 X-MS-TNEF-Correlator: X-MS-Exchange-Organization-RecordReviewCfmType: 0 x-ironport-av: E=Sophos;i="5.81,200,1610438400"; d="scan'208";a="403187696" x-ms-exchange-organization-originalclientipaddress: 10.7.209.65 x-ms-exchange-organization-originalserveripaddress: 10.152.77.57 received-spf: Fail (protection.outlook.com: domain of intel.com does not designate 192.55.55.68 as permitted sender) receiver=protection.outlook.com; client-ip=192.55.55.68; helo=edgegateway.intel.com; x-ms-publictraffictype: Email x-ms-exchange-organization-submissionquotaskipped: False authentication-results: spf=fail (sender IP is 192.55.55.68) smtp.mailfrom=intel.com; intel.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;intel.mail.onmicrosoft.com; dmarc=fail action=none header.from=intel.com; x-forefront-antispam-report: CIP:192.55.55.68;CTRY:US;LANG:en;SCL:-1;SRV:;IPV:NLI;SFV:SKI;H:edgegateway.intel.com;PTR:edgegateway.intel.com;CAT:NONE;SFS:;DIR:INB; x-ms-office365-filtering-correlation-id: 4dfeea90-d39e-4c5e-3090-08d8d807e2d5 x-ms-traffictypediagnostic: BYAPR11MB2743: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-microsoft-antispam: BCL:0; x-ms-exchange-crosstenant-originalarrivaltime: 23 Feb 2021 14:32:45.2999 (UTC) x-ms-exchange-crosstenant-network-message-id: 4dfeea90-d39e-4c5e-3090-08d8d807e2d5 x-ms-exchange-crosstenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d x-ms-exchange-crosstenant-fromentityheader: HybridOnPrem x-ms-exchange-transport-crosstenantheadersstamped: BYAPR11MB2743 x-ms-exchange-transport-endtoendlatency: 00:00:01.1831851 x-ms-exchange-processed-by-bccfoldering: 15.20.3868.033 x-originatororg: intel.onmicrosoft.com x-ms-exchange-crosstenant-originalattributedtenantconnectingip: TenantId=46c98d88-e344-4ed4-8496-4ed7712e255d;Ip=[192.55.55.68];Helo=[edgegateway.intel.com] x-eopattributedmessage: 0 x-organizationheaderspreserved: fmsmsx601.amr.corp.intel.com x-crosspremisesheaderspromoted: BL2NAM02FT062.eop-nam02.prod.protection.outlook.com x-crosspremisesheadersfiltered: BL2NAM02FT062.eop-nam02.prod.protection.outlook.com ironport-sdr: 1I5ljH8p5k+S7Tcil2KEq25Zj4AGUX4Zg/c2CH7AuVevnimOv/xcWRY0MHI8wdLOka7SQ6jhwD OARhvQEWTs0w== x-ms-exchange-crosstenant-authsource: fmsmsx606.amr.corp.intel.com x-ms-exchange-crosstenant-authas: Internal X-Microsoft-Antispam-Mailbox-Delivery: ucf:1;jmr:0;auth:0;dest:C;OFR:CustomRules;ENG:(750129)(520011016)(706158)(944506458)(944626604); X-Microsoft-Antispam-Message-Info: mhYnyahHvfwhpRcxbcJ1m6T+gtC7/8hYmxBGWG0O25Iidkz80TbcSZJaFCi/CJik0SHFMyjJMlQm9CA/uSMYSF/n07RV/Qbu1FmEa8Puxrb1tjncZysfkG2nLl2DWUP45r2fwBqBkhiTVprjv3kHY7wIpZqnmL4aZpXQw51+x2vgrEhzG4WTpgGyNdTFMaf6t9c0kcGqHaY8vNCIiCFltLckHafBNfcerx957cqYU+1W6pa4hc5KgmSKyvfxQKhxIcyxdQ8dQqdkg9yNvj6EqB8OyAbd//jPYqKjFTx5gpLV6uJ2yBro8HsGvzqklxCExTFDJp2jkZ4zZUUaoK7+3JvFBYRp0dGoY+Xrdh5T0j9Oqkz/iBxFyT9uqGuOubj7VCdtkLUabbSA2VdJLnfA4g5dPCyIVA9e4ps+6ogW5xZCH0qf7dsq4T8XSRmw/xZ7l3qAMsT4LASeskn/FRpo8LHw8S/oxAU3hx+IS5L50ali/8/o/ard4Ll8Qj1e+I0H7HBZcxrdpvw9U7Y8LqrSALd7pOWauxBq356nUe95j66MiWGtSGOLLj42Uz0FTIjd8tdZPpq4r7jyCsz80e8f4BQAwbuQkeddjnKbzCLe6o5/vjt7nmjeqPKCE3+0W4LSnydrGyx36A13PzxrCQNuxSHh0dB9sGpIetFlVnTH5ck= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 https://bugzilla.tianocore.org/show_bug.cgi?id=3D3217 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 | 17 +++++++++++++---- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 9768c2e6fb..92ff958f16 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; + UINT32 Timeout; DeviceInitStatus =3D 0xFF; @@ -761,7 +761,10 @@ UfsFinishDeviceInitialization ( return Status; } - Timeout =3D 5; + // + // There are cards that can take upto 600ms to clear fDeviceInit flag. + // + Timeout =3D UFS_INIT_COMPLETION_TIMEOUT; do { Status =3D UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus); if (EFI_ERROR (Status)) { @@ -771,7 +774,13 @@ UfsFinishDeviceInitialization ( Timeout--; } while (DeviceInitStatus !=3D 0 && Timeout !=3D 0); - return EFI_SUCCESS; + 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; + } } /** diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index ef33250c89..275351cf8e 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -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 @@ -40,6 +40,7 @@ // #define UFS_MAX_LUNS 12 #define UFS_WLUN_PREFIX 0xC1 +#define UFS_INIT_COMPLETION_TIMEOUT 600000 typedef struct { UINT8 Lun[UFS_MAX_LUNS]; -- 2.16.2.windows.1 --_002_CO1PR11MB51712B30907FB3540E36711AF9809CO1PR11MB5171namp_--