]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/NvmExpressDxe: fix error status override
authorHeyi Guo <heyi.guo@linaro.org>
Mon, 4 Dec 2017 02:27:54 +0000 (10:27 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 5 Dec 2017 00:28:37 +0000 (08:28 +0800)
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>
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c

index c33038f0e926555deca50827b021f9a38cd55d68..7356c1d673e4377334f0fa5e9c99496d02fef4a9 100644 (file)
@@ -453,6 +453,7 @@ NvmExpressPassThru (
 {\r
   NVME_CONTROLLER_PRIVATE_DATA   *Private;\r
   EFI_STATUS                     Status;\r
+  EFI_STATUS                     PreviousStatus;\r
   EFI_PCI_IO_PROTOCOL            *PciIo;\r
   NVME_SQ                        *Sq;\r
   NVME_CQ                        *Cq;\r
@@ -831,6 +832,7 @@ NvmExpressPassThru (
   }\r
 \r
   Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]);\r
+  PreviousStatus = Status;\r
   Status = PciIo->Mem.Write (\r
                PciIo,\r
                EfiPciIoWidthUint32,\r
@@ -839,6 +841,9 @@ NvmExpressPassThru (
                1,\r
                &Data\r
                );\r
+  // The return status of PciIo->Mem.Write should not override\r
+  // previous status if previous status contains error.\r
+  Status = EFI_ERROR (PreviousStatus) ? PreviousStatus : Status;\r
 \r
   //\r
   // For now, the code does not support the non-blocking feature for admin queue.\r