Re: [PATCH v2 09/15] PCI: rcar-gen4: Add Root Port reset support
From: Marek Vasut
Date: Sat Oct 17 2026 - 13:34:49 EST
On 10/5/26 8:14 AM, Koichiro Den wrote:
On Sun, Oct 04, 2026 at 02:11:37AM +0200, Marek Vasut wrote:Excellent!
On 9/28/26 6:52 PM, Koichiro Den wrote:
Implement the host bridge reset_root_port() callback so PCI error
recovery can reset and reinitialize the R-Car controller. This also
provides the reset operation for the link-down handling added later.
Call .reinit() with clocks and PHY initialization retained, restore
the Root Port registers and restart link training.
Rather than tracking which APP interrupt enables survive the power
reset, derive them from software state through a single helper. A flag
keeps the sources masked from the start of a reset until one succeeds,
so a failed reinitialization does not re-enable them against an
uninitialized controller.
Serialize the reset with a mutex, as not all callers hold the Root
Port's device lock: pci_try_reset_function() on a downstream device only
locks that device before falling back to a parent bus reset.
Please pardon my ignorance, but is this maybe something that could be fixed
in the core code ?
Yes. pci_reset_function() has locked the upstream bridge since 7e89efc6e9e4
("PCI: Lock upstream bridge for pci_reset_function()"), but
pci_try_reset_function() and pci_reset_function_locked() still do not. I am not
sure whether this is intentional, but in either case, that is a core matter and
separate from this series.
However: more to the point, your question made me look at this again, and I now
believe the mutex (rcar->reset_lock) was not needed in the first place. Every
path to reset_root_port() already holds a device lock that excludes the others:
- error recovery and bus resets go through pci_bus_lock(), which locks the Root
Port and every device below it, and
- pci_try_reset_function() (even without the upstream bridge locked, as I noted
above) holds the lock of the downstream device, which pci_parent_bus_reset()
only accepts when it is the only device on the bus.
So I will drop the mutex in v3. Thanks for making me look at this again, it
really helps!
Thank you!