From akpm@osdl.org Thu Apr 28 00:27:43 2005 Subject: [patch 06/20] acpi bridge hotadd: Take the PCI lock when modifying pci bus or device lists To: greg@kroah.com Cc: akpm@osdl.org, rajesh.shah@intel.com From: akpm@osdl.org Date: Thu, 28 Apr 2005 00:25:48 -0700 From: Rajesh Shah With root bridge and pci bridge hot-plug, new buses and devices can be added or removed at run time. Protect the pci bus and device lists with the pci lock when doing so. Signed-off-by: Rajesh Shah Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletion(-) --- gregkh-2.6.orig/drivers/pci/probe.c 2005-05-03 22:28:23.000000000 -0700 +++ gregkh-2.6/drivers/pci/probe.c 2005-05-03 22:28:25.000000000 -0700 @@ -370,8 +370,11 @@ struct pci_bus *child; child = pci_alloc_child_bus(parent, dev, busnr); - if (child) + if (child) { + spin_lock(&pci_bus_lock); list_add_tail(&child->node, &parent->children); + spin_unlock(&pci_bus_lock); + } return child; } @@ -761,7 +764,9 @@ * and the bus list for fixup functions, etc. */ INIT_LIST_HEAD(&dev->global_list); + spin_lock(&pci_bus_lock); list_add_tail(&dev->bus_list, &bus->devices); + spin_unlock(&pci_bus_lock); return dev; } @@ -882,7 +887,9 @@ pr_debug("PCI: Bus %04x:%02x already known\n", pci_domain_nr(b), bus); goto err_out; } + spin_lock(&pci_bus_lock); list_add_tail(&b->node, &pci_root_buses); + spin_unlock(&pci_bus_lock); memset(dev, 0, sizeof(*dev)); dev->parent = parent; @@ -924,7 +931,9 @@ class_dev_reg_err: device_unregister(dev); dev_reg_err: + spin_lock(&pci_bus_lock); list_del(&b->node); + spin_unlock(&pci_bus_lock); err_out: kfree(dev); kfree(b);