From: sashiko-bot@kernel.org
To: "Birk Skyum" <birk.skyum@pm.me>
Cc: linux-pci@vger.kernel.org
Subject: Re: [RFC PATCH] PCI: dwc: Power the controller down when hibernating
Date: Fri, 09 Oct 2026 20:36:06 +0000 [thread overview]
Message-ID: <sashiko-outbox-166041@kernel.org> (raw)
In-Reply-To: <179157746908.73485.2343672865542690797@pm.me>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pci: hibernation S4 WOL and thaw broken by short-circuited D3cold check
--
commit fefc3f1865b9c97f0642e5cbcd08bb6b0f27167f
Author: Birk Skyum <birk.skyum@pm.me>
PCI: dwc: Power the controller down when hibernating
This commit modifies dw_pcie_suspend_noirq() to power down the controller
during hibernation by checking pm_suspend_in_progress(). This ensures that a
hibernation image resumed after a power cycle does not crash when the kernel
reads uninitialized DBI registers.
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index 77aa79ef0ccf8..458e4c6e798b0 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
[ ... ]
> @@ -1231,7 +1232,14 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci)
> if (!dw_pcie_link_up(pci))
> goto stop_link;
>
> - if (!pci_host_common_d3cold_possible(pci->pp.bridge, &pme_capable))
> + /*
> + * Leaving the controller powered is only safe if it keeps its state
> + * until resume. A hibernation image is resumed after a power cycle, by
> + * a kernel that may not have brought this controller up, so only a
> + * suspend may leave it powered.
> + */
> + if (pm_suspend_in_progress() &&
> + !pci_host_common_d3cold_possible(pci->pp.bridge, &pme_capable))
> return 0;
[Severity: High]
Does this short-circuiting && operator cause issues during hibernation?
During hibernation phases (poweroff_noirq and freeze_noirq),
pm_suspend_in_progress() returns false. This causes the && operator to
short-circuit, skipping the call to pci_host_common_d3cold_possible().
Because of this, pme_capable remains at its default uninitialized value of
false. Later in dw_pcie_suspend_noirq(), pci->pp.skip_pwrctrl_off is assigned
the value of pme_capable:
stop_link:
...
pci->pp.skip_pwrctrl_off = pme_capable;
dw_pcie_stop_link(pci);
Since pme_capable is unconditionally false, pci_pwrctrl_power_off_devices()
will force cutting auxiliary power.
This completely breaks S4 Wake-on-LAN and wipes endpoint hardware state during
the freeze phase, violating the core PM contract that thaw operates on preserved
hardware state. Endpoints lacking D3cold support will crash or fail to resume
during the thaw phase.
>
> if (pci->pp.ops->pme_turn_off) {
--
Sashiko AI review · https://sashiko.dev/#/patchset/179157746908.73485.2343672865542690797@pm.me?part=1
next prev parent reply other threads:[~2026-10-09 20:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 20:24 [RFC PATCH] PCI: dwc: Power the controller down when hibernating Birk Skyum
2026-10-09 20:36 ` sashiko-bot [this message]
2026-10-09 21:07 ` Birk Skyum
2026-10-12 8:48 ` Krishna Chaitanya Chundru
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-166041@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=birk.skyum@pm.me \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox