From patchwork Mon Dec 4 02:27:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 120473 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3903185qgn; Sun, 3 Dec 2017 18:29:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMaOXxG8lPrgGWpHitWIRgWYcqT4fqF7Q16vugdznWhU76/W2c1MKBTe3xKWQ/6XMJs2EOhS X-Received: by 10.99.62.10 with SMTP id l10mr12401302pga.376.1512354577089; Sun, 03 Dec 2017 18:29:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512354577; cv=none; d=google.com; s=arc-20160816; b=VomDBC2ZHmU1GIX43Vz60XC0z73tZncSMpuvhoAqwxbVFl/xjd5TWrt4pFkkSo078C l543GYKGF4mG3vpA2LYHaYLXMOYllowBKQM7Z7wpGizzOhtLfMFtEVUx5zs43/xVCrZY gkfniX4RZFhSCX7W3VNrhebb93LFDVaqMMt9gLg7wsq6A8MEi3ZamrRFQRPf12y9cq0t FpJ2y2f0cufJOHlsL8CBnzSfyTyjGuzzTqX42soLTmF8qx4F4Upin4U743TeGGDtR7jQ GG7FGxh643O28zkD33b4pKK0D16oa3jebIQ8musOOngfVVLzlLUOsY2wq3t7q74Spnp8 pLzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=fiQhM/Lc4Hh/z43WlLYJ9PJrkyJYq2Qaoq68bk7CZh4=; b=Apl0Ghu2eqqC7Q/7OtBETWWorDi6rcW+sb/he2JyZspGAnQ2qy981OcELLf03YdDr6 DZCvD6l1BcuK5X5FlXQWqv1TfTGaRlmGkvGItVPuRxnDMA5Yy/Vw84aBBzD3LNVVTK7v GNzmxGirRymG1kQUfhUjBUxW9koQMSmVlaVHcYKYCwQbYJnAsydr+WCBPLgx39UpC8Ve VYFk8oB1qg5OQLeSFYws0n31brmc3szJE6x9x1YM+W1v2/sn/13C/qWnccTOxjDx21Bb FnobUDkWmmJjijvkF4LD1NmSHVhfPYHbFpdhWGdW0IMJMdzfeZnGfNOt5zNCLB2X21nw EVMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Az2MG+ss; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id u8si8550028pgp.346.2017.12.03.18.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2017 18:29:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Az2MG+ss; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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) 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-Received: by 10.84.168.226 with SMTP id f89mr13231007plb.176.1512354574267; 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) 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 Cc: Star Zeng Cc: Eric Dong Cc: Hao Wu Cc: Ruiyu Ni --- MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Hao Wu Reviewed-by: Star Zeng Reviewed-by: Hao Wu 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 ( } Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]); + PreviousStatus = Status; Status = 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 = EFI_ERROR (PreviousStatus) ? PreviousStatus : Status; // // For now, the code does not support the non-blocking feature for admin queue.