From patchwork Mon Jul 23 16:52:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alex G." X-Patchwork-Id: 10540611 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D07A5112B for ; Mon, 23 Jul 2018 16:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDB5428B36 for ; Mon, 23 Jul 2018 16:53:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B111E28B8A; Mon, 23 Jul 2018 16:53:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A95928B36 for ; Mon, 23 Jul 2018 16:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388357AbeGWRzS (ORCPT ); Mon, 23 Jul 2018 13:55:18 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36831 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388283AbeGWRzS (ORCPT ); Mon, 23 Jul 2018 13:55:18 -0400 Received: by mail-oi0-f65.google.com with SMTP id n21-v6so2365329oig.3; Mon, 23 Jul 2018 09:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dQLG0mNyRfCdnJvs632GE/CPpAlUSOPE8hbK+IFSBCo=; b=rVXBawUGjPH+mgL7YCcwd6+EQhy4Uw5eBuf7AW4ZGrP03PYgSe+cuJASNJwcrcn0ZF dvy6gHLyZSrekBJcgCeVgMatDaaZkvLrfLOKQNJl5OdWfpLAnaoBAEWmqy41IHskCnDk lhNsfMQHC1HQy6lbNnBZK9qQSv80QLNcHsOaE9e95+gzp5Ck+h07LQ9FWCoqihG2xS2E WelL9Z7mHzXVCjWymJFH/tQ2xr0za3v0SxQVzNb/2H+u96h2Am0CfLWCg+k4HhsjtzD3 Rbxc5jyCw7/ikfKPfoUUAYf5dFSeGnEsCApOBm009bfuCRYwX+/4lob5nXuCg1Yz8fnS gd0w== 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:in-reply-to :references; bh=dQLG0mNyRfCdnJvs632GE/CPpAlUSOPE8hbK+IFSBCo=; b=ZUysQgCy0CdOm7cwMuC0rOH//vMu4nNKotq36mUYBYKRWT/8o2HYvBS98w29MHNJ3V oBOT0OSucldMRKNLF/lQlI+TbHhj3zujoGmJAkI+JQIpQEz947FF1XcfG7voUwj0Bm4A aA4WvLuiVJj6VGkkkbMdF4oOXYlv6CPXRFZrRTqgmaQXG67TVwEvEbn4cfZA9UNuJbKK 1LZePErMh1MY2GpEmmwVZMZDefjWradMOHZOlHsBMV9z3tGu/+6+E7gBWepCTlGQ64p6 4rjFmZ8kU09Vrs+AeVSDBZcmQe0igaduNdeAVGt4bATkNOM2Ig7A5VlozEuSgJb/HzAJ 5cCw== X-Gm-Message-State: AOUpUlENdWLNym4Y1KdObS+gN/7YV10PxI7KsiIHrmFYRAd3G4Hkhe+T sqFYW/BUlFmGHJKTo93uS87j7Suel9E= X-Google-Smtp-Source: AAOMgpeGrs8CLZsp4wVt8TqD3CHiYI6/Gz4NtA5JVE11YzWxPIIYxevUpRLq3+uhdsOrvVezd20OAg== X-Received: by 2002:aca:c355:: with SMTP id t82-v6mr3194526oif.327.1532364791701; Mon, 23 Jul 2018 09:53:11 -0700 (PDT) Received: from nuclearis2-1.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id r3-v6sm6917610oig.49.2018.07.23.09.53.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 09:53:11 -0700 (PDT) From: Alexandru Gagniuc To: linux-pci@vger.kernel.org, bhelgaas@google.com Cc: keith.busch@intel.com, alex_gagniuc@dellteam.com, austin_bolen@dell.com, shyam_iyer@dell.com, Alexandru Gagniuc , Frederick Lawler , Greg Kroah-Hartman , Oza Pawandeep , linux-kernel@vger.kernel.org Subject: [PATCH v2] PCI/AER: Do not clear AER bits if we don't own AER Date: Mon, 23 Jul 2018 11:52:33 -0500 Message-Id: <20180723165251.11424-1-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180717153135.25925-1-mr.nuke.me@gmail.com> References: <20180717153135.25925-1-mr.nuke.me@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we don't own AER, we shouldn't touch the AER error bits. Clearing error bits willy-nilly might cause firmware to miss some errors. In theory, these bits get cleared by FFS, or via ACPI _HPX method. These mechanisms are not subject to the problem. This race is mostly of theoretical significance, since I can't reasonably demonstrate this race in the lab. On a side-note, pcie_aer_is_kernel_first() is created to alleviate the need for two checks: aer_cap and get_firmware_first(). Signed-off-by: Alexandru Gagniuc --- drivers/pci/pcie/aer.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index a2e88386af28..85c3e173c025 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -307,6 +307,12 @@ int pcie_aer_get_firmware_first(struct pci_dev *dev) aer_set_firmware_first(dev); return dev->__aer_firmware_first; } + +static bool pcie_aer_is_kernel_first(struct pci_dev *dev) +{ + return !!dev->aer_cap && !pcie_aer_get_firmware_first(dev); +} + #define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \ PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE) @@ -337,10 +343,7 @@ bool aer_acpi_firmware_first(void) int pci_enable_pcie_error_reporting(struct pci_dev *dev) { - if (pcie_aer_get_firmware_first(dev)) - return -EIO; - - if (!dev->aer_cap) + if (!pcie_aer_is_kernel_first(dev)) return -EIO; return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS); @@ -349,7 +352,7 @@ EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); int pci_disable_pcie_error_reporting(struct pci_dev *dev) { - if (pcie_aer_get_firmware_first(dev)) + if (!pcie_aer_is_kernel_first(dev)) return -EIO; return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, @@ -383,10 +386,10 @@ int pci_cleanup_aer_error_status_regs(struct pci_dev *dev) if (!pci_is_pcie(dev)) return -ENODEV; - pos = dev->aer_cap; - if (!pos) + if (pcie_aer_is_kernel_first(dev)) return -EIO; + pos = dev->aer_cap; port_type = pci_pcie_type(dev); if (port_type == PCI_EXP_TYPE_ROOT_PORT) { pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &status);