summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeyi Guo <heyi.guo@linaro.org>2017-12-04 10:27:54 +0800
committerHao Wu <hao.a.wu@intel.com>2018-09-20 15:21:29 +0800
commitacaa5d7382e3cd5a991b61cafb2c4f6807e2c07e (patch)
treeea0a3e68abb66126b1e0e58db016c1cfcee2f23c
parent87acb6e298e718250dd8b741b6888a3a54c7cb5a (diff)
downloadedk2-acaa5d7382e3cd5a991b61cafb2c4f6807e2c07e.tar.gz
edk2-acaa5d7382e3cd5a991b61cafb2c4f6807e2c07e.tar.bz2
edk2-acaa5d7382e3cd5a991b61cafb2c4f6807e2c07e.zip
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 != EFI_TIMEOUT) { if ((Cq->Sct == 0) && (Cq->Sc == 0)) { Status = EFI_SUCCESS; } else { Status = 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 <heyi.guo@linaro.org> Cc: Eric Dong <eric.dong@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> (cherry picked from commit 9a77210b43ef34af52ea7285fadc0ce5779306fe)
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
index df7ac2d011..494364ac44 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
@@ -359,6 +359,7 @@ NvmExpressPassThru (
{
NVME_CONTROLLER_PRIVATE_DATA *Private;
EFI_STATUS Status;
+ EFI_STATUS PreviousStatus;
EFI_PCI_IO_PROTOCOL *PciIo;
NVME_SQ *Sq;
NVME_CQ *Cq;
@@ -700,6 +701,7 @@ NvmExpressPassThru (
}
Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]);
+ PreviousStatus = Status;
Status = PciIo->Mem.Write (
PciIo,
EfiPciIoWidthUint32,
@@ -708,6 +710,9 @@ NvmExpressPassThru (
1,
&Data
);
+ // The return status of PciIo->Mem.Write should not override
+ // previous status if previous status contains error.
+ Status = EFI_ERROR (PreviousStatus) ? PreviousStatus : Status;
//
// For now, the code does not support the non-blocking feature for admin queue.