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 5404B220EE069 for ; Sun, 3 Dec 2017 17:28:06 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2017 17:32:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,356,1508828400"; d="scan'208";a="10086376" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 03 Dec 2017 17:32:34 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 3 Dec 2017 17:32:34 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 3 Dec 2017 17:32:34 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by shsmsx102.ccr.corp.intel.com ([169.254.2.175]) with mapi id 14.03.0319.002; Mon, 4 Dec 2017 09:32:25 +0800 From: "Wu, Hao A" To: "Zeng, Star" , Heyi Guo , "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" CC: Heyi Guo , "Dong, Eric" , "Ni, Ruiyu" Thread-Topic: [edk2] [PATCH] MdeModulePkg/NvmExpressDxe: fix error status override Thread-Index: AQHTa1Ew0YlrthnSBEK3/EUXDXEHBKMx3lOAgACI2uA= Date: Mon, 4 Dec 2017 01:32:25 +0000 Message-ID: References: <1512206536-39536-1-git-send-email-heyi.guo@linaro.org> <0C09AFA07DD0434D9E2A0C6AEB0483103B9BF055@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9BF055@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] 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 01:28:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Comments below. Best Regards, Hao Wu > -----Original Message----- > From: Zeng, Star > Sent: Monday, December 04, 2017 9:17 AM > To: Heyi Guo; linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org > Cc: Heyi Guo; Dong, Eric; Wu, Hao A; Ni, Ruiyu; Zeng, Star > Subject: RE: [edk2] [PATCH] MdeModulePkg/NvmExpressDxe: fix error status > override >=20 > Cc Hao and Ruiyu. >=20 > Thanks, > Star > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of He= yi > Guo > Sent: Saturday, December 2, 2017 5:22 PM > To: linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org > Cc: Heyi Guo ; Heyi Guo ; Dong, > Eric ; Zeng, Star > Subject: [edk2] [PATCH] MdeModulePkg/NvmExpressDxe: fix error status > override >=20 > Commit f6b139b added return status handling to PciIo->Mem.Write. > However, the second status handling will override EFI_DEVICE_ERROR return= ed > 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 > NvmExpressPassThru to return SUCCESS even when DEVICE_ERROR occurs. > Callers of NvmExpressPassThru will then continue executing which may caus= e > further unexpected results, e.g. DiscoverAllNamespaces couldn't break out= the > loop. >=20 > So we add a | (bit-or) to combine the return status together. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Heyi Guo > Cc: Star Zeng > Cc: Eric Dong > --- > MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > index c33038f..2698b27 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > @@ -831,7 +831,7 @@ NvmExpressPassThru ( > } >=20 > Data =3D ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]); > - Status =3D PciIo->Mem.Write ( > + Status |=3D PciIo->Mem.Write ( > PciIo, > EfiPciIoWidthUint32, > NVME_BAR, I searched the whole edk2 code base and did not find a similar case like: Status |=3D Foo(); I also think using the above style might cause the function returning confusing status to the caller. So how about introducing a new variable? EFI_STATUS PreviousStatus; ... Data =3D ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]); PreviousStatus =3D Status; Status =3D PciIo->Mem.Write (...); Status =3D EFI_ERROR (PreviousStatus) ? PreviousStatus : Status; > -- > 2.7.2.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel