From nobody Tue Dec 24 17:16:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151235457723068.54421458841784; Sun, 3 Dec 2017 18:29:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 694E6220EE070; Sun, 3 Dec 2017 18:25:06 -0800 (PST) Received: from mail-pf0-x232.google.com (mail-pf0-x232.google.com [IPv6:2607:f8b0:400e:c00::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9A3EF220EE069 for ; Sun, 3 Dec 2017 18:25:05 -0800 (PST) Received: by mail-pf0-x232.google.com with SMTP id a90so7442531pfk.1 for ; Sun, 03 Dec 2017 18:29:34 -0800 (PST) Received: from szxbz956.huaweiobz.com ([45.56.152.221]) by smtp.gmail.com with ESMTPSA id i3sm19376143pgc.88.2017.12.03.18.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Dec 2017 18:29:33 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::232; helo=mail-pf0-x232.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=AsRIf8lQrJkXzomH4RtlnXsMXRC/BGjMVnEkmRz8WDE=; b=Az2MG+ssSUMXnvZQxFT0fZpqdH+GP8+hZDzh2CMviHf5oZfTU8rtx9PqykXuKOkOW8 1dU1nJ9+55W8D7wyQL9XsphU5T0rBwKGLBi2+sFIB9XJqaxfNKMMxbKznNRESFRweEn3 xHBrKfGSCBK3N5Ub8eGRFBpjqprsoMHNYmhJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AsRIf8lQrJkXzomH4RtlnXsMXRC/BGjMVnEkmRz8WDE=; b=QK5d8K0FlK1oOtFo2mYxGh+86VX/kEWx+yVMwxuy9vgWYljjd5QpZUZXlfelqPlfSD sOh+y0Kxz97owuFZQjdiniiM/rV8si0GtUSGt94YPHJBqETmsQCweWEq2G356wtYhPX4 Rct4pukQ5DeDAKRPTz9NcqC00q1puhkTYqnOdYHEV+aas31HprCSsVvixJ8jykVY7z12 OZ5bDN1pDIXIocpGL1NJm+g5WplXof/onPkELOefgLALxztTfUiW9u9lwEB1LqhbFf9V F+UjCgofbdbkaoAMWJSrnGlTDc07tZhJcmd8himYyqJX/+SMkEyBi7jIiKGF3ymNbCrj xR4w== X-Gm-Message-State: AJaThX45QOOeQYX7O5CD1Eg48XQTlrfW0Ikn+mnsFvRR+Jp1nW0KkWrP xzbgxL/tvHfMDv7xDqdXTlWEKQ== X-Google-Smtp-Source: AGs4zMZwSdNiLg14Ae7NTUJ1Fb/cXyLp3YreSZvxqNTJCoRB0rVmd47ko9P0Ot2OwucBeDY5Pvaz/A== X-Received: by 10.84.168.226 with SMTP id f89mr13231007plb.176.1512354574267; Sun, 03 Dec 2017 18:29:34 -0800 (PST) From: Heyi Guo To: linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org Date: Mon, 4 Dec 2017 10:27:54 +0800 Message-Id: <1512354474-38200-1-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.2.windows.1 Subject: [edk2] [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: , Cc: Hao Wu , Ruiyu Ni , Heyi Guo , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Hao Wu Reviewed-by: Star Zeng --- MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeM= odulePkg/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 + // 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 admin= queue. --=20 2.7.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel