Commit 05508270 authored by Bjorn Helgaas's avatar Bjorn Helgaas

Merge branch 'pci/taku-prt-cleanup' into next

* pci/taku-prt-cleanup:
  PCI/ACPI: Request _OSC control before scanning PCI root bus
  PCI: Don't pass pci_dev to pci_ext_cfg_avail()
  PCI/ACPI: Add _PRT interrupt routing info before enumerating devices
  ACPI: Pass segment/bus to _PRT add/del so they don't depend on pci_bus
parents fa20f6f2 8c33f51d
...@@ -626,7 +626,7 @@ void pcibios_disable_device (struct pci_dev *dev) ...@@ -626,7 +626,7 @@ void pcibios_disable_device (struct pci_dev *dev)
pcibios_disable_irq(dev); pcibios_disable_irq(dev);
} }
int pci_ext_cfg_avail(struct pci_dev *dev) int pci_ext_cfg_avail(void)
{ {
if (raw_pci_ext_ops) if (raw_pci_ext_ops)
return 1; return 1;
......
...@@ -49,7 +49,7 @@ static int acpi_pci_unbind(struct acpi_device *device) ...@@ -49,7 +49,7 @@ static int acpi_pci_unbind(struct acpi_device *device)
if (!dev->subordinate) if (!dev->subordinate)
goto out; goto out;
acpi_pci_irq_del_prt(dev->subordinate); acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number);
device->ops.bind = NULL; device->ops.bind = NULL;
device->ops.unbind = NULL; device->ops.unbind = NULL;
...@@ -63,7 +63,7 @@ static int acpi_pci_bind(struct acpi_device *device) ...@@ -63,7 +63,7 @@ static int acpi_pci_bind(struct acpi_device *device)
{ {
acpi_status status; acpi_status status;
acpi_handle handle; acpi_handle handle;
struct pci_bus *bus; unsigned char bus;
struct pci_dev *dev; struct pci_dev *dev;
dev = acpi_get_pci_dev(device->handle); dev = acpi_get_pci_dev(device->handle);
...@@ -100,11 +100,11 @@ static int acpi_pci_bind(struct acpi_device *device) ...@@ -100,11 +100,11 @@ static int acpi_pci_bind(struct acpi_device *device)
goto out; goto out;
if (dev->subordinate) if (dev->subordinate)
bus = dev->subordinate; bus = dev->subordinate->number;
else else
bus = dev->bus; bus = dev->bus->number;
acpi_pci_irq_add_prt(device->handle, bus); acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus);
out: out:
pci_dev_put(dev); pci_dev_put(dev);
......
...@@ -184,7 +184,7 @@ static void do_prt_fixups(struct acpi_prt_entry *entry, ...@@ -184,7 +184,7 @@ static void do_prt_fixups(struct acpi_prt_entry *entry,
} }
} }
static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
struct acpi_pci_routing_table *prt) struct acpi_pci_routing_table *prt)
{ {
struct acpi_prt_entry *entry; struct acpi_prt_entry *entry;
...@@ -198,8 +198,8 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, ...@@ -198,8 +198,8 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
* 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
* it here. * it here.
*/ */
entry->id.segment = pci_domain_nr(bus); entry->id.segment = segment;
entry->id.bus = bus->number; entry->id.bus = bus;
entry->id.device = (prt->address >> 16) & 0xFFFF; entry->id.device = (prt->address >> 16) & 0xFFFF;
entry->pin = prt->pin + 1; entry->pin = prt->pin + 1;
...@@ -244,7 +244,7 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, ...@@ -244,7 +244,7 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
return 0; return 0;
} }
int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
{ {
acpi_status status; acpi_status status;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
...@@ -273,7 +273,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) ...@@ -273,7 +273,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus)
entry = buffer.pointer; entry = buffer.pointer;
while (entry && (entry->length > 0)) { while (entry && (entry->length > 0)) {
acpi_pci_irq_add_entry(handle, bus, entry); acpi_pci_irq_add_entry(handle, segment, bus, entry);
entry = (struct acpi_pci_routing_table *) entry = (struct acpi_pci_routing_table *)
((unsigned long)entry + entry->length); ((unsigned long)entry + entry->length);
} }
...@@ -282,17 +282,16 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) ...@@ -282,17 +282,16 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus)
return 0; return 0;
} }
void acpi_pci_irq_del_prt(struct pci_bus *bus) void acpi_pci_irq_del_prt(int segment, int bus)
{ {
struct acpi_prt_entry *entry, *tmp; struct acpi_prt_entry *entry, *tmp;
printk(KERN_DEBUG printk(KERN_DEBUG
"ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
pci_domain_nr(bus), bus->number); segment, bus);
spin_lock(&acpi_prt_lock); spin_lock(&acpi_prt_lock);
list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) { list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
if (pci_domain_nr(bus) == entry->id.segment if (segment == entry->id.segment && bus == entry->id.bus) {
&& bus->number == entry->id.bus) {
list_del(&entry->list); list_del(&entry->list);
kfree(entry); kfree(entry);
} }
......
...@@ -454,6 +454,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -454,6 +454,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
acpi_handle handle; acpi_handle handle;
struct acpi_device *child; struct acpi_device *child;
u32 flags, base_flags; u32 flags, base_flags;
bool is_osc_granted = false;
root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root) if (!root)
...@@ -501,52 +502,10 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -501,52 +502,10 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
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;
root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
/*
* All supported architectures that use ACPI have support for
* PCI domains, so we indicate this in _OSC support capabilities.
*/
flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
acpi_pci_osc_support(root, flags);
/*
* 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);
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),
root->segment, &root->secondary); root->segment, &root->secondary);
/*
* Scan the Root Bridge
* --------------------
* Must do this prior to any attempt to bind the root device, as the
* PCI namespace does not get created until this call is made (and
* thus the root bridge's pci_dev does not exist).
*/
root->bus = pci_acpi_scan_root(root);
if (!root->bus) {
printk(KERN_ERR PREFIX
"Bus %04x:%02x not present in PCI namespace\n",
root->segment, (unsigned int)root->secondary.start);
result = -ENODEV;
goto out_del_root;
}
/*
* Attach ACPI-PCI Context
* -----------------------
* Thus binding the ACPI and PCI devices.
*/
result = acpi_pci_bind_root(device);
if (result)
goto out_del_root;
/* /*
* PCI Routing Table * PCI Routing Table
* ----------------- * -----------------
...@@ -554,32 +513,36 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -554,32 +513,36 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
*/ */
status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
if (ACPI_SUCCESS(status)) if (ACPI_SUCCESS(status))
result = acpi_pci_irq_add_prt(device->handle, root->bus); result = acpi_pci_irq_add_prt(device->handle, root->segment,
root->secondary.start);
root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
/* /*
* Scan and bind all _ADR-Based Devices * All supported architectures that use ACPI have support for
* PCI domains, so we indicate this in _OSC support capabilities.
*/ */
list_for_each_entry(child, &device->children, node) flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
acpi_pci_bridge_scan(child); acpi_pci_osc_support(root, flags);
/* Indicate support for various _OSC capabilities. */ /* Indicate support for various _OSC capabilities. */
if (pci_ext_cfg_avail(root->bus->self)) if (pci_ext_cfg_avail())
flags |= OSC_EXT_PCI_CONFIG_SUPPORT; flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
if (pcie_aspm_support_enabled()) if (pcie_aspm_support_enabled()) {
flags |= OSC_ACTIVE_STATE_PWR_SUPPORT | flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
OSC_CLOCK_PWR_CAPABILITY_SUPPORT; OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
}
if (pci_msi_enabled()) if (pci_msi_enabled())
flags |= OSC_MSI_SUPPORT; flags |= OSC_MSI_SUPPORT;
if (flags != base_flags) { if (flags != base_flags) {
status = acpi_pci_osc_support(root, flags); status = acpi_pci_osc_support(root, flags);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
dev_info(root->bus->bridge, "ACPI _OSC support " dev_info(&device->dev, "ACPI _OSC support "
"notification failed, disabling PCIe ASPM\n"); "notification failed, disabling PCIe ASPM\n");
pcie_no_aspm(); pcie_no_aspm();
flags = base_flags; flags = base_flags;
} }
} }
if (!pcie_ports_disabled if (!pcie_ports_disabled
&& (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) { && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
...@@ -588,42 +551,83 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -588,42 +551,83 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
if (pci_aer_available()) { if (pci_aer_available()) {
if (aer_acpi_firmware_first()) if (aer_acpi_firmware_first())
dev_dbg(root->bus->bridge, dev_dbg(&device->dev,
"PCIe errors handled by BIOS.\n"); "PCIe errors handled by BIOS.\n");
else else
flags |= OSC_PCI_EXPRESS_AER_CONTROL; flags |= OSC_PCI_EXPRESS_AER_CONTROL;
} }
dev_info(root->bus->bridge, 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(device->handle, &flags,
OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
dev_info(root->bus->bridge, is_osc_granted = true;
dev_info(&device->dev,
"ACPI _OSC control (0x%02x) granted\n", flags); "ACPI _OSC control (0x%02x) granted\n", flags);
if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
/*
* We have ASPM control, but the FADT indicates
* that it's unsupported. Clear it.
*/
pcie_clear_aspm(root->bus);
}
} else { } else {
dev_info(root->bus->bridge, is_osc_granted = false;
dev_info(&device->dev,
"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, "
"disabling ASPM\n");
pcie_no_aspm();
} }
} else { } else {
dev_info(root->bus->bridge, dev_info(&device->dev,
"Unable to request _OSC control " "Unable to request _OSC control "
"(_OSC support mask: 0x%02x)\n", flags); "(_OSC support mask: 0x%02x)\n", flags);
} }
/*
* 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
* --------------------
* Must do this prior to any attempt to bind the root device, as the
* PCI namespace does not get created until this call is made (and
* thus the root bridge's pci_dev does not exist).
*/
root->bus = pci_acpi_scan_root(root);
if (!root->bus) {
printk(KERN_ERR PREFIX
"Bus %04x:%02x not present in PCI namespace\n",
root->segment, (unsigned int)root->secondary.start);
result = -ENODEV;
goto out_del_root;
}
/*
* Attach ACPI-PCI Context
* -----------------------
* Thus binding the ACPI and PCI devices.
*/
result = acpi_pci_bind_root(device);
if (result)
goto out_del_root;
/*
* Scan and bind all _ADR-Based Devices
*/
list_for_each_entry(child, &device->children, node)
acpi_pci_bridge_scan(child);
/* ASPM setting */
if (is_osc_granted) {
if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
pcie_clear_aspm(root->bus);
} else {
pr_info("ACPI _OSC control for PCIe not granted, "
"disabling ASPM\n");
pcie_no_aspm();
}
pci_acpi_add_bus_pm_notifier(device, root->bus); pci_acpi_add_bus_pm_notifier(device, root->bus);
if (device->wakeup.flags.run_wake) if (device->wakeup.flags.run_wake)
device_set_run_wake(root->bus->bridge, true); device_set_run_wake(root->bus->bridge, true);
...@@ -634,6 +638,8 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) ...@@ -634,6 +638,8 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
mutex_lock(&acpi_pci_root_lock); mutex_lock(&acpi_pci_root_lock);
list_del(&root->node); list_del(&root->node);
mutex_unlock(&acpi_pci_root_lock); mutex_unlock(&acpi_pci_root_lock);
acpi_pci_irq_del_prt(root->segment, root->secondary.start);
end: end:
kfree(root); kfree(root);
return result; return result;
...@@ -682,7 +688,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type) ...@@ -682,7 +688,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
if (ACPI_SUCCESS(status)) if (ACPI_SUCCESS(status))
acpi_pci_irq_del_prt(root->bus); acpi_pci_irq_del_prt(root->segment, root->secondary.start);
pci_remove_root_bus(root->bus); pci_remove_root_bus(root->bus);
......
...@@ -3843,14 +3843,13 @@ static void __devinit pci_no_domains(void) ...@@ -3843,14 +3843,13 @@ static void __devinit pci_no_domains(void)
} }
/** /**
* pci_ext_cfg_enabled - can we access extended PCI config space? * pci_ext_cfg_avail - can we access extended PCI config space?
* @dev: The PCI device of the root bridge.
* *
* Returns 1 if we can access PCI extended config space (offsets * Returns 1 if we can access PCI extended config space (offsets
* greater than 0xff). This is the default implementation. Architecture * greater than 0xff). This is the default implementation. Architecture
* implementations can override this. * implementations can override this.
*/ */
int __weak pci_ext_cfg_avail(struct pci_dev *dev) int __weak pci_ext_cfg_avail(void)
{ {
return 1; return 1;
} }
......
...@@ -92,8 +92,8 @@ int acpi_pci_link_free_irq(acpi_handle handle); ...@@ -92,8 +92,8 @@ int acpi_pci_link_free_irq(acpi_handle handle);
/* ACPI PCI Interrupt Routing (pci_irq.c) */ /* ACPI PCI Interrupt Routing (pci_irq.c) */
int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus); int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus);
void acpi_pci_irq_del_prt(struct pci_bus *bus); void acpi_pci_irq_del_prt(int segment, int bus);
/* ACPI PCI Device Binding (pci_bind.c) */ /* ACPI PCI Device Binding (pci_bind.c) */
......
...@@ -1604,7 +1604,7 @@ static inline void pci_mmcfg_early_init(void) { } ...@@ -1604,7 +1604,7 @@ static inline void pci_mmcfg_early_init(void) { }
static inline void pci_mmcfg_late_init(void) { } static inline void pci_mmcfg_late_init(void) { }
#endif #endif
int pci_ext_cfg_avail(struct pci_dev *dev); int pci_ext_cfg_avail(void);
void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
......
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