From patchwork Mon Sep 20 16:50:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 195432 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8KGpnRJ024209 for ; Mon, 20 Sep 2010 16:51:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756831Ab0ITQvG (ORCPT ); Mon, 20 Sep 2010 12:51:06 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:50804 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753317Ab0ITQvE convert rfc822-to-8bit (ORCPT ); Mon, 20 Sep 2010 12:51:04 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id F1C3C18FA49; Mon, 20 Sep 2010 18:28:51 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23355-04; Mon, 20 Sep 2010 18:28:44 +0200 (CEST) Received: from ferrari.rjw.lan (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id A9980145AB1; Mon, 20 Sep 2010 18:28:44 +0200 (CEST) From: "Rafael J. Wysocki" To: Chen Gong Subject: [PATCH] PCI / PCIe / AER: Disable native AER service if BIOS has precedence (v2) (was: Re: [PATCH] PCI / PCIe / AER ...) Date: Mon, 20 Sep 2010 18:50:00 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.36-rc4-rjw+; KDE/4.4.4; x86_64; ; ) Cc: Jesse Barnes , LKML , linux-pci@vger.kernel.org, Huang Ying , Hidetoshi Seto , Kenji Kaneshige , Matthew Garrett , ACPI Devel Maling List References: <201009200002.15609.rjw@sisk.pl> <4C96FCA3.2060704@linux.intel.com> In-Reply-To: <4C96FCA3.2060704@linux.intel.com> MIME-Version: 1.0 Message-Id: <201009201850.00626.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 20 Sep 2010 16:51:49 +0000 (UTC) Index: linux-2.6/drivers/pci/pcie/aer/aerdrv_acpi.c =================================================================== --- linux-2.6.orig/drivers/pci/pcie/aer/aerdrv_acpi.c +++ linux-2.6/drivers/pci/pcie/aer/aerdrv_acpi.c @@ -93,4 +93,38 @@ int pcie_aer_get_firmware_first(struct p aer_set_firmware_first(dev); return dev->__aer_firmware_first; } + +static bool aer_firmware_first; + +static int aer_hest_parse_aff(struct acpi_hest_header *hest_hdr, void *data) +{ + struct acpi_hest_aer_common *p; + + if (aer_firmware_first) + return 0; + + switch (hest_hdr->type) { + case ACPI_HEST_TYPE_AER_ROOT_PORT: + case ACPI_HEST_TYPE_AER_ENDPOINT: + case ACPI_HEST_TYPE_AER_BRIDGE: + p = (struct acpi_hest_aer_common *)(hest_hdr + 1); + aer_firmware_first = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); + default: + return 0; + } +} + +/** + * aer_acpi_firmware_first - Check if APEI should control AER. + */ +bool aer_acpi_firmware_first(void) +{ + static bool parsed = false; + + if (!parsed) { + apei_hest_parse(aer_hest_parse_aff, NULL); + parsed = true; + } + return aer_firmware_first; +} #endif Index: linux-2.6/drivers/pci/pcie/aer/aerdrv.h =================================================================== --- linux-2.6.orig/drivers/pci/pcie/aer/aerdrv.h +++ linux-2.6/drivers/pci/pcie/aer/aerdrv.h @@ -132,6 +132,7 @@ static inline int aer_osc_setup(struct p #ifdef CONFIG_ACPI_APEI extern int pcie_aer_get_firmware_first(struct pci_dev *pci_dev); +extern bool aer_acpi_firmware_first(void); #else static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev) { @@ -139,6 +140,8 @@ static inline int pcie_aer_get_firmware_ return pci_dev->__aer_firmware_first; return 0; } + +static inline bool aer_acpi_firmware_first(void) { return false; } #endif static inline void pcie_aer_force_firmware_first(struct pci_dev *pci_dev, Index: linux-2.6/drivers/pci/pcie/aer/aerdrv.c =================================================================== --- linux-2.6.orig/drivers/pci/pcie/aer/aerdrv.c +++ linux-2.6/drivers/pci/pcie/aer/aerdrv.c @@ -416,7 +416,7 @@ static void aer_error_resume(struct pci_ */ static int __init aer_service_init(void) { - if (!pci_aer_available()) + if (!pci_aer_available() || aer_acpi_firmware_first()) return -ENXIO; return pcie_port_service_register(&aerdriver); } Index: linux-2.6/drivers/pci/pcie/portdrv_acpi.c =================================================================== --- linux-2.6.orig/drivers/pci/pcie/portdrv_acpi.c +++ linux-2.6/drivers/pci/pcie/portdrv_acpi.c @@ -49,7 +49,7 @@ int pcie_port_acpi_setup(struct pci_dev | OSC_PCI_EXPRESS_PME_CONTROL; if (pci_aer_available()) { - if (pcie_aer_get_firmware_first(port)) + if (aer_acpi_firmware_first()) dev_dbg(&port->dev, "PCIe errors handled by BIOS.\n"); else flags |= OSC_PCI_EXPRESS_AER_CONTROL;