Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796365914; b=1IKazdQWBV6yKKN+hlzmheY/PTsxSBvOuqAuBUYTG3j3QFv8b77dqx5vD31D2so1Q6LW +fZWQXd+K2FhehAFNF/3m1kP/MXqRtl61S5Ks5CavBZnnPVbWTo0ifLD8tMczREZRDhru +LXYHN3GLGOzPnAoGUXg4vkFoeiWV2hHbPNkVyahIqd8LER5t+gKqwdrnwNTeJdRpB/2T xwUr0sTDHRhqt/4EId8PNTcvAHXpLgRHrWkbc5WCp0xFxqk+vgMHOuBTTyPa3Qtc8pnVU 9XLgbqEF5tPHDnNmwvuPWWnX2NeJ5TAaizW6QlVJz3fblxgYl+pCKdvAueKLyA+PWqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796365914; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=toqaaIvqreDoyYwf1AQf980wVtdV/rq9HvofENlD7IQ=; b=qjKgqfdMmJiBy9DsNDO47bjkny97HEFNkcz+x/vIm+beezG2FRmSkg1pviQKEB8OWiUZ LgNB8q7/0dMMBAS5khgI1Ff0id3HtV/pMbw0T8bMMZd6Bfs8DFki983JfJ3oyUZJJC0Oj 8powlJ6c0ssy+DcwdUqU3h+2f8G47yeMTjNaEOfQb2J+N4JmfTF7m5CVQa0hhTZf3kg4S c0HvqOeWQcuwjSmJi6Y3DeeRRLiondzVJMLpsBSbphmglXEgbh6/VKi/AkXUOXtLnurrU 3txNsRk/15hmpG3NMUmez+8SUVrKRaZXWwHO62EHFkV6x8fjJ77oUiIXeBSCpP/angQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=llKcP7GV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3070606A322 for ; Fri, 4 Dec 2026 06:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=llKcP7GV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 700391F000CE; Fri, 4 Dec 2026 06:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796365914; bh=toqaaIvqreDoyYwf1AQf980wVtdV/rq9HvofENlD7IQ=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=llKcP7GVC5nD/sbO2xE0vuu+mNZgtUSYmjsaeOkxyEaeVVBqTrSeB/2TahuERX0A+ v3w8e0nY4ZVUfgAtY8b9hYcJUuDFlftP7XkSyMuQFy8ufB3N57rwa1dg+DpL2535xP CFDakoj9neBB5ykFTn3Kljd4wn+Htx4nTCwqlN/KGaZ8fZQ18x6Zfk8fGXHRcuvvvi Ya61BxB5b+Iu8FJDiRL0QwYgHfvt4b3YRX9AWf6l9Q1d+bZzHxIdhdqxDl7TtIXgga jHSLOhQNfWEkrDnl3m/PpK9jN6eH2MunHJh2qhn0DjL4v4EZhwlsNbYHSdNpLv+Ueh ahdjkLdDyZg7Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] PCI: mvebu: Reset Root Ports with PERST# Reply-To: sashiko-reviews@lists.linux.dev To: "Rosen Penev" , linux-pci@vger.kernel.org In-Reply-To: <20261204060752.1243189-1-rosenp@gmail.com> References: <20261204060752.1243189-1-rosenp@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 06:31:54 +0000 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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); > } > =20 > +/* > + * Reset the device below a Root Port. The in-band hot reset that > + * pci_reset_secondary_bus() triggers through the emulated bridge does n= ot > + * 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 =3D pci_host_bridge_priv(bridge); > + struct mvebu_pcie_port *port; > + bool up; > + int ret; > + > + port =3D 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=3Dm? 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 =3D &mvebu_pcie_child_ops; > bridge->align_resource =3D mvebu_pcie_align_resource; > bridge->map_irq =3D mvebu_pcie_map_irq; > + bridge->reset_root_port =3D mvebu_pcie_reset_root_port; > =20 > 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 =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204060752.1243= 189-1-rosenp@gmail.com?part=3D1