[PATCH 0/1] PCI: Fix lspci hang when a reset waits for a vfio-held device

From: Ionut Nechita (Wind River)

Date: Thu Nov 19 2026 - 07:36:21 EST


From: Ionut Nechita <ionut.nechita@xxxxxxxxxxxxx>

Hi Bjorn,

When a function reset has to wait for the device lock of the function
being reset, pci_reset_function() keeps config access to the upstream
bridge blocked for the whole wait. If the device lock is held for a long
time, every config read of that bridge sleeps in pci_wait_cfg(), so
lspci, and any tool or agent that runs it, hangs in D state.

We hit this with vfio-pci: a userspace driver keeps a VF open, and a
driver unbind of that VF, a write to sriov_numvfs on the PF and a write
to the PF's "reset" attribute queue up behind each other on the device
locks. The reset is the one that leaves config access to the bridge
blocked. The patch takes both device locks before blocking config
access, so config access is only blocked while the reset itself runs.
The lock order is unchanged.

Testing:
- Reproduced on 6.18.59 (PREEMPT_RT) with an Intel FPGA PAC N3000, PF
and VFs on vfio-pci, one VF held open by a minimal vfio user (opens
the group and gets the device fd). After the unbind, sriov_numvfs=0
and reset writes, a read of the bridge's config file and lspci hang
in pci_wait_cfg() without the patch and complete with it. Killing
the vfio user releases the blocked writes as before.
- Build-tested on pci/next and next-20261118, with and without
PREEMPT_RT (W=1).

Not addressed here:
- __pci_bus_lock() (bus and slot reset) has the same pattern: it blocks
config access to the bridge before taking the device locks below it.
I kept this patch minimal; I can send a follow-up if the approach
looks right.
- The sriov_numvfs write in the scenario above holds
pci_rescan_remove_lock while it waits, so a PCI rescan or another
sriov_numvfs write also waits until the VF is released. That is a
separate issue and not changed by this patch.

Thanks,
Ionut

Ionut Nechita (1):
PCI: Don't block bridge config access while waiting for the device
lock

drivers/pci/pci.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

--
2.55.0