aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c2
-rw-r--r--arch/sparc/kernel/pci.c2
-rw-r--r--arch/x86/pci/acpi.c7
-rw-r--r--drivers/acpi/pci_root.c101
-rw-r--r--drivers/pci/ioapic.c13
-rw-r--r--drivers/pci/pci-acpi.c4
-rw-r--r--drivers/pci/pci-sysfs.c18
-rw-r--r--drivers/pci/pci.c2
-rw-r--r--drivers/pci/pcie/aspm.c29
-rw-r--r--drivers/pci/probe.c31
-rw-r--r--drivers/pci/quirks.c25
-rw-r--r--include/acpi/acpi_bus.h1
-rw-r--r--include/uapi/linux/pci_regs.h2
13 files changed, 129 insertions, 108 deletions
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 2a67e9baa59f..d2d407d65344 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -165,7 +165,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
165 pr_debug(" class: 0x%x\n", dev->class); 165 pr_debug(" class: 0x%x\n", dev->class);
166 pr_debug(" revision: 0x%x\n", dev->revision); 166 pr_debug(" revision: 0x%x\n", dev->revision);
167 167
168 dev->current_state = 4; /* unknown power state */ 168 dev->current_state = PCI_UNKNOWN; /* unknown power state */
169 dev->error_state = pci_channel_io_normal; 169 dev->error_state = pci_channel_io_normal;
170 dev->dma_mask = 0xffffffff; 170 dev->dma_mask = 0xffffffff;
171 171
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index baf4366e2d6a..972892a0aa11 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -327,7 +327,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
327 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) 327 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE)
328 pci_set_master(dev); 328 pci_set_master(dev);
329 329
330 dev->current_state = 4; /* unknown power state */ 330 dev->current_state = PCI_UNKNOWN; /* unknown power state */
331 dev->error_state = pci_channel_io_normal; 331 dev->error_state = pci_channel_io_normal;
332 dev->dma_mask = 0xffffffff; 332 dev->dma_mask = 0xffffffff;
333 333
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 3e724256dbee..d641897a1f4e 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -324,14 +324,11 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
324 res->start = start; 324 res->start = start;
325 res->end = end; 325 res->end = end;
326 info->res_offset[info->res_num] = addr.translation_offset; 326 info->res_offset[info->res_num] = addr.translation_offset;
327 info->res_num++;
327 328
328 if (!pci_use_crs) { 329 if (!pci_use_crs)
329 dev_printk(KERN_DEBUG, &info->bridge->dev, 330 dev_printk(KERN_DEBUG, &info->bridge->dev,
330 "host bridge window %pR (ignored)\n", res); 331 "host bridge window %pR (ignored)\n", res);
331 return AE_OK;
332 }
333
334 info->res_num++;
335 332
336 return AE_OK; 333 return AE_OK;
337} 334}
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 1dd6f6c85874..122b4dc7b0fa 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 handle_root_bridge_insertion(handle); 626 handle_root_bridge_insertion(handle);
646 627
@@ -648,28 +629,28 @@ static void _handle_hotplug_event_root(struct work_struct *work)
648 629
649 case ACPI_NOTIFY_DEVICE_CHECK: 630 case ACPI_NOTIFY_DEVICE_CHECK:
650 /* device check */ 631 /* device check */
651 printk(KERN_DEBUG "%s: Device check notify on %s\n", __func__, 632 acpi_handle_printk(KERN_DEBUG, handle,
652 (char *)buffer.pointer); 633 "Device check notify on %s\n", __func__);
653 if (!root) 634 if (!root)
654 handle_root_bridge_insertion(handle); 635 handle_root_bridge_insertion(handle);
655 break; 636 break;
656 637
657 case ACPI_NOTIFY_EJECT_REQUEST: 638 case ACPI_NOTIFY_EJECT_REQUEST:
658 /* request device eject */ 639 /* request device eject */
659 printk(KERN_DEBUG "%s: Device eject notify on %s\n", __func__, 640 acpi_handle_printk(KERN_DEBUG, handle,
660 (char *)buffer.pointer); 641 "Device eject notify on %s\n", __func__);
661 if (root) 642 if (root)
662 handle_root_bridge_removal(root->device); 643 handle_root_bridge_removal(root->device);
663 break; 644 break;
664 default: 645 default:
665 printk(KERN_WARNING "notify_handler: unknown event type 0x%x for %s\n", 646 acpi_handle_warn(handle,
666 type, (char *)buffer.pointer); 647 "notify_handler: unknown event type 0x%x\n",
648 type);
667 break; 649 break;
668 } 650 }
669 651
670 acpi_scan_lock_release(); 652 acpi_scan_lock_release();
671 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ 653 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */
672 kfree(buffer.pointer);
673} 654}
674 655
675static void handle_hotplug_event_root(acpi_handle handle, u32 type, 656static void handle_hotplug_event_root(acpi_handle handle, u32 type,
@@ -683,9 +664,6 @@ static acpi_status __init
683find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) 664find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
684{ 665{
685 acpi_status status; 666 acpi_status status;
686 char objname[64];
687 struct acpi_buffer buffer = { .length = sizeof(objname),
688 .pointer = objname };
689 int *count = (int *)context; 667 int *count = (int *)context;
690 668
691 if (!acpi_is_root_bridge(handle)) 669 if (!acpi_is_root_bridge(handle))
@@ -693,16 +671,15 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
693 671
694 (*count)++; 672 (*count)++;
695 673
696 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
697
698 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 674 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
699 handle_hotplug_event_root, NULL); 675 handle_hotplug_event_root, NULL);
700 if (ACPI_FAILURE(status)) 676 if (ACPI_FAILURE(status))
701 printk(KERN_DEBUG "acpi root: %s notify handler is not installed, exit status: %u\n", 677 acpi_handle_printk(KERN_DEBUG, handle,
702 objname, (unsigned int)status); 678 "notify handler is not installed, exit status: %u\n",
679 (unsigned int)status);
703 else 680 else
704 printk(KERN_DEBUG "acpi root: %s notify handler is installed\n", 681 acpi_handle_printk(KERN_DEBUG, handle,
705 objname); 682 "notify handler is installed\n");
706 683
707 return AE_OK; 684 return AE_OK;
708} 685}
diff --git a/drivers/pci/ioapic.c b/drivers/pci/ioapic.c
index 3c6bbdd059a4..1b90579b233a 100644
--- a/drivers/pci/ioapic.c
+++ b/drivers/pci/ioapic.c
@@ -113,17 +113,6 @@ static struct pci_driver ioapic_driver = {
113 .remove = ioapic_remove, 113 .remove = ioapic_remove,
114}; 114};
115 115
116static int __init ioapic_init(void) 116module_pci_driver(ioapic_driver);
117{
118 return pci_register_driver(&ioapic_driver);
119}
120
121static void __exit ioapic_exit(void)
122{
123 pci_unregister_driver(&ioapic_driver);
124}
125
126module_init(ioapic_init);
127module_exit(ioapic_exit);
128 117
129MODULE_LICENSE("GPL"); 118MODULE_LICENSE("GPL");
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index e4b1fb2c0f5d..6c15d6a96935 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -376,12 +376,12 @@ static int __init acpi_pci_init(void)
376 int ret; 376 int ret;
377 377
378 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_MSI) { 378 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_MSI) {
379 printk(KERN_INFO"ACPI FADT declares the system doesn't support MSI, so disable it\n"); 379 pr_info("ACPI FADT declares the system doesn't support MSI, so disable it\n");
380 pci_no_msi(); 380 pci_no_msi();
381 } 381 }
382 382
383 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { 383 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
384 printk(KERN_INFO"ACPI FADT declares the system doesn't support PCIe ASPM, so disable it\n"); 384 pr_info("ACPI FADT declares the system doesn't support PCIe ASPM, so disable it\n");
385 pcie_no_aspm(); 385 pcie_no_aspm();
386 } 386 }
387 387
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 5b4a9d9cd200..0b56e0865f38 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -66,7 +66,7 @@ static ssize_t broken_parity_status_store(struct device *dev,
66 struct pci_dev *pdev = to_pci_dev(dev); 66 struct pci_dev *pdev = to_pci_dev(dev);
67 unsigned long val; 67 unsigned long val;
68 68
69 if (strict_strtoul(buf, 0, &val) < 0) 69 if (kstrtoul(buf, 0, &val) < 0)
70 return -EINVAL; 70 return -EINVAL;
71 71
72 pdev->broken_parity_status = !!val; 72 pdev->broken_parity_status = !!val;
@@ -188,7 +188,7 @@ static ssize_t is_enabled_store(struct device *dev,
188{ 188{
189 struct pci_dev *pdev = to_pci_dev(dev); 189 struct pci_dev *pdev = to_pci_dev(dev);
190 unsigned long val; 190 unsigned long val;
191 ssize_t result = strict_strtoul(buf, 0, &val); 191 ssize_t result = kstrtoul(buf, 0, &val);
192 192
193 if (result < 0) 193 if (result < 0)
194 return result; 194 return result;
@@ -259,7 +259,7 @@ msi_bus_store(struct device *dev, struct device_attribute *attr,
259 struct pci_dev *pdev = to_pci_dev(dev); 259 struct pci_dev *pdev = to_pci_dev(dev);
260 unsigned long val; 260 unsigned long val;
261 261
262 if (strict_strtoul(buf, 0, &val) < 0) 262 if (kstrtoul(buf, 0, &val) < 0)
263 return -EINVAL; 263 return -EINVAL;
264 264
265 /* bad things may happen if the no_msi flag is changed 265 /* bad things may happen if the no_msi flag is changed
@@ -291,7 +291,7 @@ static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
291 unsigned long val; 291 unsigned long val;
292 struct pci_bus *b = NULL; 292 struct pci_bus *b = NULL;
293 293
294 if (strict_strtoul(buf, 0, &val) < 0) 294 if (kstrtoul(buf, 0, &val) < 0)
295 return -EINVAL; 295 return -EINVAL;
296 296
297 if (val) { 297 if (val) {
@@ -315,7 +315,7 @@ dev_rescan_store(struct device *dev, struct device_attribute *attr,
315 unsigned long val; 315 unsigned long val;
316 struct pci_dev *pdev = to_pci_dev(dev); 316 struct pci_dev *pdev = to_pci_dev(dev);
317 317
318 if (strict_strtoul(buf, 0, &val) < 0) 318 if (kstrtoul(buf, 0, &val) < 0)
319 return -EINVAL; 319 return -EINVAL;
320 320
321 if (val) { 321 if (val) {
@@ -342,7 +342,7 @@ remove_store(struct device *dev, struct device_attribute *dummy,
342 int ret = 0; 342 int ret = 0;
343 unsigned long val; 343 unsigned long val;
344 344
345 if (strict_strtoul(buf, 0, &val) < 0) 345 if (kstrtoul(buf, 0, &val) < 0)
346 return -EINVAL; 346 return -EINVAL;
347 347
348 /* An attribute cannot be unregistered by one of its own methods, 348 /* An attribute cannot be unregistered by one of its own methods,
@@ -362,7 +362,7 @@ dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
362 unsigned long val; 362 unsigned long val;
363 struct pci_bus *bus = to_pci_bus(dev); 363 struct pci_bus *bus = to_pci_bus(dev);
364 364
365 if (strict_strtoul(buf, 0, &val) < 0) 365 if (kstrtoul(buf, 0, &val) < 0)
366 return -EINVAL; 366 return -EINVAL;
367 367
368 if (val) { 368 if (val) {
@@ -384,7 +384,7 @@ static ssize_t d3cold_allowed_store(struct device *dev,
384 struct pci_dev *pdev = to_pci_dev(dev); 384 struct pci_dev *pdev = to_pci_dev(dev);
385 unsigned long val; 385 unsigned long val;
386 386
387 if (strict_strtoul(buf, 0, &val) < 0) 387 if (kstrtoul(buf, 0, &val) < 0)
388 return -EINVAL; 388 return -EINVAL;
389 389
390 pdev->d3cold_allowed = !!val; 390 pdev->d3cold_allowed = !!val;
@@ -1236,7 +1236,7 @@ static ssize_t reset_store(struct device *dev,
1236{ 1236{
1237 struct pci_dev *pdev = to_pci_dev(dev); 1237 struct pci_dev *pdev = to_pci_dev(dev);
1238 unsigned long val; 1238 unsigned long val;
1239 ssize_t result = strict_strtoul(buf, 0, &val); 1239 ssize_t result = kstrtoul(buf, 0, &val);
1240 1240
1241 if (result < 0) 1241 if (result < 0)
1242 return result; 1242 return result;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a899d8bb190d..e5f4e55d407d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2421,7 +2421,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
2421/** 2421/**
2422 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge 2422 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge
2423 * @dev: the PCI device 2423 * @dev: the PCI device
2424 * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTD, 4=INTD) 2424 * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD)
2425 * 2425 *
2426 * Perform INTx swizzling for a device behind one level of bridge. This is 2426 * Perform INTx swizzling for a device behind one level of bridge. This is
2427 * required by section 9.1 of the PCI-to-PCI bridge specification for devices 2427 * required by section 9.1 of the PCI-to-PCI bridge specification for devices
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index d320df6375a2..403a44374ed5 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -714,19 +714,12 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
714 up_read(&pci_bus_sem); 714 up_read(&pci_bus_sem);
715} 715}
716 716
717/*
718 * pci_disable_link_state - disable pci device's link state, so the link will
719 * never enter specific states
720 */
721static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem, 717static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
722 bool force) 718 bool force)
723{ 719{
724 struct pci_dev *parent = pdev->bus->self; 720 struct pci_dev *parent = pdev->bus->self;
725 struct pcie_link_state *link; 721 struct pcie_link_state *link;
726 722
727 if (aspm_disabled && !force)
728 return;
729
730 if (!pci_is_pcie(pdev)) 723 if (!pci_is_pcie(pdev))
731 return; 724 return;
732 725
@@ -736,6 +729,19 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
736 if (!parent || !parent->link_state) 729 if (!parent || !parent->link_state)
737 return; 730 return;
738 731
732 /*
733 * A driver requested that ASPM be disabled on this device, but
734 * if we don't have permission to manage ASPM (e.g., on ACPI
735 * systems we have to observe the FADT ACPI_FADT_NO_ASPM bit and
736 * the _OSC method), we can't honor that request. Windows has
737 * a similar mechanism using "PciASPMOptOut", which is also
738 * ignored in this situation.
739 */
740 if (aspm_disabled && !force) {
741 dev_warn(&pdev->dev, "can't disable ASPM; OS doesn't have ASPM control\n");
742 return;
743 }
744
739 if (sem) 745 if (sem)
740 down_read(&pci_bus_sem); 746 down_read(&pci_bus_sem);
741 mutex_lock(&aspm_lock); 747 mutex_lock(&aspm_lock);
@@ -761,6 +767,15 @@ void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
761} 767}
762EXPORT_SYMBOL(pci_disable_link_state_locked); 768EXPORT_SYMBOL(pci_disable_link_state_locked);
763 769
770/**
771 * pci_disable_link_state - Disable device's link state, so the link will
772 * never enter specific states. Note that if the BIOS didn't grant ASPM
773 * control to the OS, this does nothing because we can't touch the LNKCTL
774 * register.
775 *
776 * @pdev: PCI device
777 * @state: ASPM link state to disable
778 */
764void pci_disable_link_state(struct pci_dev *pdev, int state) 779void pci_disable_link_state(struct pci_dev *pdev, int state)
765{ 780{
766 __pci_disable_link_state(pdev, state, true, false); 781 __pci_disable_link_state(pdev, state, true, false);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 70f10fa3c1b2..fe5b50bd7536 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -170,7 +170,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
170{ 170{
171 u32 l, sz, mask; 171 u32 l, sz, mask;
172 u16 orig_cmd; 172 u16 orig_cmd;
173 struct pci_bus_region region; 173 struct pci_bus_region region, inverted_region;
174 bool bar_too_big = false, bar_disabled = false; 174 bool bar_too_big = false, bar_disabled = false;
175 175
176 mask = type ? PCI_ROM_ADDRESS_MASK : ~0; 176 mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
@@ -250,12 +250,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
250 pci_write_config_dword(dev, pos + 4, 0); 250 pci_write_config_dword(dev, pos + 4, 0);
251 region.start = 0; 251 region.start = 0;
252 region.end = sz64; 252 region.end = sz64;
253 pcibios_bus_to_resource(dev, res, &region);
254 bar_disabled = true; 253 bar_disabled = true;
255 } else { 254 } else {
256 region.start = l64; 255 region.start = l64;
257 region.end = l64 + sz64; 256 region.end = l64 + sz64;
258 pcibios_bus_to_resource(dev, res, &region);
259 } 257 }
260 } else { 258 } else {
261 sz = pci_size(l, sz, mask); 259 sz = pci_size(l, sz, mask);
@@ -265,7 +263,28 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
265 263
266 region.start = l; 264 region.start = l;
267 region.end = l + sz; 265 region.end = l + sz;
268 pcibios_bus_to_resource(dev, res, &region); 266 }
267
268 pcibios_bus_to_resource(dev, res, &region);
269 pcibios_resource_to_bus(dev, &inverted_region, res);
270
271 /*
272 * If "A" is a BAR value (a bus address), "bus_to_resource(A)" is
273 * the corresponding resource address (the physical address used by
274 * the CPU. Converting that resource address back to a bus address
275 * should yield the original BAR value:
276 *
277 * resource_to_bus(bus_to_resource(A)) == A
278 *
279 * If it doesn't, CPU accesses to "bus_to_resource(A)" will not
280 * be claimed by the device.
281 */
282 if (inverted_region.start != region.start) {
283 dev_info(&dev->dev, "reg 0x%x: initial BAR value %pa invalid; forcing reassignment\n",
284 pos, &region.start);
285 res->flags |= IORESOURCE_UNSET;
286 res->end -= res->start;
287 res->start = 0;
269 } 288 }
270 289
271 goto out; 290 goto out;
@@ -278,9 +297,9 @@ out:
278 pci_write_config_word(dev, PCI_COMMAND, orig_cmd); 297 pci_write_config_word(dev, PCI_COMMAND, orig_cmd);
279 298
280 if (bar_too_big) 299 if (bar_too_big)
281 dev_err(&dev->dev, "reg %x: can't handle 64-bit BAR\n", pos); 300 dev_err(&dev->dev, "reg 0x%x: can't handle 64-bit BAR\n", pos);
282 if (res->flags && !bar_disabled) 301 if (res->flags && !bar_disabled)
283 dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res); 302 dev_printk(KERN_DEBUG, &dev->dev, "reg 0x%x: %pR\n", pos, res);
284 303
285 return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; 304 return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;
286} 305}
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index df4655c5c138..c3a04026cca8 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2867,6 +2867,31 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata);
2867DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata); 2867DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata);
2868 2868
2869 2869
2870/*
2871 * Ivytown NTB BAR sizes are misreported by the hardware due to an erratum. To
2872 * work around this, query the size it should be configured to by the device and
2873 * modify the resource end to correspond to this new size.
2874 */
2875static void quirk_intel_ntb(struct pci_dev *dev)
2876{
2877 int rc;
2878 u8 val;
2879
2880 rc = pci_read_config_byte(dev, 0x00D0, &val);
2881 if (rc)
2882 return;
2883
2884 dev->resource[2].end = dev->resource[2].start + ((u64) 1 << val) - 1;
2885
2886 rc = pci_read_config_byte(dev, 0x00D1, &val);
2887 if (rc)
2888 return;
2889
2890 dev->resource[4].end = dev->resource[4].start + ((u64) 1 << val) - 1;
2891}
2892DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0e08, quirk_intel_ntb);
2893DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0e0d, quirk_intel_ntb);
2894
2870static ktime_t fixup_debug_start(struct pci_dev *dev, 2895static ktime_t fixup_debug_start(struct pci_dev *dev,
2871 void (*fn)(struct pci_dev *dev)) 2896 void (*fn)(struct pci_dev *dev))
2872{ 2897{
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 98db31d9f9b4..af0f840f77c8 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -472,7 +472,6 @@ int register_acpi_bus_type(struct acpi_bus_type *);
472int unregister_acpi_bus_type(struct acpi_bus_type *); 472int unregister_acpi_bus_type(struct acpi_bus_type *);
473 473
474struct acpi_pci_root { 474struct acpi_pci_root {
475 struct list_head node;
476 struct acpi_device * device; 475 struct acpi_device * device;
477 struct pci_bus *bus; 476 struct pci_bus *bus;
478 u16 segment; 477 u16 segment;
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index 864e324da80d..c3cc01d474b0 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -468,7 +468,7 @@
468#define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */ 468#define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */
469#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */ 469#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */
470#define PCI_EXP_LNKCAP_L1EL 0x00038000 /* L1 Exit Latency */ 470#define PCI_EXP_LNKCAP_L1EL 0x00038000 /* L1 Exit Latency */
471#define PCI_EXP_LNKCAP_CLKPM 0x00040000 /* L1 Clock Power Management */ 471#define PCI_EXP_LNKCAP_CLKPM 0x00040000 /* Clock Power Management */
472#define PCI_EXP_LNKCAP_SDERC 0x00080000 /* Surprise Down Error Reporting Capable */ 472#define PCI_EXP_LNKCAP_SDERC 0x00080000 /* Surprise Down Error Reporting Capable */
473#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */ 473#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */
474#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */ 474#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */