aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/pci_root.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:31:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:31:35 -0400
commit862f0012549110d6f2586bf54b52ed4540cbff3a (patch)
tree83d29a684b885b1f58af76e0cd29b8552fd480ea /drivers/acpi/pci_root.c
parentf991fae5c6d42dfc5029150b05a78cf3f6c18cc9 (diff)
parenta0f75f9d495b3905b4c658c1d813a127f558a350 (diff)
Merge tag 'pci-v3.11-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI changes from Bjorn Helgaas: "PCI device hotplug - Add pci_alloc_dev() interface (Gu Zheng) - Add pci_bus_get()/put() for reference counting (Jiang Liu) - Fix SR-IOV reference count issues (Jiang Liu) - Remove unused acpi_pci_roots list (Jiang Liu) MSI - Conserve interrupt resources on x86 (Alexander Gordeev) AER - Force fatal severity when component has been reset (Betty Dall) - Reset link below Root Port as well as Downstream Port (Betty Dall) - Fix "Firmware first" flag setting (Bjorn Helgaas) - Don't parse HEST for non-PCIe devices (Bjorn Helgaas) ASPM - Warn when we can't disable ASPM as driver requests (Bjorn Helgaas) Miscellaneous - Add CircuitCo PCI IDs (Darren Hart) - Add AMD CZ SATA and SMBus PCI IDs (Shane Huang) - Work around Ivytown NTB BAR size issue (Jon Mason) - Detect invalid initial BAR values (Kevin Hao) - Add pcibios_release_device() (Sebastian Ott) - Fix powerpc & sparc PCI_UNKNOWN power state usage (Bjorn Helgaas)" * tag 'pci-v3.11-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (51 commits) MAINTAINERS: Add ACPI folks for ACPI-related things under drivers/pci PCI: Add CircuitCo vendor ID and subsystem ID PCI: Use pdev->pm_cap instead of pci_find_capability(..,PCI_CAP_ID_PM) PCI: Return early on allocation failures to unindent mainline code PCI: Simplify IOV implementation and fix reference count races PCI: Drop redundant setting of bus->is_added in virtfn_add_bus() unicore32/PCI: Remove redundant call of pci_bus_add_devices() m68k/PCI: Remove redundant call of pci_bus_add_devices() PCI / ACPI / PM: Use correct power state strings in messages PCI: Fix comment typo for pcie_pme_remove() PCI: Rename pci_release_bus_bridge_dev() to pci_release_host_bridge_dev() PCI: Fix refcount issue in pci_create_root_bus() error recovery path ia64/PCI: Clean up pci_scan_root_bus() usage PCI/AER: Reset link for devices below Root Port or Downstream Port ACPI / APEI: Force fatal AER severity when component has been reset PCI/AER: Remove "extern" from function declarations PCI/AER: Move AER severity defines to aer.h PCI/AER: Set dev->__aer_firmware_first only for matching devices PCI/AER: Factor out HEST device type matching PCI/AER: Don't parse HEST table for non-PCIe devices ...
Diffstat (limited to 'drivers/acpi/pci_root.c')
-rw-r--r--drivers/acpi/pci_root.c101
1 files changed, 39 insertions, 62 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index e427dc516c76..5917839321b8 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -65,10 +65,6 @@ static struct acpi_scan_handler pci_root_handler = {
65 .detach = acpi_pci_root_remove, 65 .detach = acpi_pci_root_remove,
66}; 66};
67 67
68/* Lock to protect both acpi_pci_roots lists */
69static DEFINE_MUTEX(acpi_pci_root_lock);
70static LIST_HEAD(acpi_pci_roots);
71
72static DEFINE_MUTEX(osc_lock); 68static DEFINE_MUTEX(osc_lock);
73 69
74/** 70/**
@@ -100,13 +96,12 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
100{ 96{
101 struct resource *res = data; 97 struct resource *res = data;
102 struct acpi_resource_address64 address; 98 struct acpi_resource_address64 address;
99 acpi_status status;
103 100
104 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && 101 status = acpi_resource_to_address64(resource, &address);
105 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && 102 if (ACPI_FAILURE(status))
106 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
107 return AE_OK; 103 return AE_OK;
108 104
109 acpi_resource_to_address64(resource, &address);
110 if ((address.address_length > 0) && 105 if ((address.address_length > 0) &&
111 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) { 106 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) {
112 res->start = address.minimum; 107 res->start = address.minimum;
@@ -382,23 +377,24 @@ static int acpi_pci_root_add(struct acpi_device *device,
382 int result; 377 int result;
383 struct acpi_pci_root *root; 378 struct acpi_pci_root *root;
384 u32 flags, base_flags; 379 u32 flags, base_flags;
380 acpi_handle handle = device->handle;
385 381
386 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 382 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
387 if (!root) 383 if (!root)
388 return -ENOMEM; 384 return -ENOMEM;
389 385
390 segment = 0; 386 segment = 0;
391 status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL, 387 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL,
392 &segment); 388 &segment);
393 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 389 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
394 printk(KERN_ERR PREFIX "can't evaluate _SEG\n"); 390 dev_err(&device->dev, "can't evaluate _SEG\n");
395 result = -ENODEV; 391 result = -ENODEV;
396 goto end; 392 goto end;
397 } 393 }
398 394
399 /* Check _CRS first, then _BBN. If no _BBN, default to zero. */ 395 /* Check _CRS first, then _BBN. If no _BBN, default to zero. */
400 root->secondary.flags = IORESOURCE_BUS; 396 root->secondary.flags = IORESOURCE_BUS;
401 status = try_get_root_bridge_busnr(device->handle, &root->secondary); 397 status = try_get_root_bridge_busnr(handle, &root->secondary);
402 if (ACPI_FAILURE(status)) { 398 if (ACPI_FAILURE(status)) {
403 /* 399 /*
404 * We need both the start and end of the downstream bus range 400 * We need both the start and end of the downstream bus range
@@ -407,33 +403,32 @@ static int acpi_pci_root_add(struct acpi_device *device,
407 * can do is assume [_BBN-0xFF] or [0-0xFF]. 403 * can do is assume [_BBN-0xFF] or [0-0xFF].
408 */ 404 */
409 root->secondary.end = 0xFF; 405 root->secondary.end = 0xFF;
410 printk(KERN_WARNING FW_BUG PREFIX 406 dev_warn(&device->dev,
411 "no secondary bus range in _CRS\n"); 407 FW_BUG "no secondary bus range in _CRS\n");
412 status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, 408 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN,
413 NULL, &bus); 409 NULL, &bus);
414 if (ACPI_SUCCESS(status)) 410 if (ACPI_SUCCESS(status))
415 root->secondary.start = bus; 411 root->secondary.start = bus;
416 else if (status == AE_NOT_FOUND) 412 else if (status == AE_NOT_FOUND)
417 root->secondary.start = 0; 413 root->secondary.start = 0;
418 else { 414 else {
419 printk(KERN_ERR PREFIX "can't evaluate _BBN\n"); 415 dev_err(&device->dev, "can't evaluate _BBN\n");
420 result = -ENODEV; 416 result = -ENODEV;
421 goto end; 417 goto end;
422 } 418 }
423 } 419 }
424 420
425 INIT_LIST_HEAD(&root->node);
426 root->device = device; 421 root->device = device;
427 root->segment = segment & 0xFFFF; 422 root->segment = segment & 0xFFFF;
428 strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); 423 strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
429 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); 424 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
430 device->driver_data = root; 425 device->driver_data = root;
431 426
432 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", 427 pr_info(PREFIX "%s [%s] (domain %04x %pR)\n",
433 acpi_device_name(device), acpi_device_bid(device), 428 acpi_device_name(device), acpi_device_bid(device),
434 root->segment, &root->secondary); 429 root->segment, &root->secondary);
435 430
436 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle); 431 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
437 432
438 /* 433 /*
439 * All supported architectures that use ACPI have support for 434 * All supported architectures that use ACPI have support for
@@ -446,10 +441,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
446 * TBD: Need PCI interface for enumeration/configuration of roots. 441 * TBD: Need PCI interface for enumeration/configuration of roots.
447 */ 442 */
448 443
449 mutex_lock(&acpi_pci_root_lock);
450 list_add_tail(&root->node, &acpi_pci_roots);
451 mutex_unlock(&acpi_pci_root_lock);
452
453 /* 444 /*
454 * Scan the Root Bridge 445 * Scan the Root Bridge
455 * -------------------- 446 * --------------------
@@ -459,11 +450,11 @@ static int acpi_pci_root_add(struct acpi_device *device,
459 */ 450 */
460 root->bus = pci_acpi_scan_root(root); 451 root->bus = pci_acpi_scan_root(root);
461 if (!root->bus) { 452 if (!root->bus) {
462 printk(KERN_ERR PREFIX 453 dev_err(&device->dev,
463 "Bus %04x:%02x not present in PCI namespace\n", 454 "Bus %04x:%02x not present in PCI namespace\n",
464 root->segment, (unsigned int)root->secondary.start); 455 root->segment, (unsigned int)root->secondary.start);
465 result = -ENODEV; 456 result = -ENODEV;
466 goto out_del_root; 457 goto end;
467 } 458 }
468 459
469 /* Indicate support for various _OSC capabilities. */ 460 /* Indicate support for various _OSC capabilities. */
@@ -502,7 +493,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
502 dev_info(&device->dev, 493 dev_info(&device->dev,
503 "Requesting ACPI _OSC control (0x%02x)\n", flags); 494 "Requesting ACPI _OSC control (0x%02x)\n", flags);
504 495
505 status = acpi_pci_osc_control_set(device->handle, &flags, 496 status = acpi_pci_osc_control_set(handle, &flags,
506 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); 497 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
507 if (ACPI_SUCCESS(status)) { 498 if (ACPI_SUCCESS(status)) {
508 dev_info(&device->dev, 499 dev_info(&device->dev,
@@ -519,8 +510,8 @@ static int acpi_pci_root_add(struct acpi_device *device,
519 "ACPI _OSC request failed (%s), " 510 "ACPI _OSC request failed (%s), "
520 "returned control mask: 0x%02x\n", 511 "returned control mask: 0x%02x\n",
521 acpi_format_exception(status), flags); 512 acpi_format_exception(status), flags);
522 pr_info("ACPI _OSC control for PCIe not granted, " 513 dev_info(&device->dev,
523 "disabling ASPM\n"); 514 "ACPI _OSC control for PCIe not granted, disabling ASPM\n");
524 pcie_no_aspm(); 515 pcie_no_aspm();
525 } 516 }
526 } else { 517 } else {
@@ -536,20 +527,14 @@ static int acpi_pci_root_add(struct acpi_device *device,
536 if (system_state != SYSTEM_BOOTING) { 527 if (system_state != SYSTEM_BOOTING) {
537 pcibios_resource_survey_bus(root->bus); 528 pcibios_resource_survey_bus(root->bus);
538 pci_assign_unassigned_bus_resources(root->bus); 529 pci_assign_unassigned_bus_resources(root->bus);
539 }
540 530
541 /* need to after hot-added ioapic is registered */ 531 /* need to after hot-added ioapic is registered */
542 if (system_state != SYSTEM_BOOTING)
543 pci_enable_bridges(root->bus); 532 pci_enable_bridges(root->bus);
533 }
544 534
545 pci_bus_add_devices(root->bus); 535 pci_bus_add_devices(root->bus);
546 return 1; 536 return 1;
547 537
548out_del_root:
549 mutex_lock(&acpi_pci_root_lock);
550 list_del(&root->node);
551 mutex_unlock(&acpi_pci_root_lock);
552
553end: 538end:
554 kfree(root); 539 kfree(root);
555 return result; 540 return result;
@@ -566,9 +551,6 @@ static void acpi_pci_root_remove(struct acpi_device *device)
566 551
567 pci_remove_root_bus(root->bus); 552 pci_remove_root_bus(root->bus);
568 553
569 mutex_lock(&acpi_pci_root_lock);
570 list_del(&root->node);
571 mutex_unlock(&acpi_pci_root_lock);
572 kfree(root); 554 kfree(root);
573} 555}
574 556
@@ -588,12 +570,13 @@ static void handle_root_bridge_insertion(acpi_handle handle)
588 struct acpi_device *device; 570 struct acpi_device *device;
589 571
590 if (!acpi_bus_get_device(handle, &device)) { 572 if (!acpi_bus_get_device(handle, &device)) {
591 printk(KERN_DEBUG "acpi device exists...\n"); 573 dev_printk(KERN_DEBUG, &device->dev,
574 "acpi device already exists; ignoring notify\n");
592 return; 575 return;
593 } 576 }
594 577
595 if (acpi_bus_scan(handle)) 578 if (acpi_bus_scan(handle))
596 printk(KERN_ERR "cannot add bridge to acpi list\n"); 579 acpi_handle_err(handle, "cannot add bridge to acpi list\n");
597} 580}
598 581
599static void handle_root_bridge_removal(struct acpi_device *device) 582static void handle_root_bridge_removal(struct acpi_device *device)
@@ -622,7 +605,6 @@ static void handle_root_bridge_removal(struct acpi_device *device)
622static void _handle_hotplug_event_root(struct work_struct *work) 605static void _handle_hotplug_event_root(struct work_struct *work)
623{ 606{
624 struct acpi_pci_root *root; 607 struct acpi_pci_root *root;
625 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER };
626 struct acpi_hp_work *hp_work; 608 struct acpi_hp_work *hp_work;
627 acpi_handle handle; 609 acpi_handle handle;
628 u32 type; 610 u32 type;
@@ -634,13 +616,12 @@ static void _handle_hotplug_event_root(struct work_struct *work)
634 acpi_scan_lock_acquire(); 616 acpi_scan_lock_acquire();
635 617
636 root = acpi_pci_find_root(handle); 618 root = acpi_pci_find_root(handle);
637 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
638 619
639 switch (type) { 620 switch (type) {
640 case ACPI_NOTIFY_BUS_CHECK: 621 case ACPI_NOTIFY_BUS_CHECK:
641 /* bus enumerate */ 622 /* bus enumerate */
642 printk(KERN_DEBUG "%s: Bus check notify on %s\n", __func__, 623 acpi_handle_printk(KERN_DEBUG, handle,
643 (char *)buffer.pointer); 624 "Bus check notify on %s\n", __func__);
644 if (root) 625 if (root)
645 acpiphp_check_host_bridge(handle); 626 acpiphp_check_host_bridge(handle);
646 else 627 else
@@ -650,28 +631,28 @@ static void _handle_hotplug_event_root(struct work_struct *work)
650 631
651 case ACPI_NOTIFY_DEVICE_CHECK: 632 case ACPI_NOTIFY_DEVICE_CHECK:
652 /* device check */ 633 /* device check */
653 printk(KERN_DEBUG "%s: Device check notify on %s\n", __func__, 634 acpi_handle_printk(KERN_DEBUG, handle,
654 (char *)buffer.pointer); 635 "Device check notify on %s\n", __func__);
655 if (!root) 636 if (!root)
656 handle_root_bridge_insertion(handle); 637 handle_root_bridge_insertion(handle);
657 break; 638 break;
658 639
659 case ACPI_NOTIFY_EJECT_REQUEST: 640 case ACPI_NOTIFY_EJECT_REQUEST:
660 /* request device eject */ 641 /* request device eject */
661 printk(KERN_DEBUG "%s: Device eject notify on %s\n", __func__, 642 acpi_handle_printk(KERN_DEBUG, handle,
662 (char *)buffer.pointer); 643 "Device eject notify on %s\n", __func__);
663 if (root) 644 if (root)
664 handle_root_bridge_removal(root->device); 645 handle_root_bridge_removal(root->device);
665 break; 646 break;
666 default: 647 default:
667 printk(KERN_WARNING "notify_handler: unknown event type 0x%x for %s\n", 648 acpi_handle_warn(handle,
668 type, (char *)buffer.pointer); 649 "notify_handler: unknown event type 0x%x\n",
650 type);
669 break; 651 break;
670 } 652 }
671 653
672 acpi_scan_lock_release(); 654 acpi_scan_lock_release();
673 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ 655 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */
674 kfree(buffer.pointer);
675} 656}
676 657
677static void handle_hotplug_event_root(acpi_handle handle, u32 type, 658static void handle_hotplug_event_root(acpi_handle handle, u32 type,
@@ -685,9 +666,6 @@ static acpi_status __init
685find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) 666find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
686{ 667{
687 acpi_status status; 668 acpi_status status;
688 char objname[64];
689 struct acpi_buffer buffer = { .length = sizeof(objname),
690 .pointer = objname };
691 int *count = (int *)context; 669 int *count = (int *)context;
692 670
693 if (!acpi_is_root_bridge(handle)) 671 if (!acpi_is_root_bridge(handle))
@@ -695,16 +673,15 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
695 673
696 (*count)++; 674 (*count)++;
697 675
698 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
699
700 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 676 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
701 handle_hotplug_event_root, NULL); 677 handle_hotplug_event_root, NULL);
702 if (ACPI_FAILURE(status)) 678 if (ACPI_FAILURE(status))
703 printk(KERN_DEBUG "acpi root: %s notify handler is not installed, exit status: %u\n", 679 acpi_handle_printk(KERN_DEBUG, handle,
704 objname, (unsigned int)status); 680 "notify handler is not installed, exit status: %u\n",
681 (unsigned int)status);
705 else 682 else
706 printk(KERN_DEBUG "acpi root: %s notify handler is installed\n", 683 acpi_handle_printk(KERN_DEBUG, handle,
707 objname); 684 "notify handler is installed\n");
708 685
709 return AE_OK; 686 return AE_OK;
710} 687}