Commit 278934bd authored by Bjorn Helgaas's avatar Bjorn Helgaas

Merge branch 'pci/jiang-remove-global-list' into next

* pci/jiang-remove-global-list:
  PCI/ACPI: Use dev_printk(), acpi_handle_print(), pr_xxx() when possible
  PCI/ACPI: Remove unused global list acpi_pci_roots
  PCI/ACPI: Introduce "handle" local for economy of expression
  PCI/ACPI: Combine duplicate adjacent "if" tests
parents 0345d3f8 6dc7d22c
...@@ -65,10 +65,6 @@ static struct acpi_scan_handler pci_root_handler = { ...@@ -65,10 +65,6 @@ static struct acpi_scan_handler pci_root_handler = {
.detach = acpi_pci_root_remove, .detach = acpi_pci_root_remove,
}; };
/* Lock to protect both acpi_pci_roots lists */
static DEFINE_MUTEX(acpi_pci_root_lock);
static LIST_HEAD(acpi_pci_roots);
static DEFINE_MUTEX(osc_lock); static DEFINE_MUTEX(osc_lock);
/** /**
...@@ -381,23 +377,24 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -381,23 +377,24 @@ static int acpi_pci_root_add(struct acpi_device *device,
int result; int result;
struct acpi_pci_root *root; struct acpi_pci_root *root;
u32 flags, base_flags; u32 flags, base_flags;
acpi_handle handle = device->handle;
root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root) if (!root)
return -ENOMEM; return -ENOMEM;
segment = 0; segment = 0;
status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL, status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL,
&segment); &segment);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
printk(KERN_ERR PREFIX "can't evaluate _SEG\n"); dev_err(&device->dev, "can't evaluate _SEG\n");
result = -ENODEV; result = -ENODEV;
goto end; goto end;
} }
/* Check _CRS first, then _BBN. If no _BBN, default to zero. */ /* Check _CRS first, then _BBN. If no _BBN, default to zero. */
root->secondary.flags = IORESOURCE_BUS; root->secondary.flags = IORESOURCE_BUS;
status = try_get_root_bridge_busnr(device->handle, &root->secondary); status = try_get_root_bridge_busnr(handle, &root->secondary);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
/* /*
* We need both the start and end of the downstream bus range * We need both the start and end of the downstream bus range
...@@ -406,33 +403,32 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -406,33 +403,32 @@ static int acpi_pci_root_add(struct acpi_device *device,
* can do is assume [_BBN-0xFF] or [0-0xFF]. * can do is assume [_BBN-0xFF] or [0-0xFF].
*/ */
root->secondary.end = 0xFF; root->secondary.end = 0xFF;
printk(KERN_WARNING FW_BUG PREFIX dev_warn(&device->dev,
"no secondary bus range in _CRS\n"); FW_BUG "no secondary bus range in _CRS\n");
status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, status = acpi_evaluate_integer(handle, METHOD_NAME__BBN,
NULL, &bus); NULL, &bus);
if (ACPI_SUCCESS(status)) if (ACPI_SUCCESS(status))
root->secondary.start = bus; root->secondary.start = bus;
else if (status == AE_NOT_FOUND) else if (status == AE_NOT_FOUND)
root->secondary.start = 0; root->secondary.start = 0;
else { else {
printk(KERN_ERR PREFIX "can't evaluate _BBN\n"); dev_err(&device->dev, "can't evaluate _BBN\n");
result = -ENODEV; result = -ENODEV;
goto end; goto end;
} }
} }
INIT_LIST_HEAD(&root->node);
root->device = device; root->device = device;
root->segment = segment & 0xFFFF; root->segment = segment & 0xFFFF;
strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
device->driver_data = root; device->driver_data = root;
printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", pr_info(PREFIX "%s [%s] (domain %04x %pR)\n",
acpi_device_name(device), acpi_device_bid(device), acpi_device_name(device), acpi_device_bid(device),
root->segment, &root->secondary); root->segment, &root->secondary);
root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle); root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
/* /*
* All supported architectures that use ACPI have support for * All supported architectures that use ACPI have support for
...@@ -445,10 +441,6 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -445,10 +441,6 @@ static int 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.
*/ */
mutex_lock(&acpi_pci_root_lock);
list_add_tail(&root->node, &acpi_pci_roots);
mutex_unlock(&acpi_pci_root_lock);
/* /*
* Scan the Root Bridge * Scan the Root Bridge
* -------------------- * --------------------
...@@ -458,11 +450,11 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -458,11 +450,11 @@ static int acpi_pci_root_add(struct acpi_device *device,
*/ */
root->bus = pci_acpi_scan_root(root); root->bus = pci_acpi_scan_root(root);
if (!root->bus) { if (!root->bus) {
printk(KERN_ERR PREFIX dev_err(&device->dev,
"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 out_del_root; goto end;
} }
/* Indicate support for various _OSC capabilities. */ /* Indicate support for various _OSC capabilities. */
...@@ -501,7 +493,7 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -501,7 +493,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
dev_info(&device->dev, dev_info(&device->dev,
"Requesting ACPI _OSC control (0x%02x)\n", flags); "Requesting ACPI _OSC control (0x%02x)\n", flags);
status = acpi_pci_osc_control_set(device->handle, &flags, status = acpi_pci_osc_control_set(handle, &flags,
OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
dev_info(&device->dev, dev_info(&device->dev,
...@@ -518,8 +510,8 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -518,8 +510,8 @@ static int acpi_pci_root_add(struct acpi_device *device,
"ACPI _OSC request failed (%s), " "ACPI _OSC request failed (%s), "
"returned control mask: 0x%02x\n", "returned control mask: 0x%02x\n",
acpi_format_exception(status), flags); acpi_format_exception(status), flags);
pr_info("ACPI _OSC control for PCIe not granted, " dev_info(&device->dev,
"disabling ASPM\n"); "ACPI _OSC control for PCIe not granted, disabling ASPM\n");
pcie_no_aspm(); pcie_no_aspm();
} }
} else { } else {
...@@ -535,20 +527,14 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -535,20 +527,14 @@ static int acpi_pci_root_add(struct acpi_device *device,
if (system_state != SYSTEM_BOOTING) { if (system_state != SYSTEM_BOOTING) {
pcibios_resource_survey_bus(root->bus); pcibios_resource_survey_bus(root->bus);
pci_assign_unassigned_bus_resources(root->bus); pci_assign_unassigned_bus_resources(root->bus);
}
/* need to after hot-added ioapic is registered */ /* need to after hot-added ioapic is registered */
if (system_state != SYSTEM_BOOTING)
pci_enable_bridges(root->bus); pci_enable_bridges(root->bus);
}
pci_bus_add_devices(root->bus); pci_bus_add_devices(root->bus);
return 1; return 1;
out_del_root:
mutex_lock(&acpi_pci_root_lock);
list_del(&root->node);
mutex_unlock(&acpi_pci_root_lock);
end: end:
kfree(root); kfree(root);
return result; return result;
...@@ -565,9 +551,6 @@ static void acpi_pci_root_remove(struct acpi_device *device) ...@@ -565,9 +551,6 @@ static void acpi_pci_root_remove(struct acpi_device *device)
pci_remove_root_bus(root->bus); pci_remove_root_bus(root->bus);
mutex_lock(&acpi_pci_root_lock);
list_del(&root->node);
mutex_unlock(&acpi_pci_root_lock);
kfree(root); kfree(root);
} }
...@@ -587,12 +570,13 @@ static void handle_root_bridge_insertion(acpi_handle handle) ...@@ -587,12 +570,13 @@ static void handle_root_bridge_insertion(acpi_handle handle)
struct acpi_device *device; struct acpi_device *device;
if (!acpi_bus_get_device(handle, &device)) { if (!acpi_bus_get_device(handle, &device)) {
printk(KERN_DEBUG "acpi device exists...\n"); dev_printk(KERN_DEBUG, &device->dev,
"acpi device already exists; ignoring notify\n");
return; return;
} }
if (acpi_bus_scan(handle)) if (acpi_bus_scan(handle))
printk(KERN_ERR "cannot add bridge to acpi list\n"); acpi_handle_err(handle, "cannot add bridge to acpi list\n");
} }
static void handle_root_bridge_removal(struct acpi_device *device) static void handle_root_bridge_removal(struct acpi_device *device)
...@@ -621,7 +605,6 @@ static void handle_root_bridge_removal(struct acpi_device *device) ...@@ -621,7 +605,6 @@ static void handle_root_bridge_removal(struct acpi_device *device)
static void _handle_hotplug_event_root(struct work_struct *work) static void _handle_hotplug_event_root(struct work_struct *work)
{ {
struct acpi_pci_root *root; struct acpi_pci_root *root;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER };
struct acpi_hp_work *hp_work; struct acpi_hp_work *hp_work;
acpi_handle handle; acpi_handle handle;
u32 type; u32 type;
...@@ -633,13 +616,12 @@ static void _handle_hotplug_event_root(struct work_struct *work) ...@@ -633,13 +616,12 @@ static void _handle_hotplug_event_root(struct work_struct *work)
acpi_scan_lock_acquire(); acpi_scan_lock_acquire();
root = acpi_pci_find_root(handle); root = acpi_pci_find_root(handle);
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
switch (type) { switch (type) {
case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_BUS_CHECK:
/* bus enumerate */ /* bus enumerate */
printk(KERN_DEBUG "%s: Bus check notify on %s\n", __func__, acpi_handle_printk(KERN_DEBUG, handle,
(char *)buffer.pointer); "Bus check notify on %s\n", __func__);
if (!root) if (!root)
handle_root_bridge_insertion(handle); handle_root_bridge_insertion(handle);
...@@ -647,28 +629,28 @@ static void _handle_hotplug_event_root(struct work_struct *work) ...@@ -647,28 +629,28 @@ static void _handle_hotplug_event_root(struct work_struct *work)
case ACPI_NOTIFY_DEVICE_CHECK: case ACPI_NOTIFY_DEVICE_CHECK:
/* device check */ /* device check */
printk(KERN_DEBUG "%s: Device check notify on %s\n", __func__, acpi_handle_printk(KERN_DEBUG, handle,
(char *)buffer.pointer); "Device check notify on %s\n", __func__);
if (!root) if (!root)
handle_root_bridge_insertion(handle); handle_root_bridge_insertion(handle);
break; break;
case ACPI_NOTIFY_EJECT_REQUEST: case ACPI_NOTIFY_EJECT_REQUEST:
/* request device eject */ /* request device eject */
printk(KERN_DEBUG "%s: Device eject notify on %s\n", __func__, acpi_handle_printk(KERN_DEBUG, handle,
(char *)buffer.pointer); "Device eject notify on %s\n", __func__);
if (root) if (root)
handle_root_bridge_removal(root->device); handle_root_bridge_removal(root->device);
break; break;
default: default:
printk(KERN_WARNING "notify_handler: unknown event type 0x%x for %s\n", acpi_handle_warn(handle,
type, (char *)buffer.pointer); "notify_handler: unknown event type 0x%x\n",
type);
break; break;
} }
acpi_scan_lock_release(); acpi_scan_lock_release();
kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ kfree(hp_work); /* allocated in handle_hotplug_event_bridge */
kfree(buffer.pointer);
} }
static void handle_hotplug_event_root(acpi_handle handle, u32 type, static void handle_hotplug_event_root(acpi_handle handle, u32 type,
...@@ -682,9 +664,6 @@ static acpi_status __init ...@@ -682,9 +664,6 @@ static acpi_status __init
find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
{ {
acpi_status status; acpi_status status;
char objname[64];
struct acpi_buffer buffer = { .length = sizeof(objname),
.pointer = objname };
int *count = (int *)context; int *count = (int *)context;
if (!acpi_is_root_bridge(handle)) if (!acpi_is_root_bridge(handle))
...@@ -692,16 +671,15 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -692,16 +671,15 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
(*count)++; (*count)++;
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
handle_hotplug_event_root, NULL); handle_hotplug_event_root, NULL);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
printk(KERN_DEBUG "acpi root: %s notify handler is not installed, exit status: %u\n", acpi_handle_printk(KERN_DEBUG, handle,
objname, (unsigned int)status); "notify handler is not installed, exit status: %u\n",
(unsigned int)status);
else else
printk(KERN_DEBUG "acpi root: %s notify handler is installed\n", acpi_handle_printk(KERN_DEBUG, handle,
objname); "notify handler is installed\n");
return AE_OK; return AE_OK;
} }
......
...@@ -472,7 +472,6 @@ int register_acpi_bus_type(struct acpi_bus_type *); ...@@ -472,7 +472,6 @@ int register_acpi_bus_type(struct acpi_bus_type *);
int unregister_acpi_bus_type(struct acpi_bus_type *); int unregister_acpi_bus_type(struct acpi_bus_type *);
struct acpi_pci_root { struct acpi_pci_root {
struct list_head node;
struct acpi_device * device; struct acpi_device * device;
struct pci_bus *bus; struct pci_bus *bus;
u16 segment; u16 segment;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment