aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/pci/common.c2
-rw-r--r--drivers/acpi/pci_bind.c10
-rw-r--r--drivers/acpi/pci_irq.c17
-rw-r--r--drivers/acpi/pci_root.c146
-rw-r--r--drivers/pci/pci.c5
-rw-r--r--include/acpi/acpi_drivers.h4
-rw-r--r--include/linux/pci.h2
7 files changed, 95 insertions, 91 deletions
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 720e973fc34a..52dbf1aeeb63 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -626,7 +626,7 @@ void pcibios_disable_device (struct pci_dev *dev)
626 pcibios_disable_irq(dev); 626 pcibios_disable_irq(dev);
627} 627}
628 628
629int pci_ext_cfg_avail(struct pci_dev *dev) 629int pci_ext_cfg_avail(void)
630{ 630{
631 if (raw_pci_ext_ops) 631 if (raw_pci_ext_ops)
632 return 1; 632 return 1;
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 2ef04098cc1d..911144b22c89 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -49,7 +49,7 @@ static int acpi_pci_unbind(struct acpi_device *device)
49 if (!dev->subordinate) 49 if (!dev->subordinate)
50 goto out; 50 goto out;
51 51
52 acpi_pci_irq_del_prt(dev->subordinate); 52 acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number);
53 53
54 device->ops.bind = NULL; 54 device->ops.bind = NULL;
55 device->ops.unbind = NULL; 55 device->ops.unbind = NULL;
@@ -63,7 +63,7 @@ static int acpi_pci_bind(struct acpi_device *device)
63{ 63{
64 acpi_status status; 64 acpi_status status;
65 acpi_handle handle; 65 acpi_handle handle;
66 struct pci_bus *bus; 66 unsigned char bus;
67 struct pci_dev *dev; 67 struct pci_dev *dev;
68 68
69 dev = acpi_get_pci_dev(device->handle); 69 dev = acpi_get_pci_dev(device->handle);
@@ -100,11 +100,11 @@ static int acpi_pci_bind(struct acpi_device *device)
100 goto out; 100 goto out;
101 101
102 if (dev->subordinate) 102 if (dev->subordinate)
103 bus = dev->subordinate; 103 bus = dev->subordinate->number;
104 else 104 else
105 bus = dev->bus; 105 bus = dev->bus->number;
106 106
107 acpi_pci_irq_add_prt(device->handle, bus); 107 acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus);
108 108
109out: 109out:
110 pci_dev_put(dev); 110 pci_dev_put(dev);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 0eefa12e648c..8835cc38aa30 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -184,7 +184,7 @@ static void do_prt_fixups(struct acpi_prt_entry *entry,
184 } 184 }
185} 185}
186 186
187static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, 187static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
188 struct acpi_pci_routing_table *prt) 188 struct acpi_pci_routing_table *prt)
189{ 189{
190 struct acpi_prt_entry *entry; 190 struct acpi_prt_entry *entry;
@@ -198,8 +198,8 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
198 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert 198 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
199 * it here. 199 * it here.
200 */ 200 */
201 entry->id.segment = pci_domain_nr(bus); 201 entry->id.segment = segment;
202 entry->id.bus = bus->number; 202 entry->id.bus = bus;
203 entry->id.device = (prt->address >> 16) & 0xFFFF; 203 entry->id.device = (prt->address >> 16) & 0xFFFF;
204 entry->pin = prt->pin + 1; 204 entry->pin = prt->pin + 1;
205 205
@@ -244,7 +244,7 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
244 return 0; 244 return 0;
245} 245}
246 246
247int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) 247int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
248{ 248{
249 acpi_status status; 249 acpi_status status;
250 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 250 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 273
274 entry = buffer.pointer; 274 entry = buffer.pointer;
275 while (entry && (entry->length > 0)) { 275 while (entry && (entry->length > 0)) {
276 acpi_pci_irq_add_entry(handle, bus, entry); 276 acpi_pci_irq_add_entry(handle, segment, bus, entry);
277 entry = (struct acpi_pci_routing_table *) 277 entry = (struct acpi_pci_routing_table *)
278 ((unsigned long)entry + entry->length); 278 ((unsigned long)entry + entry->length);
279 } 279 }
@@ -282,17 +282,16 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus)
282 return 0; 282 return 0;
283} 283}
284 284
285void acpi_pci_irq_del_prt(struct pci_bus *bus) 285void acpi_pci_irq_del_prt(int segment, int bus)
286{ 286{
287 struct acpi_prt_entry *entry, *tmp; 287 struct acpi_prt_entry *entry, *tmp;
288 288
289 printk(KERN_DEBUG 289 printk(KERN_DEBUG
290 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", 290 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
291 pci_domain_nr(bus), bus->number); 291 segment, bus);
292 spin_lock(&acpi_prt_lock); 292 spin_lock(&acpi_prt_lock);
293 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) { 293 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
294 if (pci_domain_nr(bus) == entry->id.segment 294 if (segment == entry->id.segment && bus == entry->id.bus) {
295 && bus->number == entry->id.bus) {
296 list_del(&entry->list); 295 list_del(&entry->list);
297 kfree(entry); 296 kfree(entry);
298 } 297 }
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 012f40d1d75d..ab781f00e32d 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -454,6 +454,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
454 acpi_handle handle; 454 acpi_handle handle;
455 struct acpi_device *child; 455 struct acpi_device *child;
456 u32 flags, base_flags; 456 u32 flags, base_flags;
457 bool is_osc_granted = false;
457 458
458 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 459 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
459 if (!root) 460 if (!root)
@@ -501,85 +502,47 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
501 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); 502 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
502 device->driver_data = root; 503 device->driver_data = root;
503 504
504 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
505
506 /*
507 * All supported architectures that use ACPI have support for
508 * PCI domains, so we indicate this in _OSC support capabilities.
509 */
510 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
511 acpi_pci_osc_support(root, flags);
512
513 /*
514 * TBD: Need PCI interface for enumeration/configuration of roots.
515 */
516
517 mutex_lock(&acpi_pci_root_lock);
518 list_add_tail(&root->node, &acpi_pci_roots);
519 mutex_unlock(&acpi_pci_root_lock);
520
521 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", 505 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n",
522 acpi_device_name(device), acpi_device_bid(device), 506 acpi_device_name(device), acpi_device_bid(device),
523 root->segment, &root->secondary); 507 root->segment, &root->secondary);
524 508
525 /* 509 /*
526 * Scan the Root Bridge
527 * --------------------
528 * Must do this prior to any attempt to bind the root device, as the
529 * PCI namespace does not get created until this call is made (and
530 * thus the root bridge's pci_dev does not exist).
531 */
532 root->bus = pci_acpi_scan_root(root);
533 if (!root->bus) {
534 printk(KERN_ERR PREFIX
535 "Bus %04x:%02x not present in PCI namespace\n",
536 root->segment, (unsigned int)root->secondary.start);
537 result = -ENODEV;
538 goto out_del_root;
539 }
540
541 /*
542 * Attach ACPI-PCI Context
543 * -----------------------
544 * Thus binding the ACPI and PCI devices.
545 */
546 result = acpi_pci_bind_root(device);
547 if (result)
548 goto out_del_root;
549
550 /*
551 * PCI Routing Table 510 * PCI Routing Table
552 * ----------------- 511 * -----------------
553 * Evaluate and parse _PRT, if exists. 512 * Evaluate and parse _PRT, if exists.
554 */ 513 */
555 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); 514 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
556 if (ACPI_SUCCESS(status)) 515 if (ACPI_SUCCESS(status))
557 result = acpi_pci_irq_add_prt(device->handle, root->bus); 516 result = acpi_pci_irq_add_prt(device->handle, root->segment,
517 root->secondary.start);
518
519 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
558 520
559 /* 521 /*
560 * Scan and bind all _ADR-Based Devices 522 * All supported architectures that use ACPI have support for
523 * PCI domains, so we indicate this in _OSC support capabilities.
561 */ 524 */
562 list_for_each_entry(child, &device->children, node) 525 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
563 acpi_pci_bridge_scan(child); 526 acpi_pci_osc_support(root, flags);
564 527
565 /* Indicate support for various _OSC capabilities. */ 528 /* Indicate support for various _OSC capabilities. */
566 if (pci_ext_cfg_avail(root->bus->self)) 529 if (pci_ext_cfg_avail())
567 flags |= OSC_EXT_PCI_CONFIG_SUPPORT; 530 flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
568 if (pcie_aspm_support_enabled()) 531 if (pcie_aspm_support_enabled()) {
569 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT | 532 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
570 OSC_CLOCK_PWR_CAPABILITY_SUPPORT; 533 OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
534 }
571 if (pci_msi_enabled()) 535 if (pci_msi_enabled())
572 flags |= OSC_MSI_SUPPORT; 536 flags |= OSC_MSI_SUPPORT;
573 if (flags != base_flags) { 537 if (flags != base_flags) {
574 status = acpi_pci_osc_support(root, flags); 538 status = acpi_pci_osc_support(root, flags);
575 if (ACPI_FAILURE(status)) { 539 if (ACPI_FAILURE(status)) {
576 dev_info(root->bus->bridge, "ACPI _OSC support " 540 dev_info(&device->dev, "ACPI _OSC support "
577 "notification failed, disabling PCIe ASPM\n"); 541 "notification failed, disabling PCIe ASPM\n");
578 pcie_no_aspm(); 542 pcie_no_aspm();
579 flags = base_flags; 543 flags = base_flags;
580 } 544 }
581 } 545 }
582
583 if (!pcie_ports_disabled 546 if (!pcie_ports_disabled
584 && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) { 547 && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
585 flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL 548 flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -588,40 +551,81 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
588 551
589 if (pci_aer_available()) { 552 if (pci_aer_available()) {
590 if (aer_acpi_firmware_first()) 553 if (aer_acpi_firmware_first())
591 dev_dbg(root->bus->bridge, 554 dev_dbg(&device->dev,
592 "PCIe errors handled by BIOS.\n"); 555 "PCIe errors handled by BIOS.\n");
593 else 556 else
594 flags |= OSC_PCI_EXPRESS_AER_CONTROL; 557 flags |= OSC_PCI_EXPRESS_AER_CONTROL;
595 } 558 }
596 559
597 dev_info(root->bus->bridge, 560 dev_info(&device->dev,
598 "Requesting ACPI _OSC control (0x%02x)\n", flags); 561 "Requesting ACPI _OSC control (0x%02x)\n", flags);
599 562
600 status = acpi_pci_osc_control_set(device->handle, &flags, 563 status = acpi_pci_osc_control_set(device->handle, &flags,
601 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); 564 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
602 if (ACPI_SUCCESS(status)) { 565 if (ACPI_SUCCESS(status)) {
603 dev_info(root->bus->bridge, 566 is_osc_granted = true;
567 dev_info(&device->dev,
604 "ACPI _OSC control (0x%02x) granted\n", flags); 568 "ACPI _OSC control (0x%02x) granted\n", flags);
605 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
606 /*
607 * We have ASPM control, but the FADT indicates
608 * that it's unsupported. Clear it.
609 */
610 pcie_clear_aspm(root->bus);
611 }
612 } else { 569 } else {
613 dev_info(root->bus->bridge, 570 is_osc_granted = false;
571 dev_info(&device->dev,
614 "ACPI _OSC request failed (%s), " 572 "ACPI _OSC request failed (%s), "
615 "returned control mask: 0x%02x\n", 573 "returned control mask: 0x%02x\n",
616 acpi_format_exception(status), flags); 574 acpi_format_exception(status), flags);
617 pr_info("ACPI _OSC control for PCIe not granted, "
618 "disabling ASPM\n");
619 pcie_no_aspm();
620 } 575 }
621 } else { 576 } else {
622 dev_info(root->bus->bridge, 577 dev_info(&device->dev,
623 "Unable to request _OSC control " 578 "Unable to request _OSC control "
624 "(_OSC support mask: 0x%02x)\n", flags); 579 "(_OSC support mask: 0x%02x)\n", flags);
580 }
581
582 /*
583 * TBD: Need PCI interface for enumeration/configuration of roots.
584 */
585
586 mutex_lock(&acpi_pci_root_lock);
587 list_add_tail(&root->node, &acpi_pci_roots);
588 mutex_unlock(&acpi_pci_root_lock);
589
590 /*
591 * Scan the Root Bridge
592 * --------------------
593 * Must do this prior to any attempt to bind the root device, as the
594 * PCI namespace does not get created until this call is made (and
595 * thus the root bridge's pci_dev does not exist).
596 */
597 root->bus = pci_acpi_scan_root(root);
598 if (!root->bus) {
599 printk(KERN_ERR PREFIX
600 "Bus %04x:%02x not present in PCI namespace\n",
601 root->segment, (unsigned int)root->secondary.start);
602 result = -ENODEV;
603 goto out_del_root;
604 }
605
606 /*
607 * Attach ACPI-PCI Context
608 * -----------------------
609 * Thus binding the ACPI and PCI devices.
610 */
611 result = acpi_pci_bind_root(device);
612 if (result)
613 goto out_del_root;
614
615 /*
616 * Scan and bind all _ADR-Based Devices
617 */
618 list_for_each_entry(child, &device->children, node)
619 acpi_pci_bridge_scan(child);
620
621 /* ASPM setting */
622 if (is_osc_granted) {
623 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
624 pcie_clear_aspm(root->bus);
625 } else {
626 pr_info("ACPI _OSC control for PCIe not granted, "
627 "disabling ASPM\n");
628 pcie_no_aspm();
625 } 629 }
626 630
627 pci_acpi_add_bus_pm_notifier(device, root->bus); 631 pci_acpi_add_bus_pm_notifier(device, root->bus);
@@ -634,6 +638,8 @@ out_del_root:
634 mutex_lock(&acpi_pci_root_lock); 638 mutex_lock(&acpi_pci_root_lock);
635 list_del(&root->node); 639 list_del(&root->node);
636 mutex_unlock(&acpi_pci_root_lock); 640 mutex_unlock(&acpi_pci_root_lock);
641
642 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
637end: 643end:
638 kfree(root); 644 kfree(root);
639 return result; 645 return result;
@@ -682,7 +688,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
682 688
683 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); 689 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
684 if (ACPI_SUCCESS(status)) 690 if (ACPI_SUCCESS(status))
685 acpi_pci_irq_del_prt(root->bus); 691 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
686 692
687 pci_remove_root_bus(root->bus); 693 pci_remove_root_bus(root->bus);
688 694
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 485cfa9af2ef..05a510d1bb30 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3843,14 +3843,13 @@ static void __devinit pci_no_domains(void)
3843} 3843}
3844 3844
3845/** 3845/**
3846 * pci_ext_cfg_enabled - can we access extended PCI config space? 3846 * pci_ext_cfg_avail - can we access extended PCI config space?
3847 * @dev: The PCI device of the root bridge.
3848 * 3847 *
3849 * Returns 1 if we can access PCI extended config space (offsets 3848 * Returns 1 if we can access PCI extended config space (offsets
3850 * greater than 0xff). This is the default implementation. Architecture 3849 * greater than 0xff). This is the default implementation. Architecture
3851 * implementations can override this. 3850 * implementations can override this.
3852 */ 3851 */
3853int __weak pci_ext_cfg_avail(struct pci_dev *dev) 3852int __weak pci_ext_cfg_avail(void)
3854{ 3853{
3855 return 1; 3854 return 1;
3856} 3855}
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index bb145e4b935e..8b1d7a6a9695 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -92,8 +92,8 @@ int acpi_pci_link_free_irq(acpi_handle handle);
92 92
93/* ACPI PCI Interrupt Routing (pci_irq.c) */ 93/* ACPI PCI Interrupt Routing (pci_irq.c) */
94 94
95int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus); 95int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus);
96void acpi_pci_irq_del_prt(struct pci_bus *bus); 96void acpi_pci_irq_del_prt(int segment, int bus);
97 97
98/* ACPI PCI Device Binding (pci_bind.c) */ 98/* ACPI PCI Device Binding (pci_bind.c) */
99 99
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 786094254d57..9253af697ca4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1604,7 +1604,7 @@ static inline void pci_mmcfg_early_init(void) { }
1604static inline void pci_mmcfg_late_init(void) { } 1604static inline void pci_mmcfg_late_init(void) { }
1605#endif 1605#endif
1606 1606
1607int pci_ext_cfg_avail(struct pci_dev *dev); 1607int pci_ext_cfg_avail(void);
1608 1608
1609void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); 1609void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
1610 1610