From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: pciehp: Disable link and turn off slot power while removing
Date: Wed, 06 May 2026 20:58:25 +0000 [thread overview]
Message-ID: <20260506205825.C75DDC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260506164353.1278571-1-mario.limonciello@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Unconditional slot power-off in `pciehp_release_ctrl()` abruptly cuts power to active devices, causing kernel crashes.
- [Low] Dead code in `pciehp_power_off_slot()` due to `pciehp_link_disable()` always returning 0.
--
commit 5574c68659aab56ef2cf2ec6acc4c999a6afa1fc
Author: Mario Limonciello (AMD) <superm1@kernel.org>
PCI: pciehp: Disable link and turn off slot power while removing
This commit adds code to pciehp_power_off_slot() to disable the link
before turning off slot power. It also introduces a cleanup sequence
in pciehp_release_ctrl() to disable the link and turn off slot power
during driver removal.
> diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
> index 4c62140a3cb44..6705dcaf1ad0c 100644
> --- a/drivers/pci/hotplug/pciehp_hpc.c
> +++ b/drivers/pci/hotplug/pciehp_hpc.c
[ ... ]
> @@ -558,6 +563,12 @@ int pciehp_power_on_slot(struct controller *ctrl)
>
> void pciehp_power_off_slot(struct controller *ctrl)
> {
> + int retval;
> +
> + retval = pciehp_link_disable(ctrl);
> + if (retval)
> + ctrl_err(ctrl, "%s: Can not disable the link!\n", __func__);
Since pciehp_link_disable() calls __pciehp_link_set() which unconditionally
returns 0, will this error path ever be executed?
> +
> pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC);
> ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
> pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
[ ... ]
> @@ -1096,6 +1107,8 @@ struct controller *pcie_init(struct pcie_device *dev)
> void pciehp_release_ctrl(struct controller *ctrl)
> {
> cancel_delayed_work_sync(&ctrl->button_work);
> + if (POWER_CTRL(ctrl))
> + pciehp_power_off_slot(ctrl);
> kfree(ctrl);
> }
If the pciehp driver is unbound manually or encounters an error during
probe, could this unconditionally cut power to active devices?
Since pciehp is a port service, unbinding it removes hotplug monitoring
but does not detach the active child PCIe devices (such as NVMe drives)
from the PCI core.
If pciehp_release_ctrl() is called while child drivers are still bound and
running, does this lead to unexpected link down events and unsupported
requests?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260506164353.1278571-1-mario.limonciello@amd.com?part=1
prev parent reply other threads:[~2026-05-06 20:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 16:43 [PATCH] PCI: pciehp: Disable link and turn off slot power while removing Mario Limonciello
2026-05-06 17:55 ` Lukas Wunner
2026-05-06 19:16 ` Mario Limonciello
2026-05-07 4:26 ` Lukas Wunner
2026-05-07 5:03 ` Mario Limonciello
2026-05-06 20:58 ` sashiko-bot [this message]
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=20260506205825.C75DDC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=sashiko@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