From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2A5522035624E for ; Mon, 4 Dec 2017 16:25:04 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Dec 2017 16:29:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,362,1508828400"; d="scan'208";a="9572073" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 04 Dec 2017 16:29:34 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 4 Dec 2017 16:29:34 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 4 Dec 2017 16:29:34 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Tue, 5 Dec 2017 08:29:32 +0800 From: "Wu, Hao A" To: "Zeng, Star" , Heyi Guo , "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Ni, Ruiyu" Thread-Topic: [PATCH v2] MdeModulePkg/NvmExpressDxe: fix error status override Thread-Index: AQHTbKe+Gvx/aB7dp0CHV7pnEcYtXaMyesaw//+ucQCAAb2lkA== Date: Tue, 5 Dec 2017 00:29:31 +0000 Message-ID: References: <1512354474-38200-1-git-send-email-heyi.guo@linaro.org> <0C09AFA07DD0434D9E2A0C6AEB0483103B9BF262@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9BF262@shsmsx102.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdeModulePkg/NvmExpressDxe: fix error status override X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Dec 2017 00:25:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Pushed at 9a77210b43ef34af52ea7285fadc0ce5779306fe. Best Regards, Hao Wu > -----Original Message----- > From: Zeng, Star > Sent: Monday, December 04, 2017 1:54 PM > To: Wu, Hao A; Heyi Guo; linaro-uefi@lists.linaro.org; edk2-devel@lists.0= 1.org > Cc: Dong, Eric; Ni, Ruiyu; Zeng, Star > Subject: RE: [PATCH v2] MdeModulePkg/NvmExpressDxe: fix error status > override >=20 > Reviewed-by: Star Zeng >=20 > Hao, please help push the patch if no other comments received. >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Wu, Hao A > Sent: Monday, December 4, 2017 10:47 AM > To: Heyi Guo ; linaro-uefi@lists.linaro.org; edk2- > devel@lists.01.org > Cc: Zeng, Star ; Dong, Eric ; N= i, > Ruiyu > Subject: RE: [PATCH v2] MdeModulePkg/NvmExpressDxe: fix error status > override >=20 > Reviewed-by: Hao Wu >=20 > Best Regards, > Hao Wu >=20 >=20 > > -----Original Message----- > > From: Heyi Guo [mailto:heyi.guo@linaro.org] > > Sent: Monday, December 04, 2017 10:28 AM > > To: linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org > > Cc: Heyi Guo; Zeng, Star; Dong, Eric; Wu, Hao A; Ni, Ruiyu > > Subject: [PATCH v2] MdeModulePkg/NvmExpressDxe: fix error status > > override > > > > Commit f6b139b added return status handling to PciIo->Mem.Write. > > However, the second status handling will override EFI_DEVICE_ERROR > > returned in this branch: > > > > // > > // Check the NVMe cmd execution result > > // > > if (Status !=3D EFI_TIMEOUT) { > > if ((Cq->Sct =3D=3D 0) && (Cq->Sc =3D=3D 0)) { > > Status =3D EFI_SUCCESS; > > } else { > > Status =3D EFI_DEVICE_ERROR; > > ^^^^^^^^^^^^^^^^ > > > > Since PciIo->Mem.Write will probably return SUCCESS, it causes > > NvmExpressPassThru to return SUCCESS even when DEVICE_ERROR occurs. > > Callers of NvmExpressPassThru will then continue executing which may > > cause further unexpected results, e.g. DiscoverAllNamespaces couldn't > > break out the loop. > > > > So we save previous status before calling PciIo->Mem.Write and restore > > the previous one if it already contains error. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Heyi Guo > > Cc: Star Zeng > > Cc: Eric Dong > > Cc: Hao Wu > > Cc: Ruiyu Ni > > --- > > MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > > b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > > index c33038f..7356c1d 100644 > > --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > > +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > > @@ -453,6 +453,7 @@ NvmExpressPassThru ( { > > NVME_CONTROLLER_PRIVATE_DATA *Private; > > EFI_STATUS Status; > > + EFI_STATUS PreviousStatus; > > EFI_PCI_IO_PROTOCOL *PciIo; > > NVME_SQ *Sq; > > NVME_CQ *Cq; > > @@ -831,6 +832,7 @@ NvmExpressPassThru ( > > } > > > > Data =3D ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]); > > + PreviousStatus =3D Status; > > Status =3D PciIo->Mem.Write ( > > PciIo, > > EfiPciIoWidthUint32, > > @@ -839,6 +841,9 @@ NvmExpressPassThru ( > > 1, > > &Data > > ); > > + // The return status of PciIo->Mem.Write should not override // > > + previous status if previous status contains error. > > + Status =3D EFI_ERROR (PreviousStatus) ? PreviousStatus : Status; > > > > // > > // For now, the code does not support the non-blocking feature for > > admin queue. > > -- > > 2.7.2.windows.1