From: sashiko-bot@kernel.org
To: "Yaxiong Tian" <tianyaxiong@kylinos.cn>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH 3/3] PCI/ASPM: Disable ASPM left on by firmware after a HEADER quirk
Date: Fri, 27 Nov 2026 02:32:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-236455@kernel.org> (raw)
In-Reply-To: <20261127021345.149857-1-tianyaxiong@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] PCI/ASPM: pcie_aspm_cap_init() leaves ASPM on and state bogus
under powersave
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] PCI/ASPM: null pointer dereference in pcie_aspm_cap_init() [1]
--
commit 9e8cf781eb78db18fccd661446c689e036882231
Author: Yaxiong Tian <tianyaxiong@kylinos.cn>
PCI/ASPM: Disable ASPM left on by firmware after a HEADER quirk
When cached L0s and L1 support have no overlap between the two ends of a
link, pcie_aspm_cap_init() marks all ASPM states enabled and disabled so
a subsequent pcie_config_aspm_path() clears LNKCTL.ASPMC.
> diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
> index 6dbae7985bdc0..dc400cddf13c6 100644
> --- a/drivers/pci/pcie/aspm.c
> +++ b/drivers/pci/pcie/aspm.c
> @@ -955,12 +955,19 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
> }
>
> /*
> - * If ASPM not supported, don't mess with the clocks and link,
> - * bail out now.
> + * If ASPM not supported, don't compute anything else here. Mark all
> + * states enabled and disabled so that the next
> + * pcie_config_aspm_path() writes ASPMC=0 instead of returning early,
> + * the same way the blacklist case has always worked: the cached
> + * support may have been removed by a HEADER quirk while firmware left
> + * ASPM enabled on hardware that does implement it.
> */
> if (!(parent->aspm_l0s_support && child->aspm_l0s_support) &&
> - !(parent->aspm_l1_support && child->aspm_l1_support))
> + !(parent->aspm_l1_support && child->aspm_l1_support)) {
[Severity: High]
This problem wasn't introduced by this patch, but can child be NULL here
[1]?
alloc_pcie_link_state() sets link->downstream via pci_function_0(), which
returns NULL when the subordinate bus has no function 0 (for example with
pci=pcie_scan_all or a non-standard topology), and pcie_aspm_cap_init()
dereferences child without checking it.
> + link->aspm_enabled = PCIE_LINK_STATE_ASPM_ALL;
> + link->aspm_disable = PCIE_LINK_STATE_ASPM_ALL;
> return;
> + }
[Severity: Medium]
Does relying on a later pcie_config_aspm_path() call leave firmware ASPM
enabled in hardware and link->aspm_enabled set to PCIE_LINK_STATE_ASPM_ALL
when aspm_policy is POLICY_POWERSAVE or POLICY_POWER_SUPERSAVE?
drivers/pci/pcie/aspm.c:pcie_aspm_init_link_state() {
...
if (aspm_policy != POLICY_POWERSAVE &&
aspm_policy != POLICY_POWER_SUPERSAVE) {
pcie_config_aspm_path(link);
pcie_set_clkpm(link, policy_to_clkpm_state(link));
}
...
}
Under those policies pcie_config_aspm_path() is skipped during enumeration
and only runs when do_pci_enable_device() calls
pcie_aspm_powersave_config_link() on a downstream device. For a quirked
[1b21:1080] PCIe-to-PCI bridge with no enabled downstream device (or an
unbound endpoint behind a [1957:0451] Root Port), LNKCTL.ASPMC is never
cleared and pci_save_state() in pci_bus_add_device() saves the
firmware-enabled ASPMC bits.
Until pcie_config_aspm_path() runs, link->aspm_enabled also remains
PCIE_LINK_STATE_ASPM_ALL on every link without L0s/L1 support, so
pcie_aspm_enabled() returns true. If acpi_pci_root_add() calls
pcie_no_aspm() after pci_acpi_scan_root(), pcie_aspm_powersave_config_link()
returns early on aspm_disabled and link->aspm_enabled stays non-zero
permanently.
[1] https://sashiko.dev/#/bug/linux-3d180a28-89c5-4a58-99c3-db524bb384ac
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127021128.147354-1-tianyaxiong@kylinos.cn?part=3
next prev parent reply other threads:[~2026-11-27 2:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 2:11 [PATCH 0/3] PCI/ASPM: keep software state and hardware in sync Yaxiong Tian
2026-11-27 2:13 ` [PATCH 1/3] PCI/ASPM: Only update ASPM and CLKREQ bits in the saved LNKCTL Yaxiong Tian
2026-11-27 2:13 ` [PATCH 2/3] PCI/ASPM: Update saved LNKCTL for every function of the link Yaxiong Tian
2026-11-27 2:13 ` [PATCH 3/3] PCI/ASPM: Disable ASPM left on by firmware after a HEADER quirk Yaxiong Tian
2026-11-27 2:32 ` sashiko-bot [this message]
2026-11-27 2:33 ` [PATCH 0/3] PCI/ASPM: keep software state and hardware in sync sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-236455@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tianyaxiong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.