Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/1] PCI: Fix lspci hang when a reset waits for a vfio-held device
@ 2026-11-19 12:35 Ionut Nechita (Wind River)
  2026-11-19 12:35 ` [PATCH 1/1] PCI: Don't block bridge config access while waiting for the device lock Ionut Nechita (Wind River)
  0 siblings, 1 reply; 3+ messages in thread
From: Ionut Nechita (Wind River) @ 2026-11-19 12:35 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: helgaas, linux-pci, linux-kernel, stable, Dave Jiang,
	Alex Williamson, lukas, sebott, schnelle, bblock, linux,
	matthew.brost, michal.wajdeczko, piotr.piorkowski, dtatulea, mani,
	kbusch, lkml, alifm, julianr, ionut_n2001, sunlightlinux,
	Ionut Nechita

From: Ionut Nechita <ionut.nechita@windriver.com>

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-19 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 12:35 [PATCH 0/1] PCI: Fix lspci hang when a reset waits for a vfio-held device Ionut Nechita (Wind River)
2026-11-19 12:35 ` [PATCH 1/1] PCI: Don't block bridge config access while waiting for the device lock Ionut Nechita (Wind River)
2026-11-19 12:43   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox