From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: mvebu: Reset Root Ports with PERST#
Date: Fri, 04 Dec 2026 06:31:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-249230@kernel.org> (raw)
In-Reply-To: <20261204060752.1243189-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] PCI: mvebu: stale pci_restore_state() clears Root Port
PCIE_CMD_OFF
- [High] PCI: mvebu: unexported pci_reset_secondary_bus() breaks modular
build
--
commit 90009b7c04d34fd6a20b51652628a203f71fd40f
Author: Rosen Penev <rosenp@gmail.com>
PCI: mvebu: Reset Root Ports with PERST#
This commit implements the reset_root_port() callback for mvebu PCIe
Root Ports to pulse PERST# via the port reset GPIO, falling back to
pci_reset_secondary_bus() when no reset GPIO is present.
> diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
> index 4e9544d616226..d5c874d6c2b3a 100644
> --- a/drivers/pci/controller/pci-mvebu.c
> +++ b/drivers/pci/controller/pci-mvebu.c
[ ... ]
> @@ -1397,6 +1403,43 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port)
> clk_disable_unprepare(port->clk);
> }
>
> +/*
> + * Reset the device below a Root Port. The in-band hot reset that
> + * pci_reset_secondary_bus() triggers through the emulated bridge does not
> + * reset every device (some only return to their boot ROM on PERST#), so
> + * pulse PERST# when the port has a reset GPIO.
> + */
> +static int mvebu_pcie_reset_root_port(struct pci_host_bridge *bridge,
> + struct pci_dev *dev)
> +{
> + struct mvebu_pcie *pcie = pci_host_bridge_priv(bridge);
> + struct mvebu_pcie_port *port;
> + bool up;
> + int ret;
> +
> + port = mvebu_pcie_find_port(pcie, dev->bus, dev->devfn);
> + if (!port)
> + return -ENODEV;
> +
> + if (!port->reset_gpio) {
> + pci_reset_secondary_bus(dev);
> + return 0;
> + }
[Severity: High]
Does this break modular builds with CONFIG_PCI_MVEBU=m?
CONFIG_PCI_MVEBU is tristate, but pci_reset_secondary_bus() in
drivers/pci/pci.c is not exported, so building pci-mvebu as a module
fails at modpost with an undefined symbol error.
[ ... ]
> @@ -1622,6 +1665,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
> bridge->child_ops = &mvebu_pcie_child_ops;
> bridge->align_resource = mvebu_pcie_align_resource;
> bridge->map_irq = mvebu_pcie_map_irq;
> + bridge->reset_root_port = mvebu_pcie_reset_root_port;
>
> return pci_host_probe(bridge);
> }
[Severity: High]
Can registering reset_root_port here cause pcibios_reset_secondary_bus()
to clear PCIE_CMD_OFF on the Root Port with stale boot-time state?
Whenever host->reset_root_port() returns 0, the PCI core restores the
Root Port's saved config space:
drivers/pci/pci.c:pcibios_reset_secondary_bus() {
...
if (pci_is_root_bus(dev->bus) && host->reset_root_port) {
ret = host->reset_root_port(host, dev);
if (ret)
pci_err(dev, "Failed to reset Root Port: %d\n", ret);
else
pci_restore_state(dev);
return;
}
...
}
During probe, mvebu_pcie_setup_hw() clears PCI_COMMAND_IO,
PCI_COMMAND_MEMORY, and PCI_COMMAND_MASTER in PCIE_CMD_OFF before
pci_bus_add_device() captures the initial pci_save_state() snapshot.
Even with CONFIG_PCIEPORTBUS enabled, pcie_port_device_register() calls
pci_clear_master() right before pcie_portdrv_probe() saves state because
mvebu_pcie_map_irq() returns 0 for bus 0 and service IRQ allocation
fails.
Later, pci_enable_bridge() enables those bits in hardware and sets
enable_cnt and is_busmaster on the Root Port without updating its saved
state. On any subsequent function or bus reset (including on ports
without reset_gpio), pci_restore_state() writes the stale PCI_COMMAND
back to PCIE_CMD_OFF via mvebu_pci_bridge_emul_base_conf_write(),
clearing bus mastering (and IO/memory decoding when CONFIG_PCIEPORTBUS
is disabled).
Because enable_cnt and is_busmaster remain set in software,
pci_enable_bridge() returns early on endpoint driver rebind and never
re-enables PCIE_CMD_OFF, breaking downstream DMA/MSI and MMIO until
reboot. Calling pci_save_state(dev) before returning from
mvebu_pcie_reset_root_port() would keep the live Root Port state from
being overwritten.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204060752.1243189-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-12-04 6:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:07 [PATCH] PCI: mvebu: Reset Root Ports with PERST# Rosen Penev
2026-12-04 6:31 ` 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=sashiko-outbox-249230@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rosenp@gmail.com \
--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 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.