http://git.kernel.org/?p=linux/kernel/git/konrad/xen.git;a=commitdiff;h=4a65de894fc0af05397eedca180d0ea7d8c6caba#patch1 git/pub/scm / linux/kernel/git/konrad/xen.git / commitdiff ? search: re summary | shortlog | log | commit | commitdiff | tree raw | patch (parent: 621d869) xen-pcifront: Don't race with udev when discovering new devices. author Konrad Rzeszutek Wilk Fri, 23 Jul 2010 14:35:57 +0000 (10:35 -0400) committer Konrad Rzeszutek Wilk Fri, 23 Jul 2010 15:15:56 +0000 (11:15 -0400) We inadvertly would call 'pci_bus_add_device' right after discovering the device, but before claiming the BARs. This ended up firing off a uevent and udev loading the module and the modules failing to request_region as they were not claimed. We fix this by holding off going live by calling 'pci_bus_add_devices' at the end. Signed-off-by: Konrad Rzeszutek Wilk --- linux-2.6.34.1/drivers/xen/pcifront/pci_op.c.orig3 2010-09-29 16:32:08.324675371 +0200 +++ linux-2.6.34.1/drivers/xen/pcifront/pci_op.c 2010-09-29 16:37:23.215674973 +0200 @@ -456,17 +456,10 @@ int __devinit pcifront_scan_bus(struct p } d = pci_scan_single_device(b, devfn); - if (d) { + if (d) dev_info(&pdev->xdev->dev, "New device on " "%04x:%02x:%02x.%02x found.\n", domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - err = pci_bus_add_device(d); - if (err) { - dev_err(&pdev->xdev->dev, "Failed to add " - " device to bus.\n"); - return err; - } - } } return 0; @@ -523,6 +516,7 @@ int __devinit pcifront_scan_root(struct /* Claim resources before going "live" with our devices */ pci_walk_bus(b, pcifront_claim_resource, pdev); + /* Create SysFS and notify udev of the devices. Aka: "going live" */ pci_bus_add_devices(b); @@ -564,6 +558,9 @@ int __devinit pcifront_rescan_root(struc /* Claim resources before going "live" with our devices */ pci_walk_bus(b, pcifront_claim_resource, pdev); + /* Create SysFS and notify udev of the devices. Aka: "going live" */ + pci_bus_add_devices(b); + return err; }