Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp214978pxa; Fri, 21 Aug 2020 05:33:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiz5ZELMPikIrz+u/SVzf3wr84DmBrTjb6tBV8bhxv5MaHQ1sFIbCmRCvu4m7YmTkq9d+J X-Received: by 2002:a17:906:f1da:: with SMTP id gx26mr2698105ejb.129.1598013227492; Fri, 21 Aug 2020 05:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598013227; cv=none; d=google.com; s=arc-20160816; b=h1kqIhi7hrHJKy0EwRmhjmJnULS3Z15lHtqPuZBu4SzIesC7aMhKIXEF8CV7rQJhmk uffSQxnOohFOA8QPrB5yChMvCp0M0yC/FNDf7veAmCh1rguwtMPXcwdzHOKjdE/FxJ8f guzt5rx4o7RI24BO+fVgTrdDAG9NyhVV1/tNL7jK4xHv5tx2xIE37rihNn+0OYj3U23B R573f/dTjzqTtmpSeaFvE3n2/a681WM0/XOZLHcUVtaqgBQn8XGphIOvbafD2tUHVwOE bn76d6xAHnsjZLq1jGjCRL25WbQHFAX4MCk8GCl7MXmjj4yWivNx/fe4dd275j+Ceesw HBcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=IUqj0QqXTA2MdBMJZfjR5wXocEOltjDSSi/jFC2mbTE=; b=ciUs42g+8kJWSdoZ+TMJItCDvRV0fOa8P90mxj6Z6S4/t0CYcwtGq3dzISlKU1WhaU jRuOYGR8kMoORnl/19tTpeKdsPFk5Z8vLi04jYEjokanywTEaIxLRItdu92SZlIfbC45 dvs9R1n0Mo4E/KzMMHndaaBIYzKd/yAM3ieCaaWhdStthLE9oBJhS32be0uOoLtOIOfM R0sHdVaLjRBw3XCP+cogd4b/x3SsbS5ix1phvA1HFdym2wZfmdab/GG4Dn60fR7wNWfj LOk3Si/zqdNYGqMS36hFQy2mu4/kOimqc1s8i384d4VXFvNh0CLklxbNKjhtcevzKY7m GPMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw11si1041070ejb.6.2020.08.21.05.33.23; Fri, 21 Aug 2020 05:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728375AbgHUMck (ORCPT + 99 others); Fri, 21 Aug 2020 08:32:40 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57188 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbgHUMci (ORCPT ); Fri, 21 Aug 2020 08:32:38 -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 1k96Da-0000Fx-UJ; Fri, 21 Aug 2020 12:32:27 +0000 From: Kai-Heng Feng To: bhelgaas@google.com Cc: jonathan.derrick@intel.com, Mario.Limonciello@dell.com, Kai-Heng Feng , Heiner Kallweit , Mika Westerberg , "Rafael J. Wysocki" , Xiongfeng Wang , Krzysztof Wilczynski , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] PCI/ASPM: Enable ASPM for links under VMD domain Date: Fri, 21 Aug 2020 20:32:20 +0800 Message-Id: <20200821123222.32093-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org New Intel laptops with VMD cannot reach deeper power saving state, renders very short battery time. As BIOS may not be able to program the config space for devices under VMD domain, ASPM needs to be programmed manually by software. This is also the case under Windows. The VMD controller itself is a root complex integrated endpoint that doesn't have ASPM capability, so we can't propagate the ASPM settings to devices under it. Hence, simply apply ASPM_STATE_ALL to the links under VMD domain, unsupported states will be cleared out anyway. Signed-off-by: Kai-Heng Feng --- drivers/pci/pcie/aspm.c | 3 ++- drivers/pci/quirks.c | 11 +++++++++++ include/linux/pci.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 253c30cc1967..dcc002dbca19 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -624,7 +624,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) aspm_calc_l1ss_info(link, &upreg, &dwreg); /* Save default state */ - link->aspm_default = link->aspm_enabled; + link->aspm_default = parent->dev_flags & PCI_DEV_FLAGS_ENABLE_ASPM ? + ASPM_STATE_ALL : link->aspm_enabled; /* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support; diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index bdf9b52567e0..2e2f525bd892 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -5632,3 +5632,14 @@ static void apex_pci_fixup_class(struct pci_dev *pdev) } DECLARE_PCI_FIXUP_CLASS_HEADER(0x1ac1, 0x089a, PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class); + +/* + * Device [8086:9a09] + * BIOS may not be able to access config space of devices under VMD domain, so + * it relies on software to enable ASPM for links under VMD. + */ +static void pci_fixup_enable_aspm(struct pci_dev *pdev) +{ + pdev->dev_flags |= PCI_DEV_FLAGS_ENABLE_ASPM; +} +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9a09, pci_fixup_enable_aspm); diff --git a/include/linux/pci.h b/include/linux/pci.h index 835530605c0d..66a45916c7c6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -227,6 +227,8 @@ enum pci_dev_flags { PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10), /* Don't use Relaxed Ordering for TLPs directed at this device */ PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 11), + /* Enable ASPM regardless of how LnkCtl is programmed */ + PCI_DEV_FLAGS_ENABLE_ASPM = (__force pci_dev_flags_t) (1 << 12), }; enum pci_irq_reroute_variant { -- 2.17.1