PCI/ACPI: Protect acpi_pci_roots list with mutex
Use mutex to protect acpi_pci_roots list against PCI host bridge hotplug operations. [bhelgaas: s/struct acpi_handle *handle/acpi_handle handle/] Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
0f2bdfedcb
commit
6507e6ebeb
1 changed files with 18 additions and 9 deletions
|
@ -112,12 +112,17 @@ EXPORT_SYMBOL(acpi_pci_unregister_driver);
|
||||||
acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
|
acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
|
||||||
{
|
{
|
||||||
struct acpi_pci_root *root;
|
struct acpi_pci_root *root;
|
||||||
|
acpi_handle handle = NULL;
|
||||||
|
|
||||||
|
mutex_lock(&acpi_pci_root_lock);
|
||||||
list_for_each_entry(root, &acpi_pci_roots, node)
|
list_for_each_entry(root, &acpi_pci_roots, node)
|
||||||
if ((root->segment == (u16) seg) &&
|
if ((root->segment == (u16) seg) &&
|
||||||
(root->secondary.start == (u16) bus))
|
(root->secondary.start == (u16) bus)) {
|
||||||
return root->device->handle;
|
handle = root->device->handle;
|
||||||
return NULL;
|
break;
|
||||||
|
}
|
||||||
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle);
|
EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle);
|
||||||
|
@ -506,8 +511,9 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
|
||||||
* TBD: Need PCI interface for enumeration/configuration of roots.
|
* TBD: Need PCI interface for enumeration/configuration of roots.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* TBD: Locking */
|
mutex_lock(&acpi_pci_root_lock);
|
||||||
list_add_tail(&root->node, &acpi_pci_roots);
|
list_add_tail(&root->node, &acpi_pci_roots);
|
||||||
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
|
|
||||||
printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n",
|
printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n",
|
||||||
acpi_device_name(device), acpi_device_bid(device),
|
acpi_device_name(device), acpi_device_bid(device),
|
||||||
|
@ -526,7 +532,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
|
||||||
"Bus %04x:%02x not present in PCI namespace\n",
|
"Bus %04x:%02x not present in PCI namespace\n",
|
||||||
root->segment, (unsigned int)root->secondary.start);
|
root->segment, (unsigned int)root->secondary.start);
|
||||||
result = -ENODEV;
|
result = -ENODEV;
|
||||||
goto end;
|
goto out_del_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -536,7 +542,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
|
||||||
*/
|
*/
|
||||||
result = acpi_pci_bind_root(device);
|
result = acpi_pci_bind_root(device);
|
||||||
if (result)
|
if (result)
|
||||||
goto end;
|
goto out_del_root;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PCI Routing Table
|
* PCI Routing Table
|
||||||
|
@ -614,9 +620,11 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_del_root:
|
||||||
|
mutex_lock(&acpi_pci_root_lock);
|
||||||
|
list_del(&root->node);
|
||||||
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
end:
|
end:
|
||||||
if (!list_empty(&root->node))
|
|
||||||
list_del(&root->node);
|
|
||||||
kfree(root);
|
kfree(root);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -646,11 +654,12 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
|
||||||
list_for_each_entry(driver, &acpi_pci_drivers, node)
|
list_for_each_entry(driver, &acpi_pci_drivers, node)
|
||||||
if (driver->remove)
|
if (driver->remove)
|
||||||
driver->remove(root);
|
driver->remove(root);
|
||||||
mutex_unlock(&acpi_pci_root_lock);
|
|
||||||
|
|
||||||
device_set_run_wake(root->bus->bridge, false);
|
device_set_run_wake(root->bus->bridge, false);
|
||||||
pci_acpi_remove_bus_pm_notifier(device);
|
pci_acpi_remove_bus_pm_notifier(device);
|
||||||
|
|
||||||
|
list_del(&root->node);
|
||||||
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
kfree(root);
|
kfree(root);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue