aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/i2c/busses/i2c-piix42
-rw-r--r--arch/ia64/sn/kernel/io_init.c11
-rw-r--r--arch/m68k/platform/coldfire/pci.c1
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c5
-rw-r--r--arch/sparc/kernel/pci.c5
-rw-r--r--arch/unicore32/kernel/pci.c5
-rw-r--r--arch/x86/pci/acpi.c7
-rw-r--r--drivers/acpi/apei/ghes.c10
-rw-r--r--drivers/acpi/pci_root.c101
-rw-r--r--drivers/ata/ahci.c1
-rw-r--r--drivers/char/agp/alpha-agp.c2
-rw-r--r--drivers/char/agp/parisc-agp.c2
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-piix4.c3
-rw-r--r--drivers/pci/bus.c15
-rw-r--r--drivers/pci/ioapic.c13
-rw-r--r--drivers/pci/iov.c65
-rw-r--r--drivers/pci/pci-acpi.c10
-rw-r--r--drivers/pci/pci-sysfs.c48
-rw-r--r--drivers/pci/pci.c12
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h4
-rw-r--r--drivers/pci/pcie/aer/aerdrv_acpi.c47
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c17
-rw-r--r--drivers/pci/pcie/aspm.c29
-rw-r--r--drivers/pci/pcie/pme.c2
-rw-r--r--drivers/pci/probe.c115
-rw-r--r--drivers/pci/quirks.c27
-rw-r--r--drivers/scsi/megaraid.c2
-rw-r--r--include/acpi/acpi_bus.h1
-rw-r--r--include/linux/aer.h20
-rw-r--r--include/linux/pci.h6
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/uapi/linux/pci_regs.h2
33 files changed, 336 insertions, 259 deletions
diff --git a/Documentation/i2c/busses/i2c-piix4 b/Documentation/i2c/busses/i2c-piix4
index 1e6634f54c50..a370b2047cf3 100644
--- a/Documentation/i2c/busses/i2c-piix4
+++ b/Documentation/i2c/busses/i2c-piix4
@@ -13,7 +13,7 @@ Supported adapters:
13 * AMD SP5100 (SB700 derivative found on some server mainboards) 13 * AMD SP5100 (SB700 derivative found on some server mainboards)
14 Datasheet: Publicly available at the AMD website 14 Datasheet: Publicly available at the AMD website
15 http://support.amd.com/us/Embedded_TechDocs/44413.pdf 15 http://support.amd.com/us/Embedded_TechDocs/44413.pdf
16 * AMD Hudson-2 16 * AMD Hudson-2, CZ
17 Datasheet: Not publicly available 17 Datasheet: Not publicly available
18 * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge 18 * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge
19 Datasheet: Publicly available at the SMSC website http://www.smsc.com 19 Datasheet: Publicly available at the SMSC website http://www.smsc.com
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 238e2c511d94..e2c7733e18a7 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -326,16 +326,7 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
326 bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller, 326 bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
327 &resources); 327 &resources);
328 if (bus == NULL) 328 if (bus == NULL)
329 goto error_return; /* error, or bus already scanned */ 329 kfree(controller);
330
331 bus->sysdata = controller;
332
333 return;
334
335error_return:
336
337 kfree(controller);
338 return;
339} 330}
340 331
341/* 332/*
diff --git a/arch/m68k/platform/coldfire/pci.c b/arch/m68k/platform/coldfire/pci.c
index 8572246db84d..b33f97a13e6d 100644
--- a/arch/m68k/platform/coldfire/pci.c
+++ b/arch/m68k/platform/coldfire/pci.c
@@ -320,7 +320,6 @@ static int __init mcf_pci_init(void)
320 pci_bus_size_bridges(rootbus); 320 pci_bus_size_bridges(rootbus);
321 pci_bus_assign_resources(rootbus); 321 pci_bus_assign_resources(rootbus);
322 pci_enable_bridges(rootbus); 322 pci_enable_bridges(rootbus);
323 pci_bus_add_devices(rootbus);
324 return 0; 323 return 0;
325} 324}
326 325
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 2a67e9baa59f..6b0ba5854d99 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -128,7 +128,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
128 const char *type; 128 const char *type;
129 struct pci_slot *slot; 129 struct pci_slot *slot;
130 130
131 dev = alloc_pci_dev(); 131 dev = pci_alloc_dev(bus);
132 if (!dev) 132 if (!dev)
133 return NULL; 133 return NULL;
134 type = of_get_property(node, "device_type", NULL); 134 type = of_get_property(node, "device_type", NULL);
@@ -137,7 +137,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
137 137
138 pr_debug(" create device, devfn: %x, type: %s\n", devfn, type); 138 pr_debug(" create device, devfn: %x, type: %s\n", devfn, type);
139 139
140 dev->bus = bus;
141 dev->dev.of_node = of_node_get(node); 140 dev->dev.of_node = of_node_get(node);
142 dev->dev.parent = bus->bridge; 141 dev->dev.parent = bus->bridge;
143 dev->dev.bus = &pci_bus_type; 142 dev->dev.bus = &pci_bus_type;
@@ -165,7 +164,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
165 pr_debug(" class: 0x%x\n", dev->class); 164 pr_debug(" class: 0x%x\n", dev->class);
166 pr_debug(" revision: 0x%x\n", dev->revision); 165 pr_debug(" revision: 0x%x\n", dev->revision);
167 166
168 dev->current_state = 4; /* unknown power state */ 167 dev->current_state = PCI_UNKNOWN; /* unknown power state */
169 dev->error_state = pci_channel_io_normal; 168 dev->error_state = pci_channel_io_normal;
170 dev->dma_mask = 0xffffffff; 169 dev->dma_mask = 0xffffffff;
171 170
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index baf4366e2d6a..b16f624398af 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -254,7 +254,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
254 const char *type; 254 const char *type;
255 u32 class; 255 u32 class;
256 256
257 dev = alloc_pci_dev(); 257 dev = pci_alloc_dev(bus);
258 if (!dev) 258 if (!dev)
259 return NULL; 259 return NULL;
260 260
@@ -281,7 +281,6 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
281 printk(" create device, devfn: %x, type: %s\n", 281 printk(" create device, devfn: %x, type: %s\n",
282 devfn, type); 282 devfn, type);
283 283
284 dev->bus = bus;
285 dev->sysdata = node; 284 dev->sysdata = node;
286 dev->dev.parent = bus->bridge; 285 dev->dev.parent = bus->bridge;
287 dev->dev.bus = &pci_bus_type; 286 dev->dev.bus = &pci_bus_type;
@@ -327,7 +326,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
327 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) 326 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE)
328 pci_set_master(dev); 327 pci_set_master(dev);
329 328
330 dev->current_state = 4; /* unknown power state */ 329 dev->current_state = PCI_UNKNOWN; /* unknown power state */
331 dev->error_state = pci_channel_io_normal; 330 dev->error_state = pci_channel_io_normal;
332 dev->dma_mask = 0xffffffff; 331 dev->dma_mask = 0xffffffff;
333 332
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index ef69c0c82825..374a055a8e6b 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -277,11 +277,6 @@ static int __init pci_common_init(void)
277 pci_bus_assign_resources(puv3_bus); 277 pci_bus_assign_resources(puv3_bus);
278 } 278 }
279 279
280 /*
281 * Tell drivers about devices found.
282 */
283 pci_bus_add_devices(puv3_bus);
284
285 return 0; 280 return 0;
286} 281}
287subsys_initcall(pci_common_init); 282subsys_initcall(pci_common_init);
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/apei/ghes.c b/drivers/acpi/apei/ghes.c
index d668a8ae602b..ab315515908e 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -449,9 +449,19 @@ static void ghes_do_proc(struct ghes *ghes,
449 pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) { 449 pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) {
450 unsigned int devfn; 450 unsigned int devfn;
451 int aer_severity; 451 int aer_severity;
452
452 devfn = PCI_DEVFN(pcie_err->device_id.device, 453 devfn = PCI_DEVFN(pcie_err->device_id.device,
453 pcie_err->device_id.function); 454 pcie_err->device_id.function);
454 aer_severity = cper_severity_to_aer(sev); 455 aer_severity = cper_severity_to_aer(sev);
456
457 /*
458 * If firmware reset the component to contain
459 * the error, we must reinitialize it before
460 * use, so treat it as a fatal AER error.
461 */
462 if (gdata->flags & CPER_SEC_RESET)
463 aer_severity = AER_FATAL;
464
455 aer_recover_queue(pcie_err->device_id.segment, 465 aer_recover_queue(pcie_err->device_id.segment,
456 pcie_err->device_id.bus, 466 pcie_err->device_id.bus,
457 devfn, aer_severity); 467 devfn, aer_severity);
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/ata/ahci.c b/drivers/ata/ahci.c
index 251e57d38942..98496600a15a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -310,6 +310,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
310 310
311 /* AMD */ 311 /* AMD */
312 { PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD Hudson-2 */ 312 { PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD Hudson-2 */
313 { PCI_VDEVICE(AMD, 0x7900), board_ahci }, /* AMD CZ */
313 /* AMD is using RAID class only for ahci controllers */ 314 /* AMD is using RAID class only for ahci controllers */
314 { PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 315 { PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
315 PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci }, 316 PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci },
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index dd84af4d4f7e..199b8e99f7d7 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -174,7 +174,7 @@ alpha_core_agp_setup(void)
174 /* 174 /*
175 * Build a fake pci_dev struct 175 * Build a fake pci_dev struct
176 */ 176 */
177 pdev = alloc_pci_dev(); 177 pdev = pci_alloc_dev(NULL);
178 if (!pdev) 178 if (!pdev)
179 return -ENOMEM; 179 return -ENOMEM;
180 pdev->vendor = 0xffff; 180 pdev->vendor = 0xffff;
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 94821ab01c6d..bf5d2477cb77 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -333,7 +333,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
333 struct agp_bridge_data *bridge; 333 struct agp_bridge_data *bridge;
334 int error = 0; 334 int error = 0;
335 335
336 fake_bridge_dev = alloc_pci_dev(); 336 fake_bridge_dev = pci_alloc_dev(NULL);
337 if (!fake_bridge_dev) { 337 if (!fake_bridge_dev) {
338 error = -ENOMEM; 338 error = -ENOMEM;
339 goto fail; 339 goto fail;
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 631736e2e7ed..4faf02b3657d 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -150,6 +150,7 @@ config I2C_PIIX4
150 ATI SB700/SP5100 150 ATI SB700/SP5100
151 ATI SB800 151 ATI SB800
152 AMD Hudson-2 152 AMD Hudson-2
153 AMD CZ
153 Serverworks OSB4 154 Serverworks OSB4
154 Serverworks CSB5 155 Serverworks CSB5
155 Serverworks CSB6 156 Serverworks CSB6
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 39ab78c1a02c..d05ad590af29 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -22,7 +22,7 @@
22 Intel PIIX4, 440MX 22 Intel PIIX4, 440MX
23 Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100 23 Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100
24 ATI IXP200, IXP300, IXP400, SB600, SB700/SP5100, SB800 24 ATI IXP200, IXP300, IXP400, SB600, SB700/SP5100, SB800
25 AMD Hudson-2 25 AMD Hudson-2, CZ
26 SMSC Victory66 26 SMSC Victory66
27 27
28 Note: we assume there can only be one device, with one or more 28 Note: we assume there can only be one device, with one or more
@@ -522,6 +522,7 @@ static DEFINE_PCI_DEVICE_TABLE(piix4_ids) = {
522 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS) }, 522 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS) },
523 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS) }, 523 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS) },
524 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS) }, 524 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SMBUS) },
525 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x790b) },
525 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 526 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
526 PCI_DEVICE_ID_SERVERWORKS_OSB4) }, 527 PCI_DEVICE_ID_SERVERWORKS_OSB4) },
527 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 528 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 32e66a6f12d9..b1ff02ab4f13 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -283,6 +283,21 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
283} 283}
284EXPORT_SYMBOL_GPL(pci_walk_bus); 284EXPORT_SYMBOL_GPL(pci_walk_bus);
285 285
286struct pci_bus *pci_bus_get(struct pci_bus *bus)
287{
288 if (bus)
289 get_device(&bus->dev);
290 return bus;
291}
292EXPORT_SYMBOL(pci_bus_get);
293
294void pci_bus_put(struct pci_bus *bus)
295{
296 if (bus)
297 put_device(&bus->dev);
298}
299EXPORT_SYMBOL(pci_bus_put);
300
286EXPORT_SYMBOL(pci_bus_alloc_resource); 301EXPORT_SYMBOL(pci_bus_alloc_resource);
287EXPORT_SYMBOL_GPL(pci_bus_add_device); 302EXPORT_SYMBOL_GPL(pci_bus_add_device);
288EXPORT_SYMBOL(pci_bus_add_devices); 303EXPORT_SYMBOL(pci_bus_add_devices);
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/iov.c b/drivers/pci/iov.c
index c93071d428f5..de8ffacf9c9b 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -47,51 +47,43 @@ static struct pci_bus *virtfn_add_bus(struct pci_bus *bus, int busnr)
47 return NULL; 47 return NULL;
48 48
49 pci_bus_insert_busn_res(child, busnr, busnr); 49 pci_bus_insert_busn_res(child, busnr, busnr);
50 bus->is_added = 1;
51 50
52 return child; 51 return child;
53} 52}
54 53
55static void virtfn_remove_bus(struct pci_bus *bus, int busnr) 54static void virtfn_remove_bus(struct pci_bus *physbus, struct pci_bus *virtbus)
56{ 55{
57 struct pci_bus *child; 56 if (physbus != virtbus && list_empty(&virtbus->devices))
58 57 pci_remove_bus(virtbus);
59 if (bus->number == busnr)
60 return;
61
62 child = pci_find_bus(pci_domain_nr(bus), busnr);
63 BUG_ON(!child);
64
65 if (list_empty(&child->devices))
66 pci_remove_bus(child);
67} 58}
68 59
69static int virtfn_add(struct pci_dev *dev, int id, int reset) 60static int virtfn_add(struct pci_dev *dev, int id, int reset)
70{ 61{
71 int i; 62 int i;
72 int rc; 63 int rc = -ENOMEM;
73 u64 size; 64 u64 size;
74 char buf[VIRTFN_ID_LEN]; 65 char buf[VIRTFN_ID_LEN];
75 struct pci_dev *virtfn; 66 struct pci_dev *virtfn;
76 struct resource *res; 67 struct resource *res;
77 struct pci_sriov *iov = dev->sriov; 68 struct pci_sriov *iov = dev->sriov;
69 struct pci_bus *bus;
78 70
79 virtfn = alloc_pci_dev(); 71 mutex_lock(&iov->dev->sriov->lock);
72 bus = virtfn_add_bus(dev->bus, virtfn_bus(dev, id));
73 if (!bus)
74 goto failed;
75
76 virtfn = pci_alloc_dev(bus);
80 if (!virtfn) 77 if (!virtfn)
81 return -ENOMEM; 78 goto failed0;
82 79
83 mutex_lock(&iov->dev->sriov->lock);
84 virtfn->bus = virtfn_add_bus(dev->bus, virtfn_bus(dev, id));
85 if (!virtfn->bus) {
86 kfree(virtfn);
87 mutex_unlock(&iov->dev->sriov->lock);
88 return -ENOMEM;
89 }
90 virtfn->devfn = virtfn_devfn(dev, id); 80 virtfn->devfn = virtfn_devfn(dev, id);
91 virtfn->vendor = dev->vendor; 81 virtfn->vendor = dev->vendor;
92 pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); 82 pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
93 pci_setup_device(virtfn); 83 pci_setup_device(virtfn);
94 virtfn->dev.parent = dev->dev.parent; 84 virtfn->dev.parent = dev->dev.parent;
85 virtfn->physfn = pci_dev_get(dev);
86 virtfn->is_virtfn = 1;
95 87
96 for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { 88 for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
97 res = dev->resource + PCI_IOV_RESOURCES + i; 89 res = dev->resource + PCI_IOV_RESOURCES + i;
@@ -113,9 +105,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
113 pci_device_add(virtfn, virtfn->bus); 105 pci_device_add(virtfn, virtfn->bus);
114 mutex_unlock(&iov->dev->sriov->lock); 106 mutex_unlock(&iov->dev->sriov->lock);
115 107
116 virtfn->physfn = pci_dev_get(dev);
117 virtfn->is_virtfn = 1;
118
119 rc = pci_bus_add_device(virtfn); 108 rc = pci_bus_add_device(virtfn);
120 sprintf(buf, "virtfn%u", id); 109 sprintf(buf, "virtfn%u", id);
121 rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); 110 rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
@@ -135,7 +124,9 @@ failed1:
135 pci_dev_put(dev); 124 pci_dev_put(dev);
136 mutex_lock(&iov->dev->sriov->lock); 125 mutex_lock(&iov->dev->sriov->lock);
137 pci_stop_and_remove_bus_device(virtfn); 126 pci_stop_and_remove_bus_device(virtfn);
138 virtfn_remove_bus(dev->bus, virtfn_bus(dev, id)); 127failed0:
128 virtfn_remove_bus(dev->bus, bus);
129failed:
139 mutex_unlock(&iov->dev->sriov->lock); 130 mutex_unlock(&iov->dev->sriov->lock);
140 131
141 return rc; 132 return rc;
@@ -144,20 +135,15 @@ failed1:
144static void virtfn_remove(struct pci_dev *dev, int id, int reset) 135static void virtfn_remove(struct pci_dev *dev, int id, int reset)
145{ 136{
146 char buf[VIRTFN_ID_LEN]; 137 char buf[VIRTFN_ID_LEN];
147 struct pci_bus *bus;
148 struct pci_dev *virtfn; 138 struct pci_dev *virtfn;
149 struct pci_sriov *iov = dev->sriov; 139 struct pci_sriov *iov = dev->sriov;
150 140
151 bus = pci_find_bus(pci_domain_nr(dev->bus), virtfn_bus(dev, id)); 141 virtfn = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus),
152 if (!bus) 142 virtfn_bus(dev, id),
153 return; 143 virtfn_devfn(dev, id));
154
155 virtfn = pci_get_slot(bus, virtfn_devfn(dev, id));
156 if (!virtfn) 144 if (!virtfn)
157 return; 145 return;
158 146
159 pci_dev_put(virtfn);
160
161 if (reset) { 147 if (reset) {
162 device_release_driver(&virtfn->dev); 148 device_release_driver(&virtfn->dev);
163 __pci_reset_function(virtfn); 149 __pci_reset_function(virtfn);
@@ -175,9 +161,11 @@ static void virtfn_remove(struct pci_dev *dev, int id, int reset)
175 161
176 mutex_lock(&iov->dev->sriov->lock); 162 mutex_lock(&iov->dev->sriov->lock);
177 pci_stop_and_remove_bus_device(virtfn); 163 pci_stop_and_remove_bus_device(virtfn);
178 virtfn_remove_bus(dev->bus, virtfn_bus(dev, id)); 164 virtfn_remove_bus(dev->bus, virtfn->bus);
179 mutex_unlock(&iov->dev->sriov->lock); 165 mutex_unlock(&iov->dev->sriov->lock);
180 166
167 /* balance pci_get_domain_bus_and_slot() */
168 pci_dev_put(virtfn);
181 pci_dev_put(dev); 169 pci_dev_put(dev);
182} 170}
183 171
@@ -334,13 +322,14 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
334 if (!pdev) 322 if (!pdev)
335 return -ENODEV; 323 return -ENODEV;
336 324
337 pci_dev_put(pdev); 325 if (!pdev->is_physfn) {
338 326 pci_dev_put(pdev);
339 if (!pdev->is_physfn)
340 return -ENODEV; 327 return -ENODEV;
328 }
341 329
342 rc = sysfs_create_link(&dev->dev.kobj, 330 rc = sysfs_create_link(&dev->dev.kobj,
343 &pdev->dev.kobj, "dep_link"); 331 &pdev->dev.kobj, "dep_link");
332 pci_dev_put(pdev);
344 if (rc) 333 if (rc)
345 return rc; 334 return rc;
346 } 335 }
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index e4b1fb2c0f5d..dbdc5f7e2b29 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -186,8 +186,8 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
186 [PCI_D0] = ACPI_STATE_D0, 186 [PCI_D0] = ACPI_STATE_D0,
187 [PCI_D1] = ACPI_STATE_D1, 187 [PCI_D1] = ACPI_STATE_D1,
188 [PCI_D2] = ACPI_STATE_D2, 188 [PCI_D2] = ACPI_STATE_D2,
189 [PCI_D3hot] = ACPI_STATE_D3, 189 [PCI_D3hot] = ACPI_STATE_D3_COLD,
190 [PCI_D3cold] = ACPI_STATE_D3 190 [PCI_D3cold] = ACPI_STATE_D3_COLD,
191 }; 191 };
192 int error = -EINVAL; 192 int error = -EINVAL;
193 193
@@ -211,7 +211,7 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
211 211
212 if (!error) 212 if (!error)
213 dev_info(&dev->dev, "power state changed by ACPI to %s\n", 213 dev_info(&dev->dev, "power state changed by ACPI to %s\n",
214 pci_power_name(state)); 214 acpi_power_state_string(state_conv[state]));
215 215
216 return error; 216 return error;
217} 217}
@@ -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..c0dbe1f61362 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) {
@@ -325,6 +325,8 @@ dev_rescan_store(struct device *dev, struct device_attribute *attr,
325 } 325 }
326 return count; 326 return count;
327} 327}
328struct device_attribute dev_rescan_attr = __ATTR(rescan, (S_IWUSR|S_IWGRP),
329 NULL, dev_rescan_store);
328 330
329static void remove_callback(struct device *dev) 331static void remove_callback(struct device *dev)
330{ 332{
@@ -342,7 +344,7 @@ remove_store(struct device *dev, struct device_attribute *dummy,
342 int ret = 0; 344 int ret = 0;
343 unsigned long val; 345 unsigned long val;
344 346
345 if (strict_strtoul(buf, 0, &val) < 0) 347 if (kstrtoul(buf, 0, &val) < 0)
346 return -EINVAL; 348 return -EINVAL;
347 349
348 /* An attribute cannot be unregistered by one of its own methods, 350 /* An attribute cannot be unregistered by one of its own methods,
@@ -354,6 +356,8 @@ remove_store(struct device *dev, struct device_attribute *dummy,
354 count = ret; 356 count = ret;
355 return count; 357 return count;
356} 358}
359struct device_attribute dev_remove_attr = __ATTR(remove, (S_IWUSR|S_IWGRP),
360 NULL, remove_store);
357 361
358static ssize_t 362static ssize_t
359dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, 363dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
@@ -362,7 +366,7 @@ dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
362 unsigned long val; 366 unsigned long val;
363 struct pci_bus *bus = to_pci_bus(dev); 367 struct pci_bus *bus = to_pci_bus(dev);
364 368
365 if (strict_strtoul(buf, 0, &val) < 0) 369 if (kstrtoul(buf, 0, &val) < 0)
366 return -EINVAL; 370 return -EINVAL;
367 371
368 if (val) { 372 if (val) {
@@ -384,7 +388,7 @@ static ssize_t d3cold_allowed_store(struct device *dev,
384 struct pci_dev *pdev = to_pci_dev(dev); 388 struct pci_dev *pdev = to_pci_dev(dev);
385 unsigned long val; 389 unsigned long val;
386 390
387 if (strict_strtoul(buf, 0, &val) < 0) 391 if (kstrtoul(buf, 0, &val) < 0)
388 return -EINVAL; 392 return -EINVAL;
389 393
390 pdev->d3cold_allowed = !!val; 394 pdev->d3cold_allowed = !!val;
@@ -504,8 +508,6 @@ struct device_attribute pci_dev_attrs[] = {
504 __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), 508 __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),
505 broken_parity_status_show,broken_parity_status_store), 509 broken_parity_status_show,broken_parity_status_store),
506 __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store), 510 __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store),
507 __ATTR(remove, (S_IWUSR|S_IWGRP), NULL, remove_store),
508 __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store),
509#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) 511#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
510 __ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store), 512 __ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store),
511#endif 513#endif
@@ -1236,7 +1238,7 @@ static ssize_t reset_store(struct device *dev,
1236{ 1238{
1237 struct pci_dev *pdev = to_pci_dev(dev); 1239 struct pci_dev *pdev = to_pci_dev(dev);
1238 unsigned long val; 1240 unsigned long val;
1239 ssize_t result = strict_strtoul(buf, 0, &val); 1241 ssize_t result = kstrtoul(buf, 0, &val);
1240 1242
1241 if (result < 0) 1243 if (result < 0)
1242 return result; 1244 return result;
@@ -1463,6 +1465,29 @@ static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
1463 return a->mode; 1465 return a->mode;
1464} 1466}
1465 1467
1468static struct attribute *pci_dev_hp_attrs[] = {
1469 &dev_remove_attr.attr,
1470 &dev_rescan_attr.attr,
1471 NULL,
1472};
1473
1474static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj,
1475 struct attribute *a, int n)
1476{
1477 struct device *dev = container_of(kobj, struct device, kobj);
1478 struct pci_dev *pdev = to_pci_dev(dev);
1479
1480 if (pdev->is_virtfn)
1481 return 0;
1482
1483 return a->mode;
1484}
1485
1486static struct attribute_group pci_dev_hp_attr_group = {
1487 .attrs = pci_dev_hp_attrs,
1488 .is_visible = pci_dev_hp_attrs_are_visible,
1489};
1490
1466#ifdef CONFIG_PCI_IOV 1491#ifdef CONFIG_PCI_IOV
1467static struct attribute *sriov_dev_attrs[] = { 1492static struct attribute *sriov_dev_attrs[] = {
1468 &sriov_totalvfs_attr.attr, 1493 &sriov_totalvfs_attr.attr,
@@ -1494,6 +1519,7 @@ static struct attribute_group pci_dev_attr_group = {
1494 1519
1495static const struct attribute_group *pci_dev_attr_groups[] = { 1520static const struct attribute_group *pci_dev_attr_groups[] = {
1496 &pci_dev_attr_group, 1521 &pci_dev_attr_group,
1522 &pci_dev_hp_attr_group,
1497#ifdef CONFIG_PCI_IOV 1523#ifdef CONFIG_PCI_IOV
1498 &sriov_dev_attr_group, 1524 &sriov_dev_attr_group,
1499#endif 1525#endif
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a899d8bb190d..709791b70ca0 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1335,6 +1335,16 @@ int __weak pcibios_add_device (struct pci_dev *dev)
1335} 1335}
1336 1336
1337/** 1337/**
1338 * pcibios_release_device - provide arch specific hooks when releasing device dev
1339 * @dev: the PCI device being released
1340 *
1341 * Permits the platform to provide architecture specific functionality when
1342 * devices are released. This is the default implementation. Architecture
1343 * implementations can override this.
1344 */
1345void __weak pcibios_release_device(struct pci_dev *dev) {}
1346
1347/**
1338 * pcibios_disable_device - disable arch specific PCI resources for device dev 1348 * pcibios_disable_device - disable arch specific PCI resources for device dev
1339 * @dev: the PCI device to disable 1349 * @dev: the PCI device to disable
1340 * 1350 *
@@ -2421,7 +2431,7 @@ bool pci_acs_path_enabled(struct pci_dev *start,
2421/** 2431/**
2422 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge 2432 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge
2423 * @dev: the PCI device 2433 * @dev: the PCI device
2424 * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTD, 4=INTD) 2434 * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTC, 4=INTD)
2425 * 2435 *
2426 * Perform INTx swizzling for a device behind one level of bridge. This is 2436 * 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 2437 * required by section 9.1 of the PCI-to-PCI bridge specification for devices
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index d12c77cd6991..90ea3e88041f 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -13,10 +13,6 @@
13#include <linux/aer.h> 13#include <linux/aer.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15 15
16#define AER_NONFATAL 0
17#define AER_FATAL 1
18#define AER_CORRECTABLE 2
19
20#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \ 16#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \
21 PCI_EXP_RTCTL_SENFEE| \ 17 PCI_EXP_RTCTL_SENFEE| \
22 PCI_EXP_RTCTL_SEFEE) 18 PCI_EXP_RTCTL_SEFEE)
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
index 5194a7d41730..cf611ab2193a 100644
--- a/drivers/pci/pcie/aer/aerdrv_acpi.c
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -29,6 +29,22 @@ static inline int hest_match_pci(struct acpi_hest_aer_common *p,
29 p->function == PCI_FUNC(pci->devfn)); 29 p->function == PCI_FUNC(pci->devfn));
30} 30}
31 31
32static inline bool hest_match_type(struct acpi_hest_header *hest_hdr,
33 struct pci_dev *dev)
34{
35 u16 hest_type = hest_hdr->type;
36 u8 pcie_type = pci_pcie_type(dev);
37
38 if ((hest_type == ACPI_HEST_TYPE_AER_ROOT_PORT &&
39 pcie_type == PCI_EXP_TYPE_ROOT_PORT) ||
40 (hest_type == ACPI_HEST_TYPE_AER_ENDPOINT &&
41 pcie_type == PCI_EXP_TYPE_ENDPOINT) ||
42 (hest_type == ACPI_HEST_TYPE_AER_BRIDGE &&
43 (dev->class >> 16) == PCI_BASE_CLASS_BRIDGE))
44 return true;
45 return false;
46}
47
32struct aer_hest_parse_info { 48struct aer_hest_parse_info {
33 struct pci_dev *pci_dev; 49 struct pci_dev *pci_dev;
34 int firmware_first; 50 int firmware_first;
@@ -38,34 +54,16 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
38{ 54{
39 struct aer_hest_parse_info *info = data; 55 struct aer_hest_parse_info *info = data;
40 struct acpi_hest_aer_common *p; 56 struct acpi_hest_aer_common *p;
41 u8 pcie_type = 0; 57 int ff;
42 u8 bridge = 0;
43 int ff = 0;
44
45 switch (hest_hdr->type) {
46 case ACPI_HEST_TYPE_AER_ROOT_PORT:
47 pcie_type = PCI_EXP_TYPE_ROOT_PORT;
48 break;
49 case ACPI_HEST_TYPE_AER_ENDPOINT:
50 pcie_type = PCI_EXP_TYPE_ENDPOINT;
51 break;
52 case ACPI_HEST_TYPE_AER_BRIDGE:
53 if ((info->pci_dev->class >> 16) == PCI_BASE_CLASS_BRIDGE)
54 bridge = 1;
55 break;
56 default:
57 return 0;
58 }
59 58
60 p = (struct acpi_hest_aer_common *)(hest_hdr + 1); 59 p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
60 ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
61 if (p->flags & ACPI_HEST_GLOBAL) { 61 if (p->flags & ACPI_HEST_GLOBAL) {
62 if ((pci_is_pcie(info->pci_dev) && 62 if (hest_match_type(hest_hdr, info->pci_dev))
63 pci_pcie_type(info->pci_dev) == pcie_type) || bridge) 63 info->firmware_first = ff;
64 ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
65 } else 64 } else
66 if (hest_match_pci(p, info->pci_dev)) 65 if (hest_match_pci(p, info->pci_dev))
67 ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); 66 info->firmware_first = ff;
68 info->firmware_first = ff;
69 67
70 return 0; 68 return 0;
71} 69}
@@ -89,6 +87,9 @@ static void aer_set_firmware_first(struct pci_dev *pci_dev)
89 87
90int pcie_aer_get_firmware_first(struct pci_dev *dev) 88int pcie_aer_get_firmware_first(struct pci_dev *dev)
91{ 89{
90 if (!pci_is_pcie(dev))
91 return 0;
92
92 if (!dev->__aer_firmware_first_valid) 93 if (!dev->__aer_firmware_first_valid)
93 aer_set_firmware_first(dev); 94 aer_set_firmware_first(dev);
94 return dev->__aer_firmware_first; 95 return dev->__aer_firmware_first;
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 8ec8b4f48560..d9e776e69fe8 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -400,16 +400,16 @@ void aer_do_secondary_bus_reset(struct pci_dev *dev)
400} 400}
401 401
402/** 402/**
403 * default_downstream_reset_link - default reset function for Downstream Port 403 * default_reset_link - default reset function
404 * @dev: pointer to downstream port's pci_dev data structure 404 * @dev: pointer to pci_dev data structure
405 * 405 *
406 * Invoked when performing link reset at Downstream Port w/ no aer driver. 406 * Invoked when performing link reset on a Downstream Port or a
407 * Root Port with no aer driver.
407 */ 408 */
408static pci_ers_result_t default_downstream_reset_link(struct pci_dev *dev) 409static pci_ers_result_t default_reset_link(struct pci_dev *dev)
409{ 410{
410 aer_do_secondary_bus_reset(dev); 411 aer_do_secondary_bus_reset(dev);
411 dev_printk(KERN_DEBUG, &dev->dev, 412 dev_printk(KERN_DEBUG, &dev->dev, "downstream link has been reset\n");
412 "Downstream Port link has been reset\n");
413 return PCI_ERS_RESULT_RECOVERED; 413 return PCI_ERS_RESULT_RECOVERED;
414} 414}
415 415
@@ -458,8 +458,9 @@ static pci_ers_result_t reset_link(struct pci_dev *dev)
458 458
459 if (driver && driver->reset_link) { 459 if (driver && driver->reset_link) {
460 status = driver->reset_link(udev); 460 status = driver->reset_link(udev);
461 } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) { 461 } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM ||
462 status = default_downstream_reset_link(udev); 462 pci_pcie_type(udev) == PCI_EXP_TYPE_ROOT_PORT) {
463 status = default_reset_link(udev);
463 } else { 464 } else {
464 dev_printk(KERN_DEBUG, &dev->dev, 465 dev_printk(KERN_DEBUG, &dev->dev,
465 "no link-reset support at upstream device %s\n", 466 "no link-reset support at upstream device %s\n",
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/pcie/pme.c b/drivers/pci/pcie/pme.c
index 795db1f9d50c..e56e594ce112 100644
--- a/drivers/pci/pcie/pme.c
+++ b/drivers/pci/pcie/pme.c
@@ -408,7 +408,7 @@ static int pcie_pme_resume(struct pcie_device *srv)
408 408
409/** 409/**
410 * pcie_pme_remove - Prepare PCIe PME service device for removal. 410 * pcie_pme_remove - Prepare PCIe PME service device for removal.
411 * @srv - PCIe service device to resume. 411 * @srv - PCIe service device to remove.
412 */ 412 */
413static void pcie_pme_remove(struct pcie_device *srv) 413static void pcie_pme_remove(struct pcie_device *srv)
414{ 414{
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 70f10fa3c1b2..46ada5c098eb 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}
@@ -451,33 +470,46 @@ void pci_read_bridge_bases(struct pci_bus *child)
451 } 470 }
452} 471}
453 472
454static struct pci_bus * pci_alloc_bus(void) 473static struct pci_bus *pci_alloc_bus(void)
455{ 474{
456 struct pci_bus *b; 475 struct pci_bus *b;
457 476
458 b = kzalloc(sizeof(*b), GFP_KERNEL); 477 b = kzalloc(sizeof(*b), GFP_KERNEL);
459 if (b) { 478 if (!b)
460 INIT_LIST_HEAD(&b->node); 479 return NULL;
461 INIT_LIST_HEAD(&b->children); 480
462 INIT_LIST_HEAD(&b->devices); 481 INIT_LIST_HEAD(&b->node);
463 INIT_LIST_HEAD(&b->slots); 482 INIT_LIST_HEAD(&b->children);
464 INIT_LIST_HEAD(&b->resources); 483 INIT_LIST_HEAD(&b->devices);
465 b->max_bus_speed = PCI_SPEED_UNKNOWN; 484 INIT_LIST_HEAD(&b->slots);
466 b->cur_bus_speed = PCI_SPEED_UNKNOWN; 485 INIT_LIST_HEAD(&b->resources);
467 } 486 b->max_bus_speed = PCI_SPEED_UNKNOWN;
487 b->cur_bus_speed = PCI_SPEED_UNKNOWN;
468 return b; 488 return b;
469} 489}
470 490
491static void pci_release_host_bridge_dev(struct device *dev)
492{
493 struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
494
495 if (bridge->release_fn)
496 bridge->release_fn(bridge);
497
498 pci_free_resource_list(&bridge->windows);
499
500 kfree(bridge);
501}
502
471static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b) 503static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
472{ 504{
473 struct pci_host_bridge *bridge; 505 struct pci_host_bridge *bridge;
474 506
475 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); 507 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
476 if (bridge) { 508 if (!bridge)
477 INIT_LIST_HEAD(&bridge->windows); 509 return NULL;
478 bridge->bus = b;
479 }
480 510
511 INIT_LIST_HEAD(&bridge->windows);
512 bridge->bus = b;
481 return bridge; 513 return bridge;
482} 514}
483 515
@@ -1132,6 +1164,8 @@ static void pci_release_dev(struct device *dev)
1132 pci_dev = to_pci_dev(dev); 1164 pci_dev = to_pci_dev(dev);
1133 pci_release_capabilities(pci_dev); 1165 pci_release_capabilities(pci_dev);
1134 pci_release_of_node(pci_dev); 1166 pci_release_of_node(pci_dev);
1167 pcibios_release_device(pci_dev);
1168 pci_bus_put(pci_dev->bus);
1135 kfree(pci_dev); 1169 kfree(pci_dev);
1136} 1170}
1137 1171
@@ -1188,19 +1222,7 @@ int pci_cfg_space_size(struct pci_dev *dev)
1188 return PCI_CFG_SPACE_SIZE; 1222 return PCI_CFG_SPACE_SIZE;
1189} 1223}
1190 1224
1191static void pci_release_bus_bridge_dev(struct device *dev) 1225struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
1192{
1193 struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
1194
1195 if (bridge->release_fn)
1196 bridge->release_fn(bridge);
1197
1198 pci_free_resource_list(&bridge->windows);
1199
1200 kfree(bridge);
1201}
1202
1203struct pci_dev *alloc_pci_dev(void)
1204{ 1226{
1205 struct pci_dev *dev; 1227 struct pci_dev *dev;
1206 1228
@@ -1210,9 +1232,16 @@ struct pci_dev *alloc_pci_dev(void)
1210 1232
1211 INIT_LIST_HEAD(&dev->bus_list); 1233 INIT_LIST_HEAD(&dev->bus_list);
1212 dev->dev.type = &pci_dev_type; 1234 dev->dev.type = &pci_dev_type;
1235 dev->bus = pci_bus_get(bus);
1213 1236
1214 return dev; 1237 return dev;
1215} 1238}
1239EXPORT_SYMBOL(pci_alloc_dev);
1240
1241struct pci_dev *alloc_pci_dev(void)
1242{
1243 return pci_alloc_dev(NULL);
1244}
1216EXPORT_SYMBOL(alloc_pci_dev); 1245EXPORT_SYMBOL(alloc_pci_dev);
1217 1246
1218bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, 1247bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
@@ -1263,11 +1292,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
1263 if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) 1292 if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
1264 return NULL; 1293 return NULL;
1265 1294
1266 dev = alloc_pci_dev(); 1295 dev = pci_alloc_dev(bus);
1267 if (!dev) 1296 if (!dev)
1268 return NULL; 1297 return NULL;
1269 1298
1270 dev->bus = bus;
1271 dev->devfn = devfn; 1299 dev->devfn = devfn;
1272 dev->vendor = l & 0xffff; 1300 dev->vendor = l & 0xffff;
1273 dev->device = (l >> 16) & 0xffff; 1301 dev->device = (l >> 16) & 0xffff;
@@ -1275,6 +1303,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
1275 pci_set_of_node(dev); 1303 pci_set_of_node(dev);
1276 1304
1277 if (pci_setup_device(dev)) { 1305 if (pci_setup_device(dev)) {
1306 pci_bus_put(dev->bus);
1278 kfree(dev); 1307 kfree(dev);
1279 return NULL; 1308 return NULL;
1280 } 1309 }
@@ -1700,15 +1729,19 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
1700 goto err_out; 1729 goto err_out;
1701 1730
1702 bridge->dev.parent = parent; 1731 bridge->dev.parent = parent;
1703 bridge->dev.release = pci_release_bus_bridge_dev; 1732 bridge->dev.release = pci_release_host_bridge_dev;
1704 dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus); 1733 dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
1705 error = pcibios_root_bridge_prepare(bridge); 1734 error = pcibios_root_bridge_prepare(bridge);
1706 if (error) 1735 if (error) {
1707 goto bridge_dev_reg_err; 1736 kfree(bridge);
1737 goto err_out;
1738 }
1708 1739
1709 error = device_register(&bridge->dev); 1740 error = device_register(&bridge->dev);
1710 if (error) 1741 if (error) {
1711 goto bridge_dev_reg_err; 1742 put_device(&bridge->dev);
1743 goto err_out;
1744 }
1712 b->bridge = get_device(&bridge->dev); 1745 b->bridge = get_device(&bridge->dev);
1713 device_enable_async_suspend(b->bridge); 1746 device_enable_async_suspend(b->bridge);
1714 pci_set_bus_of_node(b); 1747 pci_set_bus_of_node(b);
@@ -1764,8 +1797,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
1764class_dev_reg_err: 1797class_dev_reg_err:
1765 put_device(&bridge->dev); 1798 put_device(&bridge->dev);
1766 device_unregister(&bridge->dev); 1799 device_unregister(&bridge->dev);
1767bridge_dev_reg_err:
1768 kfree(bridge);
1769err_out: 1800err_out:
1770 kfree(b); 1801 kfree(b);
1771 return NULL; 1802 return NULL;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 7d68aeebf56b..c3a04026cca8 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1022,6 +1022,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk
1022DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); 1022DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
1023DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode); 1023DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
1024DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode); 1024DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
1025DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode);
1026DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode);
1025 1027
1026/* 1028/*
1027 * Serverworks CSB5 IDE does not fully support native mode 1029 * Serverworks CSB5 IDE does not fully support native mode
@@ -2865,6 +2867,31 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata);
2865DECLARE_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);
2866 2868
2867 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
2868static ktime_t fixup_debug_start(struct pci_dev *dev, 2895static ktime_t fixup_debug_start(struct pci_dev *dev,
2869 void (*fn)(struct pci_dev *dev)) 2896 void (*fn)(struct pci_dev *dev))
2870{ 2897{
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 846f475f62c1..90c95a3385d1 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2026,7 +2026,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
2026static inline int 2026static inline int
2027make_local_pdev(adapter_t *adapter, struct pci_dev **pdev) 2027make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
2028{ 2028{
2029 *pdev = alloc_pci_dev(); 2029 *pdev = pci_alloc_dev(NULL);
2030 2030
2031 if( *pdev == NULL ) return -1; 2031 if( *pdev == NULL ) return -1;
2032 2032
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/linux/aer.h b/include/linux/aer.h
index ec10e1b24c1c..55bb3dc4b2db 100644
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -7,6 +7,10 @@
7#ifndef _AER_H_ 7#ifndef _AER_H_
8#define _AER_H_ 8#define _AER_H_
9 9
10#define AER_NONFATAL 0
11#define AER_FATAL 1
12#define AER_CORRECTABLE 2
13
10struct aer_header_log_regs { 14struct aer_header_log_regs {
11 unsigned int dw0; 15 unsigned int dw0;
12 unsigned int dw1; 16 unsigned int dw1;
@@ -31,9 +35,9 @@ struct aer_capability_regs {
31 35
32#if defined(CONFIG_PCIEAER) 36#if defined(CONFIG_PCIEAER)
33/* pci-e port driver needs this function to enable aer */ 37/* pci-e port driver needs this function to enable aer */
34extern int pci_enable_pcie_error_reporting(struct pci_dev *dev); 38int pci_enable_pcie_error_reporting(struct pci_dev *dev);
35extern int pci_disable_pcie_error_reporting(struct pci_dev *dev); 39int pci_disable_pcie_error_reporting(struct pci_dev *dev);
36extern int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev); 40int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev);
37#else 41#else
38static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev) 42static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
39{ 43{
@@ -49,10 +53,10 @@ static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
49} 53}
50#endif 54#endif
51 55
52extern void cper_print_aer(const char *prefix, struct pci_dev *dev, 56void cper_print_aer(const char *prefix, struct pci_dev *dev, int cper_severity,
53 int cper_severity, struct aer_capability_regs *aer); 57 struct aer_capability_regs *aer);
54extern int cper_severity_to_aer(int cper_severity); 58int cper_severity_to_aer(int cper_severity);
55extern void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn, 59void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
56 int severity); 60 int severity);
57#endif //_AER_H_ 61#endif //_AER_H_
58 62
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3a24e4ff3248..0fd1f1582fa1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -364,7 +364,8 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
364 return dev; 364 return dev;
365} 365}
366 366
367struct pci_dev *alloc_pci_dev(void); 367struct pci_dev *pci_alloc_dev(struct pci_bus *bus);
368struct pci_dev * __deprecated alloc_pci_dev(void);
368 369
369#define to_pci_dev(n) container_of(n, struct pci_dev, dev) 370#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
370#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) 371#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
@@ -1018,6 +1019,8 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
1018void pci_release_selected_regions(struct pci_dev *, int); 1019void pci_release_selected_regions(struct pci_dev *, int);
1019 1020
1020/* drivers/pci/bus.c */ 1021/* drivers/pci/bus.c */
1022struct pci_bus *pci_bus_get(struct pci_bus *bus);
1023void pci_bus_put(struct pci_bus *bus);
1021void pci_add_resource(struct list_head *resources, struct resource *res); 1024void pci_add_resource(struct list_head *resources, struct resource *res);
1022void pci_add_resource_offset(struct list_head *resources, struct resource *res, 1025void pci_add_resource_offset(struct list_head *resources, struct resource *res,
1023 resource_size_t offset); 1026 resource_size_t offset);
@@ -1643,6 +1646,7 @@ void pcibios_set_master(struct pci_dev *dev);
1643int pcibios_set_pcie_reset_state(struct pci_dev *dev, 1646int pcibios_set_pcie_reset_state(struct pci_dev *dev,
1644 enum pcie_reset_state state); 1647 enum pcie_reset_state state);
1645int pcibios_add_device(struct pci_dev *dev); 1648int pcibios_add_device(struct pci_dev *dev);
1649void pcibios_release_device(struct pci_dev *dev);
1646 1650
1647#ifdef CONFIG_PCI_MMCONFIG 1651#ifdef CONFIG_PCI_MMCONFIG
1648void __init pci_mmcfg_early_init(void); 1652void __init pci_mmcfg_early_init(void);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index c12916248469..84c0bcc2a147 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -556,7 +556,6 @@
556#define PCI_DEVICE_ID_AMD_8131_BRIDGE 0x7450 556#define PCI_DEVICE_ID_AMD_8131_BRIDGE 0x7450
557#define PCI_DEVICE_ID_AMD_8131_APIC 0x7451 557#define PCI_DEVICE_ID_AMD_8131_APIC 0x7451
558#define PCI_DEVICE_ID_AMD_8132_BRIDGE 0x7458 558#define PCI_DEVICE_ID_AMD_8132_BRIDGE 0x7458
559#define PCI_DEVICE_ID_AMD_HUDSON2_SMBUS 0x780b
560#define PCI_DEVICE_ID_AMD_CS5535_IDE 0x208F 559#define PCI_DEVICE_ID_AMD_CS5535_IDE 0x208F
561#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090 560#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090
562#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091 561#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091
@@ -568,8 +567,9 @@
568#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A 567#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A
569#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 568#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081
570#define PCI_DEVICE_ID_AMD_LX_AES 0x2082 569#define PCI_DEVICE_ID_AMD_LX_AES 0x2082
571#define PCI_DEVICE_ID_AMD_HUDSON2_IDE 0x780c
572#define PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE 0x7800 570#define PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE 0x7800
571#define PCI_DEVICE_ID_AMD_HUDSON2_SMBUS 0x780b
572#define PCI_DEVICE_ID_AMD_HUDSON2_IDE 0x780c
573 573
574#define PCI_VENDOR_ID_TRIDENT 0x1023 574#define PCI_VENDOR_ID_TRIDENT 0x1023
575#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000 575#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000
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 */