From patchwork Thu Jul 30 10:34:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1338746 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BHRby5SPrz9sSt; Thu, 30 Jul 2020 20:34:22 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1k15tC-0005J0-TA; Thu, 30 Jul 2020 10:34:18 +0000 Received: from mail-pj1-f67.google.com ([209.85.216.67]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k15t8-0005Ho-HP for kernel-team@lists.ubuntu.com; Thu, 30 Jul 2020 10:34:14 +0000 Received: by mail-pj1-f67.google.com with SMTP id t6so276350pjr.0 for ; Thu, 30 Jul 2020 03:34:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4xV9WjJSQvzr2+lrr1MzVtkickZiia238DZ984fXfEI=; b=nvfqGjGu43/io4UicfStClfKkxwgV4Hv2Y08Ndr70Q3T3pK6tfs470HJtuYh0TkQTY tyxfQSBwNJqme+NWnCZmvWyKqETG3SAcuVYHRwcNaM6JUtXz3ESgQcdTsDajvtCiHoj9 TtS4HhGzGZEu5NwJvYQzIRX4EydtXRRnrQBMEEym4Np7mWo9qron1Q0Dyr4ujm+xH+fg 1OF2jipkx0/zYbrKu1IQm4m6qUXicFp1+0eXRajiqFvY/BjQCGgt+0bKKQjPDvByUbA7 9dplfkIh/Bl49Zz50YVvsDVAbXM2nF4+hOczWE8re1jKWCuamh1I+pa3ZP5hqYOLZ8h3 kMaQ== X-Gm-Message-State: AOAM530RGVFtwSS549+Cl/I0pt8TNoSrOyj4CuGQAHcU4yP+qd4/TnCr AWlEenfJyRhppTAZbTpr9k9LbCUL/cU= X-Google-Smtp-Source: ABdhPJyTgdsc3zIOXqd7xWWhIQ2Ry9CSwPAkBBjGoCpBIgN1qmF6SY/RP0vdzgjTejgdUTi99ifvOg== X-Received: by 2002:a17:902:768b:: with SMTP id m11mr18204381pll.97.1596105250794; Thu, 30 Jul 2020 03:34:10 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id a26sm5129210pgm.20.2020.07.30.03.34.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 03:34:09 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1][U/OEM-5.6] PCI: vmd: Enable ASPM if BIOS requests it Date: Thu, 30 Jul 2020 18:34:04 +0800 Message-Id: <20200730103404.136666-2-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200730103404.136666-1-vicamo.yang@canonical.com> References: <20200730103404.136666-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.67; envelope-from=vicamo@gmail.com; helo=mail-pj1-f67.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jon Derrick BugLink: https://bugs.launchpad.net/bugs/1889384 VMD domains are not ACPI-managed devices and do not have the necessary ACPI hooks to enable ASPM. However if the BIOS has requested ASPM enablement, we should try to honor that request regardless. This patch adds the ASPM support to VMD child devices if requested by the FADT table. Signed-off-by: Jon Derrick (cherry picked from https://lore.kernel.org/linux-pci/20200728161321.38229-1-jonathan.derrick@intel.com/) Signed-off-by: You-Sheng Yang --- drivers/pci/controller/vmd.c | 9 ++++++++- drivers/pci/pcie/aspm.c | 19 ++----------------- include/linux/pci.h | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 9a64cf90c291..60a9373d3360 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -574,8 +575,14 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) * and will fail pcie_bus_configure_settings() early. It can instead be * run on each of the real root ports. */ - list_for_each_entry(child, &vmd->bus->children, node) + list_for_each_entry(child, &vmd->bus->children, node) { +#if IS_ENABLED(CONFIG_PCIEASPM) + if (!(acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)) + pcie_config_aspm_link(child->self->link_state, + ASPM_STATE_ALL); +#endif pcie_bus_configure_settings(child); + } pci_bus_add_devices(vmd->bus); diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index b17e5ffd31b1..23a3fc82364f 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -25,22 +25,6 @@ #endif #define MODULE_PARAM_PREFIX "pcie_aspm." -/* Note: those are not register definitions */ -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */ -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */ -#define ASPM_STATE_L1 (4) /* L1 state */ -#define ASPM_STATE_L1_1 (8) /* ASPM L1.1 state */ -#define ASPM_STATE_L1_2 (0x10) /* ASPM L1.2 state */ -#define ASPM_STATE_L1_1_PCIPM (0x20) /* PCI PM L1.1 state */ -#define ASPM_STATE_L1_2_PCIPM (0x40) /* PCI PM L1.2 state */ -#define ASPM_STATE_L1_SS_PCIPM (ASPM_STATE_L1_1_PCIPM | ASPM_STATE_L1_2_PCIPM) -#define ASPM_STATE_L1_2_MASK (ASPM_STATE_L1_2 | ASPM_STATE_L1_2_PCIPM) -#define ASPM_STATE_L1SS (ASPM_STATE_L1_1 | ASPM_STATE_L1_1_PCIPM |\ - ASPM_STATE_L1_2_MASK) -#define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW) -#define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1 | \ - ASPM_STATE_L1SS) - struct aspm_latency { u32 l0s; /* L0s latency (nsec) */ u32 l1; /* L1 latency (nsec) */ @@ -748,7 +732,7 @@ static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) PCI_EXP_LNKCTL_ASPMC, val); } -static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) +void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) { u32 upstream = 0, dwstream = 0; struct pci_dev *child = link->downstream, *parent = link->pdev; @@ -798,6 +782,7 @@ static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) link->aspm_enabled = state; } +EXPORT_SYMBOL_GPL(pcie_config_aspm_link); static void pcie_config_aspm_path(struct pcie_link_state *link) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 34c1c4f45288..ec0a8b7a55f8 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -377,6 +377,22 @@ struct pci_dev { unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */ #ifdef CONFIG_PCIEASPM +/* Note: those are not register definitions */ +#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */ +#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */ +#define ASPM_STATE_L1 (4) /* L1 state */ +#define ASPM_STATE_L1_1 (8) /* ASPM L1.1 state */ +#define ASPM_STATE_L1_2 (0x10) /* ASPM L1.2 state */ +#define ASPM_STATE_L1_1_PCIPM (0x20) /* PCI PM L1.1 state */ +#define ASPM_STATE_L1_2_PCIPM (0x40) /* PCI PM L1.2 state */ +#define ASPM_STATE_L1_SS_PCIPM (ASPM_STATE_L1_1_PCIPM | ASPM_STATE_L1_2_PCIPM) +#define ASPM_STATE_L1_2_MASK (ASPM_STATE_L1_2 | ASPM_STATE_L1_2_PCIPM) +#define ASPM_STATE_L1SS (ASPM_STATE_L1_1 | ASPM_STATE_L1_1_PCIPM |\ + ASPM_STATE_L1_2_MASK) +#define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW) +#define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1 | \ + ASPM_STATE_L1SS) + struct pcie_link_state *link_state; /* ASPM link state */ unsigned int ltr_path:1; /* Latency Tolerance Reporting supported from root to here */ @@ -1570,6 +1586,7 @@ extern bool pcie_ports_native; #define PCIE_LINK_STATE_L1_2_PCIPM BIT(6) #ifdef CONFIG_PCIEASPM +void pcie_config_aspm_link(struct pcie_link_state *link, u32 state); int pci_disable_link_state(struct pci_dev *pdev, int state); int pci_disable_link_state_locked(struct pci_dev *pdev, int state); void pcie_no_aspm(void);