From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 3/3] PCI: mvebu: Reset Root Ports with PERST#
Date: Sun, 06 Dec 2026 09:58:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-252325@kernel.org> (raw)
In-Reply-To: <20261206094043.971494-4-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] PCI: mvebu: mvebu_pcie_reset_root_port() latches reset
failure on link down
--
commit 9255153a273b69b64e256ee53888f19e0a4c1920
Author: Rosen Penev <rosenp@gmail.com>
PCI: mvebu: Reset Root Ports with PERST#
This commit implements reset_root_port() for pci-mvebu so Root Ports with a
reset GPIO pulse PERST# instead of triggering an in-band hot reset, and
factors out the reset-delay-us lookup from mvebu_pcie_powerup().
> 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;
> + }
> +
> + gpiod_set_value_cansleep(port->reset_gpio, 1);
> + /* PERST# must stay asserted for at least 100 us (Tperst) */
> + usleep_range(1000, 2000);
> + gpiod_set_value_cansleep(port->reset_gpio, 0);
> + msleep(mvebu_pcie_port_reset_delay_ms(port));
> +
> + ret = read_poll_timeout(mvebu_pcie_link_up, up, up, 1000,
> + USEC_PER_SEC, false, port);
> + if (ret)
> + dev_warn(&dev->dev, "link down after PERST#\n");
> +
> + return ret;
> +}
[Severity: Medium]
Should mvebu_pcie_reset_root_port() return -ETIMEDOUT when the downstream
link does not come up?
pcibios_reset_secondary_bus() treats any non-zero return from
host->reset_root_port() as a Root Port reset failure:
drivers/pci/pci.c:pcibios_reset_secondary_bus() {
...
if (!test_bit(PCI_ROOT_PORT_RESET_FAILED, &dev->priv_flags))
pci_save_state(dev);
ret = host->reset_root_port(host, dev);
if (ret) {
set_bit(PCI_ROOT_PORT_RESET_FAILED, &dev->priv_flags);
pci_err(dev, "Failed to reset Root Port: %d\n", ret);
} else {
clear_bit(PCI_ROOT_PORT_RESET_FAILED, &dev->priv_flags);
pci_restore_state(dev);
}
...
}
If an empty Root Port with a reset GPIO is reset (for example via sysfs
reset_subordinate), read_poll_timeout() returns -ETIMEDOUT and latches
PCI_ROOT_PORT_RESET_FAILED while pci_bridge_wait_for_secondary_bus() still
returns 0.
When a device is later inserted or rescanned behind that port and reset
again, pcibios_reset_secondary_bus() skips pci_save_state(dev) and restores
the stale empty-slot config space via pci_restore_state(dev).
That clears PCI_COMMAND_MEMORY and PCI_COMMAND_MASTER and causes
mvebu_pcie_handle_membase_change() to delete active MBus decode windows,
leaving the downstream device unreachable.
Returning 0 on link-wait timeout, like rockchip_pcie_rc_reset_root_port()
and qcom_pcie_reset_root_port(), lets pcibios_reset_secondary_bus() restore
Root Port state and leaves downstream readiness checks to
pci_bridge_wait_for_secondary_bus().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261206094043.971494-1-rosenp@gmail.com?part=3
next prev parent reply other threads:[~2026-12-06 9:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-06 9:40 [PATCH v2 0/3] PCI: mvebu: Reset Root Ports with PERST# Rosen Penev
2026-12-06 9:40 ` [PATCH v2 1/3] PCI: Save Root Port state before resetting it with reset_root_port() Rosen Penev
2026-12-06 10:16 ` sashiko-bot
2026-12-06 9:40 ` [PATCH v2 2/3] PCI: Export pci_reset_secondary_bus() Rosen Penev
2026-12-06 9:40 ` [PATCH v2 3/3] PCI: mvebu: Reset Root Ports with PERST# Rosen Penev
2026-12-06 9:58 ` sashiko-bot [this message]
2026-12-06 10:16 ` [PATCH v2 0/3] " 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-252325@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox