From patchwork Mon Jul 1 20:45:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 1125594 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=xes-inc.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45czsD3hN0z9sBp for ; Tue, 2 Jul 2019 06:45:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726586AbfGAUpR (ORCPT ); Mon, 1 Jul 2019 16:45:17 -0400 Received: from xes-mad.com ([162.248.234.2]:4156 "EHLO mail.xes-mad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726509AbfGAUpR (ORCPT ); Mon, 1 Jul 2019 16:45:17 -0400 Received: from asierra1.xes-mad.com (asierra1.xes-mad.com [10.52.16.65]) by mail.xes-mad.com (Postfix) with ESMTP id 01C5020356; Mon, 1 Jul 2019 15:45:16 -0500 (CDT) From: Aaron Sierra To: linux-pci@vger.kernel.org Cc: Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v4 1/3] PCI/ACPI: Homogenize _OSC negotiation output Date: Mon, 1 Jul 2019 15:45:13 -0500 Message-Id: <20190701204515.23374-2-asierra@xes-inc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701204515.23374-1-asierra@xes-inc.com> References: <20190213213242.21920-1-git-send-email-asierra@xes-inc.com> <20190701204515.23374-1-asierra@xes-inc.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Previously, the format of messages printed after negotiating _OSC depended on whether the entire operation was considered to be a success or failure. Now, printed messages are homogenized to always show what was requested 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 [] New output: 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 0d57f817ef1e..21aa56f9ca54 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -504,8 +504,9 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, requested = control; status = acpi_pci_osc_control_set(handle, &control, OSC_PCI_EXPRESS_CAPABILITY_CONTROL); + decode_osc_control(root, "OS requested", requested); + decode_osc_control(root, "platform granted", control); if (ACPI_SUCCESS(status)) { - decode_osc_control(root, "OS now controls", control); if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { /* * We have ASPM control, but the FADT indicates that @@ -516,8 +517,6 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, *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)); From patchwork Mon Jul 1 20:45:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 1125595 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=xes-inc.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45czsD6zCsz9sCJ for ; Tue, 2 Jul 2019 06:45:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726509AbfGAUpS (ORCPT ); Mon, 1 Jul 2019 16:45:18 -0400 Received: from xes-mad.com ([162.248.234.2]:9098 "EHLO mail.xes-mad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbfGAUpR (ORCPT ); Mon, 1 Jul 2019 16:45:17 -0400 Received: from asierra1.xes-mad.com (asierra1.xes-mad.com [10.52.16.65]) by mail.xes-mad.com (Postfix) with ESMTP id 076D420357; Mon, 1 Jul 2019 15:45:16 -0500 (CDT) From: Aaron Sierra To: linux-pci@vger.kernel.org Cc: Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v4 2/3] PCI/ACPI: Allow _OSC request without ASPM support Date: Mon, 1 Jul 2019 15:45:14 -0500 Message-Id: <20190701204515.23374-3-asierra@xes-inc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701204515.23374-1-asierra@xes-inc.com> References: <20190213213242.21920-1-git-send-email-asierra@xes-inc.com> <20190701204515.23374-1-asierra@xes-inc.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some use cases favor resiliency over efficiency. In my company's case, the power savings offered by Active State Power Management (ASPM) are entirely secondary to ensuring robust operation. For that same reason we want to stay aware of events reportable via Advanced Error Reporting (AER). We found, on x86 platforms, that AER has an erroneous implicit dependency on ASPM within negotiate_os_control(). This patch updates negotiate_os_control() to be less ASPM-centric in order to allow other features (notably AER) to work without enabling ASPM (either at compile time or at run time). Signed-off-by: Aaron Sierra --- drivers/acpi/pci_root.c | 49 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 21aa56f9ca54..9b8a44391ea0 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -53,9 +53,13 @@ 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) +#define OSC_CONTROL_BITS_ASPM (OSC_PCI_EXPRESS_CAPABILITY_CONTROL \ + | OSC_PCI_EXPRESS_LTR_CONTROL \ + | OSC_PCI_EXPRESS_PME_CONTROL) static const struct acpi_device_id root_device_ids[] = { {"PNP0A03", 0}, @@ -422,6 +426,11 @@ 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 void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, bool is_pcie) { @@ -475,38 +484,47 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, return; } - if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) { + /* + * Require the least restrictive set needed to satisfy at least one + * kernel feature. + */ + if (!osc_have_support(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; + control = 0; + + if (osc_have_support(support, ACPI_PCIE_ASPM_SUPPORT)) + control |= OSC_CONTROL_BITS_ASPM; - if (IS_ENABLED(CONFIG_PCIEASPM)) - control |= OSC_PCI_EXPRESS_LTR_CONTROL; + if (!control) + *no_aspm = 1; if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)) - control |= OSC_PCI_EXPRESS_NATIVE_HP_CONTROL; + control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_EXPRESS_NATIVE_HP_CONTROL; if (IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC)) - control |= OSC_PCI_SHPC_NATIVE_HP_CONTROL; + control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_SHPC_NATIVE_HP_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; + control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_EXPRESS_AER_CONTROL; } requested = control; - status = acpi_pci_osc_control_set(handle, &control, - OSC_PCI_EXPRESS_CAPABILITY_CONTROL); + acpi_pci_osc_control_set(handle, &control, 0); decode_osc_control(root, "OS requested", requested); decode_osc_control(root, "platform granted", control); - if (ACPI_SUCCESS(status)) { + + if (osc_have_support(control, OSC_CONTROL_BITS_ASPM)) { if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { /* * We have ASPM control, but the FADT indicates that @@ -516,9 +534,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 { - 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 From patchwork Mon Jul 1 20:45:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 1125593 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=xes-inc.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45czsC6s2lz9s8m for ; Tue, 2 Jul 2019 06:45:19 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726678AbfGAUpR (ORCPT ); Mon, 1 Jul 2019 16:45:17 -0400 Received: from xes-mad.com ([162.248.234.2]:52385 "EHLO mail.xes-mad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfGAUpR (ORCPT ); Mon, 1 Jul 2019 16:45:17 -0400 Received: from asierra1.xes-mad.com (asierra1.xes-mad.com [10.52.16.65]) by mail.xes-mad.com (Postfix) with ESMTP id 17D582035F; Mon, 1 Jul 2019 15:45:16 -0500 (CDT) From: Aaron Sierra To: linux-pci@vger.kernel.org Cc: Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v4 3/3] PCI/ACPI: Refactor _OSC request bit setting Date: Mon, 1 Jul 2019 15:45:15 -0500 Message-Id: <20190701204515.23374-4-asierra@xes-inc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190701204515.23374-1-asierra@xes-inc.com> References: <20190213213242.21920-1-git-send-email-asierra@xes-inc.com> <20190701204515.23374-1-asierra@xes-inc.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Provide an inline function for each feature (ASPM, PCIe hotplug, SHPC hotplug, and AER) to set its _OSC requests after performing any sanity checks that it needs. This is intended to improve readability/maintenance. Signed-off-by: Aaron Sierra --- drivers/acpi/pci_root.c | 75 ++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 9b8a44391ea0..4e499bb23352 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -431,6 +431,54 @@ static inline bool osc_have_support(u32 support, u32 required) return ((support & required) == required); } +static inline u32 osc_get_aspm_control_bits(struct acpi_pci_root *root, + u32 support) +{ + if (osc_have_support(support, ACPI_PCIE_ASPM_SUPPORT)) + return OSC_CONTROL_BITS_ASPM; + + return 0; +} + +static inline u32 osc_get_pciehp_control_bits(struct acpi_pci_root *root, + u32 support) +{ + if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE) && + osc_have_support(support, ACPI_PCIE_REQ_SUPPORT)) { + return OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_EXPRESS_NATIVE_HP_CONTROL; + } + + return 0; +} + +static inline u32 osc_get_shpchp_control_bits(struct acpi_pci_root *root, + u32 support) +{ + if (IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC) && + osc_have_support(support, ACPI_PCIE_REQ_SUPPORT)) { + return OSC_PCI_EXPRESS_CAPABILITY_CONTROL | + OSC_PCI_SHPC_NATIVE_HP_CONTROL; + } + + return 0; +} + +static inline u32 osc_get_aer_control_bits(struct acpi_pci_root *root, + u32 support) +{ + if (!pci_aer_available() || + !osc_have_support(support, ACPI_PCIE_REQ_SUPPORT)) + return 0; + + if (aer_acpi_firmware_first()) { + dev_info(&root->device->dev, "PCIe AER handled by firmware\n"); + return 0; + } + + return 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) { @@ -494,29 +542,16 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, return; } - control = 0; - - if (osc_have_support(support, ACPI_PCIE_ASPM_SUPPORT)) - control |= OSC_CONTROL_BITS_ASPM; - + control = osc_get_aspm_control_bits(root, support); if (!control) *no_aspm = 1; - if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)) - control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | - OSC_PCI_EXPRESS_NATIVE_HP_CONTROL; - - if (IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC)) - control |= OSC_PCI_EXPRESS_CAPABILITY_CONTROL | - OSC_PCI_SHPC_NATIVE_HP_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_CAPABILITY_CONTROL | - OSC_PCI_EXPRESS_AER_CONTROL; + control |= osc_get_pciehp_control_bits(root, support); + control |= osc_get_shpchp_control_bits(root, support); + control |= osc_get_aer_control_bits(root, support); + if (!control) { + dev_info(&device->dev, "_OSC: not requesting OS control\n"); + return; } requested = control;