Received: by 10.192.165.148 with SMTP id m20csp114162imm; Thu, 19 Apr 2018 14:07:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MmVtQKOn7kdVALVmAH3lCWILn8D4R6RJ367FiRi0PpVHCgKCncdT4/ssa/3/FmWcNCwIq X-Received: by 10.99.44.18 with SMTP id s18mr6394139pgs.427.1524172026762; Thu, 19 Apr 2018 14:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524172026; cv=none; d=google.com; s=arc-20160816; b=u4RspTQC7KglF2P6ahC8vaM56AZetSc85znPGRk1xdmIribVlDHRzc9xuF/8qCJchF BmHt7OZfbEZRNJNpZATtlLePzd0YugYKltmKbXSr/ZzJSVMAcAdAH5rFDRhrwYm346Vs iAmaYLbpe10ixwy9NnaTmedUK1barV6igZ1BmJ8hhA0v51bMjTv9332zrMcK+k7/CO/q nUVbNkdJOoetfZXR5qT/ckFM/i5N2oNxXVusURg7GcqPz9DoI5PeUvgfVAPOvHMXB2l0 8NjkM2Qczalf8B+qLgi/8fnti8vbU+3qiFwnw6tPthNzSGFgJse6Fa/mOa0BcmFCh/OM lGrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dmarc-filter:arc-authentication-results; bh=JGKAaY/mAE8pfjNk93FawER++kunNVEfXOZEmi2zoK0=; b=fxWqvW3fpuSYAV7cQkTq1UhWS8jAG+VLgY+JYaeXXhrN2eSvoDNo+IQKrFg4wlUTdr R9ujByEHxqGTWBsRKFuK/enx4B8DrpItO9aDHWh8GWYEogfT6iDtExl1p9hNEfUshGmy VzAst53LapIlswd1P4+5jAEiZOYwT/Pm05jqAaO9+WHPRKkh0rUCk7JgEAIqaB2GVtaG 5+oENUEPL7EPxVJKcMpep1PHifgKwDg6gBvZOdAyGEMdqoYoFuys7vqk95XDtbmEjJ6L CzuIzqtwCxdBWfAhaperowLV11kJQqFd+z2cvqr2NUz+azzGIvpL8Y1Ff8uGpWmGs5Zp 0cSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c3si3914172pfd.185.2018.04.19.14.06.52; Thu, 19 Apr 2018 14:07:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753533AbeDSVFl (ORCPT + 99 others); Thu, 19 Apr 2018 17:05:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:60492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753187AbeDSVFj (ORCPT ); Thu, 19 Apr 2018 17:05:39 -0400 Received: from localhost (unknown [69.71.5.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 170AF217AE; Thu, 19 Apr 2018 21:05:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 170AF217AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Subject: [PATCH v1 2/2] PCI/ACPI: Request LTR control from platform before using it From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: "Rafael J. Wysocki" , Sinan Kaya , Rajat Jain , Srinath Mannam , Ray Jui , Keith Busch , linux-acpi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Date: Thu, 19 Apr 2018 16:05:36 -0500 Message-ID: <152417193680.76853.4784033544317115756.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <152417080402.76853.4258398181136860884.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <152417080402.76853.4258398181136860884.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Helgaas Per the PCI Firmware spec r3.2, sec 4.5, an ACPI-based OS should use _OSC to request control of Latency Tolerance Reporting (LTR) before using it. Request control of LTR, and if the platform does not grant control, don't use it. N.B. If the hardware supports LTR and the ASPM L1.2 substate but the BIOS doesn't support LTR in _OSC, we previously would enable ASPM L1.2. This patch will prevent us from enabling ASPM L1.2 in that case. It does not prevent us from enabling PCI-PM L1.2, since that doesn't depend on LTR. See PCIe r40, sec 5.5.1, for the L1 PM substate entry conditions. Signed-off-by: Bjorn Helgaas --- drivers/acpi/pci_root.c | 7 +++++++ drivers/pci/probe.c | 5 +++++ include/linux/acpi.h | 3 ++- include/linux/pci.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 0da18bde6a16..f32d767e8e3b 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -153,6 +153,7 @@ static struct pci_osc_bit_struct pci_osc_control_bit[] = { { OSC_PCI_EXPRESS_PME_CONTROL, "PME" }, { OSC_PCI_EXPRESS_AER_CONTROL, "AER" }, { OSC_PCI_EXPRESS_CAPABILITY_CONTROL, "PCIeCapability" }, + { OSC_PCI_EXPRESS_LTR_CONTROL, "LTR" }, }; static void decode_osc_bits(struct acpi_pci_root *root, char *msg, u32 word, @@ -475,6 +476,10 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm) | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | OSC_PCI_EXPRESS_PME_CONTROL; +#ifdef CONFIG_PCIEASPM + control |= OSC_PCI_EXPRESS_LTR_CONTROL; +#endif + if (pci_aer_available()) { if (aer_acpi_firmware_first()) dev_info(&device->dev, @@ -905,6 +910,8 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, host_bridge->native_aer = 0; if (!(root->osc_control_set & OSC_PCI_EXPRESS_PME_CONTROL)) host_bridge->native_pme = 0; + if (!(root->osc_control_set & OSC_PCI_EXPRESS_LTR_CONTROL)) + host_bridge->native_ltr = 0; pci_scan_child_bus(bus); pci_set_host_bridge_release(host_bridge, acpi_pci_root_release_info, diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ac91b6fd0bcd..cc1688d75664 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -554,6 +554,7 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv) bridge->native_aer = 1; bridge->native_hotplug = 1; bridge->native_pme = 1; + bridge->native_ltr = 1; return bridge; } @@ -1954,9 +1955,13 @@ static void pci_configure_relaxed_ordering(struct pci_dev *dev) static void pci_configure_ltr(struct pci_dev *dev) { #ifdef CONFIG_PCIEASPM + struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); u32 cap; struct pci_dev *bridge; + if (!host->native_ltr) + return; + if (!pci_is_pcie(dev)) return; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 15bfb15c2fa5..49f63c67a9d1 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -506,7 +506,8 @@ extern bool osc_pc_lpi_support_confirmed; #define OSC_PCI_EXPRESS_PME_CONTROL 0x00000004 #define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008 #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010 -#define OSC_PCI_CONTROL_MASKS 0x0000001f +#define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020 +#define OSC_PCI_CONTROL_MASKS 0x0000003f #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002 #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004 diff --git a/include/linux/pci.h b/include/linux/pci.h index 73178a2fcee0..d0149c01996d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -473,6 +473,7 @@ struct pci_host_bridge { unsigned int native_aer:1; /* OS may use PCIe AER */ unsigned int native_hotplug:1; /* OS may use PCIe hotplug */ unsigned int native_pme:1; /* OS may use PCIe PME */ + unsigned int native_ltr:1; /* OS may use PCIe LTR */ /* Resource alignment requirements */ resource_size_t (*align_resource)(struct pci_dev *dev, const struct resource *res,