pci_bus_add_device() called pcibios_bus_add_device() or
> There can be two different race conditions: > function more times for same pci device throws above error message. > of these functions calls pci_create_sysfs_dev_files() and calling this > condition between pci_bus_add_device() and pci_sysfs_init() calls.
> I looked at it deeper and found out that in PCI subsystem code is race > I see following error message in dmesg which looks like a race condition: On Thursday 16 July 2020 13:04:23 Pali Rohár wrote: Hello! I would like to remind this issue which I reported month ago. 14:41 ` Pali Rohár 1 sibling, 1 reply 25+ messages in thread 11:04 PCI: Race condition in pci_create_sysfs_dev_files Pali 8:08 ` Pali Rohár
* Re: PCI: Race condition in pci_create_sysfs_dev_files Static inline void pci_create_firmware_label_files(struct pci_dev *pdev) #if !defined(CONFIG_DMI) & !defined(CONFIG_ACPI) Void pci_remove_sysfs_dev_files(struct pci_dev *pdev) +int pci_create_sysfs_dev_files(struct pci_dev *pdev, bool sysfs_initializing) int pci_create_sysfs_dev_files(struct pci_dev *pdev) * Functions internal to the PCI core code */ +++ -19,7 +19,7 bool pcie_cap_has_rtctl(const struct pci_dev *dev) + retval = pci_create_sysfs_dev_files(pdev, true) ĭiff -git a/drivers/pci/pci.h b/drivers/pci/pci.h retval = pci_create_sysfs_dev_files(pdev) + if (!sysfs_initializing & !sysfs_initialized) +int _must_check pci_create_sysfs_dev_files(struct pci_dev *pdev, bool sysfs_initializing) int _must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) + pci_create_sysfs_dev_files(dev, false) ĭiff -git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
AfterĪpplying it I'm not getting that 'sysfs: cannot create duplicate filename'Ĭan you look at it how to fix both race conditions in proper way?ĭiff -git a/drivers/pci/bus.c b/drivers/pci/bus.c I workaround both race conditions I created following hack patch. Pci_create_sysfs_dev_files() is again called two times. Pci_create_sysfs_dev_files() also for this newly registered device. Pci_sysfs_init() continues execution and calls function Pci_create_sysfs_dev_files() and registers sysfs files. Registers new PCI device and calls pci_bus_add_device() which calls Which unblock calling pci_create_sysfs_dev_files(). Pci_bus_add_device() and once from pci_sysfs_init().Ģ. Pci_create_sysfs_dev_files() is called two times, ones from Meanwhile pci_sysfs_init() is running and pci_create_sysfs_dev_files() Pci_fixup_device() but have not called pci_create_sysfs_dev_files() yet. There can be two different race conditions:ġ. Of these functions calls pci_create_sysfs_dev_files() and calling thisįunction more times for same pci device throws above error message. I looked at it deeper and found out that in PCI subsystem code is raceĬondition between pci_bus_add_device() and pci_sysfs_init() calls. I see following error message in dmesg which looks like a race condition: To: Bjorn Helgaas, linux-pci, linux-kernel
14:41 ` Pali Rohár 0 siblings, 2 replies 25+ messages in thread PCI: Race condition in pci_create_sysfs_dev_files All of help / color / mirror / Atom feed * PCI: Race condition in pci_create_sysfs_dev_files 11:04 Pali Rohár