All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PCI: Remove redudant call to pci_proc_attach_device()
@ 2026-02-28  7:21 Manivannan Sadhasivam
  2026-03-09 22:50 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Manivannan Sadhasivam @ 2026-02-28  7:21 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, linux-kernel, lukas, kwilczynski, mani,
	Manivannan Sadhasivam, Lorenzo Pieralisi, Shuan He

pci_proc_init() should just initialize the top level procfs directory for
PCI devices and let pci_bus_add_device() add the device specific procfs
attributes later.

But it is also calling pci_proc_attach_device() for each PCI device. This
causes a race condition with pci_bus_add_device(), which may run in
parallel, calling the same API, leading to the below warning spat:

 proc_dir_entry '000c:00/00.0' already registered
 WARNING: CPU: 2 PID: 179 at fs/proc/generic.c:375 proc_register+0xf6/0x180
  proc_register+0xf6/0x180
  proc_create_data+0x3e/0x60
  pci_proc_attach_device+0x74/0x130
  pci_bus_add_device+0x42/0x100
  pci_bus_add_devices+0xc6/0x110

Hence, remove the call to pci_proc_attach_device() from pci_proc_init().

Reported-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reported-by: Shuan He <heshuan@bytedance.com>
Closes: https://lore.kernel.org/linux-pci/20250702155112.40124-1-heshuan@bytedance.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---

Changes in v2:

* Dropped the sysfs change as it is supposed to be replaced by static resources
  change.

NOTE: I don't know if there is any reason to call pci_proc_attach_device()
before pci_bus_add_device(), but it definitely causes a race.

 drivers/pci/proc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index ce36e35681e8..de894ae70e9a 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -463,13 +463,10 @@ int pci_proc_detach_bus(struct pci_bus *bus)
 
 static int __init pci_proc_init(void)
 {
-	struct pci_dev *dev = NULL;
 	proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
 	proc_create_seq("devices", 0, proc_bus_pci_dir,
 		    &proc_bus_pci_devices_op);
 	proc_initialized = 1;
-	for_each_pci_dev(dev)
-		pci_proc_attach_device(dev);
 
 	return 0;
 }
-- 
2.51.0


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

end of thread, other threads:[~2026-05-01  2:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-28  7:21 [PATCH v2] PCI: Remove redudant call to pci_proc_attach_device() Manivannan Sadhasivam
2026-03-09 22:50 ` Bjorn Helgaas
2026-05-01  2:08   ` Krzysztof Wilczyński

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.