From patchwork Tue Aug 4 16:42:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taku Izumi X-Patchwork-Id: 6934791 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4BC569F39D for ; Tue, 4 Aug 2015 07:50:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FCEB20619 for ; Tue, 4 Aug 2015 07:50:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1EDEE205CB for ; Tue, 4 Aug 2015 07:50:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754911AbbHDHuL (ORCPT ); Tue, 4 Aug 2015 03:50:11 -0400 Received: from mgwym01.jp.fujitsu.com ([211.128.242.40]:35031 "EHLO mgwym01.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754807AbbHDHuL (ORCPT ); Tue, 4 Aug 2015 03:50:11 -0400 X-Greylist: delayed 619 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Aug 2015 03:50:10 EDT Received: from yt-mxq.gw.nic.fujitsu.com (unknown [192.168.229.66]) by mgwym01.jp.fujitsu.com with smtp id 47b8_1bb1_12088798_6c37_42c4_a6c4_54e7aba1358d; Tue, 04 Aug 2015 16:39:50 +0900 Received: from m3050.s.css.fujitsu.com (msm.b.css.fujitsu.com [10.134.21.208]) by yt-mxq.gw.nic.fujitsu.com (Postfix) with ESMTP id C56C6AC00CA for ; Tue, 4 Aug 2015 16:39:48 +0900 (JST) Received: from DEV.localdomain (unknown [10.125.62.37]) by m3050.s.css.fujitsu.com (Postfix) with ESMTP id A09ACDF; Tue, 4 Aug 2015 16:39:48 +0900 (JST) From: Taku Izumi To: linux-pci@vger.kernel.org, bhelgaas@google.com Cc: Taku Izumi Subject: [PATCH] PCI/AER: Cleanup AER error status registers on probing devices Date: Wed, 5 Aug 2015 01:42:13 +0900 Message-Id: <1438706533-22547-1-git-send-email-izumi.taku@jp.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 X-TM-AS-MML: disable Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP AER uncorrectable or correctable error might be recorded when power on devices. These errors can be ignored, so BIOS usually clean up these registers ahead of OS's scanning devices. However, in case of hot-plug PCIe devices, BIOS can't care. Currently OS don't clean up AER error status registers on probing devices, ignorable AER errors recorded when power-on remains. This causes false-positive. This patch address this problem by cleaning up AER error status registers on probing devices. Signed-off-by: Taku Izumi --- drivers/pci/pcie/aer/aerdrv_core.c | 26 ++++++++++++++++++++++++++ drivers/pci/probe.c | 5 +++++ include/linux/aer.h | 5 +++++ 3 files changed, 36 insertions(+) diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 9803e3d..9857cc4 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c @@ -74,6 +74,32 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status); +int pci_cleanup_aer_error_status_regs(struct pci_dev *dev) +{ + int pos; + u32 status; + int port_type; + + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); + if (!pos) + return -EIO; + + 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); + pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, status); + } + + pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status); + pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, status); + + pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status); + pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status); + + return 0; +} +EXPORT_SYMBOL_GPL(pci_cleanup_aer_error_status_regs); + /** * add_error_device - list device to be handled * @e_info: pointer to error info diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cefd636..d660db7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "pci.h" @@ -1542,6 +1543,10 @@ static void pci_init_capabilities(struct pci_dev *dev) /* Enable ACS P2P upstream forwarding */ pci_enable_acs(dev); + + /* Cleanup AER error status registerts */ + if (pci_is_pcie(dev)) + pci_cleanup_aer_error_status_regs(dev); } void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) diff --git a/include/linux/aer.h b/include/linux/aer.h index 4fef65e..744b997 100644 --- a/include/linux/aer.h +++ b/include/linux/aer.h @@ -42,6 +42,7 @@ struct aer_capability_regs { int pci_enable_pcie_error_reporting(struct pci_dev *dev); int pci_disable_pcie_error_reporting(struct pci_dev *dev); int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev); +int pci_cleanup_aer_error_status_regs(struct pci_dev *dev); #else static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev) { @@ -55,6 +56,10 @@ static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) { return -EINVAL; } +static inline int pci_cleanup_aer_error_status_regs(struct pci_dev *dev) +{ + return -EINVAL; +} #endif void cper_print_aer(struct pci_dev *dev, int cper_severity,