Re: [PATCH] vfio/pci: Only lock the upstream bridge if the reset may need it

From: Ionut Nechita (Wind River)

Date: Fri Nov 20 2026 - 03:52:14 EST


From: Ionut Nechita <ionut.nechita@xxxxxxxxxxxxx>

On Thu, 19 Nov 2026 14:32:37 -0800, Alex Williamson wrote:
> After exploring Ionut's patch[1], what I propose above is probably
> wrong. We don't have any guarantees that the sibling topology is
> static and this bus-reset-possible function presents it as immutable.

Hi Alex,

Thanks for looking at it. The reproducer hits exactly that case. On
the N3000 the FEC PF and its VFs share a bus, behind the PEX 8747
switch on the card:

0000:b0:11.0 [10b5:8747] upstream bridge
0000:b8:00.0 [8086:0d8f] PF, vfio-pci, reset_method: flr bus
0000:b8:00.1 [8086:0d90] VF, vfio-pci
0000:b8:00.2 [8086:0d90] VF, vfio-pci

"bus" is listed because it was probed when the PF was alone on the
bus. While the VFs exist pci_parent_bus_reset() returns -ENOTTY for
the PF; the sriov_numvfs=0 write that is queued ahead of the PF reset
on the PF device lock removes them, and by the time the reset gets
the lock a bus reset is possible again.

> bool pci_reset_function_needs_bridge_lock(struct pci_dev *dev)
> {
> return pci_upstream_bridge(dev) &&
> !(dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET) && !dev->is_virtfn;
> }

This looks right to me for the VF side, but it doesn't change this
case: the reset is on the PF, which is not a VF and has no
PCI_DEV_FLAGS_NO_BUS_RESET, so the bridge is still locked, even
though the PF has FLR and the reset will most likely be an FLR. My
patch is about what happens when the bridge is locked: today
pci_reset_function() blocks config access to the bridge before it
waits for the device lock of @dev, and that wait can last until the
vfio user releases the VF. Taking both device locks first and
blocking config access only around the reset keeps lspci working
meanwhile.

So I think the two are complementary, and I'm happy to rebase on top
of the helper if it goes in first. I've sent the follow-up for
__pci_bus_lock(), which has the same pattern for bus and slot resets,
separately.

For completeness, the same scenario on a Granite Rapids-D vRAN Boost
(VRB2) accelerator, an RCiEP on a root bus, has no bridge to lock at
all. There the visible symptom was reads of sriov_numvfs on the PF
sleeping behind the SR-IOV disable, which I've also sent a separate
patch for.

Thanks,
Ionut