From patchwork Sun May 11 20:10:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kenneth R. Crudup" X-Patchwork-Id: 889310 Received: from l2mail1.panix.com (l2mail1.panix.com [166.84.1.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9277419E7D0; Sun, 11 May 2025 20:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.84.1.75 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746995425; cv=none; b=S/Pf++HIYWge0IXqwd1n2F2Ixbe4o64iYwpmicu8Zm84swa0hVLtpMyGkZYubMCa61SOwV3r74HApzfId91itgS5EbyD8sJ8BO6n1ELhU2xBhC2S0Y0XRvety+3pEwANJOSomRUtNwjRJgk1Lhlb+/rH8IKFLIJNJHcxGIgbhV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746995425; c=relaxed/simple; bh=dko0hlc59DADvevFuApFKLXukjCJqFTu+nVdEA3DQMs=; h=Date:From:To:cc:Subject:Message-ID:MIME-Version:Content-Type; b=VkStQhx4+5awKwvITmA4DBEBQimiMQnFzMAJDa0z83SzX+WfyrPm8zJStmUwLKSSoAiEZFj3/oF0/CbDKqS55wvmOKWNJkjb9A+BcF3muKAWh63HgyMNWMMDLkbgIXoLmwoJVo/OVZTo5ZJM9pMuNR9BFFS8xNeTgjn8q6JyzAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=panix.com; spf=pass smtp.mailfrom=panix.com; dkim=pass (1024-bit key) header.d=panix.com header.i=@panix.com header.b=e9f0mwSl; arc=none smtp.client-ip=166.84.1.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=panix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=panix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=panix.com header.i=@panix.com header.b="e9f0mwSl" Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (1024 bits) server-digest SHA256) (No client certificate requested) by l2mail1.panix.com (Postfix) with ESMTPS id 4ZwYky1lfnzDRm; Sun, 11 May 2025 16:10:34 -0400 (EDT) Received: from xps-9320 (ip72-219-82-239.oc.oc.cox.net [72.219.82.239]) by mailbackend.panix.com (Postfix) with ESMTPSA id 4ZwYkp0xm4z1CtP; Sun, 11 May 2025 16:10:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=panix.com; s=panix; t=1746994227; bh=dko0hlc59DADvevFuApFKLXukjCJqFTu+nVdEA3DQMs=; h=Date:From:Reply-To:To:cc:Subject; b=e9f0mwSlSSg8X8hLPiyAk4BkmVl4ND1Gfzskfblydaf4wDfQ0h9hnPjTVkTfdDyQH p6Emmc6OaN6TK+4kSAz1s0Dtpc7CWfGBZmYaAc7m/ZRYN+T2ZPrJv2H9wjOtfrrzBQ UshiE2nePhhEdS3HoMtvJsr9DdVo7fPNuDGnSCR4= Date: Sun, 11 May 2025 13:10:24 -0700 (PDT) From: "Kenneth R. Crudup" Reply-To: "Kenneth R. Crudup" To: rafael@kernel.org, linux-pm@vger.kernel.org cc: Kai-Heng Feng , Vidya Sagar , Bjorn Helgaas , Andrea Righi , You-Sheng Yang , linux-pci@vger.kernel.org, "Kenneth R. Crudup" Subject: Raphael, I'd like your help upstreaming this VMD power-saving patch, please Message-ID: <0b166ece-eeec-ba5d-2212-50d995611cef@panix.com> Errors-To: kenny@panix.com Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hello Raphael, For almost two years now, I've been trying to get patches from Ubuntu that enable ASPM for devices behind Intel's VMD, necessary to get full lower-power states (including very-reduced power usage during s0ix sleep) on my Alderlake (et al.) laptop, upstreamed into mainline. One such thread: https://lore.kernel.org/linux-pm/218aa81f-9c6-5929-578d-8dc15f83dd48@panix.com/ Since the original set of patches on this, most of the work has been pushed upstream, with only this last patch required to get fully into the "CPU%LPI" and "SYS%LPI" (names according to "turbostat") states. I'm surprised that with the number of VMD-enabled laptops out there (which I had to keep on so I could dual-boot into Win11 (the disk geometry changes if I disable it, rendering the Win11 partition useless)), that there haven't been many reports of excessive power usage in Linux during sleep; perhaps because many installations are running stock Ubuntu kernels (where I assume variants of this patch remain) it isn't an issue, but I do believe having this upstreamed is still valuable. I don't have the resources you've got to test this fully for regressions, nor the expertise getting a patch into the kernel, so I'd like to again bring this up for discussion (hence the phone-book of a CC: here). If there's anything I can do to help get this done, please let me know. Thank you, -Kenneth Crudup >From ee3618a598a261bbc8a875557d42d6dbbbc4cdd0 Mon Sep 17 00:00:00 2001 From: "Kenneth R. Crudup" Date: Fri, 13 Dec 2024 15:28:42 -0800 Subject: [PATCH] PCI/ASPM: Fixup ASPM for VMD bridges Effectively a squashed commit of: UBUNTU: SAUCE: PCI/ASPM: Enable ASPM for links under VMD domain UBUNTU: SAUCE: PCI/ASPM: Enable LTR for endpoints behind VMD UBUNTU: SAUCE: vmd: fixup bridge ASPM by driver name instead --- drivers/pci/pcie/aspm.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 29fcb0689a91..fdc1ce2755ff 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -788,6 +788,31 @@ static void aspm_l1ss_init(struct pcie_link_state *link) aspm_calc_l12_info(link, parent_l1ss_cap, child_l1ss_cap); } +/* + * 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 bool pci_fixup_vmd_bridge_enable_aspm(struct pci_dev *pdev) +{ + struct pci_bus *bus = pdev->bus; + struct device *dev; + struct pci_driver *pdrv; + + if (!pci_is_root_bus(bus)) + return false; + + dev = bus->bridge->parent; + if (dev == NULL) + return false; + + pdrv = pci_dev_driver(to_pci_dev(dev)); + if (pdrv == NULL || strcmp("vmd", pdrv->name)) + return false; + + pci_info(pdev, "enable ASPM for pci bridge behind vmd"); + return true; +} + static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) { struct pci_dev *child = link->downstream, *parent = link->pdev; @@ -866,7 +891,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) } /* Save default state */ - link->aspm_default = link->aspm_enabled; + link->aspm_default = pci_fixup_vmd_bridge_enable_aspm(parent) ? + PCIE_LINK_STATE_ASPM_ALL : link->aspm_enabled; /* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support; -- 2.48.1