From patchwork Thu Oct 25 16:01:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 10656135 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 79F8814E2 for ; Thu, 25 Oct 2018 16:01:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A2872BEFC for ; Thu, 25 Oct 2018 16:01:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E8452BEFE; Thu, 25 Oct 2018 16:01:35 +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=-7.9 required=2.0 tests=BAYES_00,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 06FBA2BEFC for ; Thu, 25 Oct 2018 16:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbeJZAe5 (ORCPT ); Thu, 25 Oct 2018 20:34:57 -0400 Received: from xes-mad.com ([162.248.234.2]:48259 "EHLO mail.xes-mad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727709AbeJZAe4 (ORCPT ); Thu, 25 Oct 2018 20:34:56 -0400 Received: from asierra1.xes-mad.com (asierra1.xes-mad.com [10.52.16.65]) by mail.xes-mad.com (Postfix) with ESMTP id 58E9A264AB; Thu, 25 Oct 2018 11:01:32 -0500 (CDT) From: Aaron Sierra To: linux-pci@vger.kernel.org Cc: Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 1/2] PCI/ACPI: Move _OSC test for native services to top Date: Thu, 25 Oct 2018 11:01:31 -0500 Message-Id: <1540483292-24049-2-git-send-email-asierra@xes-inc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540483292-24049-1-git-send-email-asierra@xes-inc.com> References: <1539642186-12821-1-git-send-email-asierra@xes-inc.com> <1540483292-24049-1-git-send-email-asierra@xes-inc.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 Move the simple test for when PCIe native services are disabled closer to the top, prior to where things get more complicated. Signed-off-by: Aaron Sierra --- drivers/acpi/pci_root.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 707aafc..eb9f14e 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -441,6 +441,12 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, return; } + if (pcie_ports_disabled) { + dev_info(&device->dev, + "PCIe port services disabled; not requesting _OSC control\n"); + return; + } + /* * All supported architectures that use ACPI have support for * PCI domains, so we indicate this in _OSC support capabilities. @@ -468,11 +474,6 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, return; } - if (pcie_ports_disabled) { - dev_info(&device->dev, "PCIe port services disabled; not requesting _OSC control\n"); - return; - } - if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) { decode_osc_support(root, "not requesting OS control; OS requires", ACPI_PCIE_REQ_SUPPORT); From patchwork Thu Oct 25 16:01:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 10656137 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 468A713A9 for ; Thu, 25 Oct 2018 16:01:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35FDA2BEFC for ; Thu, 25 Oct 2018 16:01:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29DF82BEFE; Thu, 25 Oct 2018 16:01:36 +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=-7.9 required=2.0 tests=BAYES_00,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 A35072BEFC for ; Thu, 25 Oct 2018 16:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbeJZAe5 (ORCPT ); Thu, 25 Oct 2018 20:34:57 -0400 Received: from xes-mad.com ([162.248.234.2]:40441 "EHLO mail.xes-mad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727313AbeJZAe5 (ORCPT ); Thu, 25 Oct 2018 20:34:57 -0400 Received: from asierra1.xes-mad.com (asierra1.xes-mad.com [10.52.16.65]) by mail.xes-mad.com (Postfix) with ESMTP id 67BFC264AC; Thu, 25 Oct 2018 11:01:32 -0500 (CDT) From: Aaron Sierra To: linux-pci@vger.kernel.org Cc: Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v2 2/2] PCI/ACPI: Improve _OSC control request granularity Date: Thu, 25 Oct 2018 11:01:32 -0500 Message-Id: <1540483292-24049-3-git-send-email-asierra@xes-inc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540483292-24049-1-git-send-email-asierra@xes-inc.com> References: <1539642186-12821-1-git-send-email-asierra@xes-inc.com> <1540483292-24049-1-git-send-email-asierra@xes-inc.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 This patch reorganizes negotiate_os_control() to be less ASPM-centric in order to: 1. allow other features (notably AER) to work without enabling ASPM 2. better isolate feature-specific tests for readability/maintenance Each feature (ASPM, PCIe hotplug, SHPC hotplug, and AER) now has its own inline function for setting its _OSC control requests. Part of making this function more generic, required eliminating a test for overall success/failure that previously caused two different types of messages to be printed. Now, printed messages are streamlined to always show requested _OSC control versus what was granted. Previous output (success): acpi PNP0A08:00: _OSC: OS now controls [PME AER PCIeCapability LTR] Previous output (failure): acpi PNP0A08:00: _OSC: OS requested [PME AER PCIeCapability LTR] acpi PNP0A08:00: _OSC: platform willing to grant [] Now: acpi PNP0A08:00: _OSC: OS requested [PME AER PCIeCapability LTR] acpi PNP0A08:00: _OSC: platform granted [PME AER PCIeCapability LTR] Signed-off-by: Aaron Sierra --- drivers/acpi/pci_root.c | 118 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 33 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index eb9f14e..9685aba 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -53,9 +53,10 @@ static int acpi_pci_root_scan_dependent(struct acpi_device *adev) } #define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \ - | OSC_PCI_ASPM_SUPPORT \ - | OSC_PCI_CLOCK_PM_SUPPORT \ | OSC_PCI_MSI_SUPPORT) +#define ACPI_PCIE_ASPM_SUPPORT (ACPI_PCIE_REQ_SUPPORT \ + | OSC_PCI_ASPM_SUPPORT \ + | OSC_PCI_CLOCK_PM_SUPPORT) static const struct acpi_device_id root_device_ids[] = { {"PNP0A03", 0}, @@ -421,6 +422,72 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 req) } EXPORT_SYMBOL(acpi_pci_osc_control_set); +static inline bool __osc_have_support(u32 support, u32 required) +{ + return ((support & required) == required); +} + +static inline int __osc_set_aspm_control(struct acpi_pci_root *root, + u32 support, u32 *control) +{ + if (!IS_ENABLED(CONFIG_PCIEASPM) || + !__osc_have_support(support, ACPI_PCIE_ASPM_SUPPORT)) + return -ENODEV; + + *control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_EXPRESS_LTR_CONTROL | + OSC_PCI_EXPRESS_PME_CONTROL; + + return 0; +} + +static inline bool __osc_have_aspm_control(u32 control) +{ + u32 required = OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_EXPRESS_LTR_CONTROL | + OSC_PCI_EXPRESS_PME_CONTROL; + + return __osc_have_support(control, required); +} + +static inline void __osc_set_pciehp_control(struct acpi_pci_root *root, + u32 support, u32 *control) +{ + if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE) || + !__osc_have_support(support, ACPI_PCIE_REQ_SUPPORT)) + return; + + *control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_EXPRESS_NATIVE_HP_CONTROL; +} + +static inline void __osc_set_shpchp_control(struct acpi_pci_root *root, + u32 support, u32 *control) +{ + if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC) || + !__osc_have_support(support, ACPI_PCIE_REQ_SUPPORT)) + return; + + *control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_SHPC_NATIVE_HP_CONTROL; +} + +static inline void __osc_set_aer_control(struct acpi_pci_root *root, + u32 support, u32 *control) +{ + if (!pci_aer_available() || + !__osc_have_support(support, ACPI_PCIE_REQ_SUPPORT)) + return; + + if (aer_acpi_firmware_first()) { + dev_info(&root->device->dev, "PCIe AER handled by firmware\n"); + return; + } + + *control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_EXPRESS_AER_CONTROL; +} + static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, bool is_pcie) { @@ -474,37 +541,25 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, return; } - if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) { - decode_osc_support(root, "not requesting OS control; OS requires", - ACPI_PCIE_REQ_SUPPORT); - return; - } - - control = OSC_PCI_EXPRESS_CAPABILITY_CONTROL - | OSC_PCI_EXPRESS_PME_CONTROL; - - if (IS_ENABLED(CONFIG_PCIEASPM)) - control |= OSC_PCI_EXPRESS_LTR_CONTROL; - - if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)) - control |= OSC_PCI_EXPRESS_NATIVE_HP_CONTROL; + control = 0; + if (__osc_set_aspm_control(root, support, &control)) + *no_aspm = 1; - if (IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC)) - control |= OSC_PCI_SHPC_NATIVE_HP_CONTROL; + __osc_set_pciehp_control(root, support, &control); + __osc_set_shpchp_control(root, support, &control); + __osc_set_aer_control(root, support, &control); - if (pci_aer_available()) { - if (aer_acpi_firmware_first()) - dev_info(&device->dev, - "PCIe AER handled by firmware\n"); - else - control |= OSC_PCI_EXPRESS_AER_CONTROL; + if (!control) { + dev_info(&device->dev, "_OSC: not requesting OS control\n"); + return; } requested = control; - status = acpi_pci_osc_control_set(handle, &control, - OSC_PCI_EXPRESS_CAPABILITY_CONTROL); - if (ACPI_SUCCESS(status)) { - decode_osc_control(root, "OS now controls", control); + acpi_pci_osc_control_set(handle, &control, 0); + decode_osc_control(root, "OS requested", requested); + decode_osc_control(root, "platform granted", control); + + if (__osc_have_aspm_control(control)) { if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { /* * We have ASPM control, but the FADT indicates that @@ -514,11 +569,8 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, dev_info(&device->dev, "FADT indicates ASPM is unsupported, using BIOS configuration\n"); *no_aspm = 1; } - } else { - decode_osc_control(root, "OS requested", requested); - decode_osc_control(root, "platform willing to grant", control); - dev_info(&device->dev, "_OSC failed (%s); disabling ASPM\n", - acpi_format_exception(status)); + } else if (!*no_aspm) { + dev_info(&device->dev, "_OSC failed; disabling ASPM\n"); /* * We want to disable ASPM here, but aspm_disabled