From: Bjorn Helgaas <helgaas@kernel.org>
To: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Lukas Wunner" <lukas@wunner.de>,
"Shuan He" <heshuan@bytedance.com>,
linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI/proc: Fix race between pci_proc_init() and pci_bus_add_device()
Date: Fri, 1 May 2026 14:37:21 -0500 [thread overview]
Message-ID: <20260501193721.GA511830@bhelgaas> (raw)
In-Reply-To: <20260501010127.GA990551@rocinante>
On Fri, May 01, 2026 at 10:22:56AM +0900, Krzysztof Wilczyński wrote:
> Hello,
>
> > Thus, wrap the for_each_pci_dev() loop with pci_lock_rescan_remove() to
> > serialise against concurrent PCI bus operations. Add an early return in
> > pci_proc_attach_device() when dev->procent is already set, making the
> > function idempotent and symmetric with pci_proc_detach_device() which
> > clears this field.
>
> A note on testing:
>
> 0-day bot (recent test runs; newer builds will arrive later):
> - https://lore.kernel.org/linux-pci/202603162306.2oKy0qcP-lkp@intel.com
>
> Sashiko's feedback:
> - https://sashiko.dev/#/patchset/20260430003542.455198-1-kwilczynski%40kernel.org
>
> Lorenzo Pieralisi did some testing reported outside the mailing list (we
> talked on IRC) on the platform he had some boot issues. With this patch
> applied, the problems seen before were resolved.
Thanks! Can we include a link to the problem report and maybe a
couple lines of the symptoms?
Also the analysis of Sashiko feedback?
Sashiko worried about pci_lock_rescan_remove() deadlock between
pci_proc_init() and PCI controller drivers with async probing.
pci_proc_init() is a device initcall. Some drivers are also device
initcalls (imx_pcie_init(), ks_pcie_init(), rcar_pcie_init()), and it
looks like they can use async probing.
Does this rely on the pci_proc_init() device_initcall happening before
any of the driver device_initcalls? That would be non-obvious and
fragile.
The second sashiko issue (concurrent calls of
pci_proc_attach_device()) also seems worth a look. The
pci_enable_sriov() path isn't serialized by pci_lock_rescan_remove():
pci_enable_sriov
sriov_enable
sriov_add_vfs
pci_iov_add_virtfn
pci_bus_add_device
pci_proc_attach_device
bus->procdir = proc_mkdir()
If two threads race for devices on the same bus, it looks like the
loser can set bus->procdir back to NULL when proc_mkdir() fails with
"duplicate entry".
This is a per-device path, but we're creating a per-bus directory. I
wonder if that proc_mkdir() could/should be done in a bus creation
path?
next prev parent reply other threads:[~2026-05-01 19:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 0:35 [PATCH] PCI/proc: Fix race between pci_proc_init() and pci_bus_add_device() Krzysztof Wilczyński
2026-05-01 1:22 ` Krzysztof Wilczyński
2026-05-01 19:37 ` Bjorn Helgaas [this message]
2026-05-05 9:47 ` Lorenzo Pieralisi
2026-05-05 23:53 ` Krzysztof Wilczyński
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=20260501193721.GA511830@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=heshuan@bytedance.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kwilczynski@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=lukas@wunner.de \
--cc=mani@kernel.org \
/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