From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 50C3C220EE075 for ; Sun, 3 Dec 2017 21:49:50 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2017 21:54:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,357,1508828400"; d="scan'208";a="180964963" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 03 Dec 2017 21:54:19 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 3 Dec 2017 21:54:19 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 3 Dec 2017 21:54:19 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Mon, 4 Dec 2017 13:54:17 +0800 From: "Zeng, Star" To: "Wu, Hao A" , Heyi Guo , "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Ni, Ruiyu" , "Zeng, Star" Thread-Topic: [PATCH v2] MdeModulePkg/NvmExpressDxe: fix error status override Thread-Index: AQHTbKfCgNOVUoRPuE2ND+3xirPRdaMx9MmAgAC6V+A= Date: Mon, 4 Dec 2017 05:54:16 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9BF262@shsmsx102.ccr.corp.intel.com> References: <1512354474-38200-1-git-send-email-heyi.guo@linaro.org> In-Reply-To: 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: Mon, 04 Dec 2017 05:49:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Hao, please help push the patch if no other comments received. Thanks, Star -----Original Message----- From: Wu, Hao A=20 Sent: Monday, December 4, 2017 10:47 AM To: Heyi Guo ; linaro-uefi@lists.linaro.org; edk2-deve= l@lists.01.org Cc: Zeng, Star ; Dong, Eric ; Ni,= Ruiyu Subject: RE: [PATCH v2] MdeModulePkg/NvmExpressDxe: fix error status overri= de Reviewed-by: Hao Wu Best Regards, Hao Wu > -----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=20 > override >=20 > Commit f6b139b added return status handling to PciIo->Mem.Write. > However, the second status handling will override EFI_DEVICE_ERROR=20 > returned in this branch: >=20 > // > // 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; > ^^^^^^^^^^^^^^^^ >=20 > Since PciIo->Mem.Write will probably return SUCCESS, it causes=20 > NvmExpressPassThru to return SUCCESS even when DEVICE_ERROR occurs. > Callers of NvmExpressPassThru will then continue executing which may=20 > cause further unexpected results, e.g. DiscoverAllNamespaces couldn't=20 > break out the loop. >=20 > So we save previous status before calling PciIo->Mem.Write and restore=20 > the previous one if it already contains error. >=20 > 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(+) >=20 > 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 ( > } >=20 > 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 //=20 > + previous status if previous status contains error. > + Status =3D EFI_ERROR (PreviousStatus) ? PreviousStatus : Status; >=20 > // > // For now, the code does not support the non-blocking feature for=20 > admin queue. > -- > 2.7.2.windows.1