From patchwork Thu Sep 17 15:21:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 7208491 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C025BEEC1 for ; Thu, 17 Sep 2015 15:21:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 115E2207EA for ; Thu, 17 Sep 2015 15:21:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7DF220796 for ; Thu, 17 Sep 2015 15:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751818AbbIQPVi (ORCPT ); Thu, 17 Sep 2015 11:21:38 -0400 Received: from mail-io0-f176.google.com ([209.85.223.176]:36084 "EHLO mail-io0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbbIQPVg (ORCPT ); Thu, 17 Sep 2015 11:21:36 -0400 Received: by ioii196 with SMTP id i196so25542500ioi.3 for ; Thu, 17 Sep 2015 08:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=bK1RF/FKbiSDkD7h2bNEuQ0yXxKaCHAXtN6660gm5g4=; b=VrP4bTJBMJ39mHigaK+wjFS2F/iSQVLcfpUhoQ40vxBe/nyS1LmUdxMnjE5vFDz6n5 jEIvH5RKv37aGplAShTJp69c49IVqazTt+Iub7SmjmCEkm0eIOUsof9KpxrmvdY6rIgJ d6sA8zzaKEb6/sr6G1S22WDA68RHS8CP4FZXZ9tXOlJF2MQ0r5rjBOT7amVe2nl0i0cM uPS/H126L6lODWD2af5kppcSs0TWMgjtU6ASHjtjHx7fVqivnZFobfblgWXGjMl+mfsN JIAxE8/UAI3W8DnP+VldBg9/GEmIO0uRmuEBuwoWZP88ayayqeIRmrEhsn3f7gXFpMZB 2qXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=bK1RF/FKbiSDkD7h2bNEuQ0yXxKaCHAXtN6660gm5g4=; b=mY+vg8P0laGGIBKyR4eJdEvv3S6utXyJh7yUJmVzctK96XKGY5Uvw5/yELk4y9W2Br jiSdcdEXtZJ0KWKT3wgDpJ+ONvGn4sNkmmLRwa8GBE7b0TAi/PJC8I0Gb2CT/BsHgtqN ooDmjH5xfyXYDdJEJXdpbV9u1QY1M4lJVQPEqwLLPdlI9hiDOZ3rEXBSNdcnhQxaqnM2 Ms3aD3cRdTAVFtaS5Y5rbX8UzmGIjrjCmj39Y+c1rk2qXU2LDXmM+V/Y0cp52MOLkyE6 uWVghlXCDilFkVweA1ayF2ZNfmDas0jQOm6FHMtrhqGj2rcuNwpOj8LmcCVEji8ysksK 8fqw== X-Gm-Message-State: ALoCoQkSCES/N2M2O9p3/K2IGc6WsTrQsua+1k/qvgq4IlS8s9WZADUwTezx2anJ07dgx7cxwVI1 X-Received: by 10.107.15.69 with SMTP id x66mr7152123ioi.156.1442503296050; Thu, 17 Sep 2015 08:21:36 -0700 (PDT) Received: from google.com ([69.71.1.1]) by smtp.gmail.com with ESMTPSA id 95sm1492208iop.31.2015.09.17.08.21.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 17 Sep 2015 08:21:34 -0700 (PDT) Date: Thu, 17 Sep 2015 10:21:25 -0500 From: Bjorn Helgaas To: Taku Izumi Cc: linux-pci@vger.kernel.org Subject: Re: [PATCH v2] PCI/AER: Cleanup AER error status registers on probing/restoring devices Message-ID: <20150917152125.GG25767@google.com> References: <1441211451-14319-1-git-send-email-izumi.taku@jp.fujitsu.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1441211451-14319-1-git-send-email-izumi.taku@jp.fujitsu.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 On Thu, Sep 03, 2015 at 01:30:51AM +0900, Taku Izumi wrote: > AER uncorrectable or correctable error might be recorded > when power on devices. These errors can be ignored, so > BIOS usually cleans 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. > The same is true of during-resume-from-suspend. > > This patch address this problem by cleaning up AER error status > registers on probing devices and on restoring devices. > > v1 -> v2: > - delete unnecessary EXPORT_SYMBOL_GPL > - add pci_is_pcie() check to pci_cleanup_aer_error_status_regs() > - cleanup AER error status register at pci_restore_state() > > Signed-off-by: Taku Izumi Applied with tweaks as below to pci/aer for v4.4, thanks! commit b07461a8e45b7a62ef7fb46e4f6ada66f63406a8 Author: Taku Izumi Date: Thu Sep 17 10:09:37 2015 -0500 PCI/AER: Clear error status registers during enumeration and restore AER errors might be recorded when powering-on devices. These errors can be ignored, so firmware usually clears them before the OS enumerates devices. However, firmware is not involved when devices are added via hotplug, so the OS may discover power-up errors that should be ignored. The same may happen when powering up devices when resuming after suspend. Clear the AER error status registers during enumeration and resume. [bhelgaas: changelog, remove repetitive comments] Signed-off-by: Taku Izumi Signed-off-by: Bjorn Helgaas --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6a9a111..62ecf45 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "pci.h" const char *pci_power_names[] = { @@ -1099,6 +1100,8 @@ void pci_restore_state(struct pci_dev *dev) pci_restore_ats_state(dev); pci_restore_vc_state(dev); + pci_cleanup_aer_error_status_regs(dev); + pci_restore_config_space(dev); pci_restore_pcix_state(dev); diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 9803e3d..fba785e 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c @@ -74,6 +74,34 @@ 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; + + if (!pci_is_pcie(dev)) + return -ENODEV; + + 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; +} + /** * 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 0b2be17..8cd9710 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "pci.h" @@ -1621,6 +1622,8 @@ static void pci_init_capabilities(struct pci_dev *dev) /* Enable ACS P2P upstream forwarding */ pci_enable_acs(dev); + + pci_cleanup_aer_error_status_regs(dev); } static void pci_set_msi_domain(struct pci_dev *dev) 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,