From patchwork Mon May 4 07:02:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 1282253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; 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=canonical.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49Fv2Q01g7z9sSr for ; Mon, 4 May 2020 17:03:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727933AbgEDHDI (ORCPT ); Mon, 4 May 2020 03:03:08 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:55251 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbgEDHDI (ORCPT ); Mon, 4 May 2020 03:03:08 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jVV85-0002cB-SL; Mon, 04 May 2020 07:03:06 +0000 From: Kai-Heng Feng To: bhelgaas@google.com Cc: Kai-Heng Feng , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] PCI: Enable ASPM L1 on TI PCIe-to-PCI bridge Date: Mon, 4 May 2020 15:02:59 +0800 Message-Id: <20200504070259.6034-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The TI PCIe-to-PCI bridge prevents the Intel SoC from entering power state deeper than PC3, consumes lots of unnecessary power. On Windows ASPM L1 is enabled on the device and its upstream bridge, so it can make the Intel SoC reach PC8 or PC10 to save lots of power. So enable ASPM L1 like Windows does, to save additional power. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207571 Signed-off-by: Kai-Heng Feng --- drivers/pci/quirks.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index ca9ed5774eb1..ac7eccf34f87 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -2330,6 +2330,27 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s); +static void quirk_enable_aspm_l1(struct pci_dev *dev) +{ + struct pci_dev *bridge = pci_upstream_bridge(dev); + u16 lnkctl; + + pci_info(dev, "Enabling L1\n"); + pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnkctl); + if (!(lnkctl & PCI_EXP_LNKCTL_ASPM_L1)) + pcie_capability_write_word(dev, PCI_EXP_LNKCTL, + lnkctl | PCI_EXP_LNKCTL_ASPM_L1); + + if (!bridge) + return; + + pcie_capability_read_word(bridge, PCI_EXP_LNKCTL, &lnkctl); + if (!(lnkctl & PCI_EXP_LNKCTL_ASPM_L1)) + pcie_capability_write_word(bridge, PCI_EXP_LNKCTL, + lnkctl | PCI_EXP_LNKCTL_ASPM_L1); +} +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_TI, 0x8240, quirk_enable_aspm_l1); + /* * Some Pericom PCIe-to-PCI bridges in reverse mode need the PCIe Retrain * Link bit cleared after starting the link retrain process to allow this