From: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: helgaas@kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Dave Jiang <dave.jiang@intel.com>,
Alex Williamson <alex.williamson@redhat.com>,
lukas@wunner.de, sebott@linux.ibm.com, schnelle@linux.ibm.com,
bblock@linux.ibm.com, linux@roeck-us.net,
matthew.brost@intel.com, michal.wajdeczko@intel.com,
piotr.piorkowski@intel.com, dtatulea@nvidia.com, mani@kernel.org,
kbusch@kernel.org, lkml@mageta.org, alifm@linux.ibm.com,
julianr@linux.ibm.com, ionut_n2001@yahoo.com,
sunlightlinux@gmail.com,
Ionut Nechita <ionut.nechita@windriver.com>
Subject: [PATCH 0/1] PCI: Fix lspci hang when a reset waits for a vfio-held device
Date: Thu, 19 Nov 2026 14:35:03 +0200 [thread overview]
Message-ID: <20261119123504.25906-1-ionut.nechita@windriver.com> (raw)
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
next reply other threads:[~2026-11-19 12:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 12:35 Ionut Nechita (Wind River) [this message]
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 22:32 ` Alex Williamson
2026-11-20 16:48 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119123504.25906-1-ionut.nechita@windriver.com \
--to=ionut.nechita@windriver.com \
--cc=alex.williamson@redhat.com \
--cc=alifm@linux.ibm.com \
--cc=bblock@linux.ibm.com \
--cc=bhelgaas@google.com \
--cc=dave.jiang@intel.com \
--cc=dtatulea@nvidia.com \
--cc=helgaas@kernel.org \
--cc=ionut_n2001@yahoo.com \
--cc=julianr@linux.ibm.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lkml@mageta.org \
--cc=lukas@wunner.de \
--cc=mani@kernel.org \
--cc=matthew.brost@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=piotr.piorkowski@intel.com \
--cc=schnelle@linux.ibm.com \
--cc=sebott@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=sunlightlinux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®