diff options
Diffstat (limited to 'drivers/pci')
56 files changed, 2005 insertions, 1410 deletions
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 4b47f4ece5b..af3bfe22847 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile | |||
@@ -3,7 +3,8 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += access.o bus.o probe.o remove.o pci.o quirks.o slot.o \ | 5 | obj-y += access.o bus.o probe.o remove.o pci.o quirks.o slot.o \ |
6 | pci-driver.o search.o pci-sysfs.o rom.o setup-res.o | 6 | pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ |
7 | irq.o | ||
7 | obj-$(CONFIG_PROC_FS) += proc.o | 8 | obj-$(CONFIG_PROC_FS) += proc.o |
8 | 9 | ||
9 | # Build PCI Express stuff if needed | 10 | # Build PCI Express stuff if needed |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 529d9d7727b..999cc4088b5 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -151,6 +151,13 @@ void pci_bus_add_devices(struct pci_bus *bus) | |||
151 | if (retval) | 151 | if (retval) |
152 | dev_err(&dev->dev, "Error creating cpuaffinity" | 152 | dev_err(&dev->dev, "Error creating cpuaffinity" |
153 | " file, continuing...\n"); | 153 | " file, continuing...\n"); |
154 | |||
155 | retval = device_create_file(&child_bus->dev, | ||
156 | &dev_attr_cpulistaffinity); | ||
157 | if (retval) | ||
158 | dev_err(&dev->dev, | ||
159 | "Error creating cpulistaffinity" | ||
160 | " file, continuing...\n"); | ||
154 | } | 161 | } |
155 | } | 162 | } |
156 | } | 163 | } |
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c index e842e756308..691b3adeb87 100644 --- a/drivers/pci/dmar.c +++ b/drivers/pci/dmar.c | |||
@@ -188,12 +188,11 @@ dmar_parse_one_drhd(struct acpi_dmar_header *header) | |||
188 | return 0; | 188 | return 0; |
189 | } | 189 | } |
190 | 190 | ||
191 | static int __init | 191 | static int __init dmar_parse_dev(struct dmar_drhd_unit *dmaru) |
192 | dmar_parse_dev(struct dmar_drhd_unit *dmaru) | ||
193 | { | 192 | { |
194 | struct acpi_dmar_hardware_unit *drhd; | 193 | struct acpi_dmar_hardware_unit *drhd; |
195 | static int include_all; | 194 | static int include_all; |
196 | int ret; | 195 | int ret = 0; |
197 | 196 | ||
198 | drhd = (struct acpi_dmar_hardware_unit *) dmaru->hdr; | 197 | drhd = (struct acpi_dmar_hardware_unit *) dmaru->hdr; |
199 | 198 | ||
@@ -212,7 +211,7 @@ dmar_parse_dev(struct dmar_drhd_unit *dmaru) | |||
212 | include_all = 1; | 211 | include_all = 1; |
213 | } | 212 | } |
214 | 213 | ||
215 | if (ret || (dmaru->devices_cnt == 0 && !dmaru->include_all)) { | 214 | if (ret) { |
216 | list_del(&dmaru->list); | 215 | list_del(&dmaru->list); |
217 | kfree(dmaru); | 216 | kfree(dmaru); |
218 | } | 217 | } |
@@ -277,18 +276,37 @@ dmar_table_print_dmar_entry(struct acpi_dmar_header *header) | |||
277 | drhd = (struct acpi_dmar_hardware_unit *)header; | 276 | drhd = (struct acpi_dmar_hardware_unit *)header; |
278 | printk (KERN_INFO PREFIX | 277 | printk (KERN_INFO PREFIX |
279 | "DRHD (flags: 0x%08x)base: 0x%016Lx\n", | 278 | "DRHD (flags: 0x%08x)base: 0x%016Lx\n", |
280 | drhd->flags, drhd->address); | 279 | drhd->flags, (unsigned long long)drhd->address); |
281 | break; | 280 | break; |
282 | case ACPI_DMAR_TYPE_RESERVED_MEMORY: | 281 | case ACPI_DMAR_TYPE_RESERVED_MEMORY: |
283 | rmrr = (struct acpi_dmar_reserved_memory *)header; | 282 | rmrr = (struct acpi_dmar_reserved_memory *)header; |
284 | 283 | ||
285 | printk (KERN_INFO PREFIX | 284 | printk (KERN_INFO PREFIX |
286 | "RMRR base: 0x%016Lx end: 0x%016Lx\n", | 285 | "RMRR base: 0x%016Lx end: 0x%016Lx\n", |
287 | rmrr->base_address, rmrr->end_address); | 286 | (unsigned long long)rmrr->base_address, |
287 | (unsigned long long)rmrr->end_address); | ||
288 | break; | 288 | break; |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | /** | ||
293 | * dmar_table_detect - checks to see if the platform supports DMAR devices | ||
294 | */ | ||
295 | static int __init dmar_table_detect(void) | ||
296 | { | ||
297 | acpi_status status = AE_OK; | ||
298 | |||
299 | /* if we could find DMAR table, then there are DMAR devices */ | ||
300 | status = acpi_get_table(ACPI_SIG_DMAR, 0, | ||
301 | (struct acpi_table_header **)&dmar_tbl); | ||
302 | |||
303 | if (ACPI_SUCCESS(status) && !dmar_tbl) { | ||
304 | printk (KERN_WARNING PREFIX "Unable to map DMAR\n"); | ||
305 | status = AE_NOT_FOUND; | ||
306 | } | ||
307 | |||
308 | return (ACPI_SUCCESS(status) ? 1 : 0); | ||
309 | } | ||
292 | 310 | ||
293 | /** | 311 | /** |
294 | * parse_dmar_table - parses the DMA reporting table | 312 | * parse_dmar_table - parses the DMA reporting table |
@@ -300,11 +318,17 @@ parse_dmar_table(void) | |||
300 | struct acpi_dmar_header *entry_header; | 318 | struct acpi_dmar_header *entry_header; |
301 | int ret = 0; | 319 | int ret = 0; |
302 | 320 | ||
321 | /* | ||
322 | * Do it again, earlier dmar_tbl mapping could be mapped with | ||
323 | * fixed map. | ||
324 | */ | ||
325 | dmar_table_detect(); | ||
326 | |||
303 | dmar = (struct acpi_table_dmar *)dmar_tbl; | 327 | dmar = (struct acpi_table_dmar *)dmar_tbl; |
304 | if (!dmar) | 328 | if (!dmar) |
305 | return -ENODEV; | 329 | return -ENODEV; |
306 | 330 | ||
307 | if (dmar->width < PAGE_SHIFT_4K - 1) { | 331 | if (dmar->width < PAGE_SHIFT - 1) { |
308 | printk(KERN_WARNING PREFIX "Invalid DMAR haw\n"); | 332 | printk(KERN_WARNING PREFIX "Invalid DMAR haw\n"); |
309 | return -EINVAL; | 333 | return -EINVAL; |
310 | } | 334 | } |
@@ -373,10 +397,10 @@ dmar_find_matched_drhd_unit(struct pci_dev *dev) | |||
373 | 397 | ||
374 | int __init dmar_dev_scope_init(void) | 398 | int __init dmar_dev_scope_init(void) |
375 | { | 399 | { |
376 | struct dmar_drhd_unit *drhd; | 400 | struct dmar_drhd_unit *drhd, *drhd_n; |
377 | int ret = -ENODEV; | 401 | int ret = -ENODEV; |
378 | 402 | ||
379 | for_each_drhd_unit(drhd) { | 403 | list_for_each_entry_safe(drhd, drhd_n, &dmar_drhd_units, list) { |
380 | ret = dmar_parse_dev(drhd); | 404 | ret = dmar_parse_dev(drhd); |
381 | if (ret) | 405 | if (ret) |
382 | return ret; | 406 | return ret; |
@@ -384,8 +408,8 @@ int __init dmar_dev_scope_init(void) | |||
384 | 408 | ||
385 | #ifdef CONFIG_DMAR | 409 | #ifdef CONFIG_DMAR |
386 | { | 410 | { |
387 | struct dmar_rmrr_unit *rmrr; | 411 | struct dmar_rmrr_unit *rmrr, *rmrr_n; |
388 | for_each_rmrr_units(rmrr) { | 412 | list_for_each_entry_safe(rmrr, rmrr_n, &dmar_rmrr_units, list) { |
389 | ret = rmrr_parse_dev(rmrr); | 413 | ret = rmrr_parse_dev(rmrr); |
390 | if (ret) | 414 | if (ret) |
391 | return ret; | 415 | return ret; |
@@ -430,33 +454,14 @@ int __init dmar_table_init(void) | |||
430 | return 0; | 454 | return 0; |
431 | } | 455 | } |
432 | 456 | ||
433 | /** | ||
434 | * early_dmar_detect - checks to see if the platform supports DMAR devices | ||
435 | */ | ||
436 | int __init early_dmar_detect(void) | ||
437 | { | ||
438 | acpi_status status = AE_OK; | ||
439 | |||
440 | /* if we could find DMAR table, then there are DMAR devices */ | ||
441 | status = acpi_get_table(ACPI_SIG_DMAR, 0, | ||
442 | (struct acpi_table_header **)&dmar_tbl); | ||
443 | |||
444 | if (ACPI_SUCCESS(status) && !dmar_tbl) { | ||
445 | printk (KERN_WARNING PREFIX "Unable to map DMAR\n"); | ||
446 | status = AE_NOT_FOUND; | ||
447 | } | ||
448 | |||
449 | return (ACPI_SUCCESS(status) ? 1 : 0); | ||
450 | } | ||
451 | |||
452 | void __init detect_intel_iommu(void) | 457 | void __init detect_intel_iommu(void) |
453 | { | 458 | { |
454 | int ret; | 459 | int ret; |
455 | 460 | ||
456 | ret = early_dmar_detect(); | 461 | ret = dmar_table_detect(); |
457 | 462 | ||
458 | #ifdef CONFIG_DMAR | ||
459 | { | 463 | { |
464 | #ifdef CONFIG_INTR_REMAP | ||
460 | struct acpi_table_dmar *dmar; | 465 | struct acpi_table_dmar *dmar; |
461 | /* | 466 | /* |
462 | * for now we will disable dma-remapping when interrupt | 467 | * for now we will disable dma-remapping when interrupt |
@@ -465,28 +470,18 @@ void __init detect_intel_iommu(void) | |||
465 | * is added, we will not need this any more. | 470 | * is added, we will not need this any more. |
466 | */ | 471 | */ |
467 | dmar = (struct acpi_table_dmar *) dmar_tbl; | 472 | dmar = (struct acpi_table_dmar *) dmar_tbl; |
468 | if (ret && cpu_has_x2apic && dmar->flags & 0x1) { | 473 | if (ret && cpu_has_x2apic && dmar->flags & 0x1) |
469 | printk(KERN_INFO | 474 | printk(KERN_INFO |
470 | "Queued invalidation will be enabled to support " | 475 | "Queued invalidation will be enabled to support " |
471 | "x2apic and Intr-remapping.\n"); | 476 | "x2apic and Intr-remapping.\n"); |
472 | printk(KERN_INFO | 477 | #endif |
473 | "Disabling IOMMU detection, because of missing " | 478 | #ifdef CONFIG_DMAR |
474 | "queued invalidation support for IOTLB " | ||
475 | "invalidation\n"); | ||
476 | printk(KERN_INFO | ||
477 | "Use \"nox2apic\", if you want to use Intel " | ||
478 | " IOMMU for DMA-remapping and don't care about " | ||
479 | " x2apic support\n"); | ||
480 | |||
481 | dmar_disabled = 1; | ||
482 | return; | ||
483 | } | ||
484 | |||
485 | if (ret && !no_iommu && !iommu_detected && !swiotlb && | 479 | if (ret && !no_iommu && !iommu_detected && !swiotlb && |
486 | !dmar_disabled) | 480 | !dmar_disabled) |
487 | iommu_detected = 1; | 481 | iommu_detected = 1; |
488 | } | ||
489 | #endif | 482 | #endif |
483 | } | ||
484 | dmar_tbl = NULL; | ||
490 | } | 485 | } |
491 | 486 | ||
492 | 487 | ||
@@ -503,7 +498,7 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) | |||
503 | 498 | ||
504 | iommu->seq_id = iommu_allocated++; | 499 | iommu->seq_id = iommu_allocated++; |
505 | 500 | ||
506 | iommu->reg = ioremap(drhd->reg_base_addr, PAGE_SIZE_4K); | 501 | iommu->reg = ioremap(drhd->reg_base_addr, VTD_PAGE_SIZE); |
507 | if (!iommu->reg) { | 502 | if (!iommu->reg) { |
508 | printk(KERN_ERR "IOMMU: can't map the region\n"); | 503 | printk(KERN_ERR "IOMMU: can't map the region\n"); |
509 | goto error; | 504 | goto error; |
@@ -514,8 +509,8 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) | |||
514 | /* the registers might be more than one page */ | 509 | /* the registers might be more than one page */ |
515 | map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), | 510 | map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), |
516 | cap_max_fault_reg_offset(iommu->cap)); | 511 | cap_max_fault_reg_offset(iommu->cap)); |
517 | map_size = PAGE_ALIGN_4K(map_size); | 512 | map_size = VTD_PAGE_ALIGN(map_size); |
518 | if (map_size > PAGE_SIZE_4K) { | 513 | if (map_size > VTD_PAGE_SIZE) { |
519 | iounmap(iommu->reg); | 514 | iounmap(iommu->reg); |
520 | iommu->reg = ioremap(drhd->reg_base_addr, map_size); | 515 | iommu->reg = ioremap(drhd->reg_base_addr, map_size); |
521 | if (!iommu->reg) { | 516 | if (!iommu->reg) { |
@@ -526,8 +521,10 @@ int alloc_iommu(struct dmar_drhd_unit *drhd) | |||
526 | 521 | ||
527 | ver = readl(iommu->reg + DMAR_VER_REG); | 522 | ver = readl(iommu->reg + DMAR_VER_REG); |
528 | pr_debug("IOMMU %llx: ver %d:%d cap %llx ecap %llx\n", | 523 | pr_debug("IOMMU %llx: ver %d:%d cap %llx ecap %llx\n", |
529 | drhd->reg_base_addr, DMAR_VER_MAJOR(ver), DMAR_VER_MINOR(ver), | 524 | (unsigned long long)drhd->reg_base_addr, |
530 | iommu->cap, iommu->ecap); | 525 | DMAR_VER_MAJOR(ver), DMAR_VER_MINOR(ver), |
526 | (unsigned long long)iommu->cap, | ||
527 | (unsigned long long)iommu->ecap); | ||
531 | 528 | ||
532 | spin_lock_init(&iommu->register_lock); | 529 | spin_lock_init(&iommu->register_lock); |
533 | 530 | ||
@@ -580,11 +577,11 @@ void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu) | |||
580 | 577 | ||
581 | hw = qi->desc; | 578 | hw = qi->desc; |
582 | 579 | ||
583 | spin_lock(&qi->q_lock); | 580 | spin_lock_irqsave(&qi->q_lock, flags); |
584 | while (qi->free_cnt < 3) { | 581 | while (qi->free_cnt < 3) { |
585 | spin_unlock(&qi->q_lock); | 582 | spin_unlock_irqrestore(&qi->q_lock, flags); |
586 | cpu_relax(); | 583 | cpu_relax(); |
587 | spin_lock(&qi->q_lock); | 584 | spin_lock_irqsave(&qi->q_lock, flags); |
588 | } | 585 | } |
589 | 586 | ||
590 | index = qi->free_head; | 587 | index = qi->free_head; |
@@ -605,15 +602,22 @@ void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu) | |||
605 | qi->free_head = (qi->free_head + 2) % QI_LENGTH; | 602 | qi->free_head = (qi->free_head + 2) % QI_LENGTH; |
606 | qi->free_cnt -= 2; | 603 | qi->free_cnt -= 2; |
607 | 604 | ||
608 | spin_lock_irqsave(&iommu->register_lock, flags); | 605 | spin_lock(&iommu->register_lock); |
609 | /* | 606 | /* |
610 | * update the HW tail register indicating the presence of | 607 | * update the HW tail register indicating the presence of |
611 | * new descriptors. | 608 | * new descriptors. |
612 | */ | 609 | */ |
613 | writel(qi->free_head << 4, iommu->reg + DMAR_IQT_REG); | 610 | writel(qi->free_head << 4, iommu->reg + DMAR_IQT_REG); |
614 | spin_unlock_irqrestore(&iommu->register_lock, flags); | 611 | spin_unlock(&iommu->register_lock); |
615 | 612 | ||
616 | while (qi->desc_status[wait_index] != QI_DONE) { | 613 | while (qi->desc_status[wait_index] != QI_DONE) { |
614 | /* | ||
615 | * We will leave the interrupts disabled, to prevent interrupt | ||
616 | * context to queue another cmd while a cmd is already submitted | ||
617 | * and waiting for completion on this cpu. This is to avoid | ||
618 | * a deadlock where the interrupt context can wait indefinitely | ||
619 | * for free slots in the queue. | ||
620 | */ | ||
617 | spin_unlock(&qi->q_lock); | 621 | spin_unlock(&qi->q_lock); |
618 | cpu_relax(); | 622 | cpu_relax(); |
619 | spin_lock(&qi->q_lock); | 623 | spin_lock(&qi->q_lock); |
@@ -622,7 +626,7 @@ void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu) | |||
622 | qi->desc_status[index] = QI_DONE; | 626 | qi->desc_status[index] = QI_DONE; |
623 | 627 | ||
624 | reclaim_free_desc(qi); | 628 | reclaim_free_desc(qi); |
625 | spin_unlock(&qi->q_lock); | 629 | spin_unlock_irqrestore(&qi->q_lock, flags); |
626 | } | 630 | } |
627 | 631 | ||
628 | /* | 632 | /* |
@@ -638,6 +642,62 @@ void qi_global_iec(struct intel_iommu *iommu) | |||
638 | qi_submit_sync(&desc, iommu); | 642 | qi_submit_sync(&desc, iommu); |
639 | } | 643 | } |
640 | 644 | ||
645 | int qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm, | ||
646 | u64 type, int non_present_entry_flush) | ||
647 | { | ||
648 | |||
649 | struct qi_desc desc; | ||
650 | |||
651 | if (non_present_entry_flush) { | ||
652 | if (!cap_caching_mode(iommu->cap)) | ||
653 | return 1; | ||
654 | else | ||
655 | did = 0; | ||
656 | } | ||
657 | |||
658 | desc.low = QI_CC_FM(fm) | QI_CC_SID(sid) | QI_CC_DID(did) | ||
659 | | QI_CC_GRAN(type) | QI_CC_TYPE; | ||
660 | desc.high = 0; | ||
661 | |||
662 | qi_submit_sync(&desc, iommu); | ||
663 | |||
664 | return 0; | ||
665 | |||
666 | } | ||
667 | |||
668 | int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, | ||
669 | unsigned int size_order, u64 type, | ||
670 | int non_present_entry_flush) | ||
671 | { | ||
672 | u8 dw = 0, dr = 0; | ||
673 | |||
674 | struct qi_desc desc; | ||
675 | int ih = 0; | ||
676 | |||
677 | if (non_present_entry_flush) { | ||
678 | if (!cap_caching_mode(iommu->cap)) | ||
679 | return 1; | ||
680 | else | ||
681 | did = 0; | ||
682 | } | ||
683 | |||
684 | if (cap_write_drain(iommu->cap)) | ||
685 | dw = 1; | ||
686 | |||
687 | if (cap_read_drain(iommu->cap)) | ||
688 | dr = 1; | ||
689 | |||
690 | desc.low = QI_IOTLB_DID(did) | QI_IOTLB_DR(dr) | QI_IOTLB_DW(dw) | ||
691 | | QI_IOTLB_GRAN(type) | QI_IOTLB_TYPE; | ||
692 | desc.high = QI_IOTLB_ADDR(addr) | QI_IOTLB_IH(ih) | ||
693 | | QI_IOTLB_AM(size_order); | ||
694 | |||
695 | qi_submit_sync(&desc, iommu); | ||
696 | |||
697 | return 0; | ||
698 | |||
699 | } | ||
700 | |||
641 | /* | 701 | /* |
642 | * Enable Queued Invalidation interface. This is a must to support | 702 | * Enable Queued Invalidation interface. This is a must to support |
643 | * interrupt-remapping. Also used by DMA-remapping, which replaces | 703 | * interrupt-remapping. Also used by DMA-remapping, which replaces |
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index 5a58b075dd8..f9e244da30a 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -50,9 +50,6 @@ | |||
50 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) | 50 | #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) |
51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 51 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
52 | 52 | ||
53 | /* name size which is used for entries in pcihpfs */ | ||
54 | #define SLOT_NAME_SIZE 20 /* {_SUN} */ | ||
55 | |||
56 | struct acpiphp_bridge; | 53 | struct acpiphp_bridge; |
57 | struct acpiphp_slot; | 54 | struct acpiphp_slot; |
58 | 55 | ||
@@ -63,9 +60,13 @@ struct slot { | |||
63 | struct hotplug_slot *hotplug_slot; | 60 | struct hotplug_slot *hotplug_slot; |
64 | struct acpiphp_slot *acpi_slot; | 61 | struct acpiphp_slot *acpi_slot; |
65 | struct hotplug_slot_info info; | 62 | struct hotplug_slot_info info; |
66 | char name[SLOT_NAME_SIZE]; | ||
67 | }; | 63 | }; |
68 | 64 | ||
65 | static inline const char *slot_name(struct slot *slot) | ||
66 | { | ||
67 | return hotplug_slot_name(slot->hotplug_slot); | ||
68 | } | ||
69 | |||
69 | /* | 70 | /* |
70 | * struct acpiphp_bridge - PCI bridge information | 71 | * struct acpiphp_bridge - PCI bridge information |
71 | * | 72 | * |
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 0e496e866a8..95b536a23d2 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -44,6 +44,9 @@ | |||
44 | 44 | ||
45 | #define MY_NAME "acpiphp" | 45 | #define MY_NAME "acpiphp" |
46 | 46 | ||
47 | /* name size which is used for entries in pcihpfs */ | ||
48 | #define SLOT_NAME_SIZE 21 /* {_SUN} */ | ||
49 | |||
47 | static int debug; | 50 | static int debug; |
48 | int acpiphp_debug; | 51 | int acpiphp_debug; |
49 | 52 | ||
@@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = { | |||
84 | .get_adapter_status = get_adapter_status, | 87 | .get_adapter_status = get_adapter_status, |
85 | }; | 88 | }; |
86 | 89 | ||
87 | |||
88 | /** | 90 | /** |
89 | * acpiphp_register_attention - set attention LED callback | 91 | * acpiphp_register_attention - set attention LED callback |
90 | * @info: must be completely filled with LED callbacks | 92 | * @info: must be completely filled with LED callbacks |
@@ -136,7 +138,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) | |||
136 | { | 138 | { |
137 | struct slot *slot = hotplug_slot->private; | 139 | struct slot *slot = hotplug_slot->private; |
138 | 140 | ||
139 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 141 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
140 | 142 | ||
141 | /* enable the specified slot */ | 143 | /* enable the specified slot */ |
142 | return acpiphp_enable_slot(slot->acpi_slot); | 144 | return acpiphp_enable_slot(slot->acpi_slot); |
@@ -154,7 +156,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) | |||
154 | struct slot *slot = hotplug_slot->private; | 156 | struct slot *slot = hotplug_slot->private; |
155 | int retval; | 157 | int retval; |
156 | 158 | ||
157 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 159 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
158 | 160 | ||
159 | /* disable the specified slot */ | 161 | /* disable the specified slot */ |
160 | retval = acpiphp_disable_slot(slot->acpi_slot); | 162 | retval = acpiphp_disable_slot(slot->acpi_slot); |
@@ -177,7 +179,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) | |||
177 | { | 179 | { |
178 | int retval = -ENODEV; | 180 | int retval = -ENODEV; |
179 | 181 | ||
180 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 182 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot)); |
181 | 183 | ||
182 | if (attention_info && try_module_get(attention_info->owner)) { | 184 | if (attention_info && try_module_get(attention_info->owner)) { |
183 | retval = attention_info->set_attn(hotplug_slot, status); | 185 | retval = attention_info->set_attn(hotplug_slot, status); |
@@ -200,7 +202,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
200 | { | 202 | { |
201 | struct slot *slot = hotplug_slot->private; | 203 | struct slot *slot = hotplug_slot->private; |
202 | 204 | ||
203 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 205 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
204 | 206 | ||
205 | *value = acpiphp_get_power_status(slot->acpi_slot); | 207 | *value = acpiphp_get_power_status(slot->acpi_slot); |
206 | 208 | ||
@@ -222,7 +224,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
222 | { | 224 | { |
223 | int retval = -EINVAL; | 225 | int retval = -EINVAL; |
224 | 226 | ||
225 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 227 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot)); |
226 | 228 | ||
227 | if (attention_info && try_module_get(attention_info->owner)) { | 229 | if (attention_info && try_module_get(attention_info->owner)) { |
228 | retval = attention_info->get_attn(hotplug_slot, value); | 230 | retval = attention_info->get_attn(hotplug_slot, value); |
@@ -245,7 +247,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
245 | { | 247 | { |
246 | struct slot *slot = hotplug_slot->private; | 248 | struct slot *slot = hotplug_slot->private; |
247 | 249 | ||
248 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 250 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
249 | 251 | ||
250 | *value = acpiphp_get_latch_status(slot->acpi_slot); | 252 | *value = acpiphp_get_latch_status(slot->acpi_slot); |
251 | 253 | ||
@@ -265,7 +267,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
265 | { | 267 | { |
266 | struct slot *slot = hotplug_slot->private; | 268 | struct slot *slot = hotplug_slot->private; |
267 | 269 | ||
268 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 270 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
269 | 271 | ||
270 | *value = acpiphp_get_adapter_status(slot->acpi_slot); | 272 | *value = acpiphp_get_adapter_status(slot->acpi_slot); |
271 | 273 | ||
@@ -299,7 +301,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
299 | { | 301 | { |
300 | struct slot *slot = hotplug_slot->private; | 302 | struct slot *slot = hotplug_slot->private; |
301 | 303 | ||
302 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 304 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
303 | 305 | ||
304 | kfree(slot->hotplug_slot); | 306 | kfree(slot->hotplug_slot); |
305 | kfree(slot); | 307 | kfree(slot); |
@@ -310,6 +312,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) | |||
310 | { | 312 | { |
311 | struct slot *slot; | 313 | struct slot *slot; |
312 | int retval = -ENOMEM; | 314 | int retval = -ENOMEM; |
315 | char name[SLOT_NAME_SIZE]; | ||
313 | 316 | ||
314 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | 317 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
315 | if (!slot) | 318 | if (!slot) |
@@ -321,8 +324,6 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) | |||
321 | 324 | ||
322 | slot->hotplug_slot->info = &slot->info; | 325 | slot->hotplug_slot->info = &slot->info; |
323 | 326 | ||
324 | slot->hotplug_slot->name = slot->name; | ||
325 | |||
326 | slot->hotplug_slot->private = slot; | 327 | slot->hotplug_slot->private = slot; |
327 | slot->hotplug_slot->release = &release_slot; | 328 | slot->hotplug_slot->release = &release_slot; |
328 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; | 329 | slot->hotplug_slot->ops = &acpi_hotplug_slot_ops; |
@@ -336,11 +337,12 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) | |||
336 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; | 337 | slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; |
337 | 338 | ||
338 | acpiphp_slot->slot = slot; | 339 | acpiphp_slot->slot = slot; |
339 | snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun); | 340 | snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun); |
340 | 341 | ||
341 | retval = pci_hp_register(slot->hotplug_slot, | 342 | retval = pci_hp_register(slot->hotplug_slot, |
342 | acpiphp_slot->bridge->pci_bus, | 343 | acpiphp_slot->bridge->pci_bus, |
343 | acpiphp_slot->device); | 344 | acpiphp_slot->device, |
345 | name); | ||
344 | if (retval == -EBUSY) | 346 | if (retval == -EBUSY) |
345 | goto error_hpslot; | 347 | goto error_hpslot; |
346 | if (retval) { | 348 | if (retval) { |
@@ -348,7 +350,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) | |||
348 | goto error_hpslot; | 350 | goto error_hpslot; |
349 | } | 351 | } |
350 | 352 | ||
351 | info("Slot [%s] registered\n", slot->hotplug_slot->name); | 353 | info("Slot [%s] registered\n", slot_name(slot)); |
352 | 354 | ||
353 | return 0; | 355 | return 0; |
354 | error_hpslot: | 356 | error_hpslot: |
@@ -365,7 +367,7 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot) | |||
365 | struct slot *slot = acpiphp_slot->slot; | 367 | struct slot *slot = acpiphp_slot->slot; |
366 | int retval = 0; | 368 | int retval = 0; |
367 | 369 | ||
368 | info ("Slot [%s] unregistered\n", slot->hotplug_slot->name); | 370 | info("Slot [%s] unregistered\n", slot_name(slot)); |
369 | 371 | ||
370 | retval = pci_hp_deregister(slot->hotplug_slot); | 372 | retval = pci_hp_deregister(slot->hotplug_slot); |
371 | if (retval) | 373 | if (retval) |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index a3e4705dd8f..955aae4071f 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -169,7 +169,9 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val, | |||
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | 172 | static struct acpi_dock_ops acpiphp_dock_ops = { | |
173 | .handler = handle_hotplug_event_func, | ||
174 | }; | ||
173 | 175 | ||
174 | /* callback routine to register each ACPI PCI slot object */ | 176 | /* callback routine to register each ACPI PCI slot object */ |
175 | static acpi_status | 177 | static acpi_status |
@@ -180,7 +182,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
180 | struct acpiphp_func *newfunc; | 182 | struct acpiphp_func *newfunc; |
181 | acpi_handle tmp; | 183 | acpi_handle tmp; |
182 | acpi_status status = AE_OK; | 184 | acpi_status status = AE_OK; |
183 | unsigned long adr, sun; | 185 | unsigned long long adr, sun; |
184 | int device, function, retval; | 186 | int device, function, retval; |
185 | 187 | ||
186 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); | 188 | status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); |
@@ -285,7 +287,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
285 | */ | 287 | */ |
286 | newfunc->flags &= ~FUNC_HAS_EJ0; | 288 | newfunc->flags &= ~FUNC_HAS_EJ0; |
287 | if (register_hotplug_dock_device(handle, | 289 | if (register_hotplug_dock_device(handle, |
288 | handle_hotplug_event_func, newfunc)) | 290 | &acpiphp_dock_ops, newfunc)) |
289 | dbg("failed to register dock device\n"); | 291 | dbg("failed to register dock device\n"); |
290 | 292 | ||
291 | /* we need to be notified when dock events happen | 293 | /* we need to be notified when dock events happen |
@@ -528,7 +530,7 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
528 | { | 530 | { |
529 | acpi_status status; | 531 | acpi_status status; |
530 | acpi_handle dummy_handle; | 532 | acpi_handle dummy_handle; |
531 | unsigned long tmp; | 533 | unsigned long long tmp; |
532 | int device, function; | 534 | int device, function; |
533 | struct pci_dev *dev; | 535 | struct pci_dev *dev; |
534 | struct pci_bus *pci_bus = context; | 536 | struct pci_bus *pci_bus = context; |
@@ -573,7 +575,7 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
573 | static int add_bridge(acpi_handle handle) | 575 | static int add_bridge(acpi_handle handle) |
574 | { | 576 | { |
575 | acpi_status status; | 577 | acpi_status status; |
576 | unsigned long tmp; | 578 | unsigned long long tmp; |
577 | int seg, bus; | 579 | int seg, bus; |
578 | acpi_handle dummy_handle; | 580 | acpi_handle dummy_handle; |
579 | struct pci_bus *pci_bus; | 581 | struct pci_bus *pci_bus; |
@@ -767,7 +769,7 @@ static int get_gsi_base(acpi_handle handle, u32 *gsi_base) | |||
767 | { | 769 | { |
768 | acpi_status status; | 770 | acpi_status status; |
769 | int result = -1; | 771 | int result = -1; |
770 | unsigned long gsb; | 772 | unsigned long long gsb; |
771 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 773 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
772 | union acpi_object *obj; | 774 | union acpi_object *obj; |
773 | void *table; | 775 | void *table; |
@@ -808,7 +810,7 @@ static acpi_status | |||
808 | ioapic_add(acpi_handle handle, u32 lvl, void *context, void **rv) | 810 | ioapic_add(acpi_handle handle, u32 lvl, void *context, void **rv) |
809 | { | 811 | { |
810 | acpi_status status; | 812 | acpi_status status; |
811 | unsigned long sta; | 813 | unsigned long long sta; |
812 | acpi_handle tmp; | 814 | acpi_handle tmp; |
813 | struct pci_dev *pdev; | 815 | struct pci_dev *pdev; |
814 | u32 gsi_base; | 816 | u32 gsi_base; |
@@ -872,7 +874,7 @@ static acpi_status | |||
872 | ioapic_remove(acpi_handle handle, u32 lvl, void *context, void **rv) | 874 | ioapic_remove(acpi_handle handle, u32 lvl, void *context, void **rv) |
873 | { | 875 | { |
874 | acpi_status status; | 876 | acpi_status status; |
875 | unsigned long sta; | 877 | unsigned long long sta; |
876 | acpi_handle tmp; | 878 | acpi_handle tmp; |
877 | u32 gsi_base; | 879 | u32 gsi_base; |
878 | struct acpiphp_ioapic *pos, *n, *ioapic = NULL; | 880 | struct acpiphp_ioapic *pos, *n, *ioapic = NULL; |
@@ -1264,7 +1266,7 @@ static int disable_device(struct acpiphp_slot *slot) | |||
1264 | static unsigned int get_slot_status(struct acpiphp_slot *slot) | 1266 | static unsigned int get_slot_status(struct acpiphp_slot *slot) |
1265 | { | 1267 | { |
1266 | acpi_status status; | 1268 | acpi_status status; |
1267 | unsigned long sta = 0; | 1269 | unsigned long long sta = 0; |
1268 | u32 dvid; | 1270 | u32 dvid; |
1269 | struct list_head *l; | 1271 | struct list_head *l; |
1270 | struct acpiphp_func *func; | 1272 | struct acpiphp_func *func; |
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 2b7c45e3937..881fdd2b731 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
@@ -183,7 +183,7 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) | |||
183 | union acpi_object args[2]; | 183 | union acpi_object args[2]; |
184 | struct acpi_object_list params = { .pointer = args, .count = 2 }; | 184 | struct acpi_object_list params = { .pointer = args, .count = 2 }; |
185 | acpi_status stat; | 185 | acpi_status stat; |
186 | unsigned long rc; | 186 | unsigned long long rc; |
187 | union apci_descriptor *ibm_slot; | 187 | union apci_descriptor *ibm_slot; |
188 | 188 | ||
189 | ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot)); | 189 | ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot)); |
@@ -204,7 +204,7 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status) | |||
204 | err("APLS evaluation failed: 0x%08x\n", stat); | 204 | err("APLS evaluation failed: 0x%08x\n", stat); |
205 | return -ENODEV; | 205 | return -ENODEV; |
206 | } else if (!rc) { | 206 | } else if (!rc) { |
207 | err("APLS method failed: 0x%08lx\n", rc); | 207 | err("APLS method failed: 0x%08llx\n", rc); |
208 | return -ERANGE; | 208 | return -ERANGE; |
209 | } | 209 | } |
210 | return 0; | 210 | return 0; |
diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h index d9769b30be9..9fff878cf02 100644 --- a/drivers/pci/hotplug/cpci_hotplug.h +++ b/drivers/pci/hotplug/cpci_hotplug.h | |||
@@ -30,6 +30,7 @@ | |||
30 | 30 | ||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
33 | #include <linux/pci_hotplug.h> | ||
33 | 34 | ||
34 | /* PICMG 2.1 R2.0 HS CSR bits: */ | 35 | /* PICMG 2.1 R2.0 HS CSR bits: */ |
35 | #define HS_CSR_INS 0x0080 | 36 | #define HS_CSR_INS 0x0080 |
@@ -69,6 +70,11 @@ struct cpci_hp_controller { | |||
69 | struct cpci_hp_controller_ops *ops; | 70 | struct cpci_hp_controller_ops *ops; |
70 | }; | 71 | }; |
71 | 72 | ||
73 | static inline const char *slot_name(struct slot *slot) | ||
74 | { | ||
75 | return hotplug_slot_name(slot->hotplug_slot); | ||
76 | } | ||
77 | |||
72 | extern int cpci_hp_register_controller(struct cpci_hp_controller *controller); | 78 | extern int cpci_hp_register_controller(struct cpci_hp_controller *controller); |
73 | extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller); | 79 | extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller); |
74 | extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last); | 80 | extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last); |
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index 935947991dc..de94f4feef8 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c | |||
@@ -108,7 +108,7 @@ enable_slot(struct hotplug_slot *hotplug_slot) | |||
108 | struct slot *slot = hotplug_slot->private; | 108 | struct slot *slot = hotplug_slot->private; |
109 | int retval = 0; | 109 | int retval = 0; |
110 | 110 | ||
111 | dbg("%s - physical_slot = %s", __func__, hotplug_slot->name); | 111 | dbg("%s - physical_slot = %s", __func__, slot_name(slot)); |
112 | 112 | ||
113 | if (controller->ops->set_power) | 113 | if (controller->ops->set_power) |
114 | retval = controller->ops->set_power(slot, 1); | 114 | retval = controller->ops->set_power(slot, 1); |
@@ -121,25 +121,23 @@ disable_slot(struct hotplug_slot *hotplug_slot) | |||
121 | struct slot *slot = hotplug_slot->private; | 121 | struct slot *slot = hotplug_slot->private; |
122 | int retval = 0; | 122 | int retval = 0; |
123 | 123 | ||
124 | dbg("%s - physical_slot = %s", __func__, hotplug_slot->name); | 124 | dbg("%s - physical_slot = %s", __func__, slot_name(slot)); |
125 | 125 | ||
126 | down_write(&list_rwsem); | 126 | down_write(&list_rwsem); |
127 | 127 | ||
128 | /* Unconfigure device */ | 128 | /* Unconfigure device */ |
129 | dbg("%s - unconfiguring slot %s", | 129 | dbg("%s - unconfiguring slot %s", __func__, slot_name(slot)); |
130 | __func__, slot->hotplug_slot->name); | ||
131 | if ((retval = cpci_unconfigure_slot(slot))) { | 130 | if ((retval = cpci_unconfigure_slot(slot))) { |
132 | err("%s - could not unconfigure slot %s", | 131 | err("%s - could not unconfigure slot %s", |
133 | __func__, slot->hotplug_slot->name); | 132 | __func__, slot_name(slot)); |
134 | goto disable_error; | 133 | goto disable_error; |
135 | } | 134 | } |
136 | dbg("%s - finished unconfiguring slot %s", | 135 | dbg("%s - finished unconfiguring slot %s", __func__, slot_name(slot)); |
137 | __func__, slot->hotplug_slot->name); | ||
138 | 136 | ||
139 | /* Clear EXT (by setting it) */ | 137 | /* Clear EXT (by setting it) */ |
140 | if (cpci_clear_ext(slot)) { | 138 | if (cpci_clear_ext(slot)) { |
141 | err("%s - could not clear EXT for slot %s", | 139 | err("%s - could not clear EXT for slot %s", |
142 | __func__, slot->hotplug_slot->name); | 140 | __func__, slot_name(slot)); |
143 | retval = -ENODEV; | 141 | retval = -ENODEV; |
144 | goto disable_error; | 142 | goto disable_error; |
145 | } | 143 | } |
@@ -214,7 +212,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
214 | struct slot *slot = hotplug_slot->private; | 212 | struct slot *slot = hotplug_slot->private; |
215 | 213 | ||
216 | kfree(slot->hotplug_slot->info); | 214 | kfree(slot->hotplug_slot->info); |
217 | kfree(slot->hotplug_slot->name); | ||
218 | kfree(slot->hotplug_slot); | 215 | kfree(slot->hotplug_slot); |
219 | if (slot->dev) | 216 | if (slot->dev) |
220 | pci_dev_put(slot->dev); | 217 | pci_dev_put(slot->dev); |
@@ -222,12 +219,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
222 | } | 219 | } |
223 | 220 | ||
224 | #define SLOT_NAME_SIZE 6 | 221 | #define SLOT_NAME_SIZE 6 |
225 | static void | ||
226 | make_slot_name(struct slot *slot) | ||
227 | { | ||
228 | snprintf(slot->hotplug_slot->name, | ||
229 | SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number); | ||
230 | } | ||
231 | 222 | ||
232 | int | 223 | int |
233 | cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | 224 | cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) |
@@ -235,7 +226,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
235 | struct slot *slot; | 226 | struct slot *slot; |
236 | struct hotplug_slot *hotplug_slot; | 227 | struct hotplug_slot *hotplug_slot; |
237 | struct hotplug_slot_info *info; | 228 | struct hotplug_slot_info *info; |
238 | char *name; | 229 | char name[SLOT_NAME_SIZE]; |
239 | int status = -ENOMEM; | 230 | int status = -ENOMEM; |
240 | int i; | 231 | int i; |
241 | 232 | ||
@@ -262,34 +253,31 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
262 | goto error_hpslot; | 253 | goto error_hpslot; |
263 | hotplug_slot->info = info; | 254 | hotplug_slot->info = info; |
264 | 255 | ||
265 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | ||
266 | if (!name) | ||
267 | goto error_info; | ||
268 | hotplug_slot->name = name; | ||
269 | |||
270 | slot->bus = bus; | 256 | slot->bus = bus; |
271 | slot->number = i; | 257 | slot->number = i; |
272 | slot->devfn = PCI_DEVFN(i, 0); | 258 | slot->devfn = PCI_DEVFN(i, 0); |
273 | 259 | ||
260 | snprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i); | ||
261 | |||
274 | hotplug_slot->private = slot; | 262 | hotplug_slot->private = slot; |
275 | hotplug_slot->release = &release_slot; | 263 | hotplug_slot->release = &release_slot; |
276 | make_slot_name(slot); | ||
277 | hotplug_slot->ops = &cpci_hotplug_slot_ops; | 264 | hotplug_slot->ops = &cpci_hotplug_slot_ops; |
278 | 265 | ||
279 | /* | 266 | /* |
280 | * Initialize the slot info structure with some known | 267 | * Initialize the slot info structure with some known |
281 | * good values. | 268 | * good values. |
282 | */ | 269 | */ |
283 | dbg("initializing slot %s", slot->hotplug_slot->name); | 270 | dbg("initializing slot %s", name); |
284 | info->power_status = cpci_get_power_status(slot); | 271 | info->power_status = cpci_get_power_status(slot); |
285 | info->attention_status = cpci_get_attention_status(slot); | 272 | info->attention_status = cpci_get_attention_status(slot); |
286 | 273 | ||
287 | dbg("registering slot %s", slot->hotplug_slot->name); | 274 | dbg("registering slot %s", name); |
288 | status = pci_hp_register(slot->hotplug_slot, bus, i); | 275 | status = pci_hp_register(slot->hotplug_slot, bus, i, name); |
289 | if (status) { | 276 | if (status) { |
290 | err("pci_hp_register failed with error %d", status); | 277 | err("pci_hp_register failed with error %d", status); |
291 | goto error_name; | 278 | goto error_info; |
292 | } | 279 | } |
280 | dbg("slot registered with name: %s", slot_name(slot)); | ||
293 | 281 | ||
294 | /* Add slot to our internal list */ | 282 | /* Add slot to our internal list */ |
295 | down_write(&list_rwsem); | 283 | down_write(&list_rwsem); |
@@ -298,8 +286,6 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
298 | up_write(&list_rwsem); | 286 | up_write(&list_rwsem); |
299 | } | 287 | } |
300 | return 0; | 288 | return 0; |
301 | error_name: | ||
302 | kfree(name); | ||
303 | error_info: | 289 | error_info: |
304 | kfree(info); | 290 | kfree(info); |
305 | error_hpslot: | 291 | error_hpslot: |
@@ -327,7 +313,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus) | |||
327 | list_del(&slot->slot_list); | 313 | list_del(&slot->slot_list); |
328 | slots--; | 314 | slots--; |
329 | 315 | ||
330 | dbg("deregistering slot %s", slot->hotplug_slot->name); | 316 | dbg("deregistering slot %s", slot_name(slot)); |
331 | status = pci_hp_deregister(slot->hotplug_slot); | 317 | status = pci_hp_deregister(slot->hotplug_slot); |
332 | if (status) { | 318 | if (status) { |
333 | err("pci_hp_deregister failed with error %d", | 319 | err("pci_hp_deregister failed with error %d", |
@@ -379,11 +365,10 @@ init_slots(int clear_ins) | |||
379 | return -1; | 365 | return -1; |
380 | } | 366 | } |
381 | list_for_each_entry(slot, &slot_list, slot_list) { | 367 | list_for_each_entry(slot, &slot_list, slot_list) { |
382 | dbg("%s - looking at slot %s", | 368 | dbg("%s - looking at slot %s", __func__, slot_name(slot)); |
383 | __func__, slot->hotplug_slot->name); | ||
384 | if (clear_ins && cpci_check_and_clear_ins(slot)) | 369 | if (clear_ins && cpci_check_and_clear_ins(slot)) |
385 | dbg("%s - cleared INS for slot %s", | 370 | dbg("%s - cleared INS for slot %s", |
386 | __func__, slot->hotplug_slot->name); | 371 | __func__, slot_name(slot)); |
387 | dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0)); | 372 | dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0)); |
388 | if (dev) { | 373 | if (dev) { |
389 | if (update_adapter_status(slot->hotplug_slot, 1)) | 374 | if (update_adapter_status(slot->hotplug_slot, 1)) |
@@ -414,8 +399,7 @@ check_slots(void) | |||
414 | } | 399 | } |
415 | extracted = inserted = 0; | 400 | extracted = inserted = 0; |
416 | list_for_each_entry(slot, &slot_list, slot_list) { | 401 | list_for_each_entry(slot, &slot_list, slot_list) { |
417 | dbg("%s - looking at slot %s", | 402 | dbg("%s - looking at slot %s", __func__, slot_name(slot)); |
418 | __func__, slot->hotplug_slot->name); | ||
419 | if (cpci_check_and_clear_ins(slot)) { | 403 | if (cpci_check_and_clear_ins(slot)) { |
420 | /* | 404 | /* |
421 | * Some broken hardware (e.g. PLX 9054AB) asserts | 405 | * Some broken hardware (e.g. PLX 9054AB) asserts |
@@ -423,35 +407,34 @@ check_slots(void) | |||
423 | */ | 407 | */ |
424 | if (slot->dev) { | 408 | if (slot->dev) { |
425 | warn("slot %s already inserted", | 409 | warn("slot %s already inserted", |
426 | slot->hotplug_slot->name); | 410 | slot_name(slot)); |
427 | inserted++; | 411 | inserted++; |
428 | continue; | 412 | continue; |
429 | } | 413 | } |
430 | 414 | ||
431 | /* Process insertion */ | 415 | /* Process insertion */ |
432 | dbg("%s - slot %s inserted", | 416 | dbg("%s - slot %s inserted", __func__, slot_name(slot)); |
433 | __func__, slot->hotplug_slot->name); | ||
434 | 417 | ||
435 | /* GSM, debug */ | 418 | /* GSM, debug */ |
436 | hs_csr = cpci_get_hs_csr(slot); | 419 | hs_csr = cpci_get_hs_csr(slot); |
437 | dbg("%s - slot %s HS_CSR (1) = %04x", | 420 | dbg("%s - slot %s HS_CSR (1) = %04x", |
438 | __func__, slot->hotplug_slot->name, hs_csr); | 421 | __func__, slot_name(slot), hs_csr); |
439 | 422 | ||
440 | /* Configure device */ | 423 | /* Configure device */ |
441 | dbg("%s - configuring slot %s", | 424 | dbg("%s - configuring slot %s", |
442 | __func__, slot->hotplug_slot->name); | 425 | __func__, slot_name(slot)); |
443 | if (cpci_configure_slot(slot)) { | 426 | if (cpci_configure_slot(slot)) { |
444 | err("%s - could not configure slot %s", | 427 | err("%s - could not configure slot %s", |
445 | __func__, slot->hotplug_slot->name); | 428 | __func__, slot_name(slot)); |
446 | continue; | 429 | continue; |
447 | } | 430 | } |
448 | dbg("%s - finished configuring slot %s", | 431 | dbg("%s - finished configuring slot %s", |
449 | __func__, slot->hotplug_slot->name); | 432 | __func__, slot_name(slot)); |
450 | 433 | ||
451 | /* GSM, debug */ | 434 | /* GSM, debug */ |
452 | hs_csr = cpci_get_hs_csr(slot); | 435 | hs_csr = cpci_get_hs_csr(slot); |
453 | dbg("%s - slot %s HS_CSR (2) = %04x", | 436 | dbg("%s - slot %s HS_CSR (2) = %04x", |
454 | __func__, slot->hotplug_slot->name, hs_csr); | 437 | __func__, slot_name(slot), hs_csr); |
455 | 438 | ||
456 | if (update_latch_status(slot->hotplug_slot, 1)) | 439 | if (update_latch_status(slot->hotplug_slot, 1)) |
457 | warn("failure to update latch file"); | 440 | warn("failure to update latch file"); |
@@ -464,18 +447,18 @@ check_slots(void) | |||
464 | /* GSM, debug */ | 447 | /* GSM, debug */ |
465 | hs_csr = cpci_get_hs_csr(slot); | 448 | hs_csr = cpci_get_hs_csr(slot); |
466 | dbg("%s - slot %s HS_CSR (3) = %04x", | 449 | dbg("%s - slot %s HS_CSR (3) = %04x", |
467 | __func__, slot->hotplug_slot->name, hs_csr); | 450 | __func__, slot_name(slot), hs_csr); |
468 | 451 | ||
469 | inserted++; | 452 | inserted++; |
470 | } else if (cpci_check_ext(slot)) { | 453 | } else if (cpci_check_ext(slot)) { |
471 | /* Process extraction request */ | 454 | /* Process extraction request */ |
472 | dbg("%s - slot %s extracted", | 455 | dbg("%s - slot %s extracted", |
473 | __func__, slot->hotplug_slot->name); | 456 | __func__, slot_name(slot)); |
474 | 457 | ||
475 | /* GSM, debug */ | 458 | /* GSM, debug */ |
476 | hs_csr = cpci_get_hs_csr(slot); | 459 | hs_csr = cpci_get_hs_csr(slot); |
477 | dbg("%s - slot %s HS_CSR = %04x", | 460 | dbg("%s - slot %s HS_CSR = %04x", |
478 | __func__, slot->hotplug_slot->name, hs_csr); | 461 | __func__, slot_name(slot), hs_csr); |
479 | 462 | ||
480 | if (!slot->extracting) { | 463 | if (!slot->extracting) { |
481 | if (update_latch_status(slot->hotplug_slot, 0)) { | 464 | if (update_latch_status(slot->hotplug_slot, 0)) { |
@@ -493,7 +476,7 @@ check_slots(void) | |||
493 | * bother trying to tell the driver or not? | 476 | * bother trying to tell the driver or not? |
494 | */ | 477 | */ |
495 | err("card in slot %s was improperly removed", | 478 | err("card in slot %s was improperly removed", |
496 | slot->hotplug_slot->name); | 479 | slot_name(slot)); |
497 | if (update_adapter_status(slot->hotplug_slot, 0)) | 480 | if (update_adapter_status(slot->hotplug_slot, 0)) |
498 | warn("failure to update adapter file"); | 481 | warn("failure to update adapter file"); |
499 | slot->extracting = 0; | 482 | slot->extracting = 0; |
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index df82b95e287..829c327cfb5 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c | |||
@@ -209,7 +209,7 @@ int cpci_led_on(struct slot* slot) | |||
209 | hs_cap + 2, | 209 | hs_cap + 2, |
210 | hs_csr)) { | 210 | hs_csr)) { |
211 | err("Could not set LOO for slot %s", | 211 | err("Could not set LOO for slot %s", |
212 | slot->hotplug_slot->name); | 212 | hotplug_slot_name(slot->hotplug_slot)); |
213 | return -ENODEV; | 213 | return -ENODEV; |
214 | } | 214 | } |
215 | } | 215 | } |
@@ -238,7 +238,7 @@ int cpci_led_off(struct slot* slot) | |||
238 | hs_cap + 2, | 238 | hs_cap + 2, |
239 | hs_csr)) { | 239 | hs_csr)) { |
240 | err("Could not clear LOO for slot %s", | 240 | err("Could not clear LOO for slot %s", |
241 | slot->hotplug_slot->name); | 241 | hotplug_slot_name(slot->hotplug_slot)); |
242 | return -ENODEV; | 242 | return -ENODEV; |
243 | } | 243 | } |
244 | } | 244 | } |
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index b1decfa88b7..afaf8f69f73 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h | |||
@@ -449,6 +449,11 @@ extern u8 cpqhp_disk_irq; | |||
449 | 449 | ||
450 | /* inline functions */ | 450 | /* inline functions */ |
451 | 451 | ||
452 | static inline char *slot_name(struct slot *slot) | ||
453 | { | ||
454 | return hotplug_slot_name(slot->hotplug_slot); | ||
455 | } | ||
456 | |||
452 | /* | 457 | /* |
453 | * return_resource | 458 | * return_resource |
454 | * | 459 | * |
@@ -696,14 +701,6 @@ static inline int get_presence_status(struct controller *ctrl, struct slot *slot | |||
696 | return presence_save; | 701 | return presence_save; |
697 | } | 702 | } |
698 | 703 | ||
699 | #define SLOT_NAME_SIZE 10 | ||
700 | |||
701 | static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) | ||
702 | { | ||
703 | snprintf(buffer, buffer_size, "%d", slot->number); | ||
704 | } | ||
705 | |||
706 | |||
707 | static inline int wait_for_ctrl_irq(struct controller *ctrl) | 704 | static inline int wait_for_ctrl_irq(struct controller *ctrl) |
708 | { | 705 | { |
709 | DECLARE_WAITQUEUE(wait, current); | 706 | DECLARE_WAITQUEUE(wait, current); |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 54defec51d0..8514c3a1746 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -315,14 +315,15 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
315 | { | 315 | { |
316 | struct slot *slot = hotplug_slot->private; | 316 | struct slot *slot = hotplug_slot->private; |
317 | 317 | ||
318 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 318 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
319 | 319 | ||
320 | kfree(slot->hotplug_slot->info); | 320 | kfree(slot->hotplug_slot->info); |
321 | kfree(slot->hotplug_slot->name); | ||
322 | kfree(slot->hotplug_slot); | 321 | kfree(slot->hotplug_slot); |
323 | kfree(slot); | 322 | kfree(slot); |
324 | } | 323 | } |
325 | 324 | ||
325 | #define SLOT_NAME_SIZE 10 | ||
326 | |||
326 | static int ctrl_slot_setup(struct controller *ctrl, | 327 | static int ctrl_slot_setup(struct controller *ctrl, |
327 | void __iomem *smbios_start, | 328 | void __iomem *smbios_start, |
328 | void __iomem *smbios_table) | 329 | void __iomem *smbios_table) |
@@ -335,6 +336,7 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
335 | u8 slot_number; | 336 | u8 slot_number; |
336 | u8 ctrl_slot; | 337 | u8 ctrl_slot; |
337 | u32 tempdword; | 338 | u32 tempdword; |
339 | char name[SLOT_NAME_SIZE]; | ||
338 | void __iomem *slot_entry= NULL; | 340 | void __iomem *slot_entry= NULL; |
339 | int result = -ENOMEM; | 341 | int result = -ENOMEM; |
340 | 342 | ||
@@ -363,16 +365,12 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
363 | if (!hotplug_slot->info) | 365 | if (!hotplug_slot->info) |
364 | goto error_hpslot; | 366 | goto error_hpslot; |
365 | hotplug_slot_info = hotplug_slot->info; | 367 | hotplug_slot_info = hotplug_slot->info; |
366 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | ||
367 | |||
368 | if (!hotplug_slot->name) | ||
369 | goto error_info; | ||
370 | 368 | ||
371 | slot->ctrl = ctrl; | 369 | slot->ctrl = ctrl; |
372 | slot->bus = ctrl->bus; | 370 | slot->bus = ctrl->bus; |
373 | slot->device = slot_device; | 371 | slot->device = slot_device; |
374 | slot->number = slot_number; | 372 | slot->number = slot_number; |
375 | dbg("slot->number = %d\n", slot->number); | 373 | dbg("slot->number = %u\n", slot->number); |
376 | 374 | ||
377 | slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, | 375 | slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, |
378 | slot_entry); | 376 | slot_entry); |
@@ -418,9 +416,9 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
418 | /* register this slot with the hotplug pci core */ | 416 | /* register this slot with the hotplug pci core */ |
419 | hotplug_slot->release = &release_slot; | 417 | hotplug_slot->release = &release_slot; |
420 | hotplug_slot->private = slot; | 418 | hotplug_slot->private = slot; |
421 | make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot); | 419 | snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); |
422 | hotplug_slot->ops = &cpqphp_hotplug_slot_ops; | 420 | hotplug_slot->ops = &cpqphp_hotplug_slot_ops; |
423 | 421 | ||
424 | hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot); | 422 | hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot); |
425 | hotplug_slot_info->attention_status = | 423 | hotplug_slot_info->attention_status = |
426 | cpq_get_attention_status(ctrl, slot); | 424 | cpq_get_attention_status(ctrl, slot); |
@@ -435,11 +433,12 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
435 | slot->number, ctrl->slot_device_offset, | 433 | slot->number, ctrl->slot_device_offset, |
436 | slot_number); | 434 | slot_number); |
437 | result = pci_hp_register(hotplug_slot, | 435 | result = pci_hp_register(hotplug_slot, |
438 | ctrl->pci_dev->subordinate, | 436 | ctrl->pci_dev->bus, |
439 | slot->device); | 437 | slot->device, |
438 | name); | ||
440 | if (result) { | 439 | if (result) { |
441 | err("pci_hp_register failed with error %d\n", result); | 440 | err("pci_hp_register failed with error %d\n", result); |
442 | goto error_name; | 441 | goto error_info; |
443 | } | 442 | } |
444 | 443 | ||
445 | slot->next = ctrl->slot; | 444 | slot->next = ctrl->slot; |
@@ -451,8 +450,6 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
451 | } | 450 | } |
452 | 451 | ||
453 | return 0; | 452 | return 0; |
454 | error_name: | ||
455 | kfree(hotplug_slot->name); | ||
456 | error_info: | 453 | error_info: |
457 | kfree(hotplug_slot_info); | 454 | kfree(hotplug_slot_info); |
458 | error_hpslot: | 455 | error_hpslot: |
@@ -638,7 +635,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | |||
638 | u8 device; | 635 | u8 device; |
639 | u8 function; | 636 | u8 function; |
640 | 637 | ||
641 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 638 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
642 | 639 | ||
643 | if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1) | 640 | if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1) |
644 | return -ENODEV; | 641 | return -ENODEV; |
@@ -665,7 +662,7 @@ static int process_SI(struct hotplug_slot *hotplug_slot) | |||
665 | u8 device; | 662 | u8 device; |
666 | u8 function; | 663 | u8 function; |
667 | 664 | ||
668 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 665 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
669 | 666 | ||
670 | if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1) | 667 | if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1) |
671 | return -ENODEV; | 668 | return -ENODEV; |
@@ -697,7 +694,7 @@ static int process_SS(struct hotplug_slot *hotplug_slot) | |||
697 | u8 device; | 694 | u8 device; |
698 | u8 function; | 695 | u8 function; |
699 | 696 | ||
700 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 697 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
701 | 698 | ||
702 | if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1) | 699 | if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1) |
703 | return -ENODEV; | 700 | return -ENODEV; |
@@ -720,7 +717,7 @@ static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value) | |||
720 | struct slot *slot = hotplug_slot->private; | 717 | struct slot *slot = hotplug_slot->private; |
721 | struct controller *ctrl = slot->ctrl; | 718 | struct controller *ctrl = slot->ctrl; |
722 | 719 | ||
723 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 720 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
724 | 721 | ||
725 | return cpqhp_hardware_test(ctrl, value); | 722 | return cpqhp_hardware_test(ctrl, value); |
726 | } | 723 | } |
@@ -731,7 +728,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
731 | struct slot *slot = hotplug_slot->private; | 728 | struct slot *slot = hotplug_slot->private; |
732 | struct controller *ctrl = slot->ctrl; | 729 | struct controller *ctrl = slot->ctrl; |
733 | 730 | ||
734 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 731 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
735 | 732 | ||
736 | *value = get_slot_enabled(ctrl, slot); | 733 | *value = get_slot_enabled(ctrl, slot); |
737 | return 0; | 734 | return 0; |
@@ -742,7 +739,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
742 | struct slot *slot = hotplug_slot->private; | 739 | struct slot *slot = hotplug_slot->private; |
743 | struct controller *ctrl = slot->ctrl; | 740 | struct controller *ctrl = slot->ctrl; |
744 | 741 | ||
745 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 742 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
746 | 743 | ||
747 | *value = cpq_get_attention_status(ctrl, slot); | 744 | *value = cpq_get_attention_status(ctrl, slot); |
748 | return 0; | 745 | return 0; |
@@ -753,7 +750,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
753 | struct slot *slot = hotplug_slot->private; | 750 | struct slot *slot = hotplug_slot->private; |
754 | struct controller *ctrl = slot->ctrl; | 751 | struct controller *ctrl = slot->ctrl; |
755 | 752 | ||
756 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 753 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
757 | 754 | ||
758 | *value = cpq_get_latch_status(ctrl, slot); | 755 | *value = cpq_get_latch_status(ctrl, slot); |
759 | 756 | ||
@@ -765,7 +762,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
765 | struct slot *slot = hotplug_slot->private; | 762 | struct slot *slot = hotplug_slot->private; |
766 | struct controller *ctrl = slot->ctrl; | 763 | struct controller *ctrl = slot->ctrl; |
767 | 764 | ||
768 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 765 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
769 | 766 | ||
770 | *value = get_presence_status(ctrl, slot); | 767 | *value = get_presence_status(ctrl, slot); |
771 | 768 | ||
@@ -777,7 +774,7 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
777 | struct slot *slot = hotplug_slot->private; | 774 | struct slot *slot = hotplug_slot->private; |
778 | struct controller *ctrl = slot->ctrl; | 775 | struct controller *ctrl = slot->ctrl; |
779 | 776 | ||
780 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 777 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
781 | 778 | ||
782 | *value = ctrl->speed_capability; | 779 | *value = ctrl->speed_capability; |
783 | 780 | ||
@@ -789,7 +786,7 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
789 | struct slot *slot = hotplug_slot->private; | 786 | struct slot *slot = hotplug_slot->private; |
790 | struct controller *ctrl = slot->ctrl; | 787 | struct controller *ctrl = slot->ctrl; |
791 | 788 | ||
792 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 789 | dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); |
793 | 790 | ||
794 | *value = ctrl->speed; | 791 | *value = ctrl->speed; |
795 | 792 | ||
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index ef041ca91c2..a60a2529099 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
@@ -1139,7 +1139,7 @@ static u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_ | |||
1139 | for(slot = ctrl->slot; slot; slot = slot->next) { | 1139 | for(slot = ctrl->slot; slot; slot = slot->next) { |
1140 | if (slot->device == (hp_slot + ctrl->slot_device_offset)) | 1140 | if (slot->device == (hp_slot + ctrl->slot_device_offset)) |
1141 | continue; | 1141 | continue; |
1142 | if (!slot->hotplug_slot && !slot->hotplug_slot->info) | 1142 | if (!slot->hotplug_slot || !slot->hotplug_slot->info) |
1143 | continue; | 1143 | continue; |
1144 | if (slot->hotplug_slot->info->adapter_status == 0) | 1144 | if (slot->hotplug_slot->info->adapter_status == 0) |
1145 | continue; | 1145 | continue; |
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index 146ca9cd156..3a2637a0093 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c | |||
@@ -66,10 +66,10 @@ struct dummy_slot { | |||
66 | struct pci_dev *dev; | 66 | struct pci_dev *dev; |
67 | struct work_struct remove_work; | 67 | struct work_struct remove_work; |
68 | unsigned long removed; | 68 | unsigned long removed; |
69 | char name[8]; | ||
70 | }; | 69 | }; |
71 | 70 | ||
72 | static int debug; | 71 | static int debug; |
72 | static int dup_slots; | ||
73 | static LIST_HEAD(slot_list); | 73 | static LIST_HEAD(slot_list); |
74 | static struct workqueue_struct *dummyphp_wq; | 74 | static struct workqueue_struct *dummyphp_wq; |
75 | 75 | ||
@@ -96,10 +96,13 @@ static void dummy_release(struct hotplug_slot *slot) | |||
96 | kfree(dslot); | 96 | kfree(dslot); |
97 | } | 97 | } |
98 | 98 | ||
99 | #define SLOT_NAME_SIZE 8 | ||
100 | |||
99 | static int add_slot(struct pci_dev *dev) | 101 | static int add_slot(struct pci_dev *dev) |
100 | { | 102 | { |
101 | struct dummy_slot *dslot; | 103 | struct dummy_slot *dslot; |
102 | struct hotplug_slot *slot; | 104 | struct hotplug_slot *slot; |
105 | char name[SLOT_NAME_SIZE]; | ||
103 | int retval = -ENOMEM; | 106 | int retval = -ENOMEM; |
104 | static int count = 1; | 107 | static int count = 1; |
105 | 108 | ||
@@ -119,19 +122,22 @@ static int add_slot(struct pci_dev *dev) | |||
119 | if (!dslot) | 122 | if (!dslot) |
120 | goto error_info; | 123 | goto error_info; |
121 | 124 | ||
122 | slot->name = dslot->name; | 125 | if (dup_slots) |
123 | snprintf(slot->name, sizeof(dslot->name), "fake%d", count++); | 126 | snprintf(name, SLOT_NAME_SIZE, "fake"); |
124 | dbg("slot->name = %s\n", slot->name); | 127 | else |
128 | snprintf(name, SLOT_NAME_SIZE, "fake%d", count++); | ||
129 | dbg("slot->name = %s\n", name); | ||
125 | slot->ops = &dummy_hotplug_slot_ops; | 130 | slot->ops = &dummy_hotplug_slot_ops; |
126 | slot->release = &dummy_release; | 131 | slot->release = &dummy_release; |
127 | slot->private = dslot; | 132 | slot->private = dslot; |
128 | 133 | ||
129 | retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn)); | 134 | retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn), name); |
130 | if (retval) { | 135 | if (retval) { |
131 | err("pci_hp_register failed with error %d\n", retval); | 136 | err("pci_hp_register failed with error %d\n", retval); |
132 | goto error_dslot; | 137 | goto error_dslot; |
133 | } | 138 | } |
134 | 139 | ||
140 | dbg("slot->name = %s\n", hotplug_slot_name(slot)); | ||
135 | dslot->slot = slot; | 141 | dslot->slot = slot; |
136 | dslot->dev = pci_dev_get(dev); | 142 | dslot->dev = pci_dev_get(dev); |
137 | list_add (&dslot->node, &slot_list); | 143 | list_add (&dslot->node, &slot_list); |
@@ -167,10 +173,11 @@ static void remove_slot(struct dummy_slot *dslot) | |||
167 | { | 173 | { |
168 | int retval; | 174 | int retval; |
169 | 175 | ||
170 | dbg("removing slot %s\n", dslot->slot->name); | 176 | dbg("removing slot %s\n", hotplug_slot_name(dslot->slot)); |
171 | retval = pci_hp_deregister(dslot->slot); | 177 | retval = pci_hp_deregister(dslot->slot); |
172 | if (retval) | 178 | if (retval) |
173 | err("Problem unregistering a slot %s\n", dslot->slot->name); | 179 | err("Problem unregistering a slot %s\n", |
180 | hotplug_slot_name(dslot->slot)); | ||
174 | } | 181 | } |
175 | 182 | ||
176 | /* called from the single-threaded workqueue handler to remove a slot */ | 183 | /* called from the single-threaded workqueue handler to remove a slot */ |
@@ -308,7 +315,7 @@ static int disable_slot(struct hotplug_slot *slot) | |||
308 | return -ENODEV; | 315 | return -ENODEV; |
309 | dslot = slot->private; | 316 | dslot = slot->private; |
310 | 317 | ||
311 | dbg("%s - physical_slot = %s\n", __func__, slot->name); | 318 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(slot)); |
312 | 319 | ||
313 | for (func = 7; func >= 0; func--) { | 320 | for (func = 7; func >= 0; func--) { |
314 | dev = pci_get_slot(dslot->dev->bus, dslot->dev->devfn + func); | 321 | dev = pci_get_slot(dslot->dev->bus, dslot->dev->devfn + func); |
@@ -373,4 +380,5 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
373 | MODULE_LICENSE("GPL"); | 380 | MODULE_LICENSE("GPL"); |
374 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 381 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
375 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); | 382 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); |
376 | 383 | module_param(dup_slots, bool, S_IRUGO | S_IWUSR); | |
384 | MODULE_PARM_DESC(dup_slots, "Force duplicate slot names for debugging"); | ||
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h index 612d9630150..a8d391a4957 100644 --- a/drivers/pci/hotplug/ibmphp.h +++ b/drivers/pci/hotplug/ibmphp.h | |||
@@ -707,17 +707,16 @@ struct slot { | |||
707 | u8 device; | 707 | u8 device; |
708 | u8 number; | 708 | u8 number; |
709 | u8 real_physical_slot_num; | 709 | u8 real_physical_slot_num; |
710 | char name[100]; | ||
711 | u32 capabilities; | 710 | u32 capabilities; |
712 | u8 supported_speed; | 711 | u8 supported_speed; |
713 | u8 supported_bus_mode; | 712 | u8 supported_bus_mode; |
713 | u8 flag; /* this is for disable slot and polling */ | ||
714 | u8 ctlr_index; | ||
714 | struct hotplug_slot *hotplug_slot; | 715 | struct hotplug_slot *hotplug_slot; |
715 | struct controller *ctrl; | 716 | struct controller *ctrl; |
716 | struct pci_func *func; | 717 | struct pci_func *func; |
717 | u8 irq[4]; | 718 | u8 irq[4]; |
718 | u8 flag; /* this is for disable slot and polling */ | ||
719 | int bit_mode; /* 0 = 32, 1 = 64 */ | 719 | int bit_mode; /* 0 = 32, 1 = 64 */ |
720 | u8 ctlr_index; | ||
721 | struct bus_info *bus_on; | 720 | struct bus_info *bus_on; |
722 | struct list_head ibm_slot_list; | 721 | struct list_head ibm_slot_list; |
723 | u8 status; | 722 | u8 status; |
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index 7d27631e6e6..c1abac8ab5c 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -123,10 +123,8 @@ static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) | |||
123 | static void __init print_bus_info (void) | 123 | static void __init print_bus_info (void) |
124 | { | 124 | { |
125 | struct bus_info *ptr; | 125 | struct bus_info *ptr; |
126 | struct list_head *ptr1; | ||
127 | 126 | ||
128 | list_for_each (ptr1, &bus_info_head) { | 127 | list_for_each_entry(ptr, &bus_info_head, bus_info_list) { |
129 | ptr = list_entry (ptr1, struct bus_info, bus_info_list); | ||
130 | debug ("%s - slot_min = %x\n", __func__, ptr->slot_min); | 128 | debug ("%s - slot_min = %x\n", __func__, ptr->slot_min); |
131 | debug ("%s - slot_max = %x\n", __func__, ptr->slot_max); | 129 | debug ("%s - slot_max = %x\n", __func__, ptr->slot_max); |
132 | debug ("%s - slot_count = %x\n", __func__, ptr->slot_count); | 130 | debug ("%s - slot_count = %x\n", __func__, ptr->slot_count); |
@@ -146,10 +144,8 @@ static void __init print_bus_info (void) | |||
146 | static void print_lo_info (void) | 144 | static void print_lo_info (void) |
147 | { | 145 | { |
148 | struct rio_detail *ptr; | 146 | struct rio_detail *ptr; |
149 | struct list_head *ptr1; | ||
150 | debug ("print_lo_info ----\n"); | 147 | debug ("print_lo_info ----\n"); |
151 | list_for_each (ptr1, &rio_lo_head) { | 148 | list_for_each_entry(ptr, &rio_lo_head, rio_detail_list) { |
152 | ptr = list_entry (ptr1, struct rio_detail, rio_detail_list); | ||
153 | debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); | 149 | debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); |
154 | debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); | 150 | debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); |
155 | debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); | 151 | debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); |
@@ -163,10 +159,8 @@ static void print_lo_info (void) | |||
163 | static void print_vg_info (void) | 159 | static void print_vg_info (void) |
164 | { | 160 | { |
165 | struct rio_detail *ptr; | 161 | struct rio_detail *ptr; |
166 | struct list_head *ptr1; | ||
167 | debug ("%s ---\n", __func__); | 162 | debug ("%s ---\n", __func__); |
168 | list_for_each (ptr1, &rio_vg_head) { | 163 | list_for_each_entry(ptr, &rio_vg_head, rio_detail_list) { |
169 | ptr = list_entry (ptr1, struct rio_detail, rio_detail_list); | ||
170 | debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); | 164 | debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); |
171 | debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); | 165 | debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); |
172 | debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); | 166 | debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); |
@@ -180,10 +174,8 @@ static void print_vg_info (void) | |||
180 | static void __init print_ebda_pci_rsrc (void) | 174 | static void __init print_ebda_pci_rsrc (void) |
181 | { | 175 | { |
182 | struct ebda_pci_rsrc *ptr; | 176 | struct ebda_pci_rsrc *ptr; |
183 | struct list_head *ptr1; | ||
184 | 177 | ||
185 | list_for_each (ptr1, &ibmphp_ebda_pci_rsrc_head) { | 178 | list_for_each_entry(ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) { |
186 | ptr = list_entry (ptr1, struct ebda_pci_rsrc, ebda_pci_rsrc_list); | ||
187 | debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", | 179 | debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", |
188 | __func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr); | 180 | __func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr); |
189 | } | 181 | } |
@@ -192,10 +184,8 @@ static void __init print_ebda_pci_rsrc (void) | |||
192 | static void __init print_ibm_slot (void) | 184 | static void __init print_ibm_slot (void) |
193 | { | 185 | { |
194 | struct slot *ptr; | 186 | struct slot *ptr; |
195 | struct list_head *ptr1; | ||
196 | 187 | ||
197 | list_for_each (ptr1, &ibmphp_slot_head) { | 188 | list_for_each_entry(ptr, &ibmphp_slot_head, ibm_slot_list) { |
198 | ptr = list_entry (ptr1, struct slot, ibm_slot_list); | ||
199 | debug ("%s - slot_number: %x\n", __func__, ptr->number); | 189 | debug ("%s - slot_number: %x\n", __func__, ptr->number); |
200 | } | 190 | } |
201 | } | 191 | } |
@@ -203,10 +193,8 @@ static void __init print_ibm_slot (void) | |||
203 | static void __init print_opt_vg (void) | 193 | static void __init print_opt_vg (void) |
204 | { | 194 | { |
205 | struct opt_rio *ptr; | 195 | struct opt_rio *ptr; |
206 | struct list_head *ptr1; | ||
207 | debug ("%s ---\n", __func__); | 196 | debug ("%s ---\n", __func__); |
208 | list_for_each (ptr1, &opt_vg_head) { | 197 | list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { |
209 | ptr = list_entry (ptr1, struct opt_rio, opt_rio_list); | ||
210 | debug ("%s - rio_type %x\n", __func__, ptr->rio_type); | 198 | debug ("%s - rio_type %x\n", __func__, ptr->rio_type); |
211 | debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num); | 199 | debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num); |
212 | debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num); | 200 | debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num); |
@@ -217,13 +205,9 @@ static void __init print_opt_vg (void) | |||
217 | static void __init print_ebda_hpc (void) | 205 | static void __init print_ebda_hpc (void) |
218 | { | 206 | { |
219 | struct controller *hpc_ptr; | 207 | struct controller *hpc_ptr; |
220 | struct list_head *ptr1; | ||
221 | u16 index; | 208 | u16 index; |
222 | 209 | ||
223 | list_for_each (ptr1, &ebda_hpc_head) { | 210 | list_for_each_entry(hpc_ptr, &ebda_hpc_head, ebda_hpc_list) { |
224 | |||
225 | hpc_ptr = list_entry (ptr1, struct controller, ebda_hpc_list); | ||
226 | |||
227 | for (index = 0; index < hpc_ptr->slot_count; index++) { | 211 | for (index = 0; index < hpc_ptr->slot_count; index++) { |
228 | debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num); | 212 | debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num); |
229 | debug ("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num); | 213 | debug ("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num); |
@@ -460,9 +444,7 @@ static int __init ebda_rio_table (void) | |||
460 | static struct opt_rio *search_opt_vg (u8 chassis_num) | 444 | static struct opt_rio *search_opt_vg (u8 chassis_num) |
461 | { | 445 | { |
462 | struct opt_rio *ptr; | 446 | struct opt_rio *ptr; |
463 | struct list_head *ptr1; | 447 | list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { |
464 | list_for_each (ptr1, &opt_vg_head) { | ||
465 | ptr = list_entry (ptr1, struct opt_rio, opt_rio_list); | ||
466 | if (ptr->chassis_num == chassis_num) | 448 | if (ptr->chassis_num == chassis_num) |
467 | return ptr; | 449 | return ptr; |
468 | } | 450 | } |
@@ -473,10 +455,8 @@ static int __init combine_wpg_for_chassis (void) | |||
473 | { | 455 | { |
474 | struct opt_rio *opt_rio_ptr = NULL; | 456 | struct opt_rio *opt_rio_ptr = NULL; |
475 | struct rio_detail *rio_detail_ptr = NULL; | 457 | struct rio_detail *rio_detail_ptr = NULL; |
476 | struct list_head *list_head_ptr = NULL; | ||
477 | 458 | ||
478 | list_for_each (list_head_ptr, &rio_vg_head) { | 459 | list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) { |
479 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | ||
480 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); | 460 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); |
481 | if (!opt_rio_ptr) { | 461 | if (!opt_rio_ptr) { |
482 | opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); | 462 | opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); |
@@ -497,14 +477,12 @@ static int __init combine_wpg_for_chassis (void) | |||
497 | } | 477 | } |
498 | 478 | ||
499 | /* | 479 | /* |
500 | * reorgnizing linked list of expansion box | 480 | * reorganizing linked list of expansion box |
501 | */ | 481 | */ |
502 | static struct opt_rio_lo *search_opt_lo (u8 chassis_num) | 482 | static struct opt_rio_lo *search_opt_lo (u8 chassis_num) |
503 | { | 483 | { |
504 | struct opt_rio_lo *ptr; | 484 | struct opt_rio_lo *ptr; |
505 | struct list_head *ptr1; | 485 | list_for_each_entry(ptr, &opt_lo_head, opt_rio_lo_list) { |
506 | list_for_each (ptr1, &opt_lo_head) { | ||
507 | ptr = list_entry (ptr1, struct opt_rio_lo, opt_rio_lo_list); | ||
508 | if (ptr->chassis_num == chassis_num) | 486 | if (ptr->chassis_num == chassis_num) |
509 | return ptr; | 487 | return ptr; |
510 | } | 488 | } |
@@ -515,10 +493,8 @@ static int combine_wpg_for_expansion (void) | |||
515 | { | 493 | { |
516 | struct opt_rio_lo *opt_rio_lo_ptr = NULL; | 494 | struct opt_rio_lo *opt_rio_lo_ptr = NULL; |
517 | struct rio_detail *rio_detail_ptr = NULL; | 495 | struct rio_detail *rio_detail_ptr = NULL; |
518 | struct list_head *list_head_ptr = NULL; | ||
519 | 496 | ||
520 | list_for_each (list_head_ptr, &rio_lo_head) { | 497 | list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) { |
521 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | ||
522 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); | 498 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); |
523 | if (!opt_rio_lo_ptr) { | 499 | if (!opt_rio_lo_ptr) { |
524 | opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); | 500 | opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); |
@@ -550,20 +526,17 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var) | |||
550 | { | 526 | { |
551 | struct opt_rio *opt_vg_ptr = NULL; | 527 | struct opt_rio *opt_vg_ptr = NULL; |
552 | struct opt_rio_lo *opt_lo_ptr = NULL; | 528 | struct opt_rio_lo *opt_lo_ptr = NULL; |
553 | struct list_head *ptr = NULL; | ||
554 | int rc = 0; | 529 | int rc = 0; |
555 | 530 | ||
556 | if (!var) { | 531 | if (!var) { |
557 | list_for_each (ptr, &opt_vg_head) { | 532 | list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) { |
558 | opt_vg_ptr = list_entry (ptr, struct opt_rio, opt_rio_list); | ||
559 | if ((first_slot < opt_vg_ptr->first_slot_num) && (slot_num >= opt_vg_ptr->first_slot_num)) { | 533 | if ((first_slot < opt_vg_ptr->first_slot_num) && (slot_num >= opt_vg_ptr->first_slot_num)) { |
560 | rc = -ENODEV; | 534 | rc = -ENODEV; |
561 | break; | 535 | break; |
562 | } | 536 | } |
563 | } | 537 | } |
564 | } else { | 538 | } else { |
565 | list_for_each (ptr, &opt_lo_head) { | 539 | list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) { |
566 | opt_lo_ptr = list_entry (ptr, struct opt_rio_lo, opt_rio_lo_list); | ||
567 | if ((first_slot < opt_lo_ptr->first_slot_num) && (slot_num >= opt_lo_ptr->first_slot_num)) { | 540 | if ((first_slot < opt_lo_ptr->first_slot_num) && (slot_num >= opt_lo_ptr->first_slot_num)) { |
568 | rc = -ENODEV; | 541 | rc = -ENODEV; |
569 | break; | 542 | break; |
@@ -576,10 +549,8 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var) | |||
576 | static struct opt_rio_lo * find_rxe_num (u8 slot_num) | 549 | static struct opt_rio_lo * find_rxe_num (u8 slot_num) |
577 | { | 550 | { |
578 | struct opt_rio_lo *opt_lo_ptr; | 551 | struct opt_rio_lo *opt_lo_ptr; |
579 | struct list_head *ptr; | ||
580 | 552 | ||
581 | list_for_each (ptr, &opt_lo_head) { | 553 | list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) { |
582 | opt_lo_ptr = list_entry (ptr, struct opt_rio_lo, opt_rio_lo_list); | ||
583 | //check to see if this slot_num belongs to expansion box | 554 | //check to see if this slot_num belongs to expansion box |
584 | if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1))) | 555 | if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1))) |
585 | return opt_lo_ptr; | 556 | return opt_lo_ptr; |
@@ -590,10 +561,8 @@ static struct opt_rio_lo * find_rxe_num (u8 slot_num) | |||
590 | static struct opt_rio * find_chassis_num (u8 slot_num) | 561 | static struct opt_rio * find_chassis_num (u8 slot_num) |
591 | { | 562 | { |
592 | struct opt_rio *opt_vg_ptr; | 563 | struct opt_rio *opt_vg_ptr; |
593 | struct list_head *ptr; | ||
594 | 564 | ||
595 | list_for_each (ptr, &opt_vg_head) { | 565 | list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) { |
596 | opt_vg_ptr = list_entry (ptr, struct opt_rio, opt_rio_list); | ||
597 | //check to see if this slot_num belongs to chassis | 566 | //check to see if this slot_num belongs to chassis |
598 | if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0))) | 567 | if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0))) |
599 | return opt_vg_ptr; | 568 | return opt_vg_ptr; |
@@ -607,11 +576,9 @@ static struct opt_rio * find_chassis_num (u8 slot_num) | |||
607 | static u8 calculate_first_slot (u8 slot_num) | 576 | static u8 calculate_first_slot (u8 slot_num) |
608 | { | 577 | { |
609 | u8 first_slot = 1; | 578 | u8 first_slot = 1; |
610 | struct list_head * list; | ||
611 | struct slot * slot_cur; | 579 | struct slot * slot_cur; |
612 | 580 | ||
613 | list_for_each (list, &ibmphp_slot_head) { | 581 | list_for_each_entry(slot_cur, &ibmphp_slot_head, ibm_slot_list) { |
614 | slot_cur = list_entry (list, struct slot, ibm_slot_list); | ||
615 | if (slot_cur->ctrl) { | 582 | if (slot_cur->ctrl) { |
616 | if ((slot_cur->ctrl->ctlr_type != 4) && (slot_cur->ctrl->ending_slot_num > first_slot) && (slot_num > slot_cur->ctrl->ending_slot_num)) | 583 | if ((slot_cur->ctrl->ctlr_type != 4) && (slot_cur->ctrl->ending_slot_num > first_slot) && (slot_num > slot_cur->ctrl->ending_slot_num)) |
617 | first_slot = slot_cur->ctrl->ending_slot_num; | 584 | first_slot = slot_cur->ctrl->ending_slot_num; |
@@ -620,11 +587,14 @@ static u8 calculate_first_slot (u8 slot_num) | |||
620 | return first_slot + 1; | 587 | return first_slot + 1; |
621 | 588 | ||
622 | } | 589 | } |
590 | |||
591 | #define SLOT_NAME_SIZE 30 | ||
592 | |||
623 | static char *create_file_name (struct slot * slot_cur) | 593 | static char *create_file_name (struct slot * slot_cur) |
624 | { | 594 | { |
625 | struct opt_rio *opt_vg_ptr = NULL; | 595 | struct opt_rio *opt_vg_ptr = NULL; |
626 | struct opt_rio_lo *opt_lo_ptr = NULL; | 596 | struct opt_rio_lo *opt_lo_ptr = NULL; |
627 | static char str[30]; | 597 | static char str[SLOT_NAME_SIZE]; |
628 | int which = 0; /* rxe = 1, chassis = 0 */ | 598 | int which = 0; /* rxe = 1, chassis = 0 */ |
629 | u8 number = 1; /* either chassis or rxe # */ | 599 | u8 number = 1; /* either chassis or rxe # */ |
630 | u8 first_slot = 1; | 600 | u8 first_slot = 1; |
@@ -736,7 +706,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
736 | 706 | ||
737 | slot = hotplug_slot->private; | 707 | slot = hotplug_slot->private; |
738 | kfree(slot->hotplug_slot->info); | 708 | kfree(slot->hotplug_slot->info); |
739 | kfree(slot->hotplug_slot->name); | ||
740 | kfree(slot->hotplug_slot); | 709 | kfree(slot->hotplug_slot); |
741 | slot->ctrl = NULL; | 710 | slot->ctrl = NULL; |
742 | slot->bus_on = NULL; | 711 | slot->bus_on = NULL; |
@@ -767,7 +736,7 @@ static int __init ebda_rsrc_controller (void) | |||
767 | struct bus_info *bus_info_ptr1, *bus_info_ptr2; | 736 | struct bus_info *bus_info_ptr1, *bus_info_ptr2; |
768 | int rc; | 737 | int rc; |
769 | struct slot *tmp_slot; | 738 | struct slot *tmp_slot; |
770 | struct list_head *list; | 739 | char name[SLOT_NAME_SIZE]; |
771 | 740 | ||
772 | addr = hpc_list_ptr->phys_addr; | 741 | addr = hpc_list_ptr->phys_addr; |
773 | for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) { | 742 | for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) { |
@@ -931,12 +900,6 @@ static int __init ebda_rsrc_controller (void) | |||
931 | goto error_no_hp_info; | 900 | goto error_no_hp_info; |
932 | } | 901 | } |
933 | 902 | ||
934 | hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); | ||
935 | if (!hp_slot_ptr->name) { | ||
936 | rc = -ENOMEM; | ||
937 | goto error_no_hp_name; | ||
938 | } | ||
939 | |||
940 | tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); | 903 | tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); |
941 | if (!tmp_slot) { | 904 | if (!tmp_slot) { |
942 | rc = -ENOMEM; | 905 | rc = -ENOMEM; |
@@ -997,12 +960,10 @@ static int __init ebda_rsrc_controller (void) | |||
997 | 960 | ||
998 | } /* each hpc */ | 961 | } /* each hpc */ |
999 | 962 | ||
1000 | list_for_each (list, &ibmphp_slot_head) { | 963 | list_for_each_entry(tmp_slot, &ibmphp_slot_head, ibm_slot_list) { |
1001 | tmp_slot = list_entry (list, struct slot, ibm_slot_list); | 964 | snprintf(name, SLOT_NAME_SIZE, "%s", create_file_name(tmp_slot)); |
1002 | |||
1003 | snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot)); | ||
1004 | pci_hp_register(tmp_slot->hotplug_slot, | 965 | pci_hp_register(tmp_slot->hotplug_slot, |
1005 | pci_find_bus(0, tmp_slot->bus), tmp_slot->device); | 966 | pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name); |
1006 | } | 967 | } |
1007 | 968 | ||
1008 | print_ebda_hpc (); | 969 | print_ebda_hpc (); |
@@ -1012,8 +973,6 @@ static int __init ebda_rsrc_controller (void) | |||
1012 | error: | 973 | error: |
1013 | kfree (hp_slot_ptr->private); | 974 | kfree (hp_slot_ptr->private); |
1014 | error_no_slot: | 975 | error_no_slot: |
1015 | kfree (hp_slot_ptr->name); | ||
1016 | error_no_hp_name: | ||
1017 | kfree (hp_slot_ptr->info); | 976 | kfree (hp_slot_ptr->info); |
1018 | error_no_hp_info: | 977 | error_no_hp_info: |
1019 | kfree (hp_slot_ptr); | 978 | kfree (hp_slot_ptr); |
@@ -1101,10 +1060,8 @@ u16 ibmphp_get_total_controllers (void) | |||
1101 | struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) | 1060 | struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) |
1102 | { | 1061 | { |
1103 | struct slot *slot; | 1062 | struct slot *slot; |
1104 | struct list_head *list; | ||
1105 | 1063 | ||
1106 | list_for_each (list, &ibmphp_slot_head) { | 1064 | list_for_each_entry(slot, &ibmphp_slot_head, ibm_slot_list) { |
1107 | slot = list_entry (list, struct slot, ibm_slot_list); | ||
1108 | if (slot->number == physical_num) | 1065 | if (slot->number == physical_num) |
1109 | return slot; | 1066 | return slot; |
1110 | } | 1067 | } |
@@ -1120,10 +1077,8 @@ struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) | |||
1120 | struct bus_info *ibmphp_find_same_bus_num (u32 num) | 1077 | struct bus_info *ibmphp_find_same_bus_num (u32 num) |
1121 | { | 1078 | { |
1122 | struct bus_info *ptr; | 1079 | struct bus_info *ptr; |
1123 | struct list_head *ptr1; | ||
1124 | 1080 | ||
1125 | list_for_each (ptr1, &bus_info_head) { | 1081 | list_for_each_entry(ptr, &bus_info_head, bus_info_list) { |
1126 | ptr = list_entry (ptr1, struct bus_info, bus_info_list); | ||
1127 | if (ptr->busno == num) | 1082 | if (ptr->busno == num) |
1128 | return ptr; | 1083 | return ptr; |
1129 | } | 1084 | } |
@@ -1136,10 +1091,8 @@ struct bus_info *ibmphp_find_same_bus_num (u32 num) | |||
1136 | int ibmphp_get_bus_index (u8 num) | 1091 | int ibmphp_get_bus_index (u8 num) |
1137 | { | 1092 | { |
1138 | struct bus_info *ptr; | 1093 | struct bus_info *ptr; |
1139 | struct list_head *ptr1; | ||
1140 | 1094 | ||
1141 | list_for_each (ptr1, &bus_info_head) { | 1095 | list_for_each_entry(ptr, &bus_info_head, bus_info_list) { |
1142 | ptr = list_entry (ptr1, struct bus_info, bus_info_list); | ||
1143 | if (ptr->busno == num) | 1096 | if (ptr->busno == num) |
1144 | return ptr->index; | 1097 | return ptr->index; |
1145 | } | 1098 | } |
@@ -1212,11 +1165,9 @@ static struct pci_driver ibmphp_driver = { | |||
1212 | int ibmphp_register_pci (void) | 1165 | int ibmphp_register_pci (void) |
1213 | { | 1166 | { |
1214 | struct controller *ctrl; | 1167 | struct controller *ctrl; |
1215 | struct list_head *tmp; | ||
1216 | int rc = 0; | 1168 | int rc = 0; |
1217 | 1169 | ||
1218 | list_for_each (tmp, &ebda_hpc_head) { | 1170 | list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) { |
1219 | ctrl = list_entry (tmp, struct controller, ebda_hpc_list); | ||
1220 | if (ctrl->ctlr_type == 1) { | 1171 | if (ctrl->ctlr_type == 1) { |
1221 | rc = pci_register_driver(&ibmphp_driver); | 1172 | rc = pci_register_driver(&ibmphp_driver); |
1222 | break; | 1173 | break; |
@@ -1227,12 +1178,10 @@ int ibmphp_register_pci (void) | |||
1227 | static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids) | 1178 | static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids) |
1228 | { | 1179 | { |
1229 | struct controller *ctrl; | 1180 | struct controller *ctrl; |
1230 | struct list_head *tmp; | ||
1231 | 1181 | ||
1232 | debug ("inside ibmphp_probe\n"); | 1182 | debug ("inside ibmphp_probe\n"); |
1233 | 1183 | ||
1234 | list_for_each (tmp, &ebda_hpc_head) { | 1184 | list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) { |
1235 | ctrl = list_entry (tmp, struct controller, ebda_hpc_list); | ||
1236 | if (ctrl->ctlr_type == 1) { | 1185 | if (ctrl->ctlr_type == 1) { |
1237 | if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { | 1186 | if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { |
1238 | ctrl->ctrl_dev = dev; | 1187 | ctrl->ctrl_dev = dev; |
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c index 5f85b1b120e..535fce0f07f 100644 --- a/drivers/pci/hotplug/pci_hotplug_core.c +++ b/drivers/pci/hotplug/pci_hotplug_core.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/mount.h> | 38 | #include <linux/mount.h> |
39 | #include <linux/namei.h> | 39 | #include <linux/namei.h> |
40 | #include <linux/mutex.h> | ||
40 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
41 | #include <linux/pci_hotplug.h> | 42 | #include <linux/pci_hotplug.h> |
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
@@ -61,7 +62,7 @@ static int debug; | |||
61 | ////////////////////////////////////////////////////////////////// | 62 | ////////////////////////////////////////////////////////////////// |
62 | 63 | ||
63 | static LIST_HEAD(pci_hotplug_slot_list); | 64 | static LIST_HEAD(pci_hotplug_slot_list); |
64 | static DEFINE_SPINLOCK(pci_hotplug_slot_list_lock); | 65 | static DEFINE_MUTEX(pci_hp_mutex); |
65 | 66 | ||
66 | /* these strings match up with the values in pci_bus_speed */ | 67 | /* these strings match up with the values in pci_bus_speed */ |
67 | static char *pci_bus_speed_strings[] = { | 68 | static char *pci_bus_speed_strings[] = { |
@@ -102,13 +103,13 @@ static int get_##name (struct hotplug_slot *slot, type *value) \ | |||
102 | { \ | 103 | { \ |
103 | struct hotplug_slot_ops *ops = slot->ops; \ | 104 | struct hotplug_slot_ops *ops = slot->ops; \ |
104 | int retval = 0; \ | 105 | int retval = 0; \ |
105 | if (try_module_get(ops->owner)) { \ | 106 | if (!try_module_get(ops->owner)) \ |
106 | if (ops->get_##name) \ | 107 | return -ENODEV; \ |
107 | retval = ops->get_##name(slot, value); \ | 108 | if (ops->get_##name) \ |
108 | else \ | 109 | retval = ops->get_##name(slot, value); \ |
109 | *value = slot->info->name; \ | 110 | else \ |
110 | module_put(ops->owner); \ | 111 | *value = slot->info->name; \ |
111 | } \ | 112 | module_put(ops->owner); \ |
112 | return retval; \ | 113 | return retval; \ |
113 | } | 114 | } |
114 | 115 | ||
@@ -530,16 +531,12 @@ static struct hotplug_slot *get_slot_from_name (const char *name) | |||
530 | struct hotplug_slot *slot; | 531 | struct hotplug_slot *slot; |
531 | struct list_head *tmp; | 532 | struct list_head *tmp; |
532 | 533 | ||
533 | spin_lock(&pci_hotplug_slot_list_lock); | ||
534 | list_for_each (tmp, &pci_hotplug_slot_list) { | 534 | list_for_each (tmp, &pci_hotplug_slot_list) { |
535 | slot = list_entry (tmp, struct hotplug_slot, slot_list); | 535 | slot = list_entry (tmp, struct hotplug_slot, slot_list); |
536 | if (strcmp(slot->name, name) == 0) | 536 | if (strcmp(hotplug_slot_name(slot), name) == 0) |
537 | goto out; | 537 | return slot; |
538 | } | 538 | } |
539 | slot = NULL; | 539 | return NULL; |
540 | out: | ||
541 | spin_unlock(&pci_hotplug_slot_list_lock); | ||
542 | return slot; | ||
543 | } | 540 | } |
544 | 541 | ||
545 | /** | 542 | /** |
@@ -547,13 +544,15 @@ out: | |||
547 | * @bus: bus this slot is on | 544 | * @bus: bus this slot is on |
548 | * @slot: pointer to the &struct hotplug_slot to register | 545 | * @slot: pointer to the &struct hotplug_slot to register |
549 | * @slot_nr: slot number | 546 | * @slot_nr: slot number |
547 | * @name: name registered with kobject core | ||
550 | * | 548 | * |
551 | * Registers a hotplug slot with the pci hotplug subsystem, which will allow | 549 | * Registers a hotplug slot with the pci hotplug subsystem, which will allow |
552 | * userspace interaction to the slot. | 550 | * userspace interaction to the slot. |
553 | * | 551 | * |
554 | * Returns 0 if successful, anything else for an error. | 552 | * Returns 0 if successful, anything else for an error. |
555 | */ | 553 | */ |
556 | int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr) | 554 | int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr, |
555 | const char *name) | ||
557 | { | 556 | { |
558 | int result; | 557 | int result; |
559 | struct pci_slot *pci_slot; | 558 | struct pci_slot *pci_slot; |
@@ -568,48 +567,29 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr) | |||
568 | return -EINVAL; | 567 | return -EINVAL; |
569 | } | 568 | } |
570 | 569 | ||
571 | /* Check if we have already registered a slot with the same name. */ | 570 | mutex_lock(&pci_hp_mutex); |
572 | if (get_slot_from_name(slot->name)) | ||
573 | return -EEXIST; | ||
574 | 571 | ||
575 | /* | 572 | /* |
576 | * No problems if we call this interface from both ACPI_PCI_SLOT | 573 | * No problems if we call this interface from both ACPI_PCI_SLOT |
577 | * driver and call it here again. If we've already created the | 574 | * driver and call it here again. If we've already created the |
578 | * pci_slot, the interface will simply bump the refcount. | 575 | * pci_slot, the interface will simply bump the refcount. |
579 | */ | 576 | */ |
580 | pci_slot = pci_create_slot(bus, slot_nr, slot->name); | 577 | pci_slot = pci_create_slot(bus, slot_nr, name, slot); |
581 | if (IS_ERR(pci_slot)) | 578 | if (IS_ERR(pci_slot)) { |
582 | return PTR_ERR(pci_slot); | 579 | result = PTR_ERR(pci_slot); |
583 | 580 | goto out; | |
584 | if (pci_slot->hotplug) { | ||
585 | dbg("%s: already claimed\n", __func__); | ||
586 | pci_destroy_slot(pci_slot); | ||
587 | return -EBUSY; | ||
588 | } | 581 | } |
589 | 582 | ||
590 | slot->pci_slot = pci_slot; | 583 | slot->pci_slot = pci_slot; |
591 | pci_slot->hotplug = slot; | 584 | pci_slot->hotplug = slot; |
592 | 585 | ||
593 | /* | ||
594 | * Allow pcihp drivers to override the ACPI_PCI_SLOT name. | ||
595 | */ | ||
596 | if (strcmp(kobject_name(&pci_slot->kobj), slot->name)) { | ||
597 | result = kobject_rename(&pci_slot->kobj, slot->name); | ||
598 | if (result) { | ||
599 | pci_destroy_slot(pci_slot); | ||
600 | return result; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | spin_lock(&pci_hotplug_slot_list_lock); | ||
605 | list_add(&slot->slot_list, &pci_hotplug_slot_list); | 586 | list_add(&slot->slot_list, &pci_hotplug_slot_list); |
606 | spin_unlock(&pci_hotplug_slot_list_lock); | ||
607 | 587 | ||
608 | result = fs_add_slot(pci_slot); | 588 | result = fs_add_slot(pci_slot); |
609 | kobject_uevent(&pci_slot->kobj, KOBJ_ADD); | 589 | kobject_uevent(&pci_slot->kobj, KOBJ_ADD); |
610 | dbg("Added slot %s to the list\n", slot->name); | 590 | dbg("Added slot %s to the list\n", name); |
611 | 591 | out: | |
612 | 592 | mutex_unlock(&pci_hp_mutex); | |
613 | return result; | 593 | return result; |
614 | } | 594 | } |
615 | 595 | ||
@@ -630,21 +610,23 @@ int pci_hp_deregister(struct hotplug_slot *hotplug) | |||
630 | if (!hotplug) | 610 | if (!hotplug) |
631 | return -ENODEV; | 611 | return -ENODEV; |
632 | 612 | ||
633 | temp = get_slot_from_name(hotplug->name); | 613 | mutex_lock(&pci_hp_mutex); |
634 | if (temp != hotplug) | 614 | temp = get_slot_from_name(hotplug_slot_name(hotplug)); |
615 | if (temp != hotplug) { | ||
616 | mutex_unlock(&pci_hp_mutex); | ||
635 | return -ENODEV; | 617 | return -ENODEV; |
618 | } | ||
636 | 619 | ||
637 | spin_lock(&pci_hotplug_slot_list_lock); | ||
638 | list_del(&hotplug->slot_list); | 620 | list_del(&hotplug->slot_list); |
639 | spin_unlock(&pci_hotplug_slot_list_lock); | ||
640 | 621 | ||
641 | slot = hotplug->pci_slot; | 622 | slot = hotplug->pci_slot; |
642 | fs_remove_slot(slot); | 623 | fs_remove_slot(slot); |
643 | dbg("Removed slot %s from the list\n", hotplug->name); | 624 | dbg("Removed slot %s from the list\n", hotplug_slot_name(hotplug)); |
644 | 625 | ||
645 | hotplug->release(hotplug); | 626 | hotplug->release(hotplug); |
646 | slot->hotplug = NULL; | 627 | slot->hotplug = NULL; |
647 | pci_destroy_slot(slot); | 628 | pci_destroy_slot(slot); |
629 | mutex_unlock(&pci_hp_mutex); | ||
648 | 630 | ||
649 | return 0; | 631 | return 0; |
650 | } | 632 | } |
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 9e6cec67e1c..b2801a7ee37 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -57,19 +57,30 @@ extern struct workqueue_struct *pciehp_wq; | |||
57 | #define warn(format, arg...) \ | 57 | #define warn(format, arg...) \ |
58 | printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 58 | printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
59 | 59 | ||
60 | #define ctrl_dbg(ctrl, format, arg...) \ | ||
61 | do { \ | ||
62 | if (pciehp_debug) \ | ||
63 | dev_printk(, &ctrl->pcie->device, \ | ||
64 | format, ## arg); \ | ||
65 | } while (0) | ||
66 | #define ctrl_err(ctrl, format, arg...) \ | ||
67 | dev_err(&ctrl->pcie->device, format, ## arg) | ||
68 | #define ctrl_info(ctrl, format, arg...) \ | ||
69 | dev_info(&ctrl->pcie->device, format, ## arg) | ||
70 | #define ctrl_warn(ctrl, format, arg...) \ | ||
71 | dev_warn(&ctrl->pcie->device, format, ## arg) | ||
72 | |||
60 | #define SLOT_NAME_SIZE 10 | 73 | #define SLOT_NAME_SIZE 10 |
61 | struct slot { | 74 | struct slot { |
62 | u8 bus; | 75 | u8 bus; |
63 | u8 device; | 76 | u8 device; |
64 | u32 number; | ||
65 | u8 state; | 77 | u8 state; |
66 | struct timer_list task_event; | ||
67 | u8 hp_slot; | 78 | u8 hp_slot; |
79 | u32 number; | ||
68 | struct controller *ctrl; | 80 | struct controller *ctrl; |
69 | struct hpc_ops *hpc_ops; | 81 | struct hpc_ops *hpc_ops; |
70 | struct hotplug_slot *hotplug_slot; | 82 | struct hotplug_slot *hotplug_slot; |
71 | struct list_head slot_list; | 83 | struct list_head slot_list; |
72 | char name[SLOT_NAME_SIZE]; | ||
73 | unsigned long last_emi_toggle; | 84 | unsigned long last_emi_toggle; |
74 | struct delayed_work work; /* work for button event */ | 85 | struct delayed_work work; /* work for button event */ |
75 | struct mutex lock; | 86 | struct mutex lock; |
@@ -87,6 +98,7 @@ struct controller { | |||
87 | int num_slots; /* Number of slots on ctlr */ | 98 | int num_slots; /* Number of slots on ctlr */ |
88 | int slot_num_inc; /* 1 or -1 */ | 99 | int slot_num_inc; /* 1 or -1 */ |
89 | struct pci_dev *pci_dev; | 100 | struct pci_dev *pci_dev; |
101 | struct pcie_device *pcie; /* PCI Express port service */ | ||
90 | struct list_head slot_list; | 102 | struct list_head slot_list; |
91 | struct hpc_ops *hpc_ops; | 103 | struct hpc_ops *hpc_ops; |
92 | wait_queue_head_t queue; /* sleep & wake process */ | 104 | wait_queue_head_t queue; /* sleep & wake process */ |
@@ -98,6 +110,7 @@ struct controller { | |||
98 | struct timer_list poll_timer; | 110 | struct timer_list poll_timer; |
99 | int cmd_busy; | 111 | int cmd_busy; |
100 | unsigned int no_cmd_complete:1; | 112 | unsigned int no_cmd_complete:1; |
113 | unsigned int link_active_reporting:1; | ||
101 | }; | 114 | }; |
102 | 115 | ||
103 | #define INT_BUTTON_IGNORE 0 | 116 | #define INT_BUTTON_IGNORE 0 |
@@ -161,6 +174,11 @@ int pciehp_enable_slot(struct slot *p_slot); | |||
161 | int pciehp_disable_slot(struct slot *p_slot); | 174 | int pciehp_disable_slot(struct slot *p_slot); |
162 | int pcie_enable_notification(struct controller *ctrl); | 175 | int pcie_enable_notification(struct controller *ctrl); |
163 | 176 | ||
177 | static inline const char *slot_name(struct slot *slot) | ||
178 | { | ||
179 | return hotplug_slot_name(slot->hotplug_slot); | ||
180 | } | ||
181 | |||
164 | static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) | 182 | static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) |
165 | { | 183 | { |
166 | struct slot *slot; | 184 | struct slot *slot; |
@@ -170,7 +188,7 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) | |||
170 | return slot; | 188 | return slot; |
171 | } | 189 | } |
172 | 190 | ||
173 | err("%s: slot (device=0x%x) not found\n", __func__, device); | 191 | ctrl_err(ctrl, "Slot (device=0x%02x) not found\n", device); |
174 | return NULL; | 192 | return NULL; |
175 | } | 193 | } |
176 | 194 | ||
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 4fd5355bc3b..4b23bc39b11 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -144,9 +144,10 @@ set_lock_exit: | |||
144 | * sysfs interface which allows the user to toggle the Electro Mechanical | 144 | * sysfs interface which allows the user to toggle the Electro Mechanical |
145 | * Interlock. Valid values are either 0 or 1. 0 == unlock, 1 == lock | 145 | * Interlock. Valid values are either 0 or 1. 0 == unlock, 1 == lock |
146 | */ | 146 | */ |
147 | static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf, | 147 | static ssize_t lock_write_file(struct hotplug_slot *hotplug_slot, |
148 | size_t count) | 148 | const char *buf, size_t count) |
149 | { | 149 | { |
150 | struct slot *slot = hotplug_slot->private; | ||
150 | unsigned long llock; | 151 | unsigned long llock; |
151 | u8 lock; | 152 | u8 lock; |
152 | int retval = 0; | 153 | int retval = 0; |
@@ -157,10 +158,11 @@ static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf, | |||
157 | switch (lock) { | 158 | switch (lock) { |
158 | case 0: | 159 | case 0: |
159 | case 1: | 160 | case 1: |
160 | retval = set_lock_status(slot, lock); | 161 | retval = set_lock_status(hotplug_slot, lock); |
161 | break; | 162 | break; |
162 | default: | 163 | default: |
163 | err ("%d is an invalid lock value\n", lock); | 164 | ctrl_err(slot->ctrl, "%d is an invalid lock value\n", |
165 | lock); | ||
164 | retval = -EINVAL; | 166 | retval = -EINVAL; |
165 | } | 167 | } |
166 | if (retval) | 168 | if (retval) |
@@ -180,7 +182,10 @@ static struct hotplug_slot_attribute hotplug_slot_attr_lock = { | |||
180 | */ | 182 | */ |
181 | static void release_slot(struct hotplug_slot *hotplug_slot) | 183 | static void release_slot(struct hotplug_slot *hotplug_slot) |
182 | { | 184 | { |
183 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 185 | struct slot *slot = hotplug_slot->private; |
186 | |||
187 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", | ||
188 | __func__, hotplug_slot_name(hotplug_slot)); | ||
184 | 189 | ||
185 | kfree(hotplug_slot->info); | 190 | kfree(hotplug_slot->info); |
186 | kfree(hotplug_slot); | 191 | kfree(hotplug_slot); |
@@ -191,7 +196,7 @@ static int init_slots(struct controller *ctrl) | |||
191 | struct slot *slot; | 196 | struct slot *slot; |
192 | struct hotplug_slot *hotplug_slot; | 197 | struct hotplug_slot *hotplug_slot; |
193 | struct hotplug_slot_info *info; | 198 | struct hotplug_slot_info *info; |
194 | int len, dup = 1; | 199 | char name[SLOT_NAME_SIZE]; |
195 | int retval = -ENOMEM; | 200 | int retval = -ENOMEM; |
196 | 201 | ||
197 | list_for_each_entry(slot, &ctrl->slot_list, slot_list) { | 202 | list_for_each_entry(slot, &ctrl->slot_list, slot_list) { |
@@ -205,46 +210,38 @@ static int init_slots(struct controller *ctrl) | |||
205 | 210 | ||
206 | /* register this slot with the hotplug pci core */ | 211 | /* register this slot with the hotplug pci core */ |
207 | hotplug_slot->info = info; | 212 | hotplug_slot->info = info; |
208 | hotplug_slot->name = slot->name; | ||
209 | hotplug_slot->private = slot; | 213 | hotplug_slot->private = slot; |
210 | hotplug_slot->release = &release_slot; | 214 | hotplug_slot->release = &release_slot; |
211 | hotplug_slot->ops = &pciehp_hotplug_slot_ops; | 215 | hotplug_slot->ops = &pciehp_hotplug_slot_ops; |
212 | get_power_status(hotplug_slot, &info->power_status); | ||
213 | get_attention_status(hotplug_slot, &info->attention_status); | ||
214 | get_latch_status(hotplug_slot, &info->latch_status); | ||
215 | get_adapter_status(hotplug_slot, &info->adapter_status); | ||
216 | slot->hotplug_slot = hotplug_slot; | 216 | slot->hotplug_slot = hotplug_slot; |
217 | snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); | ||
217 | 218 | ||
218 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " | 219 | ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:%02x " |
219 | "slot_device_offset=%x\n", slot->bus, slot->device, | 220 | "hp_slot=%x sun=%x slot_device_offset=%x\n", |
220 | slot->hp_slot, slot->number, ctrl->slot_device_offset); | 221 | pci_domain_nr(ctrl->pci_dev->subordinate), |
221 | duplicate_name: | 222 | slot->bus, slot->device, slot->hp_slot, slot->number, |
223 | ctrl->slot_device_offset); | ||
222 | retval = pci_hp_register(hotplug_slot, | 224 | retval = pci_hp_register(hotplug_slot, |
223 | ctrl->pci_dev->subordinate, | 225 | ctrl->pci_dev->subordinate, |
224 | slot->device); | 226 | slot->device, |
227 | name); | ||
225 | if (retval) { | 228 | if (retval) { |
226 | /* | 229 | ctrl_err(ctrl, "pci_hp_register failed with error %d\n", |
227 | * If slot N already exists, we'll try to create | 230 | retval); |
228 | * slot N-1, N-2 ... N-M, until we overflow. | ||
229 | */ | ||
230 | if (retval == -EEXIST) { | ||
231 | len = snprintf(slot->name, SLOT_NAME_SIZE, | ||
232 | "%d-%d", slot->number, dup++); | ||
233 | if (len < SLOT_NAME_SIZE) | ||
234 | goto duplicate_name; | ||
235 | else | ||
236 | err("duplicate slot name overflow\n"); | ||
237 | } | ||
238 | err("pci_hp_register failed with error %d\n", retval); | ||
239 | goto error_info; | 231 | goto error_info; |
240 | } | 232 | } |
233 | get_power_status(hotplug_slot, &info->power_status); | ||
234 | get_attention_status(hotplug_slot, &info->attention_status); | ||
235 | get_latch_status(hotplug_slot, &info->latch_status); | ||
236 | get_adapter_status(hotplug_slot, &info->adapter_status); | ||
241 | /* create additional sysfs entries */ | 237 | /* create additional sysfs entries */ |
242 | if (EMI(ctrl)) { | 238 | if (EMI(ctrl)) { |
243 | retval = sysfs_create_file(&hotplug_slot->pci_slot->kobj, | 239 | retval = sysfs_create_file(&hotplug_slot->pci_slot->kobj, |
244 | &hotplug_slot_attr_lock.attr); | 240 | &hotplug_slot_attr_lock.attr); |
245 | if (retval) { | 241 | if (retval) { |
246 | pci_hp_deregister(hotplug_slot); | 242 | pci_hp_deregister(hotplug_slot); |
247 | err("cannot create additional sysfs entries\n"); | 243 | ctrl_err(ctrl, "Cannot create additional sysfs " |
244 | "entries\n"); | ||
248 | goto error_info; | 245 | goto error_info; |
249 | } | 246 | } |
250 | } | 247 | } |
@@ -278,7 +275,8 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) | |||
278 | { | 275 | { |
279 | struct slot *slot = hotplug_slot->private; | 276 | struct slot *slot = hotplug_slot->private; |
280 | 277 | ||
281 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 278 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
279 | __func__, slot_name(slot)); | ||
282 | 280 | ||
283 | hotplug_slot->info->attention_status = status; | 281 | hotplug_slot->info->attention_status = status; |
284 | 282 | ||
@@ -293,7 +291,8 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) | |||
293 | { | 291 | { |
294 | struct slot *slot = hotplug_slot->private; | 292 | struct slot *slot = hotplug_slot->private; |
295 | 293 | ||
296 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 294 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
295 | __func__, slot_name(slot)); | ||
297 | 296 | ||
298 | return pciehp_sysfs_enable_slot(slot); | 297 | return pciehp_sysfs_enable_slot(slot); |
299 | } | 298 | } |
@@ -303,7 +302,8 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) | |||
303 | { | 302 | { |
304 | struct slot *slot = hotplug_slot->private; | 303 | struct slot *slot = hotplug_slot->private; |
305 | 304 | ||
306 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 305 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
306 | __func__, slot_name(slot)); | ||
307 | 307 | ||
308 | return pciehp_sysfs_disable_slot(slot); | 308 | return pciehp_sysfs_disable_slot(slot); |
309 | } | 309 | } |
@@ -313,7 +313,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
313 | struct slot *slot = hotplug_slot->private; | 313 | struct slot *slot = hotplug_slot->private; |
314 | int retval; | 314 | int retval; |
315 | 315 | ||
316 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 316 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
317 | __func__, slot_name(slot)); | ||
317 | 318 | ||
318 | retval = slot->hpc_ops->get_power_status(slot, value); | 319 | retval = slot->hpc_ops->get_power_status(slot, value); |
319 | if (retval < 0) | 320 | if (retval < 0) |
@@ -327,7 +328,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
327 | struct slot *slot = hotplug_slot->private; | 328 | struct slot *slot = hotplug_slot->private; |
328 | int retval; | 329 | int retval; |
329 | 330 | ||
330 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 331 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
332 | __func__, slot_name(slot)); | ||
331 | 333 | ||
332 | retval = slot->hpc_ops->get_attention_status(slot, value); | 334 | retval = slot->hpc_ops->get_attention_status(slot, value); |
333 | if (retval < 0) | 335 | if (retval < 0) |
@@ -341,7 +343,8 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
341 | struct slot *slot = hotplug_slot->private; | 343 | struct slot *slot = hotplug_slot->private; |
342 | int retval; | 344 | int retval; |
343 | 345 | ||
344 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 346 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
347 | __func__, slot_name(slot)); | ||
345 | 348 | ||
346 | retval = slot->hpc_ops->get_latch_status(slot, value); | 349 | retval = slot->hpc_ops->get_latch_status(slot, value); |
347 | if (retval < 0) | 350 | if (retval < 0) |
@@ -355,7 +358,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
355 | struct slot *slot = hotplug_slot->private; | 358 | struct slot *slot = hotplug_slot->private; |
356 | int retval; | 359 | int retval; |
357 | 360 | ||
358 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 361 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
362 | __func__, slot_name(slot)); | ||
359 | 363 | ||
360 | retval = slot->hpc_ops->get_adapter_status(slot, value); | 364 | retval = slot->hpc_ops->get_adapter_status(slot, value); |
361 | if (retval < 0) | 365 | if (retval < 0) |
@@ -370,7 +374,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, | |||
370 | struct slot *slot = hotplug_slot->private; | 374 | struct slot *slot = hotplug_slot->private; |
371 | int retval; | 375 | int retval; |
372 | 376 | ||
373 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 377 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
378 | __func__, slot_name(slot)); | ||
374 | 379 | ||
375 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); | 380 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); |
376 | if (retval < 0) | 381 | if (retval < 0) |
@@ -384,7 +389,8 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe | |||
384 | struct slot *slot = hotplug_slot->private; | 389 | struct slot *slot = hotplug_slot->private; |
385 | int retval; | 390 | int retval; |
386 | 391 | ||
387 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 392 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
393 | __func__, slot_name(slot)); | ||
388 | 394 | ||
389 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); | 395 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); |
390 | if (retval < 0) | 396 | if (retval < 0) |
@@ -402,14 +408,15 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
402 | struct pci_dev *pdev = dev->port; | 408 | struct pci_dev *pdev = dev->port; |
403 | 409 | ||
404 | if (pciehp_force) | 410 | if (pciehp_force) |
405 | dbg("Bypassing BIOS check for pciehp use on %s\n", | 411 | dev_info(&dev->device, |
406 | pci_name(pdev)); | 412 | "Bypassing BIOS check for pciehp use on %s\n", |
413 | pci_name(pdev)); | ||
407 | else if (pciehp_get_hp_hw_control_from_firmware(pdev)) | 414 | else if (pciehp_get_hp_hw_control_from_firmware(pdev)) |
408 | goto err_out_none; | 415 | goto err_out_none; |
409 | 416 | ||
410 | ctrl = pcie_init(dev); | 417 | ctrl = pcie_init(dev); |
411 | if (!ctrl) { | 418 | if (!ctrl) { |
412 | dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME); | 419 | dev_err(&dev->device, "Controller initialization failed\n"); |
413 | goto err_out_none; | 420 | goto err_out_none; |
414 | } | 421 | } |
415 | set_service_data(dev, ctrl); | 422 | set_service_data(dev, ctrl); |
@@ -418,11 +425,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ | |||
418 | rc = init_slots(ctrl); | 425 | rc = init_slots(ctrl); |
419 | if (rc) { | 426 | if (rc) { |
420 | if (rc == -EBUSY) | 427 | if (rc == -EBUSY) |
421 | warn("%s: slot already registered by another " | 428 | ctrl_warn(ctrl, "Slot already registered by another " |
422 | "hotplug driver\n", PCIE_MODULE_NAME); | 429 | "hotplug driver\n"); |
423 | else | 430 | else |
424 | err("%s: slot initialization failed\n", | 431 | ctrl_err(ctrl, "Slot initialization failed\n"); |
425 | PCIE_MODULE_NAME); | ||
426 | goto err_out_release_ctlr; | 432 | goto err_out_release_ctlr; |
427 | } | 433 | } |
428 | 434 | ||
@@ -461,13 +467,13 @@ static void pciehp_remove (struct pcie_device *dev) | |||
461 | #ifdef CONFIG_PM | 467 | #ifdef CONFIG_PM |
462 | static int pciehp_suspend (struct pcie_device *dev, pm_message_t state) | 468 | static int pciehp_suspend (struct pcie_device *dev, pm_message_t state) |
463 | { | 469 | { |
464 | printk("%s ENTRY\n", __func__); | 470 | dev_info(&dev->device, "%s ENTRY\n", __func__); |
465 | return 0; | 471 | return 0; |
466 | } | 472 | } |
467 | 473 | ||
468 | static int pciehp_resume (struct pcie_device *dev) | 474 | static int pciehp_resume (struct pcie_device *dev) |
469 | { | 475 | { |
470 | printk("%s ENTRY\n", __func__); | 476 | dev_info(&dev->device, "%s ENTRY\n", __func__); |
471 | if (pciehp_force) { | 477 | if (pciehp_force) { |
472 | struct controller *ctrl = get_service_data(dev); | 478 | struct controller *ctrl = get_service_data(dev); |
473 | struct slot *t_slot; | 479 | struct slot *t_slot; |
@@ -497,10 +503,9 @@ static struct pcie_port_service_id port_pci_ids[] = { { | |||
497 | .driver_data = 0, | 503 | .driver_data = 0, |
498 | }, { /* end: all zeroes */ } | 504 | }, { /* end: all zeroes */ } |
499 | }; | 505 | }; |
500 | static const char device_name[] = "hpdriver"; | ||
501 | 506 | ||
502 | static struct pcie_port_service_driver hpdriver_portdrv = { | 507 | static struct pcie_port_service_driver hpdriver_portdrv = { |
503 | .name = (char *)device_name, | 508 | .name = PCIE_MODULE_NAME, |
504 | .id_table = &port_pci_ids[0], | 509 | .id_table = &port_pci_ids[0], |
505 | 510 | ||
506 | .probe = pciehp_probe, | 511 | .probe = pciehp_probe, |
@@ -520,7 +525,7 @@ static int __init pcied_init(void) | |||
520 | dbg("pcie_port_service_register = %d\n", retval); | 525 | dbg("pcie_port_service_register = %d\n", retval); |
521 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 526 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
522 | if (retval) | 527 | if (retval) |
523 | dbg("%s: Failure to register service\n", __func__); | 528 | dbg("Failure to register service\n"); |
524 | return retval; | 529 | return retval; |
525 | } | 530 | } |
526 | 531 | ||
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 96a5d55a498..fead63c6b49 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -58,14 +58,15 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type) | |||
58 | u8 pciehp_handle_attention_button(struct slot *p_slot) | 58 | u8 pciehp_handle_attention_button(struct slot *p_slot) |
59 | { | 59 | { |
60 | u32 event_type; | 60 | u32 event_type; |
61 | struct controller *ctrl = p_slot->ctrl; | ||
61 | 62 | ||
62 | /* Attention Button Change */ | 63 | /* Attention Button Change */ |
63 | dbg("pciehp: Attention button interrupt received.\n"); | 64 | ctrl_dbg(ctrl, "Attention button interrupt received\n"); |
64 | 65 | ||
65 | /* | 66 | /* |
66 | * Button pressed - See if need to TAKE ACTION!!! | 67 | * Button pressed - See if need to TAKE ACTION!!! |
67 | */ | 68 | */ |
68 | info("Button pressed on Slot(%s)\n", p_slot->name); | 69 | ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot)); |
69 | event_type = INT_BUTTON_PRESS; | 70 | event_type = INT_BUTTON_PRESS; |
70 | 71 | ||
71 | queue_interrupt_event(p_slot, event_type); | 72 | queue_interrupt_event(p_slot, event_type); |
@@ -77,22 +78,23 @@ u8 pciehp_handle_switch_change(struct slot *p_slot) | |||
77 | { | 78 | { |
78 | u8 getstatus; | 79 | u8 getstatus; |
79 | u32 event_type; | 80 | u32 event_type; |
81 | struct controller *ctrl = p_slot->ctrl; | ||
80 | 82 | ||
81 | /* Switch Change */ | 83 | /* Switch Change */ |
82 | dbg("pciehp: Switch interrupt received.\n"); | 84 | ctrl_dbg(ctrl, "Switch interrupt received\n"); |
83 | 85 | ||
84 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 86 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
85 | if (getstatus) { | 87 | if (getstatus) { |
86 | /* | 88 | /* |
87 | * Switch opened | 89 | * Switch opened |
88 | */ | 90 | */ |
89 | info("Latch open on Slot(%s)\n", p_slot->name); | 91 | ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot)); |
90 | event_type = INT_SWITCH_OPEN; | 92 | event_type = INT_SWITCH_OPEN; |
91 | } else { | 93 | } else { |
92 | /* | 94 | /* |
93 | * Switch closed | 95 | * Switch closed |
94 | */ | 96 | */ |
95 | info("Latch close on Slot(%s)\n", p_slot->name); | 97 | ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot)); |
96 | event_type = INT_SWITCH_CLOSE; | 98 | event_type = INT_SWITCH_CLOSE; |
97 | } | 99 | } |
98 | 100 | ||
@@ -105,9 +107,10 @@ u8 pciehp_handle_presence_change(struct slot *p_slot) | |||
105 | { | 107 | { |
106 | u32 event_type; | 108 | u32 event_type; |
107 | u8 presence_save; | 109 | u8 presence_save; |
110 | struct controller *ctrl = p_slot->ctrl; | ||
108 | 111 | ||
109 | /* Presence Change */ | 112 | /* Presence Change */ |
110 | dbg("pciehp: Presence/Notify input change.\n"); | 113 | ctrl_dbg(ctrl, "Presence/Notify input change\n"); |
111 | 114 | ||
112 | /* Switch is open, assume a presence change | 115 | /* Switch is open, assume a presence change |
113 | * Save the presence state | 116 | * Save the presence state |
@@ -117,13 +120,14 @@ u8 pciehp_handle_presence_change(struct slot *p_slot) | |||
117 | /* | 120 | /* |
118 | * Card Present | 121 | * Card Present |
119 | */ | 122 | */ |
120 | info("Card present on Slot(%s)\n", p_slot->name); | 123 | ctrl_info(ctrl, "Card present on Slot(%s)\n", slot_name(p_slot)); |
121 | event_type = INT_PRESENCE_ON; | 124 | event_type = INT_PRESENCE_ON; |
122 | } else { | 125 | } else { |
123 | /* | 126 | /* |
124 | * Not Present | 127 | * Not Present |
125 | */ | 128 | */ |
126 | info("Card not present on Slot(%s)\n", p_slot->name); | 129 | ctrl_info(ctrl, "Card not present on Slot(%s)\n", |
130 | slot_name(p_slot)); | ||
127 | event_type = INT_PRESENCE_OFF; | 131 | event_type = INT_PRESENCE_OFF; |
128 | } | 132 | } |
129 | 133 | ||
@@ -135,23 +139,25 @@ u8 pciehp_handle_presence_change(struct slot *p_slot) | |||
135 | u8 pciehp_handle_power_fault(struct slot *p_slot) | 139 | u8 pciehp_handle_power_fault(struct slot *p_slot) |
136 | { | 140 | { |
137 | u32 event_type; | 141 | u32 event_type; |
142 | struct controller *ctrl = p_slot->ctrl; | ||
138 | 143 | ||
139 | /* power fault */ | 144 | /* power fault */ |
140 | dbg("pciehp: Power fault interrupt received.\n"); | 145 | ctrl_dbg(ctrl, "Power fault interrupt received\n"); |
141 | 146 | ||
142 | if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { | 147 | if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { |
143 | /* | 148 | /* |
144 | * power fault Cleared | 149 | * power fault Cleared |
145 | */ | 150 | */ |
146 | info("Power fault cleared on Slot(%s)\n", p_slot->name); | 151 | ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n", |
152 | slot_name(p_slot)); | ||
147 | event_type = INT_POWER_FAULT_CLEAR; | 153 | event_type = INT_POWER_FAULT_CLEAR; |
148 | } else { | 154 | } else { |
149 | /* | 155 | /* |
150 | * power fault | 156 | * power fault |
151 | */ | 157 | */ |
152 | info("Power fault on Slot(%s)\n", p_slot->name); | 158 | ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot)); |
153 | event_type = INT_POWER_FAULT; | 159 | event_type = INT_POWER_FAULT; |
154 | info("power fault bit %x set\n", 0); | 160 | ctrl_info(ctrl, "Power fault bit %x set\n", 0); |
155 | } | 161 | } |
156 | 162 | ||
157 | queue_interrupt_event(p_slot, event_type); | 163 | queue_interrupt_event(p_slot, event_type); |
@@ -168,8 +174,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) | |||
168 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ | 174 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ |
169 | if (POWER_CTRL(ctrl)) { | 175 | if (POWER_CTRL(ctrl)) { |
170 | if (pslot->hpc_ops->power_off_slot(pslot)) { | 176 | if (pslot->hpc_ops->power_off_slot(pslot)) { |
171 | err("%s: Issue of Slot Power Off command failed\n", | 177 | ctrl_err(ctrl, |
172 | __func__); | 178 | "Issue of Slot Power Off command failed\n"); |
173 | return; | 179 | return; |
174 | } | 180 | } |
175 | } | 181 | } |
@@ -186,8 +192,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) | |||
186 | 192 | ||
187 | if (ATTN_LED(ctrl)) { | 193 | if (ATTN_LED(ctrl)) { |
188 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { | 194 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { |
189 | err("%s: Issue of Set Attention Led command failed\n", | 195 | ctrl_err(ctrl, |
190 | __func__); | 196 | "Issue of Set Attention Led command failed\n"); |
191 | return; | 197 | return; |
192 | } | 198 | } |
193 | } | 199 | } |
@@ -204,10 +210,11 @@ static int board_added(struct slot *p_slot) | |||
204 | { | 210 | { |
205 | int retval = 0; | 211 | int retval = 0; |
206 | struct controller *ctrl = p_slot->ctrl; | 212 | struct controller *ctrl = p_slot->ctrl; |
213 | struct pci_bus *parent = ctrl->pci_dev->subordinate; | ||
207 | 214 | ||
208 | dbg("%s: slot device, slot offset, hp slot = %d, %d ,%d\n", | 215 | ctrl_dbg(ctrl, "%s: slot device, slot offset, hp slot = %d, %d, %d\n", |
209 | __func__, p_slot->device, | 216 | __func__, p_slot->device, ctrl->slot_device_offset, |
210 | ctrl->slot_device_offset, p_slot->hp_slot); | 217 | p_slot->hp_slot); |
211 | 218 | ||
212 | if (POWER_CTRL(ctrl)) { | 219 | if (POWER_CTRL(ctrl)) { |
213 | /* Power on slot */ | 220 | /* Power on slot */ |
@@ -219,28 +226,25 @@ static int board_added(struct slot *p_slot) | |||
219 | if (PWR_LED(ctrl)) | 226 | if (PWR_LED(ctrl)) |
220 | p_slot->hpc_ops->green_led_blink(p_slot); | 227 | p_slot->hpc_ops->green_led_blink(p_slot); |
221 | 228 | ||
222 | /* Wait for ~1 second */ | ||
223 | msleep(1000); | ||
224 | |||
225 | /* Check link training status */ | 229 | /* Check link training status */ |
226 | retval = p_slot->hpc_ops->check_lnk_status(ctrl); | 230 | retval = p_slot->hpc_ops->check_lnk_status(ctrl); |
227 | if (retval) { | 231 | if (retval) { |
228 | err("%s: Failed to check link status\n", __func__); | 232 | ctrl_err(ctrl, "Failed to check link status\n"); |
229 | set_slot_off(ctrl, p_slot); | 233 | set_slot_off(ctrl, p_slot); |
230 | return retval; | 234 | return retval; |
231 | } | 235 | } |
232 | 236 | ||
233 | /* Check for a power fault */ | 237 | /* Check for a power fault */ |
234 | if (p_slot->hpc_ops->query_power_fault(p_slot)) { | 238 | if (p_slot->hpc_ops->query_power_fault(p_slot)) { |
235 | dbg("%s: power fault detected\n", __func__); | 239 | ctrl_dbg(ctrl, "Power fault detected\n"); |
236 | retval = POWER_FAILURE; | 240 | retval = POWER_FAILURE; |
237 | goto err_exit; | 241 | goto err_exit; |
238 | } | 242 | } |
239 | 243 | ||
240 | retval = pciehp_configure_device(p_slot); | 244 | retval = pciehp_configure_device(p_slot); |
241 | if (retval) { | 245 | if (retval) { |
242 | err("Cannot add device 0x%x:%x\n", p_slot->bus, | 246 | ctrl_err(ctrl, "Cannot add device at %04x:%02x:%02x\n", |
243 | p_slot->device); | 247 | pci_domain_nr(parent), p_slot->bus, p_slot->device); |
244 | goto err_exit; | 248 | goto err_exit; |
245 | } | 249 | } |
246 | 250 | ||
@@ -272,14 +276,14 @@ static int remove_board(struct slot *p_slot) | |||
272 | if (retval) | 276 | if (retval) |
273 | return retval; | 277 | return retval; |
274 | 278 | ||
275 | dbg("In %s, hp_slot = %d\n", __func__, p_slot->hp_slot); | 279 | ctrl_dbg(ctrl, "%s: hp_slot = %d\n", __func__, p_slot->hp_slot); |
276 | 280 | ||
277 | if (POWER_CTRL(ctrl)) { | 281 | if (POWER_CTRL(ctrl)) { |
278 | /* power off slot */ | 282 | /* power off slot */ |
279 | retval = p_slot->hpc_ops->power_off_slot(p_slot); | 283 | retval = p_slot->hpc_ops->power_off_slot(p_slot); |
280 | if (retval) { | 284 | if (retval) { |
281 | err("%s: Issue of Slot Disable command failed\n", | 285 | ctrl_err(ctrl, |
282 | __func__); | 286 | "Issue of Slot Disable command failed\n"); |
283 | return retval; | 287 | return retval; |
284 | } | 288 | } |
285 | } | 289 | } |
@@ -320,8 +324,10 @@ static void pciehp_power_thread(struct work_struct *work) | |||
320 | switch (p_slot->state) { | 324 | switch (p_slot->state) { |
321 | case POWEROFF_STATE: | 325 | case POWEROFF_STATE: |
322 | mutex_unlock(&p_slot->lock); | 326 | mutex_unlock(&p_slot->lock); |
323 | dbg("%s: disabling bus:device(%x:%x)\n", | 327 | ctrl_dbg(p_slot->ctrl, |
324 | __func__, p_slot->bus, p_slot->device); | 328 | "Disabling domain:bus:device=%04x:%02x:%02x\n", |
329 | pci_domain_nr(p_slot->ctrl->pci_dev->subordinate), | ||
330 | p_slot->bus, p_slot->device); | ||
325 | pciehp_disable_slot(p_slot); | 331 | pciehp_disable_slot(p_slot); |
326 | mutex_lock(&p_slot->lock); | 332 | mutex_lock(&p_slot->lock); |
327 | p_slot->state = STATIC_STATE; | 333 | p_slot->state = STATIC_STATE; |
@@ -349,7 +355,8 @@ void pciehp_queue_pushbutton_work(struct work_struct *work) | |||
349 | 355 | ||
350 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 356 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
351 | if (!info) { | 357 | if (!info) { |
352 | err("%s: Cannot allocate memory\n", __func__); | 358 | ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n", |
359 | __func__); | ||
353 | return; | 360 | return; |
354 | } | 361 | } |
355 | info->p_slot = p_slot; | 362 | info->p_slot = p_slot; |
@@ -403,12 +410,14 @@ static void handle_button_press_event(struct slot *p_slot) | |||
403 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 410 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
404 | if (getstatus) { | 411 | if (getstatus) { |
405 | p_slot->state = BLINKINGOFF_STATE; | 412 | p_slot->state = BLINKINGOFF_STATE; |
406 | info("PCI slot #%s - powering off due to button " | 413 | ctrl_info(ctrl, |
407 | "press.\n", p_slot->name); | 414 | "PCI slot #%s - powering off due to button " |
415 | "press.\n", slot_name(p_slot)); | ||
408 | } else { | 416 | } else { |
409 | p_slot->state = BLINKINGON_STATE; | 417 | p_slot->state = BLINKINGON_STATE; |
410 | info("PCI slot #%s - powering on due to button " | 418 | ctrl_info(ctrl, |
411 | "press.\n", p_slot->name); | 419 | "PCI slot #%s - powering on due to button " |
420 | "press.\n", slot_name(p_slot)); | ||
412 | } | 421 | } |
413 | /* blink green LED and turn off amber */ | 422 | /* blink green LED and turn off amber */ |
414 | if (PWR_LED(ctrl)) | 423 | if (PWR_LED(ctrl)) |
@@ -425,8 +434,7 @@ static void handle_button_press_event(struct slot *p_slot) | |||
425 | * press the attention again before the 5 sec. limit | 434 | * press the attention again before the 5 sec. limit |
426 | * expires to cancel hot-add or hot-remove | 435 | * expires to cancel hot-add or hot-remove |
427 | */ | 436 | */ |
428 | info("Button cancel on Slot(%s)\n", p_slot->name); | 437 | ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot)); |
429 | dbg("%s: button cancel\n", __func__); | ||
430 | cancel_delayed_work(&p_slot->work); | 438 | cancel_delayed_work(&p_slot->work); |
431 | if (p_slot->state == BLINKINGOFF_STATE) { | 439 | if (p_slot->state == BLINKINGOFF_STATE) { |
432 | if (PWR_LED(ctrl)) | 440 | if (PWR_LED(ctrl)) |
@@ -437,8 +445,8 @@ static void handle_button_press_event(struct slot *p_slot) | |||
437 | } | 445 | } |
438 | if (ATTN_LED(ctrl)) | 446 | if (ATTN_LED(ctrl)) |
439 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 447 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
440 | info("PCI slot #%s - action canceled due to button press\n", | 448 | ctrl_info(ctrl, "PCI slot #%s - action canceled " |
441 | p_slot->name); | 449 | "due to button press\n", slot_name(p_slot)); |
442 | p_slot->state = STATIC_STATE; | 450 | p_slot->state = STATIC_STATE; |
443 | break; | 451 | break; |
444 | case POWEROFF_STATE: | 452 | case POWEROFF_STATE: |
@@ -448,11 +456,11 @@ static void handle_button_press_event(struct slot *p_slot) | |||
448 | * this means that the previous attention button action | 456 | * this means that the previous attention button action |
449 | * to hot-add or hot-remove is undergoing | 457 | * to hot-add or hot-remove is undergoing |
450 | */ | 458 | */ |
451 | info("Button ignore on Slot(%s)\n", p_slot->name); | 459 | ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot)); |
452 | update_slot_info(p_slot); | 460 | update_slot_info(p_slot); |
453 | break; | 461 | break; |
454 | default: | 462 | default: |
455 | warn("Not a valid state\n"); | 463 | ctrl_warn(ctrl, "Not a valid state\n"); |
456 | break; | 464 | break; |
457 | } | 465 | } |
458 | } | 466 | } |
@@ -467,7 +475,8 @@ static void handle_surprise_event(struct slot *p_slot) | |||
467 | 475 | ||
468 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 476 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
469 | if (!info) { | 477 | if (!info) { |
470 | err("%s: Cannot allocate memory\n", __func__); | 478 | ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n", |
479 | __func__); | ||
471 | return; | 480 | return; |
472 | } | 481 | } |
473 | info->p_slot = p_slot; | 482 | info->p_slot = p_slot; |
@@ -505,7 +514,7 @@ static void interrupt_event_handler(struct work_struct *work) | |||
505 | case INT_PRESENCE_OFF: | 514 | case INT_PRESENCE_OFF: |
506 | if (!HP_SUPR_RM(ctrl)) | 515 | if (!HP_SUPR_RM(ctrl)) |
507 | break; | 516 | break; |
508 | dbg("Surprise Removal\n"); | 517 | ctrl_dbg(ctrl, "Surprise Removal\n"); |
509 | update_slot_info(p_slot); | 518 | update_slot_info(p_slot); |
510 | handle_surprise_event(p_slot); | 519 | handle_surprise_event(p_slot); |
511 | break; | 520 | break; |
@@ -522,22 +531,22 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
522 | { | 531 | { |
523 | u8 getstatus = 0; | 532 | u8 getstatus = 0; |
524 | int rc; | 533 | int rc; |
534 | struct controller *ctrl = p_slot->ctrl; | ||
525 | 535 | ||
526 | /* Check to see if (latch closed, card present, power off) */ | 536 | /* Check to see if (latch closed, card present, power off) */ |
527 | mutex_lock(&p_slot->ctrl->crit_sect); | 537 | mutex_lock(&p_slot->ctrl->crit_sect); |
528 | 538 | ||
529 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 539 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
530 | if (rc || !getstatus) { | 540 | if (rc || !getstatus) { |
531 | info("%s: no adapter on slot(%s)\n", __func__, | 541 | ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); |
532 | p_slot->name); | ||
533 | mutex_unlock(&p_slot->ctrl->crit_sect); | 542 | mutex_unlock(&p_slot->ctrl->crit_sect); |
534 | return -ENODEV; | 543 | return -ENODEV; |
535 | } | 544 | } |
536 | if (MRL_SENS(p_slot->ctrl)) { | 545 | if (MRL_SENS(p_slot->ctrl)) { |
537 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 546 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
538 | if (rc || getstatus) { | 547 | if (rc || getstatus) { |
539 | info("%s: latch open on slot(%s)\n", __func__, | 548 | ctrl_info(ctrl, "Latch open on slot(%s)\n", |
540 | p_slot->name); | 549 | slot_name(p_slot)); |
541 | mutex_unlock(&p_slot->ctrl->crit_sect); | 550 | mutex_unlock(&p_slot->ctrl->crit_sect); |
542 | return -ENODEV; | 551 | return -ENODEV; |
543 | } | 552 | } |
@@ -546,8 +555,8 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
546 | if (POWER_CTRL(p_slot->ctrl)) { | 555 | if (POWER_CTRL(p_slot->ctrl)) { |
547 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 556 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
548 | if (rc || getstatus) { | 557 | if (rc || getstatus) { |
549 | info("%s: already enabled on slot(%s)\n", __func__, | 558 | ctrl_info(ctrl, "Already enabled on slot(%s)\n", |
550 | p_slot->name); | 559 | slot_name(p_slot)); |
551 | mutex_unlock(&p_slot->ctrl->crit_sect); | 560 | mutex_unlock(&p_slot->ctrl->crit_sect); |
552 | return -EINVAL; | 561 | return -EINVAL; |
553 | } | 562 | } |
@@ -571,6 +580,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
571 | { | 580 | { |
572 | u8 getstatus = 0; | 581 | u8 getstatus = 0; |
573 | int ret = 0; | 582 | int ret = 0; |
583 | struct controller *ctrl = p_slot->ctrl; | ||
574 | 584 | ||
575 | if (!p_slot->ctrl) | 585 | if (!p_slot->ctrl) |
576 | return 1; | 586 | return 1; |
@@ -581,8 +591,8 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
581 | if (!HP_SUPR_RM(p_slot->ctrl)) { | 591 | if (!HP_SUPR_RM(p_slot->ctrl)) { |
582 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 592 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
583 | if (ret || !getstatus) { | 593 | if (ret || !getstatus) { |
584 | info("%s: no adapter on slot(%s)\n", __func__, | 594 | ctrl_info(ctrl, "No adapter on slot(%s)\n", |
585 | p_slot->name); | 595 | slot_name(p_slot)); |
586 | mutex_unlock(&p_slot->ctrl->crit_sect); | 596 | mutex_unlock(&p_slot->ctrl->crit_sect); |
587 | return -ENODEV; | 597 | return -ENODEV; |
588 | } | 598 | } |
@@ -591,8 +601,8 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
591 | if (MRL_SENS(p_slot->ctrl)) { | 601 | if (MRL_SENS(p_slot->ctrl)) { |
592 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 602 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
593 | if (ret || getstatus) { | 603 | if (ret || getstatus) { |
594 | info("%s: latch open on slot(%s)\n", __func__, | 604 | ctrl_info(ctrl, "Latch open on slot(%s)\n", |
595 | p_slot->name); | 605 | slot_name(p_slot)); |
596 | mutex_unlock(&p_slot->ctrl->crit_sect); | 606 | mutex_unlock(&p_slot->ctrl->crit_sect); |
597 | return -ENODEV; | 607 | return -ENODEV; |
598 | } | 608 | } |
@@ -601,8 +611,8 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
601 | if (POWER_CTRL(p_slot->ctrl)) { | 611 | if (POWER_CTRL(p_slot->ctrl)) { |
602 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 612 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
603 | if (ret || !getstatus) { | 613 | if (ret || !getstatus) { |
604 | info("%s: already disabled slot(%s)\n", __func__, | 614 | ctrl_info(ctrl, "Already disabled on slot(%s)\n", |
605 | p_slot->name); | 615 | slot_name(p_slot)); |
606 | mutex_unlock(&p_slot->ctrl->crit_sect); | 616 | mutex_unlock(&p_slot->ctrl->crit_sect); |
607 | return -EINVAL; | 617 | return -EINVAL; |
608 | } | 618 | } |
@@ -618,6 +628,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
618 | int pciehp_sysfs_enable_slot(struct slot *p_slot) | 628 | int pciehp_sysfs_enable_slot(struct slot *p_slot) |
619 | { | 629 | { |
620 | int retval = -ENODEV; | 630 | int retval = -ENODEV; |
631 | struct controller *ctrl = p_slot->ctrl; | ||
621 | 632 | ||
622 | mutex_lock(&p_slot->lock); | 633 | mutex_lock(&p_slot->lock); |
623 | switch (p_slot->state) { | 634 | switch (p_slot->state) { |
@@ -631,15 +642,17 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot) | |||
631 | p_slot->state = STATIC_STATE; | 642 | p_slot->state = STATIC_STATE; |
632 | break; | 643 | break; |
633 | case POWERON_STATE: | 644 | case POWERON_STATE: |
634 | info("Slot %s is already in powering on state\n", | 645 | ctrl_info(ctrl, "Slot %s is already in powering on state\n", |
635 | p_slot->name); | 646 | slot_name(p_slot)); |
636 | break; | 647 | break; |
637 | case BLINKINGOFF_STATE: | 648 | case BLINKINGOFF_STATE: |
638 | case POWEROFF_STATE: | 649 | case POWEROFF_STATE: |
639 | info("Already enabled on slot %s\n", p_slot->name); | 650 | ctrl_info(ctrl, "Already enabled on slot %s\n", |
651 | slot_name(p_slot)); | ||
640 | break; | 652 | break; |
641 | default: | 653 | default: |
642 | err("Not a valid state on slot %s\n", p_slot->name); | 654 | ctrl_err(ctrl, "Not a valid state on slot %s\n", |
655 | slot_name(p_slot)); | ||
643 | break; | 656 | break; |
644 | } | 657 | } |
645 | mutex_unlock(&p_slot->lock); | 658 | mutex_unlock(&p_slot->lock); |
@@ -650,6 +663,7 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot) | |||
650 | int pciehp_sysfs_disable_slot(struct slot *p_slot) | 663 | int pciehp_sysfs_disable_slot(struct slot *p_slot) |
651 | { | 664 | { |
652 | int retval = -ENODEV; | 665 | int retval = -ENODEV; |
666 | struct controller *ctrl = p_slot->ctrl; | ||
653 | 667 | ||
654 | mutex_lock(&p_slot->lock); | 668 | mutex_lock(&p_slot->lock); |
655 | switch (p_slot->state) { | 669 | switch (p_slot->state) { |
@@ -663,15 +677,17 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot) | |||
663 | p_slot->state = STATIC_STATE; | 677 | p_slot->state = STATIC_STATE; |
664 | break; | 678 | break; |
665 | case POWEROFF_STATE: | 679 | case POWEROFF_STATE: |
666 | info("Slot %s is already in powering off state\n", | 680 | ctrl_info(ctrl, "Slot %s is already in powering off state\n", |
667 | p_slot->name); | 681 | slot_name(p_slot)); |
668 | break; | 682 | break; |
669 | case BLINKINGON_STATE: | 683 | case BLINKINGON_STATE: |
670 | case POWERON_STATE: | 684 | case POWERON_STATE: |
671 | info("Already disabled on slot %s\n", p_slot->name); | 685 | ctrl_info(ctrl, "Already disabled on slot %s\n", |
686 | slot_name(p_slot)); | ||
672 | break; | 687 | break; |
673 | default: | 688 | default: |
674 | err("Not a valid state on slot %s\n", p_slot->name); | 689 | ctrl_err(ctrl, "Not a valid state on slot %s\n", |
690 | slot_name(p_slot)); | ||
675 | break; | 691 | break; |
676 | } | 692 | } |
677 | mutex_unlock(&p_slot->lock); | 693 | mutex_unlock(&p_slot->lock); |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 9d934ddee95..b643ca13e4f 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -125,6 +125,7 @@ static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value) | |||
125 | /* Field definitions in Link Capabilities Register */ | 125 | /* Field definitions in Link Capabilities Register */ |
126 | #define MAX_LNK_SPEED 0x000F | 126 | #define MAX_LNK_SPEED 0x000F |
127 | #define MAX_LNK_WIDTH 0x03F0 | 127 | #define MAX_LNK_WIDTH 0x03F0 |
128 | #define LINK_ACTIVE_REPORTING 0x00100000 | ||
128 | 129 | ||
129 | /* Link Width Encoding */ | 130 | /* Link Width Encoding */ |
130 | #define LNK_X1 0x01 | 131 | #define LNK_X1 0x01 |
@@ -141,6 +142,7 @@ static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value) | |||
141 | #define LNK_TRN_ERR 0x0400 | 142 | #define LNK_TRN_ERR 0x0400 |
142 | #define LNK_TRN 0x0800 | 143 | #define LNK_TRN 0x0800 |
143 | #define SLOT_CLK_CONF 0x1000 | 144 | #define SLOT_CLK_CONF 0x1000 |
145 | #define LINK_ACTIVE 0x2000 | ||
144 | 146 | ||
145 | /* Field definitions in Slot Capabilities Register */ | 147 | /* Field definitions in Slot Capabilities Register */ |
146 | #define ATTN_BUTTN_PRSN 0x00000001 | 148 | #define ATTN_BUTTN_PRSN 0x00000001 |
@@ -223,7 +225,7 @@ static void start_int_poll_timer(struct controller *ctrl, int sec) | |||
223 | 225 | ||
224 | static inline int pciehp_request_irq(struct controller *ctrl) | 226 | static inline int pciehp_request_irq(struct controller *ctrl) |
225 | { | 227 | { |
226 | int retval, irq = ctrl->pci_dev->irq; | 228 | int retval, irq = ctrl->pcie->irq; |
227 | 229 | ||
228 | /* Install interrupt polling timer. Start with 10 sec delay */ | 230 | /* Install interrupt polling timer. Start with 10 sec delay */ |
229 | if (pciehp_poll_mode) { | 231 | if (pciehp_poll_mode) { |
@@ -235,7 +237,8 @@ static inline int pciehp_request_irq(struct controller *ctrl) | |||
235 | /* Installs the interrupt handler */ | 237 | /* Installs the interrupt handler */ |
236 | retval = request_irq(irq, pcie_isr, IRQF_SHARED, MY_NAME, ctrl); | 238 | retval = request_irq(irq, pcie_isr, IRQF_SHARED, MY_NAME, ctrl); |
237 | if (retval) | 239 | if (retval) |
238 | err("Cannot get irq %d for the hotplug controller\n", irq); | 240 | ctrl_err(ctrl, "Cannot get irq %d for the hotplug controller\n", |
241 | irq); | ||
239 | return retval; | 242 | return retval; |
240 | } | 243 | } |
241 | 244 | ||
@@ -244,7 +247,7 @@ static inline void pciehp_free_irq(struct controller *ctrl) | |||
244 | if (pciehp_poll_mode) | 247 | if (pciehp_poll_mode) |
245 | del_timer_sync(&ctrl->poll_timer); | 248 | del_timer_sync(&ctrl->poll_timer); |
246 | else | 249 | else |
247 | free_irq(ctrl->pci_dev->irq, ctrl); | 250 | free_irq(ctrl->pcie->irq, ctrl); |
248 | } | 251 | } |
249 | 252 | ||
250 | static int pcie_poll_cmd(struct controller *ctrl) | 253 | static int pcie_poll_cmd(struct controller *ctrl) |
@@ -282,7 +285,7 @@ static void pcie_wait_cmd(struct controller *ctrl, int poll) | |||
282 | else | 285 | else |
283 | rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout); | 286 | rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout); |
284 | if (!rc) | 287 | if (!rc) |
285 | dbg("Command not completed in 1000 msec\n"); | 288 | ctrl_dbg(ctrl, "Command not completed in 1000 msec\n"); |
286 | } | 289 | } |
287 | 290 | ||
288 | /** | 291 | /** |
@@ -301,7 +304,8 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) | |||
301 | 304 | ||
302 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); | 305 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); |
303 | if (retval) { | 306 | if (retval) { |
304 | err("%s: Cannot read SLOTSTATUS register\n", __func__); | 307 | ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", |
308 | __func__); | ||
305 | goto out; | 309 | goto out; |
306 | } | 310 | } |
307 | 311 | ||
@@ -312,26 +316,25 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) | |||
312 | * proceed forward to issue the next command according | 316 | * proceed forward to issue the next command according |
313 | * to spec. Just print out the error message. | 317 | * to spec. Just print out the error message. |
314 | */ | 318 | */ |
315 | dbg("%s: CMD_COMPLETED not clear after 1 sec.\n", | 319 | ctrl_dbg(ctrl, "CMD_COMPLETED not clear after 1 sec\n"); |
316 | __func__); | ||
317 | } else if (!NO_CMD_CMPL(ctrl)) { | 320 | } else if (!NO_CMD_CMPL(ctrl)) { |
318 | /* | 321 | /* |
319 | * This controller semms to notify of command completed | 322 | * This controller semms to notify of command completed |
320 | * event even though it supports none of power | 323 | * event even though it supports none of power |
321 | * controller, attention led, power led and EMI. | 324 | * controller, attention led, power led and EMI. |
322 | */ | 325 | */ |
323 | dbg("%s: Unexpected CMD_COMPLETED. Need to wait for " | 326 | ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Need to " |
324 | "command completed event.\n", __func__); | 327 | "wait for command completed event.\n"); |
325 | ctrl->no_cmd_complete = 0; | 328 | ctrl->no_cmd_complete = 0; |
326 | } else { | 329 | } else { |
327 | dbg("%s: Unexpected CMD_COMPLETED. Maybe the " | 330 | ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Maybe " |
328 | "controller is broken.\n", __func__); | 331 | "the controller is broken.\n"); |
329 | } | 332 | } |
330 | } | 333 | } |
331 | 334 | ||
332 | retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); | 335 | retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); |
333 | if (retval) { | 336 | if (retval) { |
334 | err("%s: Cannot read SLOTCTRL register\n", __func__); | 337 | ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); |
335 | goto out; | 338 | goto out; |
336 | } | 339 | } |
337 | 340 | ||
@@ -341,7 +344,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) | |||
341 | smp_mb(); | 344 | smp_mb(); |
342 | retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl); | 345 | retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl); |
343 | if (retval) | 346 | if (retval) |
344 | err("%s: Cannot write to SLOTCTRL register\n", __func__); | 347 | ctrl_err(ctrl, "Cannot write to SLOTCTRL register\n"); |
345 | 348 | ||
346 | /* | 349 | /* |
347 | * Wait for command completion. | 350 | * Wait for command completion. |
@@ -363,21 +366,62 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) | |||
363 | return retval; | 366 | return retval; |
364 | } | 367 | } |
365 | 368 | ||
369 | static inline int check_link_active(struct controller *ctrl) | ||
370 | { | ||
371 | u16 link_status; | ||
372 | |||
373 | if (pciehp_readw(ctrl, LNKSTATUS, &link_status)) | ||
374 | return 0; | ||
375 | return !!(link_status & LINK_ACTIVE); | ||
376 | } | ||
377 | |||
378 | static void pcie_wait_link_active(struct controller *ctrl) | ||
379 | { | ||
380 | int timeout = 1000; | ||
381 | |||
382 | if (check_link_active(ctrl)) | ||
383 | return; | ||
384 | while (timeout > 0) { | ||
385 | msleep(10); | ||
386 | timeout -= 10; | ||
387 | if (check_link_active(ctrl)) | ||
388 | return; | ||
389 | } | ||
390 | ctrl_dbg(ctrl, "Data Link Layer Link Active not set in 1000 msec\n"); | ||
391 | } | ||
392 | |||
366 | static int hpc_check_lnk_status(struct controller *ctrl) | 393 | static int hpc_check_lnk_status(struct controller *ctrl) |
367 | { | 394 | { |
368 | u16 lnk_status; | 395 | u16 lnk_status; |
369 | int retval = 0; | 396 | int retval = 0; |
370 | 397 | ||
398 | /* | ||
399 | * Data Link Layer Link Active Reporting must be capable for | ||
400 | * hot-plug capable downstream port. But old controller might | ||
401 | * not implement it. In this case, we wait for 1000 ms. | ||
402 | */ | ||
403 | if (ctrl->link_active_reporting){ | ||
404 | /* Wait for Data Link Layer Link Active bit to be set */ | ||
405 | pcie_wait_link_active(ctrl); | ||
406 | /* | ||
407 | * We must wait for 100 ms after the Data Link Layer | ||
408 | * Link Active bit reads 1b before initiating a | ||
409 | * configuration access to the hot added device. | ||
410 | */ | ||
411 | msleep(100); | ||
412 | } else | ||
413 | msleep(1000); | ||
414 | |||
371 | retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); | 415 | retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); |
372 | if (retval) { | 416 | if (retval) { |
373 | err("%s: Cannot read LNKSTATUS register\n", __func__); | 417 | ctrl_err(ctrl, "Cannot read LNKSTATUS register\n"); |
374 | return retval; | 418 | return retval; |
375 | } | 419 | } |
376 | 420 | ||
377 | dbg("%s: lnk_status = %x\n", __func__, lnk_status); | 421 | ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); |
378 | if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) || | 422 | if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) || |
379 | !(lnk_status & NEG_LINK_WD)) { | 423 | !(lnk_status & NEG_LINK_WD)) { |
380 | err("%s : Link Training Error occurs \n", __func__); | 424 | ctrl_err(ctrl, "Link Training Error occurs \n"); |
381 | retval = -1; | 425 | retval = -1; |
382 | return retval; | 426 | return retval; |
383 | } | 427 | } |
@@ -394,12 +438,12 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status) | |||
394 | 438 | ||
395 | retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); | 439 | retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); |
396 | if (retval) { | 440 | if (retval) { |
397 | err("%s: Cannot read SLOTCTRL register\n", __func__); | 441 | ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); |
398 | return retval; | 442 | return retval; |
399 | } | 443 | } |
400 | 444 | ||
401 | dbg("%s: SLOTCTRL %x, value read %x\n", | 445 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n", |
402 | __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); | 446 | __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); |
403 | 447 | ||
404 | atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; | 448 | atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; |
405 | 449 | ||
@@ -433,11 +477,11 @@ static int hpc_get_power_status(struct slot *slot, u8 *status) | |||
433 | 477 | ||
434 | retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); | 478 | retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); |
435 | if (retval) { | 479 | if (retval) { |
436 | err("%s: Cannot read SLOTCTRL register\n", __func__); | 480 | ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); |
437 | return retval; | 481 | return retval; |
438 | } | 482 | } |
439 | dbg("%s: SLOTCTRL %x value read %x\n", | 483 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n", |
440 | __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); | 484 | __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); |
441 | 485 | ||
442 | pwr_state = (slot_ctrl & PWR_CTRL) >> 10; | 486 | pwr_state = (slot_ctrl & PWR_CTRL) >> 10; |
443 | 487 | ||
@@ -464,7 +508,8 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status) | |||
464 | 508 | ||
465 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); | 509 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); |
466 | if (retval) { | 510 | if (retval) { |
467 | err("%s: Cannot read SLOTSTATUS register\n", __func__); | 511 | ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", |
512 | __func__); | ||
468 | return retval; | 513 | return retval; |
469 | } | 514 | } |
470 | 515 | ||
@@ -482,7 +527,8 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status) | |||
482 | 527 | ||
483 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); | 528 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); |
484 | if (retval) { | 529 | if (retval) { |
485 | err("%s: Cannot read SLOTSTATUS register\n", __func__); | 530 | ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", |
531 | __func__); | ||
486 | return retval; | 532 | return retval; |
487 | } | 533 | } |
488 | card_state = (u8)((slot_status & PRSN_STATE) >> 6); | 534 | card_state = (u8)((slot_status & PRSN_STATE) >> 6); |
@@ -500,7 +546,7 @@ static int hpc_query_power_fault(struct slot *slot) | |||
500 | 546 | ||
501 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); | 547 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); |
502 | if (retval) { | 548 | if (retval) { |
503 | err("%s: Cannot check for power fault\n", __func__); | 549 | ctrl_err(ctrl, "Cannot check for power fault\n"); |
504 | return retval; | 550 | return retval; |
505 | } | 551 | } |
506 | pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); | 552 | pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); |
@@ -516,7 +562,7 @@ static int hpc_get_emi_status(struct slot *slot, u8 *status) | |||
516 | 562 | ||
517 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); | 563 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); |
518 | if (retval) { | 564 | if (retval) { |
519 | err("%s : Cannot check EMI status\n", __func__); | 565 | ctrl_err(ctrl, "Cannot check EMI status\n"); |
520 | return retval; | 566 | return retval; |
521 | } | 567 | } |
522 | *status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT; | 568 | *status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT; |
@@ -560,8 +606,8 @@ static int hpc_set_attention_status(struct slot *slot, u8 value) | |||
560 | return -1; | 606 | return -1; |
561 | } | 607 | } |
562 | rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | 608 | rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); |
563 | dbg("%s: SLOTCTRL %x write cmd %x\n", | 609 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", |
564 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); | 610 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); |
565 | 611 | ||
566 | return rc; | 612 | return rc; |
567 | } | 613 | } |
@@ -575,8 +621,8 @@ static void hpc_set_green_led_on(struct slot *slot) | |||
575 | slot_cmd = 0x0100; | 621 | slot_cmd = 0x0100; |
576 | cmd_mask = PWR_LED_CTRL; | 622 | cmd_mask = PWR_LED_CTRL; |
577 | pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | 623 | pcie_write_cmd(ctrl, slot_cmd, cmd_mask); |
578 | dbg("%s: SLOTCTRL %x write cmd %x\n", | 624 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", |
579 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); | 625 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); |
580 | } | 626 | } |
581 | 627 | ||
582 | static void hpc_set_green_led_off(struct slot *slot) | 628 | static void hpc_set_green_led_off(struct slot *slot) |
@@ -588,8 +634,8 @@ static void hpc_set_green_led_off(struct slot *slot) | |||
588 | slot_cmd = 0x0300; | 634 | slot_cmd = 0x0300; |
589 | cmd_mask = PWR_LED_CTRL; | 635 | cmd_mask = PWR_LED_CTRL; |
590 | pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | 636 | pcie_write_cmd(ctrl, slot_cmd, cmd_mask); |
591 | dbg("%s: SLOTCTRL %x write cmd %x\n", | 637 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", |
592 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); | 638 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); |
593 | } | 639 | } |
594 | 640 | ||
595 | static void hpc_set_green_led_blink(struct slot *slot) | 641 | static void hpc_set_green_led_blink(struct slot *slot) |
@@ -601,8 +647,8 @@ static void hpc_set_green_led_blink(struct slot *slot) | |||
601 | slot_cmd = 0x0200; | 647 | slot_cmd = 0x0200; |
602 | cmd_mask = PWR_LED_CTRL; | 648 | cmd_mask = PWR_LED_CTRL; |
603 | pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | 649 | pcie_write_cmd(ctrl, slot_cmd, cmd_mask); |
604 | dbg("%s: SLOTCTRL %x write cmd %x\n", | 650 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", |
605 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); | 651 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); |
606 | } | 652 | } |
607 | 653 | ||
608 | static int hpc_power_on_slot(struct slot * slot) | 654 | static int hpc_power_on_slot(struct slot * slot) |
@@ -613,20 +659,22 @@ static int hpc_power_on_slot(struct slot * slot) | |||
613 | u16 slot_status; | 659 | u16 slot_status; |
614 | int retval = 0; | 660 | int retval = 0; |
615 | 661 | ||
616 | dbg("%s: slot->hp_slot %x\n", __func__, slot->hp_slot); | 662 | ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot); |
617 | 663 | ||
618 | /* Clear sticky power-fault bit from previous power failures */ | 664 | /* Clear sticky power-fault bit from previous power failures */ |
619 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); | 665 | retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); |
620 | if (retval) { | 666 | if (retval) { |
621 | err("%s: Cannot read SLOTSTATUS register\n", __func__); | 667 | ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", |
668 | __func__); | ||
622 | return retval; | 669 | return retval; |
623 | } | 670 | } |
624 | slot_status &= PWR_FAULT_DETECTED; | 671 | slot_status &= PWR_FAULT_DETECTED; |
625 | if (slot_status) { | 672 | if (slot_status) { |
626 | retval = pciehp_writew(ctrl, SLOTSTATUS, slot_status); | 673 | retval = pciehp_writew(ctrl, SLOTSTATUS, slot_status); |
627 | if (retval) { | 674 | if (retval) { |
628 | err("%s: Cannot write to SLOTSTATUS register\n", | 675 | ctrl_err(ctrl, |
629 | __func__); | 676 | "%s: Cannot write to SLOTSTATUS register\n", |
677 | __func__); | ||
630 | return retval; | 678 | return retval; |
631 | } | 679 | } |
632 | } | 680 | } |
@@ -644,11 +692,11 @@ static int hpc_power_on_slot(struct slot * slot) | |||
644 | retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | 692 | retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); |
645 | 693 | ||
646 | if (retval) { | 694 | if (retval) { |
647 | err("%s: Write %x command failed!\n", __func__, slot_cmd); | 695 | ctrl_err(ctrl, "Write %x command failed!\n", slot_cmd); |
648 | return -1; | 696 | return -1; |
649 | } | 697 | } |
650 | dbg("%s: SLOTCTRL %x write cmd %x\n", | 698 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", |
651 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); | 699 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); |
652 | 700 | ||
653 | return retval; | 701 | return retval; |
654 | } | 702 | } |
@@ -694,7 +742,7 @@ static int hpc_power_off_slot(struct slot * slot) | |||
694 | int retval = 0; | 742 | int retval = 0; |
695 | int changed; | 743 | int changed; |
696 | 744 | ||
697 | dbg("%s: slot->hp_slot %x\n", __func__, slot->hp_slot); | 745 | ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot); |
698 | 746 | ||
699 | /* | 747 | /* |
700 | * Set Bad DLLP Mask bit in Correctable Error Mask | 748 | * Set Bad DLLP Mask bit in Correctable Error Mask |
@@ -722,12 +770,12 @@ static int hpc_power_off_slot(struct slot * slot) | |||
722 | 770 | ||
723 | retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); | 771 | retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); |
724 | if (retval) { | 772 | if (retval) { |
725 | err("%s: Write command failed!\n", __func__); | 773 | ctrl_err(ctrl, "Write command failed!\n"); |
726 | retval = -1; | 774 | retval = -1; |
727 | goto out; | 775 | goto out; |
728 | } | 776 | } |
729 | dbg("%s: SLOTCTRL %x write cmd %x\n", | 777 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", |
730 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); | 778 | __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); |
731 | out: | 779 | out: |
732 | if (changed) | 780 | if (changed) |
733 | pcie_unmask_bad_dllp(ctrl); | 781 | pcie_unmask_bad_dllp(ctrl); |
@@ -749,7 +797,8 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) | |||
749 | intr_loc = 0; | 797 | intr_loc = 0; |
750 | do { | 798 | do { |
751 | if (pciehp_readw(ctrl, SLOTSTATUS, &detected)) { | 799 | if (pciehp_readw(ctrl, SLOTSTATUS, &detected)) { |
752 | err("%s: Cannot read SLOTSTATUS\n", __func__); | 800 | ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS\n", |
801 | __func__); | ||
753 | return IRQ_NONE; | 802 | return IRQ_NONE; |
754 | } | 803 | } |
755 | 804 | ||
@@ -760,12 +809,13 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) | |||
760 | if (!intr_loc) | 809 | if (!intr_loc) |
761 | return IRQ_NONE; | 810 | return IRQ_NONE; |
762 | if (detected && pciehp_writew(ctrl, SLOTSTATUS, detected)) { | 811 | if (detected && pciehp_writew(ctrl, SLOTSTATUS, detected)) { |
763 | err("%s: Cannot write to SLOTSTATUS\n", __func__); | 812 | ctrl_err(ctrl, "%s: Cannot write to SLOTSTATUS\n", |
813 | __func__); | ||
764 | return IRQ_NONE; | 814 | return IRQ_NONE; |
765 | } | 815 | } |
766 | } while (detected); | 816 | } while (detected); |
767 | 817 | ||
768 | dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); | 818 | ctrl_dbg(ctrl, "%s: intr_loc %x\n", __func__, intr_loc); |
769 | 819 | ||
770 | /* Check Command Complete Interrupt Pending */ | 820 | /* Check Command Complete Interrupt Pending */ |
771 | if (intr_loc & CMD_COMPLETED) { | 821 | if (intr_loc & CMD_COMPLETED) { |
@@ -807,7 +857,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value) | |||
807 | 857 | ||
808 | retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); | 858 | retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); |
809 | if (retval) { | 859 | if (retval) { |
810 | err("%s: Cannot read LNKCAP register\n", __func__); | 860 | ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); |
811 | return retval; | 861 | return retval; |
812 | } | 862 | } |
813 | 863 | ||
@@ -821,7 +871,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value) | |||
821 | } | 871 | } |
822 | 872 | ||
823 | *value = lnk_speed; | 873 | *value = lnk_speed; |
824 | dbg("Max link speed = %d\n", lnk_speed); | 874 | ctrl_dbg(ctrl, "Max link speed = %d\n", lnk_speed); |
825 | 875 | ||
826 | return retval; | 876 | return retval; |
827 | } | 877 | } |
@@ -836,7 +886,7 @@ static int hpc_get_max_lnk_width(struct slot *slot, | |||
836 | 886 | ||
837 | retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); | 887 | retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); |
838 | if (retval) { | 888 | if (retval) { |
839 | err("%s: Cannot read LNKCAP register\n", __func__); | 889 | ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); |
840 | return retval; | 890 | return retval; |
841 | } | 891 | } |
842 | 892 | ||
@@ -871,7 +921,7 @@ static int hpc_get_max_lnk_width(struct slot *slot, | |||
871 | } | 921 | } |
872 | 922 | ||
873 | *value = lnk_wdth; | 923 | *value = lnk_wdth; |
874 | dbg("Max link width = %d\n", lnk_wdth); | 924 | ctrl_dbg(ctrl, "Max link width = %d\n", lnk_wdth); |
875 | 925 | ||
876 | return retval; | 926 | return retval; |
877 | } | 927 | } |
@@ -885,7 +935,8 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value) | |||
885 | 935 | ||
886 | retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); | 936 | retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); |
887 | if (retval) { | 937 | if (retval) { |
888 | err("%s: Cannot read LNKSTATUS register\n", __func__); | 938 | ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n", |
939 | __func__); | ||
889 | return retval; | 940 | return retval; |
890 | } | 941 | } |
891 | 942 | ||
@@ -899,7 +950,7 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value) | |||
899 | } | 950 | } |
900 | 951 | ||
901 | *value = lnk_speed; | 952 | *value = lnk_speed; |
902 | dbg("Current link speed = %d\n", lnk_speed); | 953 | ctrl_dbg(ctrl, "Current link speed = %d\n", lnk_speed); |
903 | 954 | ||
904 | return retval; | 955 | return retval; |
905 | } | 956 | } |
@@ -914,7 +965,8 @@ static int hpc_get_cur_lnk_width(struct slot *slot, | |||
914 | 965 | ||
915 | retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); | 966 | retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); |
916 | if (retval) { | 967 | if (retval) { |
917 | err("%s: Cannot read LNKSTATUS register\n", __func__); | 968 | ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n", |
969 | __func__); | ||
918 | return retval; | 970 | return retval; |
919 | } | 971 | } |
920 | 972 | ||
@@ -949,7 +1001,7 @@ static int hpc_get_cur_lnk_width(struct slot *slot, | |||
949 | } | 1001 | } |
950 | 1002 | ||
951 | *value = lnk_wdth; | 1003 | *value = lnk_wdth; |
952 | dbg("Current link width = %d\n", lnk_wdth); | 1004 | ctrl_dbg(ctrl, "Current link width = %d\n", lnk_wdth); |
953 | 1005 | ||
954 | return retval; | 1006 | return retval; |
955 | } | 1007 | } |
@@ -998,7 +1050,7 @@ int pcie_enable_notification(struct controller *ctrl) | |||
998 | PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; | 1050 | PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; |
999 | 1051 | ||
1000 | if (pcie_write_cmd(ctrl, cmd, mask)) { | 1052 | if (pcie_write_cmd(ctrl, cmd, mask)) { |
1001 | err("%s: Cannot enable software notification\n", __func__); | 1053 | ctrl_err(ctrl, "Cannot enable software notification\n"); |
1002 | return -1; | 1054 | return -1; |
1003 | } | 1055 | } |
1004 | return 0; | 1056 | return 0; |
@@ -1010,7 +1062,7 @@ static void pcie_disable_notification(struct controller *ctrl) | |||
1010 | mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | | 1062 | mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | |
1011 | PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; | 1063 | PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; |
1012 | if (pcie_write_cmd(ctrl, 0, mask)) | 1064 | if (pcie_write_cmd(ctrl, 0, mask)) |
1013 | warn("%s: Cannot disable software notification\n", __func__); | 1065 | ctrl_warn(ctrl, "Cannot disable software notification\n"); |
1014 | } | 1066 | } |
1015 | 1067 | ||
1016 | static int pcie_init_notification(struct controller *ctrl) | 1068 | static int pcie_init_notification(struct controller *ctrl) |
@@ -1044,7 +1096,6 @@ static int pcie_init_slot(struct controller *ctrl) | |||
1044 | slot->device = ctrl->slot_device_offset + slot->hp_slot; | 1096 | slot->device = ctrl->slot_device_offset + slot->hp_slot; |
1045 | slot->hpc_ops = ctrl->hpc_ops; | 1097 | slot->hpc_ops = ctrl->hpc_ops; |
1046 | slot->number = ctrl->first_slot; | 1098 | slot->number = ctrl->first_slot; |
1047 | snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number); | ||
1048 | mutex_init(&slot->lock); | 1099 | mutex_init(&slot->lock); |
1049 | INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); | 1100 | INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); |
1050 | list_add(&slot->slot_list, &ctrl->slot_list); | 1101 | list_add(&slot->slot_list, &ctrl->slot_list); |
@@ -1071,58 +1122,70 @@ static inline void dbg_ctrl(struct controller *ctrl) | |||
1071 | if (!pciehp_debug) | 1122 | if (!pciehp_debug) |
1072 | return; | 1123 | return; |
1073 | 1124 | ||
1074 | dbg("Hotplug Controller:\n"); | 1125 | ctrl_info(ctrl, "Hotplug Controller:\n"); |
1075 | dbg(" Seg/Bus/Dev/Func/IRQ : %s IRQ %d\n", pci_name(pdev), pdev->irq); | 1126 | ctrl_info(ctrl, " Seg/Bus/Dev/Func/IRQ : %s IRQ %d\n", |
1076 | dbg(" Vendor ID : 0x%04x\n", pdev->vendor); | 1127 | pci_name(pdev), pdev->irq); |
1077 | dbg(" Device ID : 0x%04x\n", pdev->device); | 1128 | ctrl_info(ctrl, " Vendor ID : 0x%04x\n", pdev->vendor); |
1078 | dbg(" Subsystem ID : 0x%04x\n", pdev->subsystem_device); | 1129 | ctrl_info(ctrl, " Device ID : 0x%04x\n", pdev->device); |
1079 | dbg(" Subsystem Vendor ID : 0x%04x\n", pdev->subsystem_vendor); | 1130 | ctrl_info(ctrl, " Subsystem ID : 0x%04x\n", |
1080 | dbg(" PCIe Cap offset : 0x%02x\n", ctrl->cap_base); | 1131 | pdev->subsystem_device); |
1132 | ctrl_info(ctrl, " Subsystem Vendor ID : 0x%04x\n", | ||
1133 | pdev->subsystem_vendor); | ||
1134 | ctrl_info(ctrl, " PCIe Cap offset : 0x%02x\n", ctrl->cap_base); | ||
1081 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 1135 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
1082 | if (!pci_resource_len(pdev, i)) | 1136 | if (!pci_resource_len(pdev, i)) |
1083 | continue; | 1137 | continue; |
1084 | dbg(" PCI resource [%d] : 0x%llx@0x%llx\n", i, | 1138 | ctrl_info(ctrl, " PCI resource [%d] : 0x%llx@0x%llx\n", |
1085 | (unsigned long long)pci_resource_len(pdev, i), | 1139 | i, (unsigned long long)pci_resource_len(pdev, i), |
1086 | (unsigned long long)pci_resource_start(pdev, i)); | 1140 | (unsigned long long)pci_resource_start(pdev, i)); |
1087 | } | 1141 | } |
1088 | dbg("Slot Capabilities : 0x%08x\n", ctrl->slot_cap); | 1142 | ctrl_info(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap); |
1089 | dbg(" Physical Slot Number : %d\n", ctrl->first_slot); | 1143 | ctrl_info(ctrl, " Physical Slot Number : %d\n", ctrl->first_slot); |
1090 | dbg(" Attention Button : %3s\n", ATTN_BUTTN(ctrl) ? "yes" : "no"); | 1144 | ctrl_info(ctrl, " Attention Button : %3s\n", |
1091 | dbg(" Power Controller : %3s\n", POWER_CTRL(ctrl) ? "yes" : "no"); | 1145 | ATTN_BUTTN(ctrl) ? "yes" : "no"); |
1092 | dbg(" MRL Sensor : %3s\n", MRL_SENS(ctrl) ? "yes" : "no"); | 1146 | ctrl_info(ctrl, " Power Controller : %3s\n", |
1093 | dbg(" Attention Indicator : %3s\n", ATTN_LED(ctrl) ? "yes" : "no"); | 1147 | POWER_CTRL(ctrl) ? "yes" : "no"); |
1094 | dbg(" Power Indicator : %3s\n", PWR_LED(ctrl) ? "yes" : "no"); | 1148 | ctrl_info(ctrl, " MRL Sensor : %3s\n", |
1095 | dbg(" Hot-Plug Surprise : %3s\n", HP_SUPR_RM(ctrl) ? "yes" : "no"); | 1149 | MRL_SENS(ctrl) ? "yes" : "no"); |
1096 | dbg(" EMI Present : %3s\n", EMI(ctrl) ? "yes" : "no"); | 1150 | ctrl_info(ctrl, " Attention Indicator : %3s\n", |
1097 | dbg(" Command Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes"); | 1151 | ATTN_LED(ctrl) ? "yes" : "no"); |
1152 | ctrl_info(ctrl, " Power Indicator : %3s\n", | ||
1153 | PWR_LED(ctrl) ? "yes" : "no"); | ||
1154 | ctrl_info(ctrl, " Hot-Plug Surprise : %3s\n", | ||
1155 | HP_SUPR_RM(ctrl) ? "yes" : "no"); | ||
1156 | ctrl_info(ctrl, " EMI Present : %3s\n", | ||
1157 | EMI(ctrl) ? "yes" : "no"); | ||
1158 | ctrl_info(ctrl, " Command Completed : %3s\n", | ||
1159 | NO_CMD_CMPL(ctrl) ? "no" : "yes"); | ||
1098 | pciehp_readw(ctrl, SLOTSTATUS, ®16); | 1160 | pciehp_readw(ctrl, SLOTSTATUS, ®16); |
1099 | dbg("Slot Status : 0x%04x\n", reg16); | 1161 | ctrl_info(ctrl, "Slot Status : 0x%04x\n", reg16); |
1100 | pciehp_readw(ctrl, SLOTCTRL, ®16); | 1162 | pciehp_readw(ctrl, SLOTCTRL, ®16); |
1101 | dbg("Slot Control : 0x%04x\n", reg16); | 1163 | ctrl_info(ctrl, "Slot Control : 0x%04x\n", reg16); |
1102 | } | 1164 | } |
1103 | 1165 | ||
1104 | struct controller *pcie_init(struct pcie_device *dev) | 1166 | struct controller *pcie_init(struct pcie_device *dev) |
1105 | { | 1167 | { |
1106 | struct controller *ctrl; | 1168 | struct controller *ctrl; |
1107 | u32 slot_cap; | 1169 | u32 slot_cap, link_cap; |
1108 | struct pci_dev *pdev = dev->port; | 1170 | struct pci_dev *pdev = dev->port; |
1109 | 1171 | ||
1110 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); | 1172 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
1111 | if (!ctrl) { | 1173 | if (!ctrl) { |
1112 | err("%s : out of memory\n", __func__); | 1174 | dev_err(&dev->device, "%s: Out of memory\n", __func__); |
1113 | goto abort; | 1175 | goto abort; |
1114 | } | 1176 | } |
1115 | INIT_LIST_HEAD(&ctrl->slot_list); | 1177 | INIT_LIST_HEAD(&ctrl->slot_list); |
1116 | 1178 | ||
1179 | ctrl->pcie = dev; | ||
1117 | ctrl->pci_dev = pdev; | 1180 | ctrl->pci_dev = pdev; |
1118 | ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP); | 1181 | ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP); |
1119 | if (!ctrl->cap_base) { | 1182 | if (!ctrl->cap_base) { |
1120 | err("%s: Cannot find PCI Express capability\n", __func__); | 1183 | ctrl_err(ctrl, "Cannot find PCI Express capability\n"); |
1121 | goto abort; | 1184 | goto abort_ctrl; |
1122 | } | 1185 | } |
1123 | if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) { | 1186 | if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) { |
1124 | err("%s: Cannot read SLOTCAP register\n", __func__); | 1187 | ctrl_err(ctrl, "Cannot read SLOTCAP register\n"); |
1125 | goto abort; | 1188 | goto abort_ctrl; |
1126 | } | 1189 | } |
1127 | 1190 | ||
1128 | ctrl->slot_cap = slot_cap; | 1191 | ctrl->slot_cap = slot_cap; |
@@ -1144,6 +1207,16 @@ struct controller *pcie_init(struct pcie_device *dev) | |||
1144 | !(POWER_CTRL(ctrl) | ATTN_LED(ctrl) | PWR_LED(ctrl) | EMI(ctrl))) | 1207 | !(POWER_CTRL(ctrl) | ATTN_LED(ctrl) | PWR_LED(ctrl) | EMI(ctrl))) |
1145 | ctrl->no_cmd_complete = 1; | 1208 | ctrl->no_cmd_complete = 1; |
1146 | 1209 | ||
1210 | /* Check if Data Link Layer Link Active Reporting is implemented */ | ||
1211 | if (pciehp_readl(ctrl, LNKCAP, &link_cap)) { | ||
1212 | ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); | ||
1213 | goto abort_ctrl; | ||
1214 | } | ||
1215 | if (link_cap & LINK_ACTIVE_REPORTING) { | ||
1216 | ctrl_dbg(ctrl, "Link Active Reporting supported\n"); | ||
1217 | ctrl->link_active_reporting = 1; | ||
1218 | } | ||
1219 | |||
1147 | /* Clear all remaining event bits in Slot Status register */ | 1220 | /* Clear all remaining event bits in Slot Status register */ |
1148 | if (pciehp_writew(ctrl, SLOTSTATUS, 0x1f)) | 1221 | if (pciehp_writew(ctrl, SLOTSTATUS, 0x1f)) |
1149 | goto abort_ctrl; | 1222 | goto abort_ctrl; |
@@ -1161,9 +1234,9 @@ struct controller *pcie_init(struct pcie_device *dev) | |||
1161 | goto abort_ctrl; | 1234 | goto abort_ctrl; |
1162 | } | 1235 | } |
1163 | 1236 | ||
1164 | info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", | 1237 | ctrl_info(ctrl, "HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", |
1165 | pdev->vendor, pdev->device, | 1238 | pdev->vendor, pdev->device, pdev->subsystem_vendor, |
1166 | pdev->subsystem_vendor, pdev->subsystem_device); | 1239 | pdev->subsystem_device); |
1167 | 1240 | ||
1168 | if (pcie_init_slot(ctrl)) | 1241 | if (pcie_init_slot(ctrl)) |
1169 | goto abort_ctrl; | 1242 | goto abort_ctrl; |
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 6040dcceb25..10f9566ccee 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c | |||
@@ -39,8 +39,7 @@ static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp) | |||
39 | u16 pci_cmd, pci_bctl; | 39 | u16 pci_cmd, pci_bctl; |
40 | 40 | ||
41 | if (hpp->revision > 1) { | 41 | if (hpp->revision > 1) { |
42 | printk(KERN_WARNING "%s: Rev.%d type0 record not supported\n", | 42 | warn("Rev.%d type0 record not supported\n", hpp->revision); |
43 | __func__, hpp->revision); | ||
44 | return; | 43 | return; |
45 | } | 44 | } |
46 | 45 | ||
@@ -81,8 +80,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) | |||
81 | u32 reg32; | 80 | u32 reg32; |
82 | 81 | ||
83 | if (hpp->revision > 1) { | 82 | if (hpp->revision > 1) { |
84 | printk(KERN_WARNING "%s: Rev.%d type2 record not supported\n", | 83 | warn("Rev.%d type2 record not supported\n", hpp->revision); |
85 | __func__, hpp->revision); | ||
86 | return; | 84 | return; |
87 | } | 85 | } |
88 | 86 | ||
@@ -149,8 +147,7 @@ static void program_fw_provided_values(struct pci_dev *dev) | |||
149 | return; | 147 | return; |
150 | 148 | ||
151 | if (pciehp_get_hp_params_from_firmware(dev, &hpp)) { | 149 | if (pciehp_get_hp_params_from_firmware(dev, &hpp)) { |
152 | printk(KERN_WARNING "%s: Could not get hotplug parameters\n", | 150 | warn("Could not get hotplug parameters\n"); |
153 | __func__); | ||
154 | return; | 151 | return; |
155 | } | 152 | } |
156 | 153 | ||
@@ -198,18 +195,20 @@ int pciehp_configure_device(struct slot *p_slot) | |||
198 | struct pci_dev *dev; | 195 | struct pci_dev *dev; |
199 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; | 196 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; |
200 | int num, fn; | 197 | int num, fn; |
198 | struct controller *ctrl = p_slot->ctrl; | ||
201 | 199 | ||
202 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); | 200 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); |
203 | if (dev) { | 201 | if (dev) { |
204 | err("Device %s already exists at %x:%x, cannot hot-add\n", | 202 | ctrl_err(ctrl, "Device %s already exists " |
205 | pci_name(dev), p_slot->bus, p_slot->device); | 203 | "at %04x:%02x:%02x, cannot hot-add\n", pci_name(dev), |
204 | pci_domain_nr(parent), p_slot->bus, p_slot->device); | ||
206 | pci_dev_put(dev); | 205 | pci_dev_put(dev); |
207 | return -EINVAL; | 206 | return -EINVAL; |
208 | } | 207 | } |
209 | 208 | ||
210 | num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); | 209 | num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); |
211 | if (num == 0) { | 210 | if (num == 0) { |
212 | err("No new device found\n"); | 211 | ctrl_err(ctrl, "No new device found\n"); |
213 | return -ENODEV; | 212 | return -ENODEV; |
214 | } | 213 | } |
215 | 214 | ||
@@ -218,8 +217,8 @@ int pciehp_configure_device(struct slot *p_slot) | |||
218 | if (!dev) | 217 | if (!dev) |
219 | continue; | 218 | continue; |
220 | if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { | 219 | if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { |
221 | err("Cannot hot-add display device %s\n", | 220 | ctrl_err(ctrl, "Cannot hot-add display device %s\n", |
222 | pci_name(dev)); | 221 | pci_name(dev)); |
223 | pci_dev_put(dev); | 222 | pci_dev_put(dev); |
224 | continue; | 223 | continue; |
225 | } | 224 | } |
@@ -244,9 +243,10 @@ int pciehp_unconfigure_device(struct slot *p_slot) | |||
244 | u8 presence = 0; | 243 | u8 presence = 0; |
245 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; | 244 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; |
246 | u16 command; | 245 | u16 command; |
246 | struct controller *ctrl = p_slot->ctrl; | ||
247 | 247 | ||
248 | dbg("%s: bus/dev = %x/%x\n", __func__, p_slot->bus, | 248 | ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n", |
249 | p_slot->device); | 249 | __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device); |
250 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence); | 250 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence); |
251 | if (ret) | 251 | if (ret) |
252 | presence = 0; | 252 | presence = 0; |
@@ -257,16 +257,17 @@ int pciehp_unconfigure_device(struct slot *p_slot) | |||
257 | if (!temp) | 257 | if (!temp) |
258 | continue; | 258 | continue; |
259 | if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { | 259 | if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { |
260 | err("Cannot remove display device %s\n", | 260 | ctrl_err(ctrl, "Cannot remove display device %s\n", |
261 | pci_name(temp)); | 261 | pci_name(temp)); |
262 | pci_dev_put(temp); | 262 | pci_dev_put(temp); |
263 | continue; | 263 | continue; |
264 | } | 264 | } |
265 | if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { | 265 | if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { |
266 | pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); | 266 | pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); |
267 | if (bctl & PCI_BRIDGE_CTL_VGA) { | 267 | if (bctl & PCI_BRIDGE_CTL_VGA) { |
268 | err("Cannot remove display device %s\n", | 268 | ctrl_err(ctrl, |
269 | pci_name(temp)); | 269 | "Cannot remove display device %s\n", |
270 | pci_name(temp)); | ||
270 | pci_dev_put(temp); | 271 | pci_dev_put(temp); |
271 | continue; | 272 | continue; |
272 | } | 273 | } |
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 7d5921b1ee7..419919a87b0 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h | |||
@@ -46,10 +46,10 @@ | |||
46 | #define PRESENT 1 /* Card in slot */ | 46 | #define PRESENT 1 /* Card in slot */ |
47 | 47 | ||
48 | #define MY_NAME "rpaphp" | 48 | #define MY_NAME "rpaphp" |
49 | extern int debug; | 49 | extern int rpaphp_debug; |
50 | #define dbg(format, arg...) \ | 50 | #define dbg(format, arg...) \ |
51 | do { \ | 51 | do { \ |
52 | if (debug) \ | 52 | if (rpaphp_debug) \ |
53 | printk(KERN_DEBUG "%s: " format, \ | 53 | printk(KERN_DEBUG "%s: " format, \ |
54 | MY_NAME , ## arg); \ | 54 | MY_NAME , ## arg); \ |
55 | } while (0) | 55 | } while (0) |
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 1f84f402acd..95d02a08fdc 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c | |||
@@ -37,7 +37,7 @@ | |||
37 | /* and pci_do_scan_bus */ | 37 | /* and pci_do_scan_bus */ |
38 | #include "rpaphp.h" | 38 | #include "rpaphp.h" |
39 | 39 | ||
40 | int debug; | 40 | int rpaphp_debug; |
41 | LIST_HEAD(rpaphp_slot_head); | 41 | LIST_HEAD(rpaphp_slot_head); |
42 | 42 | ||
43 | #define DRIVER_VERSION "0.1" | 43 | #define DRIVER_VERSION "0.1" |
@@ -50,7 +50,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
50 | MODULE_DESCRIPTION(DRIVER_DESC); | 50 | MODULE_DESCRIPTION(DRIVER_DESC); |
51 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
52 | 52 | ||
53 | module_param(debug, bool, 0644); | 53 | module_param_named(debug, rpaphp_debug, bool, 0644); |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * set_attention_status - set attention LED | 56 | * set_attention_status - set attention LED |
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 5acfd4f3d4c..513e1e28239 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c | |||
@@ -123,7 +123,7 @@ int rpaphp_enable_slot(struct slot *slot) | |||
123 | slot->state = CONFIGURED; | 123 | slot->state = CONFIGURED; |
124 | } | 124 | } |
125 | 125 | ||
126 | if (debug) { | 126 | if (rpaphp_debug) { |
127 | struct pci_dev *dev; | 127 | struct pci_dev *dev; |
128 | dbg("%s: pci_devs of slot[%s]\n", __func__, slot->dn->full_name); | 128 | dbg("%s: pci_devs of slot[%s]\n", __func__, slot->dn->full_name); |
129 | list_for_each_entry (dev, &bus->devices, bus_list) | 129 | list_for_each_entry (dev, &bus->devices, bus_list) |
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 50884507b8b..2ea9cf1a8d0 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c | |||
@@ -43,7 +43,7 @@ static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot) | |||
43 | void dealloc_slot_struct(struct slot *slot) | 43 | void dealloc_slot_struct(struct slot *slot) |
44 | { | 44 | { |
45 | kfree(slot->hotplug_slot->info); | 45 | kfree(slot->hotplug_slot->info); |
46 | kfree(slot->hotplug_slot->name); | 46 | kfree(slot->name); |
47 | kfree(slot->hotplug_slot); | 47 | kfree(slot->hotplug_slot); |
48 | kfree(slot); | 48 | kfree(slot); |
49 | } | 49 | } |
@@ -63,11 +63,9 @@ struct slot *alloc_slot_struct(struct device_node *dn, | |||
63 | GFP_KERNEL); | 63 | GFP_KERNEL); |
64 | if (!slot->hotplug_slot->info) | 64 | if (!slot->hotplug_slot->info) |
65 | goto error_hpslot; | 65 | goto error_hpslot; |
66 | slot->hotplug_slot->name = kmalloc(strlen(drc_name) + 1, GFP_KERNEL); | 66 | slot->name = kstrdup(drc_name, GFP_KERNEL); |
67 | if (!slot->hotplug_slot->name) | 67 | if (!slot->name) |
68 | goto error_info; | 68 | goto error_info; |
69 | slot->name = slot->hotplug_slot->name; | ||
70 | strcpy(slot->name, drc_name); | ||
71 | slot->dn = dn; | 69 | slot->dn = dn; |
72 | slot->index = drc_index; | 70 | slot->index = drc_index; |
73 | slot->power_domain = power_domain; | 71 | slot->power_domain = power_domain; |
@@ -137,7 +135,7 @@ int rpaphp_register_slot(struct slot *slot) | |||
137 | slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn); | 135 | slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn); |
138 | else | 136 | else |
139 | slotno = -1; | 137 | slotno = -1; |
140 | retval = pci_hp_register(php_slot, slot->bus, slotno); | 138 | retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name); |
141 | if (retval) { | 139 | if (retval) { |
142 | err("pci_hp_register failed with error %d\n", retval); | 140 | err("pci_hp_register failed with error %d\n", retval); |
143 | return retval; | 141 | return retval; |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index 410fe0394a8..3eee70928d4 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -161,7 +161,8 @@ static int sn_pci_bus_valid(struct pci_bus *pci_bus) | |||
161 | } | 161 | } |
162 | 162 | ||
163 | static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, | 163 | static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, |
164 | struct pci_bus *pci_bus, int device) | 164 | struct pci_bus *pci_bus, int device, |
165 | char *name) | ||
165 | { | 166 | { |
166 | struct pcibus_info *pcibus_info; | 167 | struct pcibus_info *pcibus_info; |
167 | struct slot *slot; | 168 | struct slot *slot; |
@@ -173,15 +174,9 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot, | |||
173 | return -ENOMEM; | 174 | return -ENOMEM; |
174 | bss_hotplug_slot->private = slot; | 175 | bss_hotplug_slot->private = slot; |
175 | 176 | ||
176 | bss_hotplug_slot->name = kmalloc(SN_SLOT_NAME_SIZE, GFP_KERNEL); | ||
177 | if (!bss_hotplug_slot->name) { | ||
178 | kfree(bss_hotplug_slot->private); | ||
179 | return -ENOMEM; | ||
180 | } | ||
181 | |||
182 | slot->device_num = device; | 177 | slot->device_num = device; |
183 | slot->pci_bus = pci_bus; | 178 | slot->pci_bus = pci_bus; |
184 | sprintf(bss_hotplug_slot->name, "%04x:%02x:%02x", | 179 | sprintf(name, "%04x:%02x:%02x", |
185 | pci_domain_nr(pci_bus), | 180 | pci_domain_nr(pci_bus), |
186 | ((u16)pcibus_info->pbi_buscommon.bs_persist_busnum), | 181 | ((u16)pcibus_info->pbi_buscommon.bs_persist_busnum), |
187 | device + 1); | 182 | device + 1); |
@@ -418,7 +413,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
418 | /* | 413 | /* |
419 | * Add the slot's devices to the ACPI infrastructure */ | 414 | * Add the slot's devices to the ACPI infrastructure */ |
420 | if (SN_ACPI_BASE_SUPPORT() && ssdt) { | 415 | if (SN_ACPI_BASE_SUPPORT() && ssdt) { |
421 | unsigned long adr; | 416 | unsigned long long adr; |
422 | struct acpi_device *pdevice; | 417 | struct acpi_device *pdevice; |
423 | struct acpi_device *device; | 418 | struct acpi_device *device; |
424 | acpi_handle phandle; | 419 | acpi_handle phandle; |
@@ -510,7 +505,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
510 | /* free the ACPI resources for the slot */ | 505 | /* free the ACPI resources for the slot */ |
511 | if (SN_ACPI_BASE_SUPPORT() && | 506 | if (SN_ACPI_BASE_SUPPORT() && |
512 | PCI_CONTROLLER(slot->pci_bus)->acpi_handle) { | 507 | PCI_CONTROLLER(slot->pci_bus)->acpi_handle) { |
513 | unsigned long adr; | 508 | unsigned long long adr; |
514 | struct acpi_device *device; | 509 | struct acpi_device *device; |
515 | acpi_handle phandle; | 510 | acpi_handle phandle; |
516 | acpi_handle chandle = NULL; | 511 | acpi_handle chandle = NULL; |
@@ -608,7 +603,6 @@ static inline int get_power_status(struct hotplug_slot *bss_hotplug_slot, | |||
608 | static void sn_release_slot(struct hotplug_slot *bss_hotplug_slot) | 603 | static void sn_release_slot(struct hotplug_slot *bss_hotplug_slot) |
609 | { | 604 | { |
610 | kfree(bss_hotplug_slot->info); | 605 | kfree(bss_hotplug_slot->info); |
611 | kfree(bss_hotplug_slot->name); | ||
612 | kfree(bss_hotplug_slot->private); | 606 | kfree(bss_hotplug_slot->private); |
613 | kfree(bss_hotplug_slot); | 607 | kfree(bss_hotplug_slot); |
614 | } | 608 | } |
@@ -618,6 +612,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | |||
618 | int device; | 612 | int device; |
619 | struct pci_slot *pci_slot; | 613 | struct pci_slot *pci_slot; |
620 | struct hotplug_slot *bss_hotplug_slot; | 614 | struct hotplug_slot *bss_hotplug_slot; |
615 | char name[SN_SLOT_NAME_SIZE]; | ||
621 | int rc = 0; | 616 | int rc = 0; |
622 | 617 | ||
623 | /* | 618 | /* |
@@ -645,15 +640,14 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus) | |||
645 | } | 640 | } |
646 | 641 | ||
647 | if (sn_hp_slot_private_alloc(bss_hotplug_slot, | 642 | if (sn_hp_slot_private_alloc(bss_hotplug_slot, |
648 | pci_bus, device)) { | 643 | pci_bus, device, name)) { |
649 | rc = -ENOMEM; | 644 | rc = -ENOMEM; |
650 | goto alloc_err; | 645 | goto alloc_err; |
651 | } | 646 | } |
652 | |||
653 | bss_hotplug_slot->ops = &sn_hotplug_slot_ops; | 647 | bss_hotplug_slot->ops = &sn_hotplug_slot_ops; |
654 | bss_hotplug_slot->release = &sn_release_slot; | 648 | bss_hotplug_slot->release = &sn_release_slot; |
655 | 649 | ||
656 | rc = pci_hp_register(bss_hotplug_slot, pci_bus, device); | 650 | rc = pci_hp_register(bss_hotplug_slot, pci_bus, device, name); |
657 | if (rc) | 651 | if (rc) |
658 | goto register_err; | 652 | goto register_err; |
659 | 653 | ||
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 8a026f750de..6aba0b6cf2e 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h | |||
@@ -59,6 +59,20 @@ extern struct workqueue_struct *shpchp_wq; | |||
59 | #define warn(format, arg...) \ | 59 | #define warn(format, arg...) \ |
60 | printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) | 60 | printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) |
61 | 61 | ||
62 | #define ctrl_dbg(ctrl, format, arg...) \ | ||
63 | do { \ | ||
64 | if (shpchp_debug) \ | ||
65 | dev_printk(, &ctrl->pci_dev->dev, \ | ||
66 | format, ## arg); \ | ||
67 | } while (0) | ||
68 | #define ctrl_err(ctrl, format, arg...) \ | ||
69 | dev_err(&ctrl->pci_dev->dev, format, ## arg) | ||
70 | #define ctrl_info(ctrl, format, arg...) \ | ||
71 | dev_info(&ctrl->pci_dev->dev, format, ## arg) | ||
72 | #define ctrl_warn(ctrl, format, arg...) \ | ||
73 | dev_warn(&ctrl->pci_dev->dev, format, ## arg) | ||
74 | |||
75 | |||
62 | #define SLOT_NAME_SIZE 10 | 76 | #define SLOT_NAME_SIZE 10 |
63 | struct slot { | 77 | struct slot { |
64 | u8 bus; | 78 | u8 bus; |
@@ -69,15 +83,13 @@ struct slot { | |||
69 | u8 state; | 83 | u8 state; |
70 | u8 presence_save; | 84 | u8 presence_save; |
71 | u8 pwr_save; | 85 | u8 pwr_save; |
72 | struct timer_list task_event; | ||
73 | u8 hp_slot; | ||
74 | struct controller *ctrl; | 86 | struct controller *ctrl; |
75 | struct hpc_ops *hpc_ops; | 87 | struct hpc_ops *hpc_ops; |
76 | struct hotplug_slot *hotplug_slot; | 88 | struct hotplug_slot *hotplug_slot; |
77 | struct list_head slot_list; | 89 | struct list_head slot_list; |
78 | char name[SLOT_NAME_SIZE]; | ||
79 | struct delayed_work work; /* work for button event */ | 90 | struct delayed_work work; /* work for button event */ |
80 | struct mutex lock; | 91 | struct mutex lock; |
92 | u8 hp_slot; | ||
81 | }; | 93 | }; |
82 | 94 | ||
83 | struct event_info { | 95 | struct event_info { |
@@ -169,6 +181,11 @@ extern void cleanup_slots(struct controller *ctrl); | |||
169 | extern void shpchp_queue_pushbutton_work(struct work_struct *work); | 181 | extern void shpchp_queue_pushbutton_work(struct work_struct *work); |
170 | extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev); | 182 | extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev); |
171 | 183 | ||
184 | static inline const char *slot_name(struct slot *slot) | ||
185 | { | ||
186 | return hotplug_slot_name(slot->hotplug_slot); | ||
187 | } | ||
188 | |||
172 | #ifdef CONFIG_ACPI | 189 | #ifdef CONFIG_ACPI |
173 | #include <linux/pci-acpi.h> | 190 | #include <linux/pci-acpi.h> |
174 | static inline int get_hp_params_from_firmware(struct pci_dev *dev, | 191 | static inline int get_hp_params_from_firmware(struct pci_dev *dev, |
@@ -236,7 +253,7 @@ static inline struct slot *shpchp_find_slot(struct controller *ctrl, u8 device) | |||
236 | return slot; | 253 | return slot; |
237 | } | 254 | } |
238 | 255 | ||
239 | err("%s: slot (device=0x%x) not found\n", __func__, device); | 256 | ctrl_err(ctrl, "Slot (device=0x%02x) not found\n", device); |
240 | return NULL; | 257 | return NULL; |
241 | } | 258 | } |
242 | 259 | ||
@@ -270,7 +287,9 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot) | |||
270 | pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, &pcix_bridge_errors_reg); | 287 | pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, &pcix_bridge_errors_reg); |
271 | perr_set = pcix_bridge_errors_reg & PERR_OBSERVED_MASK; | 288 | perr_set = pcix_bridge_errors_reg & PERR_OBSERVED_MASK; |
272 | if (perr_set) { | 289 | if (perr_set) { |
273 | dbg ("%s W1C: Bridge_Errors[ PERR_OBSERVED = %08X]\n",__func__ , perr_set); | 290 | ctrl_dbg(p_slot->ctrl, |
291 | "Bridge_Errors[ PERR_OBSERVED = %08X] (W1C)\n", | ||
292 | perr_set); | ||
274 | 293 | ||
275 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, perr_set); | 294 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, perr_set); |
276 | } | 295 | } |
@@ -279,7 +298,7 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot) | |||
279 | pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, &pcix_mem_base_reg); | 298 | pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, &pcix_mem_base_reg); |
280 | rse_set = pcix_mem_base_reg & RSE_MASK; | 299 | rse_set = pcix_mem_base_reg & RSE_MASK; |
281 | if (rse_set) { | 300 | if (rse_set) { |
282 | dbg ("%s W1C: Memory_Base_Limit[ RSE ]\n",__func__ ); | 301 | ctrl_dbg(p_slot->ctrl, "Memory_Base_Limit[ RSE ] (W1C)\n"); |
283 | 302 | ||
284 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); | 303 | pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); |
285 | } | 304 | } |
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index cc38615395f..fe8d149c229 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -89,7 +89,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
89 | { | 89 | { |
90 | struct slot *slot = hotplug_slot->private; | 90 | struct slot *slot = hotplug_slot->private; |
91 | 91 | ||
92 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 92 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
93 | __func__, slot_name(slot)); | ||
93 | 94 | ||
94 | kfree(slot->hotplug_slot->info); | 95 | kfree(slot->hotplug_slot->info); |
95 | kfree(slot->hotplug_slot); | 96 | kfree(slot->hotplug_slot); |
@@ -101,8 +102,9 @@ static int init_slots(struct controller *ctrl) | |||
101 | struct slot *slot; | 102 | struct slot *slot; |
102 | struct hotplug_slot *hotplug_slot; | 103 | struct hotplug_slot *hotplug_slot; |
103 | struct hotplug_slot_info *info; | 104 | struct hotplug_slot_info *info; |
105 | char name[SLOT_NAME_SIZE]; | ||
104 | int retval = -ENOMEM; | 106 | int retval = -ENOMEM; |
105 | int i, len, dup = 1; | 107 | int i; |
106 | 108 | ||
107 | for (i = 0; i < ctrl->num_slots; i++) { | 109 | for (i = 0; i < ctrl->num_slots; i++) { |
108 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | 110 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
@@ -119,8 +121,6 @@ static int init_slots(struct controller *ctrl) | |||
119 | goto error_hpslot; | 121 | goto error_hpslot; |
120 | hotplug_slot->info = info; | 122 | hotplug_slot->info = info; |
121 | 123 | ||
122 | hotplug_slot->name = slot->name; | ||
123 | |||
124 | slot->hp_slot = i; | 124 | slot->hp_slot = i; |
125 | slot->ctrl = ctrl; | 125 | slot->ctrl = ctrl; |
126 | slot->bus = ctrl->pci_dev->subordinate->number; | 126 | slot->bus = ctrl->pci_dev->subordinate->number; |
@@ -133,37 +133,27 @@ static int init_slots(struct controller *ctrl) | |||
133 | /* register this slot with the hotplug pci core */ | 133 | /* register this slot with the hotplug pci core */ |
134 | hotplug_slot->private = slot; | 134 | hotplug_slot->private = slot; |
135 | hotplug_slot->release = &release_slot; | 135 | hotplug_slot->release = &release_slot; |
136 | snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number); | 136 | snprintf(name, SLOT_NAME_SIZE, "%d", slot->number); |
137 | hotplug_slot->ops = &shpchp_hotplug_slot_ops; | 137 | hotplug_slot->ops = &shpchp_hotplug_slot_ops; |
138 | 138 | ||
139 | get_power_status(hotplug_slot, &info->power_status); | 139 | ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:%02x " |
140 | get_attention_status(hotplug_slot, &info->attention_status); | 140 | "hp_slot=%x sun=%x slot_device_offset=%x\n", |
141 | get_latch_status(hotplug_slot, &info->latch_status); | 141 | pci_domain_nr(ctrl->pci_dev->subordinate), |
142 | get_adapter_status(hotplug_slot, &info->adapter_status); | 142 | slot->bus, slot->device, slot->hp_slot, slot->number, |
143 | 143 | ctrl->slot_device_offset); | |
144 | dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " | ||
145 | "slot_device_offset=%x\n", slot->bus, slot->device, | ||
146 | slot->hp_slot, slot->number, ctrl->slot_device_offset); | ||
147 | duplicate_name: | ||
148 | retval = pci_hp_register(slot->hotplug_slot, | 144 | retval = pci_hp_register(slot->hotplug_slot, |
149 | ctrl->pci_dev->subordinate, slot->device); | 145 | ctrl->pci_dev->subordinate, slot->device, name); |
150 | if (retval) { | 146 | if (retval) { |
151 | /* | 147 | ctrl_err(ctrl, "pci_hp_register failed with error %d\n", |
152 | * If slot N already exists, we'll try to create | 148 | retval); |
153 | * slot N-1, N-2 ... N-M, until we overflow. | ||
154 | */ | ||
155 | if (retval == -EEXIST) { | ||
156 | len = snprintf(slot->name, SLOT_NAME_SIZE, | ||
157 | "%d-%d", slot->number, dup++); | ||
158 | if (len < SLOT_NAME_SIZE) | ||
159 | goto duplicate_name; | ||
160 | else | ||
161 | err("duplicate slot name overflow\n"); | ||
162 | } | ||
163 | err("pci_hp_register failed with error %d\n", retval); | ||
164 | goto error_info; | 149 | goto error_info; |
165 | } | 150 | } |
166 | 151 | ||
152 | get_power_status(hotplug_slot, &info->power_status); | ||
153 | get_attention_status(hotplug_slot, &info->attention_status); | ||
154 | get_latch_status(hotplug_slot, &info->latch_status); | ||
155 | get_adapter_status(hotplug_slot, &info->adapter_status); | ||
156 | |||
167 | list_add(&slot->slot_list, &ctrl->slot_list); | 157 | list_add(&slot->slot_list, &ctrl->slot_list); |
168 | } | 158 | } |
169 | 159 | ||
@@ -201,7 +191,8 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) | |||
201 | { | 191 | { |
202 | struct slot *slot = get_slot(hotplug_slot); | 192 | struct slot *slot = get_slot(hotplug_slot); |
203 | 193 | ||
204 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 194 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
195 | __func__, slot_name(slot)); | ||
205 | 196 | ||
206 | hotplug_slot->info->attention_status = status; | 197 | hotplug_slot->info->attention_status = status; |
207 | slot->hpc_ops->set_attention_status(slot, status); | 198 | slot->hpc_ops->set_attention_status(slot, status); |
@@ -213,7 +204,8 @@ static int enable_slot (struct hotplug_slot *hotplug_slot) | |||
213 | { | 204 | { |
214 | struct slot *slot = get_slot(hotplug_slot); | 205 | struct slot *slot = get_slot(hotplug_slot); |
215 | 206 | ||
216 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 207 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
208 | __func__, slot_name(slot)); | ||
217 | 209 | ||
218 | return shpchp_sysfs_enable_slot(slot); | 210 | return shpchp_sysfs_enable_slot(slot); |
219 | } | 211 | } |
@@ -222,7 +214,8 @@ static int disable_slot (struct hotplug_slot *hotplug_slot) | |||
222 | { | 214 | { |
223 | struct slot *slot = get_slot(hotplug_slot); | 215 | struct slot *slot = get_slot(hotplug_slot); |
224 | 216 | ||
225 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 217 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
218 | __func__, slot_name(slot)); | ||
226 | 219 | ||
227 | return shpchp_sysfs_disable_slot(slot); | 220 | return shpchp_sysfs_disable_slot(slot); |
228 | } | 221 | } |
@@ -232,7 +225,8 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
232 | struct slot *slot = get_slot(hotplug_slot); | 225 | struct slot *slot = get_slot(hotplug_slot); |
233 | int retval; | 226 | int retval; |
234 | 227 | ||
235 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 228 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
229 | __func__, slot_name(slot)); | ||
236 | 230 | ||
237 | retval = slot->hpc_ops->get_power_status(slot, value); | 231 | retval = slot->hpc_ops->get_power_status(slot, value); |
238 | if (retval < 0) | 232 | if (retval < 0) |
@@ -246,7 +240,8 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
246 | struct slot *slot = get_slot(hotplug_slot); | 240 | struct slot *slot = get_slot(hotplug_slot); |
247 | int retval; | 241 | int retval; |
248 | 242 | ||
249 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 243 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
244 | __func__, slot_name(slot)); | ||
250 | 245 | ||
251 | retval = slot->hpc_ops->get_attention_status(slot, value); | 246 | retval = slot->hpc_ops->get_attention_status(slot, value); |
252 | if (retval < 0) | 247 | if (retval < 0) |
@@ -260,7 +255,8 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
260 | struct slot *slot = get_slot(hotplug_slot); | 255 | struct slot *slot = get_slot(hotplug_slot); |
261 | int retval; | 256 | int retval; |
262 | 257 | ||
263 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 258 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
259 | __func__, slot_name(slot)); | ||
264 | 260 | ||
265 | retval = slot->hpc_ops->get_latch_status(slot, value); | 261 | retval = slot->hpc_ops->get_latch_status(slot, value); |
266 | if (retval < 0) | 262 | if (retval < 0) |
@@ -274,7 +270,8 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) | |||
274 | struct slot *slot = get_slot(hotplug_slot); | 270 | struct slot *slot = get_slot(hotplug_slot); |
275 | int retval; | 271 | int retval; |
276 | 272 | ||
277 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 273 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
274 | __func__, slot_name(slot)); | ||
278 | 275 | ||
279 | retval = slot->hpc_ops->get_adapter_status(slot, value); | 276 | retval = slot->hpc_ops->get_adapter_status(slot, value); |
280 | if (retval < 0) | 277 | if (retval < 0) |
@@ -289,7 +286,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, | |||
289 | struct slot *slot = get_slot(hotplug_slot); | 286 | struct slot *slot = get_slot(hotplug_slot); |
290 | int retval; | 287 | int retval; |
291 | 288 | ||
292 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 289 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
290 | __func__, slot_name(slot)); | ||
293 | 291 | ||
294 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); | 292 | retval = slot->hpc_ops->get_max_bus_speed(slot, value); |
295 | if (retval < 0) | 293 | if (retval < 0) |
@@ -303,7 +301,8 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
303 | struct slot *slot = get_slot(hotplug_slot); | 301 | struct slot *slot = get_slot(hotplug_slot); |
304 | int retval; | 302 | int retval; |
305 | 303 | ||
306 | dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); | 304 | ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", |
305 | __func__, slot_name(slot)); | ||
307 | 306 | ||
308 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); | 307 | retval = slot->hpc_ops->get_cur_bus_speed(slot, value); |
309 | if (retval < 0) | 308 | if (retval < 0) |
@@ -334,15 +333,14 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
334 | 333 | ||
335 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); | 334 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
336 | if (!ctrl) { | 335 | if (!ctrl) { |
337 | err("%s : out of memory\n", __func__); | 336 | dev_err(&pdev->dev, "%s: Out of memory\n", __func__); |
338 | goto err_out_none; | 337 | goto err_out_none; |
339 | } | 338 | } |
340 | INIT_LIST_HEAD(&ctrl->slot_list); | 339 | INIT_LIST_HEAD(&ctrl->slot_list); |
341 | 340 | ||
342 | rc = shpc_init(ctrl, pdev); | 341 | rc = shpc_init(ctrl, pdev); |
343 | if (rc) { | 342 | if (rc) { |
344 | dbg("%s: controller initialization failed\n", | 343 | ctrl_dbg(ctrl, "Controller initialization failed\n"); |
345 | SHPC_MODULE_NAME); | ||
346 | goto err_out_free_ctrl; | 344 | goto err_out_free_ctrl; |
347 | } | 345 | } |
348 | 346 | ||
@@ -351,7 +349,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
351 | /* Setup the slot information structures */ | 349 | /* Setup the slot information structures */ |
352 | rc = init_slots(ctrl); | 350 | rc = init_slots(ctrl); |
353 | if (rc) { | 351 | if (rc) { |
354 | err("%s: slot initialization failed\n", SHPC_MODULE_NAME); | 352 | ctrl_err(ctrl, "Slot initialization failed\n"); |
355 | goto err_out_release_ctlr; | 353 | goto err_out_release_ctlr; |
356 | } | 354 | } |
357 | 355 | ||
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index dfb53932dfb..b8ab2796e66 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c | |||
@@ -62,7 +62,7 @@ u8 shpchp_handle_attention_button(u8 hp_slot, struct controller *ctrl) | |||
62 | u32 event_type; | 62 | u32 event_type; |
63 | 63 | ||
64 | /* Attention Button Change */ | 64 | /* Attention Button Change */ |
65 | dbg("shpchp: Attention button interrupt received.\n"); | 65 | ctrl_dbg(ctrl, "Attention button interrupt received\n"); |
66 | 66 | ||
67 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 67 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
68 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); | 68 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
@@ -70,7 +70,7 @@ u8 shpchp_handle_attention_button(u8 hp_slot, struct controller *ctrl) | |||
70 | /* | 70 | /* |
71 | * Button pressed - See if need to TAKE ACTION!!! | 71 | * Button pressed - See if need to TAKE ACTION!!! |
72 | */ | 72 | */ |
73 | info("Button pressed on Slot(%s)\n", p_slot->name); | 73 | ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot)); |
74 | event_type = INT_BUTTON_PRESS; | 74 | event_type = INT_BUTTON_PRESS; |
75 | 75 | ||
76 | queue_interrupt_event(p_slot, event_type); | 76 | queue_interrupt_event(p_slot, event_type); |
@@ -86,29 +86,29 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl) | |||
86 | u32 event_type; | 86 | u32 event_type; |
87 | 87 | ||
88 | /* Switch Change */ | 88 | /* Switch Change */ |
89 | dbg("shpchp: Switch interrupt received.\n"); | 89 | ctrl_dbg(ctrl, "Switch interrupt received\n"); |
90 | 90 | ||
91 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 91 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
92 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); | 92 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
93 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 93 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
94 | dbg("%s: Card present %x Power status %x\n", __func__, | 94 | ctrl_dbg(ctrl, "Card present %x Power status %x\n", |
95 | p_slot->presence_save, p_slot->pwr_save); | 95 | p_slot->presence_save, p_slot->pwr_save); |
96 | 96 | ||
97 | if (getstatus) { | 97 | if (getstatus) { |
98 | /* | 98 | /* |
99 | * Switch opened | 99 | * Switch opened |
100 | */ | 100 | */ |
101 | info("Latch open on Slot(%s)\n", p_slot->name); | 101 | ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot)); |
102 | event_type = INT_SWITCH_OPEN; | 102 | event_type = INT_SWITCH_OPEN; |
103 | if (p_slot->pwr_save && p_slot->presence_save) { | 103 | if (p_slot->pwr_save && p_slot->presence_save) { |
104 | event_type = INT_POWER_FAULT; | 104 | event_type = INT_POWER_FAULT; |
105 | err("Surprise Removal of card\n"); | 105 | ctrl_err(ctrl, "Surprise Removal of card\n"); |
106 | } | 106 | } |
107 | } else { | 107 | } else { |
108 | /* | 108 | /* |
109 | * Switch closed | 109 | * Switch closed |
110 | */ | 110 | */ |
111 | info("Latch close on Slot(%s)\n", p_slot->name); | 111 | ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot)); |
112 | event_type = INT_SWITCH_CLOSE; | 112 | event_type = INT_SWITCH_CLOSE; |
113 | } | 113 | } |
114 | 114 | ||
@@ -123,7 +123,7 @@ u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl) | |||
123 | u32 event_type; | 123 | u32 event_type; |
124 | 124 | ||
125 | /* Presence Change */ | 125 | /* Presence Change */ |
126 | dbg("shpchp: Presence/Notify input change.\n"); | 126 | ctrl_dbg(ctrl, "Presence/Notify input change\n"); |
127 | 127 | ||
128 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 128 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
129 | 129 | ||
@@ -135,13 +135,15 @@ u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl) | |||
135 | /* | 135 | /* |
136 | * Card Present | 136 | * Card Present |
137 | */ | 137 | */ |
138 | info("Card present on Slot(%s)\n", p_slot->name); | 138 | ctrl_info(ctrl, "Card present on Slot(%s)\n", |
139 | slot_name(p_slot)); | ||
139 | event_type = INT_PRESENCE_ON; | 140 | event_type = INT_PRESENCE_ON; |
140 | } else { | 141 | } else { |
141 | /* | 142 | /* |
142 | * Not Present | 143 | * Not Present |
143 | */ | 144 | */ |
144 | info("Card not present on Slot(%s)\n", p_slot->name); | 145 | ctrl_info(ctrl, "Card not present on Slot(%s)\n", |
146 | slot_name(p_slot)); | ||
145 | event_type = INT_PRESENCE_OFF; | 147 | event_type = INT_PRESENCE_OFF; |
146 | } | 148 | } |
147 | 149 | ||
@@ -156,7 +158,7 @@ u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl) | |||
156 | u32 event_type; | 158 | u32 event_type; |
157 | 159 | ||
158 | /* Power fault */ | 160 | /* Power fault */ |
159 | dbg("shpchp: Power fault interrupt received.\n"); | 161 | ctrl_dbg(ctrl, "Power fault interrupt received\n"); |
160 | 162 | ||
161 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 163 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
162 | 164 | ||
@@ -164,18 +166,19 @@ u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl) | |||
164 | /* | 166 | /* |
165 | * Power fault Cleared | 167 | * Power fault Cleared |
166 | */ | 168 | */ |
167 | info("Power fault cleared on Slot(%s)\n", p_slot->name); | 169 | ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n", |
170 | slot_name(p_slot)); | ||
168 | p_slot->status = 0x00; | 171 | p_slot->status = 0x00; |
169 | event_type = INT_POWER_FAULT_CLEAR; | 172 | event_type = INT_POWER_FAULT_CLEAR; |
170 | } else { | 173 | } else { |
171 | /* | 174 | /* |
172 | * Power fault | 175 | * Power fault |
173 | */ | 176 | */ |
174 | info("Power fault on Slot(%s)\n", p_slot->name); | 177 | ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot)); |
175 | event_type = INT_POWER_FAULT; | 178 | event_type = INT_POWER_FAULT; |
176 | /* set power fault status for this board */ | 179 | /* set power fault status for this board */ |
177 | p_slot->status = 0xFF; | 180 | p_slot->status = 0xFF; |
178 | info("power fault bit %x set\n", hp_slot); | 181 | ctrl_info(ctrl, "Power fault bit %x set\n", hp_slot); |
179 | } | 182 | } |
180 | 183 | ||
181 | queue_interrupt_event(p_slot, event_type); | 184 | queue_interrupt_event(p_slot, event_type); |
@@ -191,10 +194,10 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot, | |||
191 | { | 194 | { |
192 | int rc = 0; | 195 | int rc = 0; |
193 | 196 | ||
194 | dbg("%s: change to speed %d\n", __func__, speed); | 197 | ctrl_dbg(ctrl, "Change speed to %d\n", speed); |
195 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { | 198 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { |
196 | err("%s: Issue of set bus speed mode command failed\n", | 199 | ctrl_err(ctrl, "%s: Issue of set bus speed mode command " |
197 | __func__); | 200 | "failed\n", __func__); |
198 | return WRONG_BUS_FREQUENCY; | 201 | return WRONG_BUS_FREQUENCY; |
199 | } | 202 | } |
200 | return rc; | 203 | return rc; |
@@ -212,8 +215,8 @@ static int fix_bus_speed(struct controller *ctrl, struct slot *pslot, | |||
212 | */ | 215 | */ |
213 | if (flag) { | 216 | if (flag) { |
214 | if (asp < bsp) { | 217 | if (asp < bsp) { |
215 | err("%s: speed of bus %x and adapter %x mismatch\n", | 218 | ctrl_err(ctrl, "Speed of bus %x and adapter %x " |
216 | __func__, bsp, asp); | 219 | "mismatch\n", bsp, asp); |
217 | rc = WRONG_BUS_FREQUENCY; | 220 | rc = WRONG_BUS_FREQUENCY; |
218 | } | 221 | } |
219 | return rc; | 222 | return rc; |
@@ -243,17 +246,18 @@ static int board_added(struct slot *p_slot) | |||
243 | int rc = 0; | 246 | int rc = 0; |
244 | enum pci_bus_speed asp, bsp, msp; | 247 | enum pci_bus_speed asp, bsp, msp; |
245 | struct controller *ctrl = p_slot->ctrl; | 248 | struct controller *ctrl = p_slot->ctrl; |
249 | struct pci_bus *parent = ctrl->pci_dev->subordinate; | ||
246 | 250 | ||
247 | hp_slot = p_slot->device - ctrl->slot_device_offset; | 251 | hp_slot = p_slot->device - ctrl->slot_device_offset; |
248 | 252 | ||
249 | dbg("%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n", | 253 | ctrl_dbg(ctrl, |
250 | __func__, p_slot->device, | 254 | "%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n", |
251 | ctrl->slot_device_offset, hp_slot); | 255 | __func__, p_slot->device, ctrl->slot_device_offset, hp_slot); |
252 | 256 | ||
253 | /* Power on slot without connecting to bus */ | 257 | /* Power on slot without connecting to bus */ |
254 | rc = p_slot->hpc_ops->power_on_slot(p_slot); | 258 | rc = p_slot->hpc_ops->power_on_slot(p_slot); |
255 | if (rc) { | 259 | if (rc) { |
256 | err("%s: Failed to power on slot\n", __func__); | 260 | ctrl_err(ctrl, "Failed to power on slot\n"); |
257 | return -1; | 261 | return -1; |
258 | } | 262 | } |
259 | 263 | ||
@@ -262,33 +266,34 @@ static int board_added(struct slot *p_slot) | |||
262 | return WRONG_BUS_FREQUENCY; | 266 | return WRONG_BUS_FREQUENCY; |
263 | 267 | ||
264 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { | 268 | if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { |
265 | err("%s: Issue of set bus speed mode command failed\n", __func__); | 269 | ctrl_err(ctrl, "%s: Issue of set bus speed mode command" |
270 | " failed\n", __func__); | ||
266 | return WRONG_BUS_FREQUENCY; | 271 | return WRONG_BUS_FREQUENCY; |
267 | } | 272 | } |
268 | 273 | ||
269 | /* turn on board, blink green LED, turn off Amber LED */ | 274 | /* turn on board, blink green LED, turn off Amber LED */ |
270 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { | 275 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { |
271 | err("%s: Issue of Slot Enable command failed\n", __func__); | 276 | ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); |
272 | return rc; | 277 | return rc; |
273 | } | 278 | } |
274 | } | 279 | } |
275 | 280 | ||
276 | rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp); | 281 | rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp); |
277 | if (rc) { | 282 | if (rc) { |
278 | err("%s: Can't get adapter speed or bus mode mismatch\n", | 283 | ctrl_err(ctrl, "Can't get adapter speed or " |
279 | __func__); | 284 | "bus mode mismatch\n"); |
280 | return WRONG_BUS_FREQUENCY; | 285 | return WRONG_BUS_FREQUENCY; |
281 | } | 286 | } |
282 | 287 | ||
283 | rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bsp); | 288 | rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bsp); |
284 | if (rc) { | 289 | if (rc) { |
285 | err("%s: Can't get bus operation speed\n", __func__); | 290 | ctrl_err(ctrl, "Can't get bus operation speed\n"); |
286 | return WRONG_BUS_FREQUENCY; | 291 | return WRONG_BUS_FREQUENCY; |
287 | } | 292 | } |
288 | 293 | ||
289 | rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &msp); | 294 | rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &msp); |
290 | if (rc) { | 295 | if (rc) { |
291 | err("%s: Can't get max bus operation speed\n", __func__); | 296 | ctrl_err(ctrl, "Can't get max bus operation speed\n"); |
292 | msp = bsp; | 297 | msp = bsp; |
293 | } | 298 | } |
294 | 299 | ||
@@ -296,9 +301,9 @@ static int board_added(struct slot *p_slot) | |||
296 | if (!list_empty(&ctrl->pci_dev->subordinate->devices)) | 301 | if (!list_empty(&ctrl->pci_dev->subordinate->devices)) |
297 | slots_not_empty = 1; | 302 | slots_not_empty = 1; |
298 | 303 | ||
299 | dbg("%s: slots_not_empty %d, adapter_speed %d, bus_speed %d, " | 304 | ctrl_dbg(ctrl, "%s: slots_not_empty %d, adapter_speed %d, bus_speed %d," |
300 | "max_bus_speed %d\n", __func__, slots_not_empty, asp, | 305 | " max_bus_speed %d\n", __func__, slots_not_empty, asp, |
301 | bsp, msp); | 306 | bsp, msp); |
302 | 307 | ||
303 | rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp); | 308 | rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp); |
304 | if (rc) | 309 | if (rc) |
@@ -306,26 +311,26 @@ static int board_added(struct slot *p_slot) | |||
306 | 311 | ||
307 | /* turn on board, blink green LED, turn off Amber LED */ | 312 | /* turn on board, blink green LED, turn off Amber LED */ |
308 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { | 313 | if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { |
309 | err("%s: Issue of Slot Enable command failed\n", __func__); | 314 | ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); |
310 | return rc; | 315 | return rc; |
311 | } | 316 | } |
312 | 317 | ||
313 | /* Wait for ~1 second */ | 318 | /* Wait for ~1 second */ |
314 | msleep(1000); | 319 | msleep(1000); |
315 | 320 | ||
316 | dbg("%s: slot status = %x\n", __func__, p_slot->status); | 321 | ctrl_dbg(ctrl, "%s: slot status = %x\n", __func__, p_slot->status); |
317 | /* Check for a power fault */ | 322 | /* Check for a power fault */ |
318 | if (p_slot->status == 0xFF) { | 323 | if (p_slot->status == 0xFF) { |
319 | /* power fault occurred, but it was benign */ | 324 | /* power fault occurred, but it was benign */ |
320 | dbg("%s: power fault\n", __func__); | 325 | ctrl_dbg(ctrl, "%s: Power fault\n", __func__); |
321 | rc = POWER_FAILURE; | 326 | rc = POWER_FAILURE; |
322 | p_slot->status = 0; | 327 | p_slot->status = 0; |
323 | goto err_exit; | 328 | goto err_exit; |
324 | } | 329 | } |
325 | 330 | ||
326 | if (shpchp_configure_device(p_slot)) { | 331 | if (shpchp_configure_device(p_slot)) { |
327 | err("Cannot add device at 0x%x:0x%x\n", p_slot->bus, | 332 | ctrl_err(ctrl, "Cannot add device at %04x:%02x:%02x\n", |
328 | p_slot->device); | 333 | pci_domain_nr(parent), p_slot->bus, p_slot->device); |
329 | goto err_exit; | 334 | goto err_exit; |
330 | } | 335 | } |
331 | 336 | ||
@@ -341,7 +346,8 @@ err_exit: | |||
341 | /* turn off slot, turn on Amber LED, turn off Green LED */ | 346 | /* turn off slot, turn on Amber LED, turn off Green LED */ |
342 | rc = p_slot->hpc_ops->slot_disable(p_slot); | 347 | rc = p_slot->hpc_ops->slot_disable(p_slot); |
343 | if (rc) { | 348 | if (rc) { |
344 | err("%s: Issue of Slot Disable command failed\n", __func__); | 349 | ctrl_err(ctrl, "%s: Issue of Slot Disable command failed\n", |
350 | __func__); | ||
345 | return rc; | 351 | return rc; |
346 | } | 352 | } |
347 | 353 | ||
@@ -365,7 +371,7 @@ static int remove_board(struct slot *p_slot) | |||
365 | hp_slot = p_slot->device - ctrl->slot_device_offset; | 371 | hp_slot = p_slot->device - ctrl->slot_device_offset; |
366 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); | 372 | p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
367 | 373 | ||
368 | dbg("In %s, hp_slot = %d\n", __func__, hp_slot); | 374 | ctrl_dbg(ctrl, "%s: hp_slot = %d\n", __func__, hp_slot); |
369 | 375 | ||
370 | /* Change status to shutdown */ | 376 | /* Change status to shutdown */ |
371 | if (p_slot->is_a_board) | 377 | if (p_slot->is_a_board) |
@@ -374,13 +380,14 @@ static int remove_board(struct slot *p_slot) | |||
374 | /* turn off slot, turn on Amber LED, turn off Green LED */ | 380 | /* turn off slot, turn on Amber LED, turn off Green LED */ |
375 | rc = p_slot->hpc_ops->slot_disable(p_slot); | 381 | rc = p_slot->hpc_ops->slot_disable(p_slot); |
376 | if (rc) { | 382 | if (rc) { |
377 | err("%s: Issue of Slot Disable command failed\n", __func__); | 383 | ctrl_err(ctrl, "%s: Issue of Slot Disable command failed\n", |
384 | __func__); | ||
378 | return rc; | 385 | return rc; |
379 | } | 386 | } |
380 | 387 | ||
381 | rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); | 388 | rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); |
382 | if (rc) { | 389 | if (rc) { |
383 | err("%s: Issue of Set Attention command failed\n", __func__); | 390 | ctrl_err(ctrl, "Issue of Set Attention command failed\n"); |
384 | return rc; | 391 | return rc; |
385 | } | 392 | } |
386 | 393 | ||
@@ -439,7 +446,8 @@ void shpchp_queue_pushbutton_work(struct work_struct *work) | |||
439 | 446 | ||
440 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 447 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
441 | if (!info) { | 448 | if (!info) { |
442 | err("%s: Cannot allocate memory\n", __func__); | 449 | ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n", |
450 | __func__); | ||
443 | return; | 451 | return; |
444 | } | 452 | } |
445 | info->p_slot = p_slot; | 453 | info->p_slot = p_slot; |
@@ -486,18 +494,19 @@ static int update_slot_info (struct slot *slot) | |||
486 | static void handle_button_press_event(struct slot *p_slot) | 494 | static void handle_button_press_event(struct slot *p_slot) |
487 | { | 495 | { |
488 | u8 getstatus; | 496 | u8 getstatus; |
497 | struct controller *ctrl = p_slot->ctrl; | ||
489 | 498 | ||
490 | switch (p_slot->state) { | 499 | switch (p_slot->state) { |
491 | case STATIC_STATE: | 500 | case STATIC_STATE: |
492 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 501 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
493 | if (getstatus) { | 502 | if (getstatus) { |
494 | p_slot->state = BLINKINGOFF_STATE; | 503 | p_slot->state = BLINKINGOFF_STATE; |
495 | info("PCI slot #%s - powering off due to button " | 504 | ctrl_info(ctrl, "PCI slot #%s - powering off due to " |
496 | "press.\n", p_slot->name); | 505 | "button press.\n", slot_name(p_slot)); |
497 | } else { | 506 | } else { |
498 | p_slot->state = BLINKINGON_STATE; | 507 | p_slot->state = BLINKINGON_STATE; |
499 | info("PCI slot #%s - powering on due to button " | 508 | ctrl_info(ctrl, "PCI slot #%s - powering on due to " |
500 | "press.\n", p_slot->name); | 509 | "button press.\n", slot_name(p_slot)); |
501 | } | 510 | } |
502 | /* blink green LED and turn off amber */ | 511 | /* blink green LED and turn off amber */ |
503 | p_slot->hpc_ops->green_led_blink(p_slot); | 512 | p_slot->hpc_ops->green_led_blink(p_slot); |
@@ -512,16 +521,16 @@ static void handle_button_press_event(struct slot *p_slot) | |||
512 | * press the attention again before the 5 sec. limit | 521 | * press the attention again before the 5 sec. limit |
513 | * expires to cancel hot-add or hot-remove | 522 | * expires to cancel hot-add or hot-remove |
514 | */ | 523 | */ |
515 | info("Button cancel on Slot(%s)\n", p_slot->name); | 524 | ctrl_info(ctrl, "Button cancel on Slot(%s)\n", |
516 | dbg("%s: button cancel\n", __func__); | 525 | slot_name(p_slot)); |
517 | cancel_delayed_work(&p_slot->work); | 526 | cancel_delayed_work(&p_slot->work); |
518 | if (p_slot->state == BLINKINGOFF_STATE) | 527 | if (p_slot->state == BLINKINGOFF_STATE) |
519 | p_slot->hpc_ops->green_led_on(p_slot); | 528 | p_slot->hpc_ops->green_led_on(p_slot); |
520 | else | 529 | else |
521 | p_slot->hpc_ops->green_led_off(p_slot); | 530 | p_slot->hpc_ops->green_led_off(p_slot); |
522 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 531 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
523 | info("PCI slot #%s - action canceled due to button press\n", | 532 | ctrl_info(ctrl, "PCI slot #%s - action canceled due to " |
524 | p_slot->name); | 533 | "button press\n", slot_name(p_slot)); |
525 | p_slot->state = STATIC_STATE; | 534 | p_slot->state = STATIC_STATE; |
526 | break; | 535 | break; |
527 | case POWEROFF_STATE: | 536 | case POWEROFF_STATE: |
@@ -531,11 +540,12 @@ static void handle_button_press_event(struct slot *p_slot) | |||
531 | * this means that the previous attention button action | 540 | * this means that the previous attention button action |
532 | * to hot-add or hot-remove is undergoing | 541 | * to hot-add or hot-remove is undergoing |
533 | */ | 542 | */ |
534 | info("Button ignore on Slot(%s)\n", p_slot->name); | 543 | ctrl_info(ctrl, "Button ignore on Slot(%s)\n", |
544 | slot_name(p_slot)); | ||
535 | update_slot_info(p_slot); | 545 | update_slot_info(p_slot); |
536 | break; | 546 | break; |
537 | default: | 547 | default: |
538 | warn("Not a valid state\n"); | 548 | ctrl_warn(ctrl, "Not a valid state\n"); |
539 | break; | 549 | break; |
540 | } | 550 | } |
541 | } | 551 | } |
@@ -551,7 +561,7 @@ static void interrupt_event_handler(struct work_struct *work) | |||
551 | handle_button_press_event(p_slot); | 561 | handle_button_press_event(p_slot); |
552 | break; | 562 | break; |
553 | case INT_POWER_FAULT: | 563 | case INT_POWER_FAULT: |
554 | dbg("%s: power fault\n", __func__); | 564 | ctrl_dbg(p_slot->ctrl, "%s: Power fault\n", __func__); |
555 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | 565 | p_slot->hpc_ops->set_attention_status(p_slot, 1); |
556 | p_slot->hpc_ops->green_led_off(p_slot); | 566 | p_slot->hpc_ops->green_led_off(p_slot); |
557 | break; | 567 | break; |
@@ -569,22 +579,24 @@ static int shpchp_enable_slot (struct slot *p_slot) | |||
569 | { | 579 | { |
570 | u8 getstatus = 0; | 580 | u8 getstatus = 0; |
571 | int rc, retval = -ENODEV; | 581 | int rc, retval = -ENODEV; |
582 | struct controller *ctrl = p_slot->ctrl; | ||
572 | 583 | ||
573 | /* Check to see if (latch closed, card present, power off) */ | 584 | /* Check to see if (latch closed, card present, power off) */ |
574 | mutex_lock(&p_slot->ctrl->crit_sect); | 585 | mutex_lock(&p_slot->ctrl->crit_sect); |
575 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 586 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
576 | if (rc || !getstatus) { | 587 | if (rc || !getstatus) { |
577 | info("No adapter on slot(%s)\n", p_slot->name); | 588 | ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); |
578 | goto out; | 589 | goto out; |
579 | } | 590 | } |
580 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 591 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
581 | if (rc || getstatus) { | 592 | if (rc || getstatus) { |
582 | info("Latch open on slot(%s)\n", p_slot->name); | 593 | ctrl_info(ctrl, "Latch open on slot(%s)\n", slot_name(p_slot)); |
583 | goto out; | 594 | goto out; |
584 | } | 595 | } |
585 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 596 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
586 | if (rc || getstatus) { | 597 | if (rc || getstatus) { |
587 | info("Already enabled on slot(%s)\n", p_slot->name); | 598 | ctrl_info(ctrl, "Already enabled on slot(%s)\n", |
599 | slot_name(p_slot)); | ||
588 | goto out; | 600 | goto out; |
589 | } | 601 | } |
590 | 602 | ||
@@ -593,7 +605,7 @@ static int shpchp_enable_slot (struct slot *p_slot) | |||
593 | /* We have to save the presence info for these slots */ | 605 | /* We have to save the presence info for these slots */ |
594 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); | 606 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
595 | p_slot->hpc_ops->get_power_status(p_slot, &(p_slot->pwr_save)); | 607 | p_slot->hpc_ops->get_power_status(p_slot, &(p_slot->pwr_save)); |
596 | dbg("%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save); | 608 | ctrl_dbg(ctrl, "%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save); |
597 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 609 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
598 | 610 | ||
599 | if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || | 611 | if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || |
@@ -624,6 +636,7 @@ static int shpchp_disable_slot (struct slot *p_slot) | |||
624 | { | 636 | { |
625 | u8 getstatus = 0; | 637 | u8 getstatus = 0; |
626 | int rc, retval = -ENODEV; | 638 | int rc, retval = -ENODEV; |
639 | struct controller *ctrl = p_slot->ctrl; | ||
627 | 640 | ||
628 | if (!p_slot->ctrl) | 641 | if (!p_slot->ctrl) |
629 | return -ENODEV; | 642 | return -ENODEV; |
@@ -633,17 +646,18 @@ static int shpchp_disable_slot (struct slot *p_slot) | |||
633 | 646 | ||
634 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 647 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
635 | if (rc || !getstatus) { | 648 | if (rc || !getstatus) { |
636 | info("No adapter on slot(%s)\n", p_slot->name); | 649 | ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); |
637 | goto out; | 650 | goto out; |
638 | } | 651 | } |
639 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 652 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
640 | if (rc || getstatus) { | 653 | if (rc || getstatus) { |
641 | info("Latch open on slot(%s)\n", p_slot->name); | 654 | ctrl_info(ctrl, "Latch open on slot(%s)\n", slot_name(p_slot)); |
642 | goto out; | 655 | goto out; |
643 | } | 656 | } |
644 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 657 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
645 | if (rc || !getstatus) { | 658 | if (rc || !getstatus) { |
646 | info("Already disabled slot(%s)\n", p_slot->name); | 659 | ctrl_info(ctrl, "Already disabled on slot(%s)\n", |
660 | slot_name(p_slot)); | ||
647 | goto out; | 661 | goto out; |
648 | } | 662 | } |
649 | 663 | ||
@@ -657,6 +671,7 @@ static int shpchp_disable_slot (struct slot *p_slot) | |||
657 | int shpchp_sysfs_enable_slot(struct slot *p_slot) | 671 | int shpchp_sysfs_enable_slot(struct slot *p_slot) |
658 | { | 672 | { |
659 | int retval = -ENODEV; | 673 | int retval = -ENODEV; |
674 | struct controller *ctrl = p_slot->ctrl; | ||
660 | 675 | ||
661 | mutex_lock(&p_slot->lock); | 676 | mutex_lock(&p_slot->lock); |
662 | switch (p_slot->state) { | 677 | switch (p_slot->state) { |
@@ -670,15 +685,17 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot) | |||
670 | p_slot->state = STATIC_STATE; | 685 | p_slot->state = STATIC_STATE; |
671 | break; | 686 | break; |
672 | case POWERON_STATE: | 687 | case POWERON_STATE: |
673 | info("Slot %s is already in powering on state\n", | 688 | ctrl_info(ctrl, "Slot %s is already in powering on state\n", |
674 | p_slot->name); | 689 | slot_name(p_slot)); |
675 | break; | 690 | break; |
676 | case BLINKINGOFF_STATE: | 691 | case BLINKINGOFF_STATE: |
677 | case POWEROFF_STATE: | 692 | case POWEROFF_STATE: |
678 | info("Already enabled on slot %s\n", p_slot->name); | 693 | ctrl_info(ctrl, "Already enabled on slot %s\n", |
694 | slot_name(p_slot)); | ||
679 | break; | 695 | break; |
680 | default: | 696 | default: |
681 | err("Not a valid state on slot %s\n", p_slot->name); | 697 | ctrl_err(ctrl, "Not a valid state on slot %s\n", |
698 | slot_name(p_slot)); | ||
682 | break; | 699 | break; |
683 | } | 700 | } |
684 | mutex_unlock(&p_slot->lock); | 701 | mutex_unlock(&p_slot->lock); |
@@ -689,6 +706,7 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot) | |||
689 | int shpchp_sysfs_disable_slot(struct slot *p_slot) | 706 | int shpchp_sysfs_disable_slot(struct slot *p_slot) |
690 | { | 707 | { |
691 | int retval = -ENODEV; | 708 | int retval = -ENODEV; |
709 | struct controller *ctrl = p_slot->ctrl; | ||
692 | 710 | ||
693 | mutex_lock(&p_slot->lock); | 711 | mutex_lock(&p_slot->lock); |
694 | switch (p_slot->state) { | 712 | switch (p_slot->state) { |
@@ -702,15 +720,17 @@ int shpchp_sysfs_disable_slot(struct slot *p_slot) | |||
702 | p_slot->state = STATIC_STATE; | 720 | p_slot->state = STATIC_STATE; |
703 | break; | 721 | break; |
704 | case POWEROFF_STATE: | 722 | case POWEROFF_STATE: |
705 | info("Slot %s is already in powering off state\n", | 723 | ctrl_info(ctrl, "Slot %s is already in powering off state\n", |
706 | p_slot->name); | 724 | slot_name(p_slot)); |
707 | break; | 725 | break; |
708 | case BLINKINGON_STATE: | 726 | case BLINKINGON_STATE: |
709 | case POWERON_STATE: | 727 | case POWERON_STATE: |
710 | info("Already disabled on slot %s\n", p_slot->name); | 728 | ctrl_info(ctrl, "Already disabled on slot %s\n", |
729 | slot_name(p_slot)); | ||
711 | break; | 730 | break; |
712 | default: | 731 | default: |
713 | err("Not a valid state on slot %s\n", p_slot->name); | 732 | ctrl_err(ctrl, "Not a valid state on slot %s\n", |
733 | slot_name(p_slot)); | ||
714 | break; | 734 | break; |
715 | } | 735 | } |
716 | mutex_unlock(&p_slot->lock); | 736 | mutex_unlock(&p_slot->lock); |
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index 7a0bff364cd..86dc3984776 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c | |||
@@ -300,10 +300,10 @@ static inline int shpc_wait_cmd(struct controller *ctrl) | |||
300 | !is_ctrl_busy(ctrl), timeout); | 300 | !is_ctrl_busy(ctrl), timeout); |
301 | if (!rc && is_ctrl_busy(ctrl)) { | 301 | if (!rc && is_ctrl_busy(ctrl)) { |
302 | retval = -EIO; | 302 | retval = -EIO; |
303 | err("Command not completed in 1000 msec\n"); | 303 | ctrl_err(ctrl, "Command not completed in 1000 msec\n"); |
304 | } else if (rc < 0) { | 304 | } else if (rc < 0) { |
305 | retval = -EINTR; | 305 | retval = -EINTR; |
306 | info("Command was interrupted by a signal\n"); | 306 | ctrl_info(ctrl, "Command was interrupted by a signal\n"); |
307 | } | 307 | } |
308 | 308 | ||
309 | return retval; | 309 | return retval; |
@@ -320,15 +320,14 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
320 | 320 | ||
321 | if (!shpc_poll_ctrl_busy(ctrl)) { | 321 | if (!shpc_poll_ctrl_busy(ctrl)) { |
322 | /* After 1 sec and and the controller is still busy */ | 322 | /* After 1 sec and and the controller is still busy */ |
323 | err("%s : Controller is still busy after 1 sec.\n", | 323 | ctrl_err(ctrl, "Controller is still busy after 1 sec\n"); |
324 | __func__); | ||
325 | retval = -EBUSY; | 324 | retval = -EBUSY; |
326 | goto out; | 325 | goto out; |
327 | } | 326 | } |
328 | 327 | ||
329 | ++t_slot; | 328 | ++t_slot; |
330 | temp_word = (t_slot << 8) | (cmd & 0xFF); | 329 | temp_word = (t_slot << 8) | (cmd & 0xFF); |
331 | dbg("%s: t_slot %x cmd %x\n", __func__, t_slot, cmd); | 330 | ctrl_dbg(ctrl, "%s: t_slot %x cmd %x\n", __func__, t_slot, cmd); |
332 | 331 | ||
333 | /* To make sure the Controller Busy bit is 0 before we send out the | 332 | /* To make sure the Controller Busy bit is 0 before we send out the |
334 | * command. | 333 | * command. |
@@ -344,8 +343,9 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) | |||
344 | 343 | ||
345 | cmd_status = hpc_check_cmd_status(slot->ctrl); | 344 | cmd_status = hpc_check_cmd_status(slot->ctrl); |
346 | if (cmd_status) { | 345 | if (cmd_status) { |
347 | err("%s: Failed to issued command 0x%x (error code = %d)\n", | 346 | ctrl_err(ctrl, |
348 | __func__, cmd, cmd_status); | 347 | "Failed to issued command 0x%x (error code = %d)\n", |
348 | cmd, cmd_status); | ||
349 | retval = -EIO; | 349 | retval = -EIO; |
350 | } | 350 | } |
351 | out: | 351 | out: |
@@ -364,15 +364,15 @@ static int hpc_check_cmd_status(struct controller *ctrl) | |||
364 | break; | 364 | break; |
365 | case 1: | 365 | case 1: |
366 | retval = SWITCH_OPEN; | 366 | retval = SWITCH_OPEN; |
367 | err("%s: Switch opened!\n", __func__); | 367 | ctrl_err(ctrl, "Switch opened!\n"); |
368 | break; | 368 | break; |
369 | case 2: | 369 | case 2: |
370 | retval = INVALID_CMD; | 370 | retval = INVALID_CMD; |
371 | err("%s: Invalid HPC command!\n", __func__); | 371 | ctrl_err(ctrl, "Invalid HPC command!\n"); |
372 | break; | 372 | break; |
373 | case 4: | 373 | case 4: |
374 | retval = INVALID_SPEED_MODE; | 374 | retval = INVALID_SPEED_MODE; |
375 | err("%s: Invalid bus speed/mode!\n", __func__); | 375 | ctrl_err(ctrl, "Invalid bus speed/mode!\n"); |
376 | break; | 376 | break; |
377 | default: | 377 | default: |
378 | retval = cmd_status; | 378 | retval = cmd_status; |
@@ -483,8 +483,8 @@ static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) | |||
483 | return -ENODEV; | 483 | return -ENODEV; |
484 | } | 484 | } |
485 | 485 | ||
486 | dbg("%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n", | 486 | ctrl_dbg(ctrl, "%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n", |
487 | __func__, slot_reg, pcix_cap, m66_cap); | 487 | __func__, slot_reg, pcix_cap, m66_cap); |
488 | 488 | ||
489 | switch (pcix_cap) { | 489 | switch (pcix_cap) { |
490 | case 0x0: | 490 | case 0x0: |
@@ -509,7 +509,7 @@ static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) | |||
509 | break; | 509 | break; |
510 | } | 510 | } |
511 | 511 | ||
512 | dbg("Adapter speed = %d\n", *value); | 512 | ctrl_dbg(ctrl, "Adapter speed = %d\n", *value); |
513 | return retval; | 513 | return retval; |
514 | } | 514 | } |
515 | 515 | ||
@@ -526,7 +526,7 @@ static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode) | |||
526 | retval = -1; | 526 | retval = -1; |
527 | } | 527 | } |
528 | 528 | ||
529 | dbg("Mode 1 ECC cap = %d\n", *mode); | 529 | ctrl_dbg(ctrl, "Mode 1 ECC cap = %d\n", *mode); |
530 | return retval; | 530 | return retval; |
531 | } | 531 | } |
532 | 532 | ||
@@ -629,7 +629,7 @@ static int hpc_power_on_slot(struct slot * slot) | |||
629 | 629 | ||
630 | retval = shpc_write_cmd(slot, slot->hp_slot, SET_SLOT_PWR); | 630 | retval = shpc_write_cmd(slot, slot->hp_slot, SET_SLOT_PWR); |
631 | if (retval) | 631 | if (retval) |
632 | err("%s: Write command failed!\n", __func__); | 632 | ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__); |
633 | 633 | ||
634 | return retval; | 634 | return retval; |
635 | } | 635 | } |
@@ -642,7 +642,7 @@ static int hpc_slot_enable(struct slot * slot) | |||
642 | retval = shpc_write_cmd(slot, slot->hp_slot, | 642 | retval = shpc_write_cmd(slot, slot->hp_slot, |
643 | SET_SLOT_ENABLE | SET_PWR_BLINK | SET_ATTN_OFF); | 643 | SET_SLOT_ENABLE | SET_PWR_BLINK | SET_ATTN_OFF); |
644 | if (retval) | 644 | if (retval) |
645 | err("%s: Write command failed!\n", __func__); | 645 | ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__); |
646 | 646 | ||
647 | return retval; | 647 | return retval; |
648 | } | 648 | } |
@@ -655,7 +655,7 @@ static int hpc_slot_disable(struct slot * slot) | |||
655 | retval = shpc_write_cmd(slot, slot->hp_slot, | 655 | retval = shpc_write_cmd(slot, slot->hp_slot, |
656 | SET_SLOT_DISABLE | SET_PWR_OFF | SET_ATTN_ON); | 656 | SET_SLOT_DISABLE | SET_PWR_OFF | SET_ATTN_ON); |
657 | if (retval) | 657 | if (retval) |
658 | err("%s: Write command failed!\n", __func__); | 658 | ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__); |
659 | 659 | ||
660 | return retval; | 660 | return retval; |
661 | } | 661 | } |
@@ -719,7 +719,7 @@ static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value) | |||
719 | 719 | ||
720 | retval = shpc_write_cmd(slot, 0, cmd); | 720 | retval = shpc_write_cmd(slot, 0, cmd); |
721 | if (retval) | 721 | if (retval) |
722 | err("%s: Write command failed!\n", __func__); | 722 | ctrl_err(ctrl, "%s: Write command failed!\n", __func__); |
723 | 723 | ||
724 | return retval; | 724 | return retval; |
725 | } | 725 | } |
@@ -735,7 +735,7 @@ static irqreturn_t shpc_isr(int irq, void *dev_id) | |||
735 | if (!intr_loc) | 735 | if (!intr_loc) |
736 | return IRQ_NONE; | 736 | return IRQ_NONE; |
737 | 737 | ||
738 | dbg("%s: intr_loc = %x\n",__func__, intr_loc); | 738 | ctrl_dbg(ctrl, "%s: intr_loc = %x\n", __func__, intr_loc); |
739 | 739 | ||
740 | if(!shpchp_poll_mode) { | 740 | if(!shpchp_poll_mode) { |
741 | /* | 741 | /* |
@@ -748,7 +748,7 @@ static irqreturn_t shpc_isr(int irq, void *dev_id) | |||
748 | shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int); | 748 | shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int); |
749 | 749 | ||
750 | intr_loc2 = shpc_readl(ctrl, INTR_LOC); | 750 | intr_loc2 = shpc_readl(ctrl, INTR_LOC); |
751 | dbg("%s: intr_loc2 = %x\n",__func__, intr_loc2); | 751 | ctrl_dbg(ctrl, "%s: intr_loc2 = %x\n", __func__, intr_loc2); |
752 | } | 752 | } |
753 | 753 | ||
754 | if (intr_loc & CMD_INTR_PENDING) { | 754 | if (intr_loc & CMD_INTR_PENDING) { |
@@ -773,8 +773,8 @@ static irqreturn_t shpc_isr(int irq, void *dev_id) | |||
773 | continue; | 773 | continue; |
774 | 774 | ||
775 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); | 775 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); |
776 | dbg("%s: Slot %x with intr, slot register = %x\n", | 776 | ctrl_dbg(ctrl, "Slot %x with intr, slot register = %x\n", |
777 | __func__, hp_slot, slot_reg); | 777 | hp_slot, slot_reg); |
778 | 778 | ||
779 | if (slot_reg & MRL_CHANGE_DETECTED) | 779 | if (slot_reg & MRL_CHANGE_DETECTED) |
780 | shpchp_handle_switch_change(hp_slot, ctrl); | 780 | shpchp_handle_switch_change(hp_slot, ctrl); |
@@ -843,7 +843,7 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) | |||
843 | } | 843 | } |
844 | 844 | ||
845 | *value = bus_speed; | 845 | *value = bus_speed; |
846 | dbg("Max bus speed = %d\n", bus_speed); | 846 | ctrl_dbg(ctrl, "Max bus speed = %d\n", bus_speed); |
847 | 847 | ||
848 | return retval; | 848 | return retval; |
849 | } | 849 | } |
@@ -911,7 +911,7 @@ static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value) | |||
911 | break; | 911 | break; |
912 | } | 912 | } |
913 | 913 | ||
914 | dbg("Current bus speed = %d\n", bus_speed); | 914 | ctrl_dbg(ctrl, "Current bus speed = %d\n", bus_speed); |
915 | return retval; | 915 | return retval; |
916 | } | 916 | } |
917 | 917 | ||
@@ -949,6 +949,7 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
949 | u8 i; | 949 | u8 i; |
950 | 950 | ||
951 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ | 951 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ |
952 | ctrl_dbg(ctrl, "Hotplug Controller:\n"); | ||
952 | 953 | ||
953 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == | 954 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == |
954 | PCI_DEVICE_ID_AMD_GOLAM_7450)) { | 955 | PCI_DEVICE_ID_AMD_GOLAM_7450)) { |
@@ -958,34 +959,33 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
958 | } else { | 959 | } else { |
959 | ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC); | 960 | ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC); |
960 | if (!ctrl->cap_offset) { | 961 | if (!ctrl->cap_offset) { |
961 | err("%s : cap_offset == 0\n", __func__); | 962 | ctrl_err(ctrl, "Cannot find PCI capability\n"); |
962 | goto abort; | 963 | goto abort; |
963 | } | 964 | } |
964 | dbg("%s: cap_offset = %x\n", __func__, ctrl->cap_offset); | 965 | ctrl_dbg(ctrl, " cap_offset = %x\n", ctrl->cap_offset); |
965 | 966 | ||
966 | rc = shpc_indirect_read(ctrl, 0, &shpc_base_offset); | 967 | rc = shpc_indirect_read(ctrl, 0, &shpc_base_offset); |
967 | if (rc) { | 968 | if (rc) { |
968 | err("%s: cannot read base_offset\n", __func__); | 969 | ctrl_err(ctrl, "Cannot read base_offset\n"); |
969 | goto abort; | 970 | goto abort; |
970 | } | 971 | } |
971 | 972 | ||
972 | rc = shpc_indirect_read(ctrl, 3, &tempdword); | 973 | rc = shpc_indirect_read(ctrl, 3, &tempdword); |
973 | if (rc) { | 974 | if (rc) { |
974 | err("%s: cannot read slot config\n", __func__); | 975 | ctrl_err(ctrl, "Cannot read slot config\n"); |
975 | goto abort; | 976 | goto abort; |
976 | } | 977 | } |
977 | num_slots = tempdword & SLOT_NUM; | 978 | num_slots = tempdword & SLOT_NUM; |
978 | dbg("%s: num_slots (indirect) %x\n", __func__, num_slots); | 979 | ctrl_dbg(ctrl, " num_slots (indirect) %x\n", num_slots); |
979 | 980 | ||
980 | for (i = 0; i < 9 + num_slots; i++) { | 981 | for (i = 0; i < 9 + num_slots; i++) { |
981 | rc = shpc_indirect_read(ctrl, i, &tempdword); | 982 | rc = shpc_indirect_read(ctrl, i, &tempdword); |
982 | if (rc) { | 983 | if (rc) { |
983 | err("%s: cannot read creg (index = %d)\n", | 984 | ctrl_err(ctrl, |
984 | __func__, i); | 985 | "Cannot read creg (index = %d)\n", i); |
985 | goto abort; | 986 | goto abort; |
986 | } | 987 | } |
987 | dbg("%s: offset %d: value %x\n", __func__,i, | 988 | ctrl_dbg(ctrl, " offset %d: value %x\n", i, tempdword); |
988 | tempdword); | ||
989 | } | 989 | } |
990 | 990 | ||
991 | ctrl->mmio_base = | 991 | ctrl->mmio_base = |
@@ -993,30 +993,31 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
993 | ctrl->mmio_size = 0x24 + 0x4 * num_slots; | 993 | ctrl->mmio_size = 0x24 + 0x4 * num_slots; |
994 | } | 994 | } |
995 | 995 | ||
996 | info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, | 996 | ctrl_info(ctrl, "HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", |
997 | pdev->subsystem_device); | 997 | pdev->vendor, pdev->device, pdev->subsystem_vendor, |
998 | pdev->subsystem_device); | ||
998 | 999 | ||
999 | rc = pci_enable_device(pdev); | 1000 | rc = pci_enable_device(pdev); |
1000 | if (rc) { | 1001 | if (rc) { |
1001 | err("%s: pci_enable_device failed\n", __func__); | 1002 | ctrl_err(ctrl, "pci_enable_device failed\n"); |
1002 | goto abort; | 1003 | goto abort; |
1003 | } | 1004 | } |
1004 | 1005 | ||
1005 | if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { | 1006 | if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { |
1006 | err("%s: cannot reserve MMIO region\n", __func__); | 1007 | ctrl_err(ctrl, "Cannot reserve MMIO region\n"); |
1007 | rc = -1; | 1008 | rc = -1; |
1008 | goto abort; | 1009 | goto abort; |
1009 | } | 1010 | } |
1010 | 1011 | ||
1011 | ctrl->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size); | 1012 | ctrl->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size); |
1012 | if (!ctrl->creg) { | 1013 | if (!ctrl->creg) { |
1013 | err("%s: cannot remap MMIO region %lx @ %lx\n", __func__, | 1014 | ctrl_err(ctrl, "Cannot remap MMIO region %lx @ %lx\n", |
1014 | ctrl->mmio_size, ctrl->mmio_base); | 1015 | ctrl->mmio_size, ctrl->mmio_base); |
1015 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); | 1016 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); |
1016 | rc = -1; | 1017 | rc = -1; |
1017 | goto abort; | 1018 | goto abort; |
1018 | } | 1019 | } |
1019 | dbg("%s: ctrl->creg %p\n", __func__, ctrl->creg); | 1020 | ctrl_dbg(ctrl, "ctrl->creg %p\n", ctrl->creg); |
1020 | 1021 | ||
1021 | mutex_init(&ctrl->crit_sect); | 1022 | mutex_init(&ctrl->crit_sect); |
1022 | mutex_init(&ctrl->cmd_lock); | 1023 | mutex_init(&ctrl->cmd_lock); |
@@ -1035,21 +1036,21 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
1035 | 1036 | ||
1036 | /* Mask Global Interrupt Mask & Command Complete Interrupt Mask */ | 1037 | /* Mask Global Interrupt Mask & Command Complete Interrupt Mask */ |
1037 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); | 1038 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
1038 | dbg("%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); | 1039 | ctrl_dbg(ctrl, "SERR_INTR_ENABLE = %x\n", tempdword); |
1039 | tempdword |= (GLOBAL_INTR_MASK | GLOBAL_SERR_MASK | | 1040 | tempdword |= (GLOBAL_INTR_MASK | GLOBAL_SERR_MASK | |
1040 | COMMAND_INTR_MASK | ARBITER_SERR_MASK); | 1041 | COMMAND_INTR_MASK | ARBITER_SERR_MASK); |
1041 | tempdword &= ~SERR_INTR_RSVDZ_MASK; | 1042 | tempdword &= ~SERR_INTR_RSVDZ_MASK; |
1042 | shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); | 1043 | shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); |
1043 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); | 1044 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
1044 | dbg("%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); | 1045 | ctrl_dbg(ctrl, "SERR_INTR_ENABLE = %x\n", tempdword); |
1045 | 1046 | ||
1046 | /* Mask the MRL sensor SERR Mask of individual slot in | 1047 | /* Mask the MRL sensor SERR Mask of individual slot in |
1047 | * Slot SERR-INT Mask & clear all the existing event if any | 1048 | * Slot SERR-INT Mask & clear all the existing event if any |
1048 | */ | 1049 | */ |
1049 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { | 1050 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { |
1050 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); | 1051 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); |
1051 | dbg("%s: Default Logical Slot Register %d value %x\n", __func__, | 1052 | ctrl_dbg(ctrl, "Default Logical Slot Register %d value %x\n", |
1052 | hp_slot, slot_reg); | 1053 | hp_slot, slot_reg); |
1053 | slot_reg |= (PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | | 1054 | slot_reg |= (PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | |
1054 | BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | | 1055 | BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | |
1055 | CON_PFAULT_INTR_MASK | MRL_CHANGE_SERR_MASK | | 1056 | CON_PFAULT_INTR_MASK | MRL_CHANGE_SERR_MASK | |
@@ -1066,24 +1067,24 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
1066 | /* Installs the interrupt handler */ | 1067 | /* Installs the interrupt handler */ |
1067 | rc = pci_enable_msi(pdev); | 1068 | rc = pci_enable_msi(pdev); |
1068 | if (rc) { | 1069 | if (rc) { |
1069 | info("Can't get msi for the hotplug controller\n"); | 1070 | ctrl_info(ctrl, |
1070 | info("Use INTx for the hotplug controller\n"); | 1071 | "Can't get msi for the hotplug controller\n"); |
1072 | ctrl_info(ctrl, | ||
1073 | "Use INTx for the hotplug controller\n"); | ||
1071 | } | 1074 | } |
1072 | 1075 | ||
1073 | rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED, | 1076 | rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED, |
1074 | MY_NAME, (void *)ctrl); | 1077 | MY_NAME, (void *)ctrl); |
1075 | dbg("%s: request_irq %d for hpc%d (returns %d)\n", | 1078 | ctrl_dbg(ctrl, "request_irq %d for hpc%d (returns %d)\n", |
1076 | __func__, ctrl->pci_dev->irq, | 1079 | ctrl->pci_dev->irq, |
1077 | atomic_read(&shpchp_num_controllers), rc); | 1080 | atomic_read(&shpchp_num_controllers), rc); |
1078 | if (rc) { | 1081 | if (rc) { |
1079 | err("Can't get irq %d for the hotplug controller\n", | 1082 | ctrl_err(ctrl, "Can't get irq %d for the hotplug " |
1080 | ctrl->pci_dev->irq); | 1083 | "controller\n", ctrl->pci_dev->irq); |
1081 | goto abort_iounmap; | 1084 | goto abort_iounmap; |
1082 | } | 1085 | } |
1083 | } | 1086 | } |
1084 | dbg("%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", __func__, | 1087 | ctrl_dbg(ctrl, "HPC at %s irq=%x\n", pci_name(pdev), pdev->irq); |
1085 | pdev->bus->number, PCI_SLOT(pdev->devfn), | ||
1086 | PCI_FUNC(pdev->devfn), pdev->irq); | ||
1087 | 1088 | ||
1088 | /* | 1089 | /* |
1089 | * If this is the first controller to be initialized, | 1090 | * If this is the first controller to be initialized, |
@@ -1102,8 +1103,8 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
1102 | */ | 1103 | */ |
1103 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { | 1104 | for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { |
1104 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); | 1105 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); |
1105 | dbg("%s: Default Logical Slot Register %d value %x\n", __func__, | 1106 | ctrl_dbg(ctrl, "Default Logical Slot Register %d value %x\n", |
1106 | hp_slot, slot_reg); | 1107 | hp_slot, slot_reg); |
1107 | slot_reg &= ~(PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | | 1108 | slot_reg &= ~(PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | |
1108 | BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | | 1109 | BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | |
1109 | CON_PFAULT_INTR_MASK | SLOT_REG_RSVDZ_MASK); | 1110 | CON_PFAULT_INTR_MASK | SLOT_REG_RSVDZ_MASK); |
@@ -1116,7 +1117,7 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev) | |||
1116 | SERR_INTR_RSVDZ_MASK); | 1117 | SERR_INTR_RSVDZ_MASK); |
1117 | shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); | 1118 | shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); |
1118 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); | 1119 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
1119 | dbg("%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); | 1120 | ctrl_dbg(ctrl, "SERR_INTR_ENABLE = %x\n", tempdword); |
1120 | } | 1121 | } |
1121 | 1122 | ||
1122 | return 0; | 1123 | return 0; |
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index 3fc4ec0eea0..138f161becc 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c | |||
@@ -49,9 +49,7 @@ static void program_fw_provided_values(struct pci_dev *dev) | |||
49 | /* use default values if we can't get them from firmware */ | 49 | /* use default values if we can't get them from firmware */ |
50 | if (get_hp_params_from_firmware(dev, &hpp) || | 50 | if (get_hp_params_from_firmware(dev, &hpp) || |
51 | !hpp.t0 || (hpp.t0->revision > 1)) { | 51 | !hpp.t0 || (hpp.t0->revision > 1)) { |
52 | printk(KERN_WARNING | 52 | warn("Could not get hotplug parameters. Use defaults\n"); |
53 | "%s: Could not get hotplug parameters. Use defaults\n", | ||
54 | __func__); | ||
55 | hpp.t0 = &hpp.type0_data; | 53 | hpp.t0 = &hpp.type0_data; |
56 | hpp.t0->revision = 0; | 54 | hpp.t0->revision = 0; |
57 | hpp.t0->cache_line_size = 8; | 55 | hpp.t0->cache_line_size = 8; |
@@ -101,18 +99,20 @@ int __ref shpchp_configure_device(struct slot *p_slot) | |||
101 | struct pci_dev *dev; | 99 | struct pci_dev *dev; |
102 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; | 100 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; |
103 | int num, fn; | 101 | int num, fn; |
102 | struct controller *ctrl = p_slot->ctrl; | ||
104 | 103 | ||
105 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); | 104 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); |
106 | if (dev) { | 105 | if (dev) { |
107 | err("Device %s already exists at %x:%x, cannot hot-add\n", | 106 | ctrl_err(ctrl, "Device %s already exists " |
108 | pci_name(dev), p_slot->bus, p_slot->device); | 107 | "at %04x:%02x:%02x, cannot hot-add\n", pci_name(dev), |
108 | pci_domain_nr(parent), p_slot->bus, p_slot->device); | ||
109 | pci_dev_put(dev); | 109 | pci_dev_put(dev); |
110 | return -EINVAL; | 110 | return -EINVAL; |
111 | } | 111 | } |
112 | 112 | ||
113 | num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); | 113 | num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); |
114 | if (num == 0) { | 114 | if (num == 0) { |
115 | err("No new device found\n"); | 115 | ctrl_err(ctrl, "No new device found\n"); |
116 | return -ENODEV; | 116 | return -ENODEV; |
117 | } | 117 | } |
118 | 118 | ||
@@ -121,8 +121,8 @@ int __ref shpchp_configure_device(struct slot *p_slot) | |||
121 | if (!dev) | 121 | if (!dev) |
122 | continue; | 122 | continue; |
123 | if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { | 123 | if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { |
124 | err("Cannot hot-add display device %s\n", | 124 | ctrl_err(ctrl, "Cannot hot-add display device %s\n", |
125 | pci_name(dev)); | 125 | pci_name(dev)); |
126 | pci_dev_put(dev); | 126 | pci_dev_put(dev); |
127 | continue; | 127 | continue; |
128 | } | 128 | } |
@@ -138,14 +138,15 @@ int __ref shpchp_configure_device(struct slot *p_slot) | |||
138 | break; | 138 | break; |
139 | } | 139 | } |
140 | if (busnr >= end) { | 140 | if (busnr >= end) { |
141 | err("No free bus for hot-added bridge\n"); | 141 | ctrl_err(ctrl, |
142 | "No free bus for hot-added bridge\n"); | ||
142 | pci_dev_put(dev); | 143 | pci_dev_put(dev); |
143 | continue; | 144 | continue; |
144 | } | 145 | } |
145 | child = pci_add_new_bus(parent, dev, busnr); | 146 | child = pci_add_new_bus(parent, dev, busnr); |
146 | if (!child) { | 147 | if (!child) { |
147 | err("Cannot add new bus for %s\n", | 148 | ctrl_err(ctrl, "Cannot add new bus for %s\n", |
148 | pci_name(dev)); | 149 | pci_name(dev)); |
149 | pci_dev_put(dev); | 150 | pci_dev_put(dev); |
150 | continue; | 151 | continue; |
151 | } | 152 | } |
@@ -168,8 +169,10 @@ int shpchp_unconfigure_device(struct slot *p_slot) | |||
168 | int j; | 169 | int j; |
169 | u8 bctl = 0; | 170 | u8 bctl = 0; |
170 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; | 171 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; |
172 | struct controller *ctrl = p_slot->ctrl; | ||
171 | 173 | ||
172 | dbg("%s: bus/dev = %x/%x\n", __func__, p_slot->bus, p_slot->device); | 174 | ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n", |
175 | __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device); | ||
173 | 176 | ||
174 | for (j=0; j<8 ; j++) { | 177 | for (j=0; j<8 ; j++) { |
175 | struct pci_dev* temp = pci_get_slot(parent, | 178 | struct pci_dev* temp = pci_get_slot(parent, |
@@ -177,16 +180,17 @@ int shpchp_unconfigure_device(struct slot *p_slot) | |||
177 | if (!temp) | 180 | if (!temp) |
178 | continue; | 181 | continue; |
179 | if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { | 182 | if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { |
180 | err("Cannot remove display device %s\n", | 183 | ctrl_err(ctrl, "Cannot remove display device %s\n", |
181 | pci_name(temp)); | 184 | pci_name(temp)); |
182 | pci_dev_put(temp); | 185 | pci_dev_put(temp); |
183 | continue; | 186 | continue; |
184 | } | 187 | } |
185 | if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | 188 | if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
186 | pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); | 189 | pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); |
187 | if (bctl & PCI_BRIDGE_CTL_VGA) { | 190 | if (bctl & PCI_BRIDGE_CTL_VGA) { |
188 | err("Cannot remove display device %s\n", | 191 | ctrl_err(ctrl, |
189 | pci_name(temp)); | 192 | "Cannot remove display device %s\n", |
193 | pci_name(temp)); | ||
190 | pci_dev_put(temp); | 194 | pci_dev_put(temp); |
191 | continue; | 195 | continue; |
192 | } | 196 | } |
diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c index 279c940a003..bf7d6ce9bbb 100644 --- a/drivers/pci/htirq.c +++ b/drivers/pci/htirq.c | |||
@@ -126,7 +126,8 @@ int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update) | |||
126 | cfg->msg.address_hi = 0xffffffff; | 126 | cfg->msg.address_hi = 0xffffffff; |
127 | 127 | ||
128 | irq = create_irq(); | 128 | irq = create_irq(); |
129 | if (irq < 0) { | 129 | |
130 | if (irq <= 0) { | ||
130 | kfree(cfg); | 131 | kfree(cfg); |
131 | return -EBUSY; | 132 | return -EBUSY; |
132 | } | 133 | } |
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index fc5f2dbf532..a2692724b68 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * Author: Ashok Raj <ashok.raj@intel.com> | 18 | * Author: Ashok Raj <ashok.raj@intel.com> |
19 | * Author: Shaohua Li <shaohua.li@intel.com> | 19 | * Author: Shaohua Li <shaohua.li@intel.com> |
20 | * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 20 | * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> |
21 | * Author: Fenghua Yu <fenghua.yu@intel.com> | ||
21 | */ | 22 | */ |
22 | 23 | ||
23 | #include <linux/init.h> | 24 | #include <linux/init.h> |
@@ -35,11 +36,13 @@ | |||
35 | #include <linux/timer.h> | 36 | #include <linux/timer.h> |
36 | #include <linux/iova.h> | 37 | #include <linux/iova.h> |
37 | #include <linux/intel-iommu.h> | 38 | #include <linux/intel-iommu.h> |
38 | #include <asm/proto.h> /* force_iommu in this header in x86-64*/ | ||
39 | #include <asm/cacheflush.h> | 39 | #include <asm/cacheflush.h> |
40 | #include <asm/iommu.h> | 40 | #include <asm/iommu.h> |
41 | #include "pci.h" | 41 | #include "pci.h" |
42 | 42 | ||
43 | #define ROOT_SIZE VTD_PAGE_SIZE | ||
44 | #define CONTEXT_SIZE VTD_PAGE_SIZE | ||
45 | |||
43 | #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) | 46 | #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) |
44 | #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) | 47 | #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) |
45 | 48 | ||
@@ -199,7 +202,7 @@ static struct context_entry * device_to_context_entry(struct intel_iommu *iommu, | |||
199 | spin_unlock_irqrestore(&iommu->lock, flags); | 202 | spin_unlock_irqrestore(&iommu->lock, flags); |
200 | return NULL; | 203 | return NULL; |
201 | } | 204 | } |
202 | __iommu_flush_cache(iommu, (void *)context, PAGE_SIZE_4K); | 205 | __iommu_flush_cache(iommu, (void *)context, CONTEXT_SIZE); |
203 | phy_addr = virt_to_phys((void *)context); | 206 | phy_addr = virt_to_phys((void *)context); |
204 | set_root_value(root, phy_addr); | 207 | set_root_value(root, phy_addr); |
205 | set_root_present(root); | 208 | set_root_present(root); |
@@ -345,7 +348,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) | |||
345 | return NULL; | 348 | return NULL; |
346 | } | 349 | } |
347 | __iommu_flush_cache(domain->iommu, tmp_page, | 350 | __iommu_flush_cache(domain->iommu, tmp_page, |
348 | PAGE_SIZE_4K); | 351 | PAGE_SIZE); |
349 | dma_set_pte_addr(*pte, virt_to_phys(tmp_page)); | 352 | dma_set_pte_addr(*pte, virt_to_phys(tmp_page)); |
350 | /* | 353 | /* |
351 | * high level table always sets r/w, last level page | 354 | * high level table always sets r/w, last level page |
@@ -408,13 +411,13 @@ static void dma_pte_clear_range(struct dmar_domain *domain, u64 start, u64 end) | |||
408 | start &= (((u64)1) << addr_width) - 1; | 411 | start &= (((u64)1) << addr_width) - 1; |
409 | end &= (((u64)1) << addr_width) - 1; | 412 | end &= (((u64)1) << addr_width) - 1; |
410 | /* in case it's partial page */ | 413 | /* in case it's partial page */ |
411 | start = PAGE_ALIGN_4K(start); | 414 | start = PAGE_ALIGN(start); |
412 | end &= PAGE_MASK_4K; | 415 | end &= PAGE_MASK; |
413 | 416 | ||
414 | /* we don't need lock here, nobody else touches the iova range */ | 417 | /* we don't need lock here, nobody else touches the iova range */ |
415 | while (start < end) { | 418 | while (start < end) { |
416 | dma_pte_clear_one(domain, start); | 419 | dma_pte_clear_one(domain, start); |
417 | start += PAGE_SIZE_4K; | 420 | start += VTD_PAGE_SIZE; |
418 | } | 421 | } |
419 | } | 422 | } |
420 | 423 | ||
@@ -468,7 +471,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu) | |||
468 | if (!root) | 471 | if (!root) |
469 | return -ENOMEM; | 472 | return -ENOMEM; |
470 | 473 | ||
471 | __iommu_flush_cache(iommu, root, PAGE_SIZE_4K); | 474 | __iommu_flush_cache(iommu, root, ROOT_SIZE); |
472 | 475 | ||
473 | spin_lock_irqsave(&iommu->lock, flags); | 476 | spin_lock_irqsave(&iommu->lock, flags); |
474 | iommu->root_entry = root; | 477 | iommu->root_entry = root; |
@@ -563,31 +566,10 @@ static int __iommu_flush_context(struct intel_iommu *iommu, | |||
563 | 566 | ||
564 | spin_unlock_irqrestore(&iommu->register_lock, flag); | 567 | spin_unlock_irqrestore(&iommu->register_lock, flag); |
565 | 568 | ||
566 | /* flush context entry will implictly flush write buffer */ | 569 | /* flush context entry will implicitly flush write buffer */ |
567 | return 0; | 570 | return 0; |
568 | } | 571 | } |
569 | 572 | ||
570 | static int inline iommu_flush_context_global(struct intel_iommu *iommu, | ||
571 | int non_present_entry_flush) | ||
572 | { | ||
573 | return __iommu_flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL, | ||
574 | non_present_entry_flush); | ||
575 | } | ||
576 | |||
577 | static int inline iommu_flush_context_domain(struct intel_iommu *iommu, u16 did, | ||
578 | int non_present_entry_flush) | ||
579 | { | ||
580 | return __iommu_flush_context(iommu, did, 0, 0, DMA_CCMD_DOMAIN_INVL, | ||
581 | non_present_entry_flush); | ||
582 | } | ||
583 | |||
584 | static int inline iommu_flush_context_device(struct intel_iommu *iommu, | ||
585 | u16 did, u16 source_id, u8 function_mask, int non_present_entry_flush) | ||
586 | { | ||
587 | return __iommu_flush_context(iommu, did, source_id, function_mask, | ||
588 | DMA_CCMD_DEVICE_INVL, non_present_entry_flush); | ||
589 | } | ||
590 | |||
591 | /* return value determine if we need a write buffer flush */ | 573 | /* return value determine if we need a write buffer flush */ |
592 | static int __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did, | 574 | static int __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did, |
593 | u64 addr, unsigned int size_order, u64 type, | 575 | u64 addr, unsigned int size_order, u64 type, |
@@ -655,37 +637,25 @@ static int __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did, | |||
655 | printk(KERN_ERR"IOMMU: flush IOTLB failed\n"); | 637 | printk(KERN_ERR"IOMMU: flush IOTLB failed\n"); |
656 | if (DMA_TLB_IAIG(val) != DMA_TLB_IIRG(type)) | 638 | if (DMA_TLB_IAIG(val) != DMA_TLB_IIRG(type)) |
657 | pr_debug("IOMMU: tlb flush request %Lx, actual %Lx\n", | 639 | pr_debug("IOMMU: tlb flush request %Lx, actual %Lx\n", |
658 | DMA_TLB_IIRG(type), DMA_TLB_IAIG(val)); | 640 | (unsigned long long)DMA_TLB_IIRG(type), |
659 | /* flush context entry will implictly flush write buffer */ | 641 | (unsigned long long)DMA_TLB_IAIG(val)); |
642 | /* flush iotlb entry will implicitly flush write buffer */ | ||
660 | return 0; | 643 | return 0; |
661 | } | 644 | } |
662 | 645 | ||
663 | static int inline iommu_flush_iotlb_global(struct intel_iommu *iommu, | ||
664 | int non_present_entry_flush) | ||
665 | { | ||
666 | return __iommu_flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH, | ||
667 | non_present_entry_flush); | ||
668 | } | ||
669 | |||
670 | static int inline iommu_flush_iotlb_dsi(struct intel_iommu *iommu, u16 did, | ||
671 | int non_present_entry_flush) | ||
672 | { | ||
673 | return __iommu_flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH, | ||
674 | non_present_entry_flush); | ||
675 | } | ||
676 | |||
677 | static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, | 646 | static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, |
678 | u64 addr, unsigned int pages, int non_present_entry_flush) | 647 | u64 addr, unsigned int pages, int non_present_entry_flush) |
679 | { | 648 | { |
680 | unsigned int mask; | 649 | unsigned int mask; |
681 | 650 | ||
682 | BUG_ON(addr & (~PAGE_MASK_4K)); | 651 | BUG_ON(addr & (~VTD_PAGE_MASK)); |
683 | BUG_ON(pages == 0); | 652 | BUG_ON(pages == 0); |
684 | 653 | ||
685 | /* Fallback to domain selective flush if no PSI support */ | 654 | /* Fallback to domain selective flush if no PSI support */ |
686 | if (!cap_pgsel_inv(iommu->cap)) | 655 | if (!cap_pgsel_inv(iommu->cap)) |
687 | return iommu_flush_iotlb_dsi(iommu, did, | 656 | return iommu->flush.flush_iotlb(iommu, did, 0, 0, |
688 | non_present_entry_flush); | 657 | DMA_TLB_DSI_FLUSH, |
658 | non_present_entry_flush); | ||
689 | 659 | ||
690 | /* | 660 | /* |
691 | * PSI requires page size to be 2 ^ x, and the base address is naturally | 661 | * PSI requires page size to be 2 ^ x, and the base address is naturally |
@@ -694,11 +664,12 @@ static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, | |||
694 | mask = ilog2(__roundup_pow_of_two(pages)); | 664 | mask = ilog2(__roundup_pow_of_two(pages)); |
695 | /* Fallback to domain selective flush if size is too big */ | 665 | /* Fallback to domain selective flush if size is too big */ |
696 | if (mask > cap_max_amask_val(iommu->cap)) | 666 | if (mask > cap_max_amask_val(iommu->cap)) |
697 | return iommu_flush_iotlb_dsi(iommu, did, | 667 | return iommu->flush.flush_iotlb(iommu, did, 0, 0, |
698 | non_present_entry_flush); | 668 | DMA_TLB_DSI_FLUSH, non_present_entry_flush); |
699 | 669 | ||
700 | return __iommu_flush_iotlb(iommu, did, addr, mask, | 670 | return iommu->flush.flush_iotlb(iommu, did, addr, mask, |
701 | DMA_TLB_PSI_FLUSH, non_present_entry_flush); | 671 | DMA_TLB_PSI_FLUSH, |
672 | non_present_entry_flush); | ||
702 | } | 673 | } |
703 | 674 | ||
704 | static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu) | 675 | static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu) |
@@ -831,7 +802,7 @@ void dmar_msi_read(int irq, struct msi_msg *msg) | |||
831 | } | 802 | } |
832 | 803 | ||
833 | static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, | 804 | static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, |
834 | u8 fault_reason, u16 source_id, u64 addr) | 805 | u8 fault_reason, u16 source_id, unsigned long long addr) |
835 | { | 806 | { |
836 | const char *reason; | 807 | const char *reason; |
837 | 808 | ||
@@ -1084,9 +1055,9 @@ static void dmar_init_reserved_ranges(void) | |||
1084 | if (!r->flags || !(r->flags & IORESOURCE_MEM)) | 1055 | if (!r->flags || !(r->flags & IORESOURCE_MEM)) |
1085 | continue; | 1056 | continue; |
1086 | addr = r->start; | 1057 | addr = r->start; |
1087 | addr &= PAGE_MASK_4K; | 1058 | addr &= PAGE_MASK; |
1088 | size = r->end - addr; | 1059 | size = r->end - addr; |
1089 | size = PAGE_ALIGN_4K(size); | 1060 | size = PAGE_ALIGN(size); |
1090 | iova = reserve_iova(&reserved_iova_list, IOVA_PFN(addr), | 1061 | iova = reserve_iova(&reserved_iova_list, IOVA_PFN(addr), |
1091 | IOVA_PFN(size + addr) - 1); | 1062 | IOVA_PFN(size + addr) - 1); |
1092 | if (!iova) | 1063 | if (!iova) |
@@ -1148,7 +1119,7 @@ static int domain_init(struct dmar_domain *domain, int guest_width) | |||
1148 | domain->pgd = (struct dma_pte *)alloc_pgtable_page(); | 1119 | domain->pgd = (struct dma_pte *)alloc_pgtable_page(); |
1149 | if (!domain->pgd) | 1120 | if (!domain->pgd) |
1150 | return -ENOMEM; | 1121 | return -ENOMEM; |
1151 | __iommu_flush_cache(iommu, domain->pgd, PAGE_SIZE_4K); | 1122 | __iommu_flush_cache(iommu, domain->pgd, PAGE_SIZE); |
1152 | return 0; | 1123 | return 0; |
1153 | } | 1124 | } |
1154 | 1125 | ||
@@ -1164,7 +1135,7 @@ static void domain_exit(struct dmar_domain *domain) | |||
1164 | /* destroy iovas */ | 1135 | /* destroy iovas */ |
1165 | put_iova_domain(&domain->iovad); | 1136 | put_iova_domain(&domain->iovad); |
1166 | end = DOMAIN_MAX_ADDR(domain->gaw); | 1137 | end = DOMAIN_MAX_ADDR(domain->gaw); |
1167 | end = end & (~PAGE_MASK_4K); | 1138 | end = end & (~PAGE_MASK); |
1168 | 1139 | ||
1169 | /* clear ptes */ | 1140 | /* clear ptes */ |
1170 | dma_pte_clear_range(domain, 0, end); | 1141 | dma_pte_clear_range(domain, 0, end); |
@@ -1204,11 +1175,13 @@ static int domain_context_mapping_one(struct dmar_domain *domain, | |||
1204 | __iommu_flush_cache(iommu, context, sizeof(*context)); | 1175 | __iommu_flush_cache(iommu, context, sizeof(*context)); |
1205 | 1176 | ||
1206 | /* it's a non-present to present mapping */ | 1177 | /* it's a non-present to present mapping */ |
1207 | if (iommu_flush_context_device(iommu, domain->id, | 1178 | if (iommu->flush.flush_context(iommu, domain->id, |
1208 | (((u16)bus) << 8) | devfn, DMA_CCMD_MASK_NOBIT, 1)) | 1179 | (((u16)bus) << 8) | devfn, DMA_CCMD_MASK_NOBIT, |
1180 | DMA_CCMD_DEVICE_INVL, 1)) | ||
1209 | iommu_flush_write_buffer(iommu); | 1181 | iommu_flush_write_buffer(iommu); |
1210 | else | 1182 | else |
1211 | iommu_flush_iotlb_dsi(iommu, 0, 0); | 1183 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH, 0); |
1184 | |||
1212 | spin_unlock_irqrestore(&iommu->lock, flags); | 1185 | spin_unlock_irqrestore(&iommu->lock, flags); |
1213 | return 0; | 1186 | return 0; |
1214 | } | 1187 | } |
@@ -1283,22 +1256,25 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova, | |||
1283 | u64 start_pfn, end_pfn; | 1256 | u64 start_pfn, end_pfn; |
1284 | struct dma_pte *pte; | 1257 | struct dma_pte *pte; |
1285 | int index; | 1258 | int index; |
1259 | int addr_width = agaw_to_width(domain->agaw); | ||
1260 | |||
1261 | hpa &= (((u64)1) << addr_width) - 1; | ||
1286 | 1262 | ||
1287 | if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0) | 1263 | if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0) |
1288 | return -EINVAL; | 1264 | return -EINVAL; |
1289 | iova &= PAGE_MASK_4K; | 1265 | iova &= PAGE_MASK; |
1290 | start_pfn = ((u64)hpa) >> PAGE_SHIFT_4K; | 1266 | start_pfn = ((u64)hpa) >> VTD_PAGE_SHIFT; |
1291 | end_pfn = (PAGE_ALIGN_4K(((u64)hpa) + size)) >> PAGE_SHIFT_4K; | 1267 | end_pfn = (VTD_PAGE_ALIGN(((u64)hpa) + size)) >> VTD_PAGE_SHIFT; |
1292 | index = 0; | 1268 | index = 0; |
1293 | while (start_pfn < end_pfn) { | 1269 | while (start_pfn < end_pfn) { |
1294 | pte = addr_to_dma_pte(domain, iova + PAGE_SIZE_4K * index); | 1270 | pte = addr_to_dma_pte(domain, iova + VTD_PAGE_SIZE * index); |
1295 | if (!pte) | 1271 | if (!pte) |
1296 | return -ENOMEM; | 1272 | return -ENOMEM; |
1297 | /* We don't need lock here, nobody else | 1273 | /* We don't need lock here, nobody else |
1298 | * touches the iova range | 1274 | * touches the iova range |
1299 | */ | 1275 | */ |
1300 | BUG_ON(dma_pte_addr(*pte)); | 1276 | BUG_ON(dma_pte_addr(*pte)); |
1301 | dma_set_pte_addr(*pte, start_pfn << PAGE_SHIFT_4K); | 1277 | dma_set_pte_addr(*pte, start_pfn << VTD_PAGE_SHIFT); |
1302 | dma_set_pte_prot(*pte, prot); | 1278 | dma_set_pte_prot(*pte, prot); |
1303 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); | 1279 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); |
1304 | start_pfn++; | 1280 | start_pfn++; |
@@ -1310,8 +1286,10 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova, | |||
1310 | static void detach_domain_for_dev(struct dmar_domain *domain, u8 bus, u8 devfn) | 1286 | static void detach_domain_for_dev(struct dmar_domain *domain, u8 bus, u8 devfn) |
1311 | { | 1287 | { |
1312 | clear_context_table(domain->iommu, bus, devfn); | 1288 | clear_context_table(domain->iommu, bus, devfn); |
1313 | iommu_flush_context_global(domain->iommu, 0); | 1289 | domain->iommu->flush.flush_context(domain->iommu, 0, 0, 0, |
1314 | iommu_flush_iotlb_global(domain->iommu, 0); | 1290 | DMA_CCMD_GLOBAL_INVL, 0); |
1291 | domain->iommu->flush.flush_iotlb(domain->iommu, 0, 0, 0, | ||
1292 | DMA_TLB_GLOBAL_FLUSH, 0); | ||
1315 | } | 1293 | } |
1316 | 1294 | ||
1317 | static void domain_remove_dev_info(struct dmar_domain *domain) | 1295 | static void domain_remove_dev_info(struct dmar_domain *domain) |
@@ -1474,11 +1452,13 @@ error: | |||
1474 | return find_domain(pdev); | 1452 | return find_domain(pdev); |
1475 | } | 1453 | } |
1476 | 1454 | ||
1477 | static int iommu_prepare_identity_map(struct pci_dev *pdev, u64 start, u64 end) | 1455 | static int iommu_prepare_identity_map(struct pci_dev *pdev, |
1456 | unsigned long long start, | ||
1457 | unsigned long long end) | ||
1478 | { | 1458 | { |
1479 | struct dmar_domain *domain; | 1459 | struct dmar_domain *domain; |
1480 | unsigned long size; | 1460 | unsigned long size; |
1481 | u64 base; | 1461 | unsigned long long base; |
1482 | int ret; | 1462 | int ret; |
1483 | 1463 | ||
1484 | printk(KERN_INFO | 1464 | printk(KERN_INFO |
@@ -1490,9 +1470,9 @@ static int iommu_prepare_identity_map(struct pci_dev *pdev, u64 start, u64 end) | |||
1490 | return -ENOMEM; | 1470 | return -ENOMEM; |
1491 | 1471 | ||
1492 | /* The address might not be aligned */ | 1472 | /* The address might not be aligned */ |
1493 | base = start & PAGE_MASK_4K; | 1473 | base = start & PAGE_MASK; |
1494 | size = end - base; | 1474 | size = end - base; |
1495 | size = PAGE_ALIGN_4K(size); | 1475 | size = PAGE_ALIGN(size); |
1496 | if (!reserve_iova(&domain->iovad, IOVA_PFN(base), | 1476 | if (!reserve_iova(&domain->iovad, IOVA_PFN(base), |
1497 | IOVA_PFN(base + size) - 1)) { | 1477 | IOVA_PFN(base + size) - 1)) { |
1498 | printk(KERN_ERR "IOMMU: reserve iova failed\n"); | 1478 | printk(KERN_ERR "IOMMU: reserve iova failed\n"); |
@@ -1662,6 +1642,28 @@ int __init init_dmars(void) | |||
1662 | } | 1642 | } |
1663 | } | 1643 | } |
1664 | 1644 | ||
1645 | for_each_drhd_unit(drhd) { | ||
1646 | if (drhd->ignored) | ||
1647 | continue; | ||
1648 | |||
1649 | iommu = drhd->iommu; | ||
1650 | if (dmar_enable_qi(iommu)) { | ||
1651 | /* | ||
1652 | * Queued Invalidate not enabled, use Register Based | ||
1653 | * Invalidate | ||
1654 | */ | ||
1655 | iommu->flush.flush_context = __iommu_flush_context; | ||
1656 | iommu->flush.flush_iotlb = __iommu_flush_iotlb; | ||
1657 | printk(KERN_INFO "IOMMU 0x%Lx: using Register based " | ||
1658 | "invalidation\n", drhd->reg_base_addr); | ||
1659 | } else { | ||
1660 | iommu->flush.flush_context = qi_flush_context; | ||
1661 | iommu->flush.flush_iotlb = qi_flush_iotlb; | ||
1662 | printk(KERN_INFO "IOMMU 0x%Lx: using Queued " | ||
1663 | "invalidation\n", drhd->reg_base_addr); | ||
1664 | } | ||
1665 | } | ||
1666 | |||
1665 | /* | 1667 | /* |
1666 | * For each rmrr | 1668 | * For each rmrr |
1667 | * for each dev attached to rmrr | 1669 | * for each dev attached to rmrr |
@@ -1714,9 +1716,10 @@ int __init init_dmars(void) | |||
1714 | 1716 | ||
1715 | iommu_set_root_entry(iommu); | 1717 | iommu_set_root_entry(iommu); |
1716 | 1718 | ||
1717 | iommu_flush_context_global(iommu, 0); | 1719 | iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL, |
1718 | iommu_flush_iotlb_global(iommu, 0); | 1720 | 0); |
1719 | 1721 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH, | |
1722 | 0); | ||
1720 | iommu_disable_protect_mem_regions(iommu); | 1723 | iommu_disable_protect_mem_regions(iommu); |
1721 | 1724 | ||
1722 | ret = iommu_enable_translation(iommu); | 1725 | ret = iommu_enable_translation(iommu); |
@@ -1738,8 +1741,8 @@ error: | |||
1738 | static inline u64 aligned_size(u64 host_addr, size_t size) | 1741 | static inline u64 aligned_size(u64 host_addr, size_t size) |
1739 | { | 1742 | { |
1740 | u64 addr; | 1743 | u64 addr; |
1741 | addr = (host_addr & (~PAGE_MASK_4K)) + size; | 1744 | addr = (host_addr & (~PAGE_MASK)) + size; |
1742 | return PAGE_ALIGN_4K(addr); | 1745 | return PAGE_ALIGN(addr); |
1743 | } | 1746 | } |
1744 | 1747 | ||
1745 | struct iova * | 1748 | struct iova * |
@@ -1753,20 +1756,20 @@ iommu_alloc_iova(struct dmar_domain *domain, size_t size, u64 end) | |||
1753 | return NULL; | 1756 | return NULL; |
1754 | 1757 | ||
1755 | piova = alloc_iova(&domain->iovad, | 1758 | piova = alloc_iova(&domain->iovad, |
1756 | size >> PAGE_SHIFT_4K, IOVA_PFN(end), 1); | 1759 | size >> PAGE_SHIFT, IOVA_PFN(end), 1); |
1757 | return piova; | 1760 | return piova; |
1758 | } | 1761 | } |
1759 | 1762 | ||
1760 | static struct iova * | 1763 | static struct iova * |
1761 | __intel_alloc_iova(struct device *dev, struct dmar_domain *domain, | 1764 | __intel_alloc_iova(struct device *dev, struct dmar_domain *domain, |
1762 | size_t size) | 1765 | size_t size, u64 dma_mask) |
1763 | { | 1766 | { |
1764 | struct pci_dev *pdev = to_pci_dev(dev); | 1767 | struct pci_dev *pdev = to_pci_dev(dev); |
1765 | struct iova *iova = NULL; | 1768 | struct iova *iova = NULL; |
1766 | 1769 | ||
1767 | if ((pdev->dma_mask <= DMA_32BIT_MASK) || (dmar_forcedac)) { | 1770 | if (dma_mask <= DMA_32BIT_MASK || dmar_forcedac) |
1768 | iova = iommu_alloc_iova(domain, size, pdev->dma_mask); | 1771 | iova = iommu_alloc_iova(domain, size, dma_mask); |
1769 | } else { | 1772 | else { |
1770 | /* | 1773 | /* |
1771 | * First try to allocate an io virtual address in | 1774 | * First try to allocate an io virtual address in |
1772 | * DMA_32BIT_MASK and if that fails then try allocating | 1775 | * DMA_32BIT_MASK and if that fails then try allocating |
@@ -1774,7 +1777,7 @@ __intel_alloc_iova(struct device *dev, struct dmar_domain *domain, | |||
1774 | */ | 1777 | */ |
1775 | iova = iommu_alloc_iova(domain, size, DMA_32BIT_MASK); | 1778 | iova = iommu_alloc_iova(domain, size, DMA_32BIT_MASK); |
1776 | if (!iova) | 1779 | if (!iova) |
1777 | iova = iommu_alloc_iova(domain, size, pdev->dma_mask); | 1780 | iova = iommu_alloc_iova(domain, size, dma_mask); |
1778 | } | 1781 | } |
1779 | 1782 | ||
1780 | if (!iova) { | 1783 | if (!iova) { |
@@ -1813,12 +1816,12 @@ get_valid_domain_for_dev(struct pci_dev *pdev) | |||
1813 | return domain; | 1816 | return domain; |
1814 | } | 1817 | } |
1815 | 1818 | ||
1816 | static dma_addr_t | 1819 | static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr, |
1817 | intel_map_single(struct device *hwdev, phys_addr_t paddr, size_t size, int dir) | 1820 | size_t size, int dir, u64 dma_mask) |
1818 | { | 1821 | { |
1819 | struct pci_dev *pdev = to_pci_dev(hwdev); | 1822 | struct pci_dev *pdev = to_pci_dev(hwdev); |
1820 | struct dmar_domain *domain; | 1823 | struct dmar_domain *domain; |
1821 | unsigned long start_paddr; | 1824 | phys_addr_t start_paddr; |
1822 | struct iova *iova; | 1825 | struct iova *iova; |
1823 | int prot = 0; | 1826 | int prot = 0; |
1824 | int ret; | 1827 | int ret; |
@@ -1833,11 +1836,11 @@ intel_map_single(struct device *hwdev, phys_addr_t paddr, size_t size, int dir) | |||
1833 | 1836 | ||
1834 | size = aligned_size((u64)paddr, size); | 1837 | size = aligned_size((u64)paddr, size); |
1835 | 1838 | ||
1836 | iova = __intel_alloc_iova(hwdev, domain, size); | 1839 | iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask); |
1837 | if (!iova) | 1840 | if (!iova) |
1838 | goto error; | 1841 | goto error; |
1839 | 1842 | ||
1840 | start_paddr = iova->pfn_lo << PAGE_SHIFT_4K; | 1843 | start_paddr = (phys_addr_t)iova->pfn_lo << PAGE_SHIFT; |
1841 | 1844 | ||
1842 | /* | 1845 | /* |
1843 | * Check if DMAR supports zero-length reads on write only | 1846 | * Check if DMAR supports zero-length reads on write only |
@@ -1855,30 +1858,33 @@ intel_map_single(struct device *hwdev, phys_addr_t paddr, size_t size, int dir) | |||
1855 | * is not a big problem | 1858 | * is not a big problem |
1856 | */ | 1859 | */ |
1857 | ret = domain_page_mapping(domain, start_paddr, | 1860 | ret = domain_page_mapping(domain, start_paddr, |
1858 | ((u64)paddr) & PAGE_MASK_4K, size, prot); | 1861 | ((u64)paddr) & PAGE_MASK, size, prot); |
1859 | if (ret) | 1862 | if (ret) |
1860 | goto error; | 1863 | goto error; |
1861 | 1864 | ||
1862 | pr_debug("Device %s request: %lx@%llx mapping: %lx@%llx, dir %d\n", | ||
1863 | pci_name(pdev), size, (u64)paddr, | ||
1864 | size, (u64)start_paddr, dir); | ||
1865 | |||
1866 | /* it's a non-present to present mapping */ | 1865 | /* it's a non-present to present mapping */ |
1867 | ret = iommu_flush_iotlb_psi(domain->iommu, domain->id, | 1866 | ret = iommu_flush_iotlb_psi(domain->iommu, domain->id, |
1868 | start_paddr, size >> PAGE_SHIFT_4K, 1); | 1867 | start_paddr, size >> VTD_PAGE_SHIFT, 1); |
1869 | if (ret) | 1868 | if (ret) |
1870 | iommu_flush_write_buffer(domain->iommu); | 1869 | iommu_flush_write_buffer(domain->iommu); |
1871 | 1870 | ||
1872 | return (start_paddr + ((u64)paddr & (~PAGE_MASK_4K))); | 1871 | return start_paddr + ((u64)paddr & (~PAGE_MASK)); |
1873 | 1872 | ||
1874 | error: | 1873 | error: |
1875 | if (iova) | 1874 | if (iova) |
1876 | __free_iova(&domain->iovad, iova); | 1875 | __free_iova(&domain->iovad, iova); |
1877 | printk(KERN_ERR"Device %s request: %lx@%llx dir %d --- failed\n", | 1876 | printk(KERN_ERR"Device %s request: %lx@%llx dir %d --- failed\n", |
1878 | pci_name(pdev), size, (u64)paddr, dir); | 1877 | pci_name(pdev), size, (unsigned long long)paddr, dir); |
1879 | return 0; | 1878 | return 0; |
1880 | } | 1879 | } |
1881 | 1880 | ||
1881 | dma_addr_t intel_map_single(struct device *hwdev, phys_addr_t paddr, | ||
1882 | size_t size, int dir) | ||
1883 | { | ||
1884 | return __intel_map_single(hwdev, paddr, size, dir, | ||
1885 | to_pci_dev(hwdev)->dma_mask); | ||
1886 | } | ||
1887 | |||
1882 | static void flush_unmaps(void) | 1888 | static void flush_unmaps(void) |
1883 | { | 1889 | { |
1884 | int i, j; | 1890 | int i, j; |
@@ -1891,7 +1897,8 @@ static void flush_unmaps(void) | |||
1891 | struct intel_iommu *iommu = | 1897 | struct intel_iommu *iommu = |
1892 | deferred_flush[i].domain[0]->iommu; | 1898 | deferred_flush[i].domain[0]->iommu; |
1893 | 1899 | ||
1894 | iommu_flush_iotlb_global(iommu, 0); | 1900 | iommu->flush.flush_iotlb(iommu, 0, 0, 0, |
1901 | DMA_TLB_GLOBAL_FLUSH, 0); | ||
1895 | for (j = 0; j < deferred_flush[i].next; j++) { | 1902 | for (j = 0; j < deferred_flush[i].next; j++) { |
1896 | __free_iova(&deferred_flush[i].domain[j]->iovad, | 1903 | __free_iova(&deferred_flush[i].domain[j]->iovad, |
1897 | deferred_flush[i].iova[j]); | 1904 | deferred_flush[i].iova[j]); |
@@ -1936,8 +1943,8 @@ static void add_unmap(struct dmar_domain *dom, struct iova *iova) | |||
1936 | spin_unlock_irqrestore(&async_umap_flush_lock, flags); | 1943 | spin_unlock_irqrestore(&async_umap_flush_lock, flags); |
1937 | } | 1944 | } |
1938 | 1945 | ||
1939 | static void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, | 1946 | void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, |
1940 | size_t size, int dir) | 1947 | int dir) |
1941 | { | 1948 | { |
1942 | struct pci_dev *pdev = to_pci_dev(dev); | 1949 | struct pci_dev *pdev = to_pci_dev(dev); |
1943 | struct dmar_domain *domain; | 1950 | struct dmar_domain *domain; |
@@ -1953,11 +1960,11 @@ static void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, | |||
1953 | if (!iova) | 1960 | if (!iova) |
1954 | return; | 1961 | return; |
1955 | 1962 | ||
1956 | start_addr = iova->pfn_lo << PAGE_SHIFT_4K; | 1963 | start_addr = iova->pfn_lo << PAGE_SHIFT; |
1957 | size = aligned_size((u64)dev_addr, size); | 1964 | size = aligned_size((u64)dev_addr, size); |
1958 | 1965 | ||
1959 | pr_debug("Device %s unmapping: %lx@%llx\n", | 1966 | pr_debug("Device %s unmapping: %lx@%llx\n", |
1960 | pci_name(pdev), size, (u64)start_addr); | 1967 | pci_name(pdev), size, (unsigned long long)start_addr); |
1961 | 1968 | ||
1962 | /* clear the whole page */ | 1969 | /* clear the whole page */ |
1963 | dma_pte_clear_range(domain, start_addr, start_addr + size); | 1970 | dma_pte_clear_range(domain, start_addr, start_addr + size); |
@@ -1965,7 +1972,7 @@ static void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, | |||
1965 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); | 1972 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); |
1966 | if (intel_iommu_strict) { | 1973 | if (intel_iommu_strict) { |
1967 | if (iommu_flush_iotlb_psi(domain->iommu, | 1974 | if (iommu_flush_iotlb_psi(domain->iommu, |
1968 | domain->id, start_addr, size >> PAGE_SHIFT_4K, 0)) | 1975 | domain->id, start_addr, size >> VTD_PAGE_SHIFT, 0)) |
1969 | iommu_flush_write_buffer(domain->iommu); | 1976 | iommu_flush_write_buffer(domain->iommu); |
1970 | /* free iova */ | 1977 | /* free iova */ |
1971 | __free_iova(&domain->iovad, iova); | 1978 | __free_iova(&domain->iovad, iova); |
@@ -1978,13 +1985,13 @@ static void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, | |||
1978 | } | 1985 | } |
1979 | } | 1986 | } |
1980 | 1987 | ||
1981 | static void * intel_alloc_coherent(struct device *hwdev, size_t size, | 1988 | void *intel_alloc_coherent(struct device *hwdev, size_t size, |
1982 | dma_addr_t *dma_handle, gfp_t flags) | 1989 | dma_addr_t *dma_handle, gfp_t flags) |
1983 | { | 1990 | { |
1984 | void *vaddr; | 1991 | void *vaddr; |
1985 | int order; | 1992 | int order; |
1986 | 1993 | ||
1987 | size = PAGE_ALIGN_4K(size); | 1994 | size = PAGE_ALIGN(size); |
1988 | order = get_order(size); | 1995 | order = get_order(size); |
1989 | flags &= ~(GFP_DMA | GFP_DMA32); | 1996 | flags &= ~(GFP_DMA | GFP_DMA32); |
1990 | 1997 | ||
@@ -1993,19 +2000,21 @@ static void * intel_alloc_coherent(struct device *hwdev, size_t size, | |||
1993 | return NULL; | 2000 | return NULL; |
1994 | memset(vaddr, 0, size); | 2001 | memset(vaddr, 0, size); |
1995 | 2002 | ||
1996 | *dma_handle = intel_map_single(hwdev, virt_to_bus(vaddr), size, DMA_BIDIRECTIONAL); | 2003 | *dma_handle = __intel_map_single(hwdev, virt_to_bus(vaddr), size, |
2004 | DMA_BIDIRECTIONAL, | ||
2005 | hwdev->coherent_dma_mask); | ||
1997 | if (*dma_handle) | 2006 | if (*dma_handle) |
1998 | return vaddr; | 2007 | return vaddr; |
1999 | free_pages((unsigned long)vaddr, order); | 2008 | free_pages((unsigned long)vaddr, order); |
2000 | return NULL; | 2009 | return NULL; |
2001 | } | 2010 | } |
2002 | 2011 | ||
2003 | static void intel_free_coherent(struct device *hwdev, size_t size, | 2012 | void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, |
2004 | void *vaddr, dma_addr_t dma_handle) | 2013 | dma_addr_t dma_handle) |
2005 | { | 2014 | { |
2006 | int order; | 2015 | int order; |
2007 | 2016 | ||
2008 | size = PAGE_ALIGN_4K(size); | 2017 | size = PAGE_ALIGN(size); |
2009 | order = get_order(size); | 2018 | order = get_order(size); |
2010 | 2019 | ||
2011 | intel_unmap_single(hwdev, dma_handle, size, DMA_BIDIRECTIONAL); | 2020 | intel_unmap_single(hwdev, dma_handle, size, DMA_BIDIRECTIONAL); |
@@ -2013,8 +2022,9 @@ static void intel_free_coherent(struct device *hwdev, size_t size, | |||
2013 | } | 2022 | } |
2014 | 2023 | ||
2015 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) | 2024 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) |
2016 | static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | 2025 | |
2017 | int nelems, int dir) | 2026 | void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, |
2027 | int nelems, int dir) | ||
2018 | { | 2028 | { |
2019 | int i; | 2029 | int i; |
2020 | struct pci_dev *pdev = to_pci_dev(hwdev); | 2030 | struct pci_dev *pdev = to_pci_dev(hwdev); |
@@ -2038,7 +2048,7 @@ static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | |||
2038 | size += aligned_size((u64)addr, sg->length); | 2048 | size += aligned_size((u64)addr, sg->length); |
2039 | } | 2049 | } |
2040 | 2050 | ||
2041 | start_addr = iova->pfn_lo << PAGE_SHIFT_4K; | 2051 | start_addr = iova->pfn_lo << PAGE_SHIFT; |
2042 | 2052 | ||
2043 | /* clear the whole page */ | 2053 | /* clear the whole page */ |
2044 | dma_pte_clear_range(domain, start_addr, start_addr + size); | 2054 | dma_pte_clear_range(domain, start_addr, start_addr + size); |
@@ -2046,7 +2056,7 @@ static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | |||
2046 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); | 2056 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); |
2047 | 2057 | ||
2048 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, start_addr, | 2058 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, start_addr, |
2049 | size >> PAGE_SHIFT_4K, 0)) | 2059 | size >> VTD_PAGE_SHIFT, 0)) |
2050 | iommu_flush_write_buffer(domain->iommu); | 2060 | iommu_flush_write_buffer(domain->iommu); |
2051 | 2061 | ||
2052 | /* free iova */ | 2062 | /* free iova */ |
@@ -2067,8 +2077,8 @@ static int intel_nontranslate_map_sg(struct device *hddev, | |||
2067 | return nelems; | 2077 | return nelems; |
2068 | } | 2078 | } |
2069 | 2079 | ||
2070 | static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, | 2080 | int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, |
2071 | int nelems, int dir) | 2081 | int dir) |
2072 | { | 2082 | { |
2073 | void *addr; | 2083 | void *addr; |
2074 | int i; | 2084 | int i; |
@@ -2096,7 +2106,7 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, | |||
2096 | size += aligned_size((u64)addr, sg->length); | 2106 | size += aligned_size((u64)addr, sg->length); |
2097 | } | 2107 | } |
2098 | 2108 | ||
2099 | iova = __intel_alloc_iova(hwdev, domain, size); | 2109 | iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask); |
2100 | if (!iova) { | 2110 | if (!iova) { |
2101 | sglist->dma_length = 0; | 2111 | sglist->dma_length = 0; |
2102 | return 0; | 2112 | return 0; |
@@ -2112,14 +2122,14 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, | |||
2112 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) | 2122 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) |
2113 | prot |= DMA_PTE_WRITE; | 2123 | prot |= DMA_PTE_WRITE; |
2114 | 2124 | ||
2115 | start_addr = iova->pfn_lo << PAGE_SHIFT_4K; | 2125 | start_addr = iova->pfn_lo << PAGE_SHIFT; |
2116 | offset = 0; | 2126 | offset = 0; |
2117 | for_each_sg(sglist, sg, nelems, i) { | 2127 | for_each_sg(sglist, sg, nelems, i) { |
2118 | addr = SG_ENT_VIRT_ADDRESS(sg); | 2128 | addr = SG_ENT_VIRT_ADDRESS(sg); |
2119 | addr = (void *)virt_to_phys(addr); | 2129 | addr = (void *)virt_to_phys(addr); |
2120 | size = aligned_size((u64)addr, sg->length); | 2130 | size = aligned_size((u64)addr, sg->length); |
2121 | ret = domain_page_mapping(domain, start_addr + offset, | 2131 | ret = domain_page_mapping(domain, start_addr + offset, |
2122 | ((u64)addr) & PAGE_MASK_4K, | 2132 | ((u64)addr) & PAGE_MASK, |
2123 | size, prot); | 2133 | size, prot); |
2124 | if (ret) { | 2134 | if (ret) { |
2125 | /* clear the page */ | 2135 | /* clear the page */ |
@@ -2133,14 +2143,14 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, | |||
2133 | return 0; | 2143 | return 0; |
2134 | } | 2144 | } |
2135 | sg->dma_address = start_addr + offset + | 2145 | sg->dma_address = start_addr + offset + |
2136 | ((u64)addr & (~PAGE_MASK_4K)); | 2146 | ((u64)addr & (~PAGE_MASK)); |
2137 | sg->dma_length = sg->length; | 2147 | sg->dma_length = sg->length; |
2138 | offset += size; | 2148 | offset += size; |
2139 | } | 2149 | } |
2140 | 2150 | ||
2141 | /* it's a non-present to present mapping */ | 2151 | /* it's a non-present to present mapping */ |
2142 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, | 2152 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, |
2143 | start_addr, offset >> PAGE_SHIFT_4K, 1)) | 2153 | start_addr, offset >> VTD_PAGE_SHIFT, 1)) |
2144 | iommu_flush_write_buffer(domain->iommu); | 2154 | iommu_flush_write_buffer(domain->iommu); |
2145 | return nelems; | 2155 | return nelems; |
2146 | } | 2156 | } |
@@ -2180,7 +2190,6 @@ static inline int iommu_devinfo_cache_init(void) | |||
2180 | sizeof(struct device_domain_info), | 2190 | sizeof(struct device_domain_info), |
2181 | 0, | 2191 | 0, |
2182 | SLAB_HWCACHE_ALIGN, | 2192 | SLAB_HWCACHE_ALIGN, |
2183 | |||
2184 | NULL); | 2193 | NULL); |
2185 | if (!iommu_devinfo_cache) { | 2194 | if (!iommu_devinfo_cache) { |
2186 | printk(KERN_ERR "Couldn't create devinfo cache\n"); | 2195 | printk(KERN_ERR "Couldn't create devinfo cache\n"); |
@@ -2198,7 +2207,6 @@ static inline int iommu_iova_cache_init(void) | |||
2198 | sizeof(struct iova), | 2207 | sizeof(struct iova), |
2199 | 0, | 2208 | 0, |
2200 | SLAB_HWCACHE_ALIGN, | 2209 | SLAB_HWCACHE_ALIGN, |
2201 | |||
2202 | NULL); | 2210 | NULL); |
2203 | if (!iommu_iova_cache) { | 2211 | if (!iommu_iova_cache) { |
2204 | printk(KERN_ERR "Couldn't create iova cache\n"); | 2212 | printk(KERN_ERR "Couldn't create iova cache\n"); |
@@ -2327,7 +2335,7 @@ void intel_iommu_domain_exit(struct dmar_domain *domain) | |||
2327 | return; | 2335 | return; |
2328 | 2336 | ||
2329 | end = DOMAIN_MAX_ADDR(domain->gaw); | 2337 | end = DOMAIN_MAX_ADDR(domain->gaw); |
2330 | end = end & (~PAGE_MASK_4K); | 2338 | end = end & (~VTD_PAGE_MASK); |
2331 | 2339 | ||
2332 | /* clear ptes */ | 2340 | /* clear ptes */ |
2333 | dma_pte_clear_range(domain, 0, end); | 2341 | dma_pte_clear_range(domain, 0, end); |
@@ -2423,6 +2431,6 @@ u64 intel_iommu_iova_to_pfn(struct dmar_domain *domain, u64 iova) | |||
2423 | if (pte) | 2431 | if (pte) |
2424 | pfn = dma_pte_addr(*pte); | 2432 | pfn = dma_pte_addr(*pte); |
2425 | 2433 | ||
2426 | return pfn >> PAGE_SHIFT_4K; | 2434 | return pfn >> VTD_PAGE_SHIFT; |
2427 | } | 2435 | } |
2428 | EXPORT_SYMBOL_GPL(intel_iommu_iova_to_pfn); | 2436 | EXPORT_SYMBOL_GPL(intel_iommu_iova_to_pfn); |
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c index 738d4c89581..2de5a3238c9 100644 --- a/drivers/pci/intr_remapping.c +++ b/drivers/pci/intr_remapping.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <linux/interrupt.h> | ||
1 | #include <linux/dmar.h> | 2 | #include <linux/dmar.h> |
2 | #include <linux/spinlock.h> | 3 | #include <linux/spinlock.h> |
3 | #include <linux/jiffies.h> | 4 | #include <linux/jiffies.h> |
@@ -11,41 +12,64 @@ static struct ioapic_scope ir_ioapic[MAX_IO_APICS]; | |||
11 | static int ir_ioapic_num; | 12 | static int ir_ioapic_num; |
12 | int intr_remapping_enabled; | 13 | int intr_remapping_enabled; |
13 | 14 | ||
14 | static struct { | 15 | struct irq_2_iommu { |
15 | struct intel_iommu *iommu; | 16 | struct intel_iommu *iommu; |
16 | u16 irte_index; | 17 | u16 irte_index; |
17 | u16 sub_handle; | 18 | u16 sub_handle; |
18 | u8 irte_mask; | 19 | u8 irte_mask; |
19 | } irq_2_iommu[NR_IRQS]; | 20 | }; |
21 | |||
22 | static struct irq_2_iommu irq_2_iommuX[NR_IRQS]; | ||
23 | |||
24 | static struct irq_2_iommu *irq_2_iommu(unsigned int irq) | ||
25 | { | ||
26 | return (irq < nr_irqs) ? irq_2_iommuX + irq : NULL; | ||
27 | } | ||
28 | |||
29 | static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq) | ||
30 | { | ||
31 | return irq_2_iommu(irq); | ||
32 | } | ||
20 | 33 | ||
21 | static DEFINE_SPINLOCK(irq_2_ir_lock); | 34 | static DEFINE_SPINLOCK(irq_2_ir_lock); |
22 | 35 | ||
23 | int irq_remapped(int irq) | 36 | static struct irq_2_iommu *valid_irq_2_iommu(unsigned int irq) |
24 | { | 37 | { |
25 | if (irq > NR_IRQS) | 38 | struct irq_2_iommu *irq_iommu; |
26 | return 0; | 39 | |
40 | irq_iommu = irq_2_iommu(irq); | ||
41 | |||
42 | if (!irq_iommu) | ||
43 | return NULL; | ||
44 | |||
45 | if (!irq_iommu->iommu) | ||
46 | return NULL; | ||
27 | 47 | ||
28 | if (!irq_2_iommu[irq].iommu) | 48 | return irq_iommu; |
29 | return 0; | 49 | } |
30 | 50 | ||
31 | return 1; | 51 | int irq_remapped(int irq) |
52 | { | ||
53 | return valid_irq_2_iommu(irq) != NULL; | ||
32 | } | 54 | } |
33 | 55 | ||
34 | int get_irte(int irq, struct irte *entry) | 56 | int get_irte(int irq, struct irte *entry) |
35 | { | 57 | { |
36 | int index; | 58 | int index; |
59 | struct irq_2_iommu *irq_iommu; | ||
37 | 60 | ||
38 | if (!entry || irq > NR_IRQS) | 61 | if (!entry) |
39 | return -1; | 62 | return -1; |
40 | 63 | ||
41 | spin_lock(&irq_2_ir_lock); | 64 | spin_lock(&irq_2_ir_lock); |
42 | if (!irq_2_iommu[irq].iommu) { | 65 | irq_iommu = valid_irq_2_iommu(irq); |
66 | if (!irq_iommu) { | ||
43 | spin_unlock(&irq_2_ir_lock); | 67 | spin_unlock(&irq_2_ir_lock); |
44 | return -1; | 68 | return -1; |
45 | } | 69 | } |
46 | 70 | ||
47 | index = irq_2_iommu[irq].irte_index + irq_2_iommu[irq].sub_handle; | 71 | index = irq_iommu->irte_index + irq_iommu->sub_handle; |
48 | *entry = *(irq_2_iommu[irq].iommu->ir_table->base + index); | 72 | *entry = *(irq_iommu->iommu->ir_table->base + index); |
49 | 73 | ||
50 | spin_unlock(&irq_2_ir_lock); | 74 | spin_unlock(&irq_2_ir_lock); |
51 | return 0; | 75 | return 0; |
@@ -54,6 +78,7 @@ int get_irte(int irq, struct irte *entry) | |||
54 | int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) | 78 | int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) |
55 | { | 79 | { |
56 | struct ir_table *table = iommu->ir_table; | 80 | struct ir_table *table = iommu->ir_table; |
81 | struct irq_2_iommu *irq_iommu; | ||
57 | u16 index, start_index; | 82 | u16 index, start_index; |
58 | unsigned int mask = 0; | 83 | unsigned int mask = 0; |
59 | int i; | 84 | int i; |
@@ -61,6 +86,10 @@ int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) | |||
61 | if (!count) | 86 | if (!count) |
62 | return -1; | 87 | return -1; |
63 | 88 | ||
89 | /* protect irq_2_iommu_alloc later */ | ||
90 | if (irq >= nr_irqs) | ||
91 | return -1; | ||
92 | |||
64 | /* | 93 | /* |
65 | * start the IRTE search from index 0. | 94 | * start the IRTE search from index 0. |
66 | */ | 95 | */ |
@@ -100,10 +129,11 @@ int alloc_irte(struct intel_iommu *iommu, int irq, u16 count) | |||
100 | for (i = index; i < index + count; i++) | 129 | for (i = index; i < index + count; i++) |
101 | table->base[i].present = 1; | 130 | table->base[i].present = 1; |
102 | 131 | ||
103 | irq_2_iommu[irq].iommu = iommu; | 132 | irq_iommu = irq_2_iommu_alloc(irq); |
104 | irq_2_iommu[irq].irte_index = index; | 133 | irq_iommu->iommu = iommu; |
105 | irq_2_iommu[irq].sub_handle = 0; | 134 | irq_iommu->irte_index = index; |
106 | irq_2_iommu[irq].irte_mask = mask; | 135 | irq_iommu->sub_handle = 0; |
136 | irq_iommu->irte_mask = mask; | ||
107 | 137 | ||
108 | spin_unlock(&irq_2_ir_lock); | 138 | spin_unlock(&irq_2_ir_lock); |
109 | 139 | ||
@@ -124,31 +154,33 @@ static void qi_flush_iec(struct intel_iommu *iommu, int index, int mask) | |||
124 | int map_irq_to_irte_handle(int irq, u16 *sub_handle) | 154 | int map_irq_to_irte_handle(int irq, u16 *sub_handle) |
125 | { | 155 | { |
126 | int index; | 156 | int index; |
157 | struct irq_2_iommu *irq_iommu; | ||
127 | 158 | ||
128 | spin_lock(&irq_2_ir_lock); | 159 | spin_lock(&irq_2_ir_lock); |
129 | if (irq >= NR_IRQS || !irq_2_iommu[irq].iommu) { | 160 | irq_iommu = valid_irq_2_iommu(irq); |
161 | if (!irq_iommu) { | ||
130 | spin_unlock(&irq_2_ir_lock); | 162 | spin_unlock(&irq_2_ir_lock); |
131 | return -1; | 163 | return -1; |
132 | } | 164 | } |
133 | 165 | ||
134 | *sub_handle = irq_2_iommu[irq].sub_handle; | 166 | *sub_handle = irq_iommu->sub_handle; |
135 | index = irq_2_iommu[irq].irte_index; | 167 | index = irq_iommu->irte_index; |
136 | spin_unlock(&irq_2_ir_lock); | 168 | spin_unlock(&irq_2_ir_lock); |
137 | return index; | 169 | return index; |
138 | } | 170 | } |
139 | 171 | ||
140 | int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle) | 172 | int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle) |
141 | { | 173 | { |
174 | struct irq_2_iommu *irq_iommu; | ||
175 | |||
142 | spin_lock(&irq_2_ir_lock); | 176 | spin_lock(&irq_2_ir_lock); |
143 | if (irq >= NR_IRQS || irq_2_iommu[irq].iommu) { | ||
144 | spin_unlock(&irq_2_ir_lock); | ||
145 | return -1; | ||
146 | } | ||
147 | 177 | ||
148 | irq_2_iommu[irq].iommu = iommu; | 178 | irq_iommu = irq_2_iommu_alloc(irq); |
149 | irq_2_iommu[irq].irte_index = index; | 179 | |
150 | irq_2_iommu[irq].sub_handle = subhandle; | 180 | irq_iommu->iommu = iommu; |
151 | irq_2_iommu[irq].irte_mask = 0; | 181 | irq_iommu->irte_index = index; |
182 | irq_iommu->sub_handle = subhandle; | ||
183 | irq_iommu->irte_mask = 0; | ||
152 | 184 | ||
153 | spin_unlock(&irq_2_ir_lock); | 185 | spin_unlock(&irq_2_ir_lock); |
154 | 186 | ||
@@ -157,16 +189,19 @@ int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, u16 subhandle) | |||
157 | 189 | ||
158 | int clear_irte_irq(int irq, struct intel_iommu *iommu, u16 index) | 190 | int clear_irte_irq(int irq, struct intel_iommu *iommu, u16 index) |
159 | { | 191 | { |
192 | struct irq_2_iommu *irq_iommu; | ||
193 | |||
160 | spin_lock(&irq_2_ir_lock); | 194 | spin_lock(&irq_2_ir_lock); |
161 | if (irq >= NR_IRQS || !irq_2_iommu[irq].iommu) { | 195 | irq_iommu = valid_irq_2_iommu(irq); |
196 | if (!irq_iommu) { | ||
162 | spin_unlock(&irq_2_ir_lock); | 197 | spin_unlock(&irq_2_ir_lock); |
163 | return -1; | 198 | return -1; |
164 | } | 199 | } |
165 | 200 | ||
166 | irq_2_iommu[irq].iommu = NULL; | 201 | irq_iommu->iommu = NULL; |
167 | irq_2_iommu[irq].irte_index = 0; | 202 | irq_iommu->irte_index = 0; |
168 | irq_2_iommu[irq].sub_handle = 0; | 203 | irq_iommu->sub_handle = 0; |
169 | irq_2_iommu[irq].irte_mask = 0; | 204 | irq_2_iommu(irq)->irte_mask = 0; |
170 | 205 | ||
171 | spin_unlock(&irq_2_ir_lock); | 206 | spin_unlock(&irq_2_ir_lock); |
172 | 207 | ||
@@ -178,16 +213,18 @@ int modify_irte(int irq, struct irte *irte_modified) | |||
178 | int index; | 213 | int index; |
179 | struct irte *irte; | 214 | struct irte *irte; |
180 | struct intel_iommu *iommu; | 215 | struct intel_iommu *iommu; |
216 | struct irq_2_iommu *irq_iommu; | ||
181 | 217 | ||
182 | spin_lock(&irq_2_ir_lock); | 218 | spin_lock(&irq_2_ir_lock); |
183 | if (irq >= NR_IRQS || !irq_2_iommu[irq].iommu) { | 219 | irq_iommu = valid_irq_2_iommu(irq); |
220 | if (!irq_iommu) { | ||
184 | spin_unlock(&irq_2_ir_lock); | 221 | spin_unlock(&irq_2_ir_lock); |
185 | return -1; | 222 | return -1; |
186 | } | 223 | } |
187 | 224 | ||
188 | iommu = irq_2_iommu[irq].iommu; | 225 | iommu = irq_iommu->iommu; |
189 | 226 | ||
190 | index = irq_2_iommu[irq].irte_index + irq_2_iommu[irq].sub_handle; | 227 | index = irq_iommu->irte_index + irq_iommu->sub_handle; |
191 | irte = &iommu->ir_table->base[index]; | 228 | irte = &iommu->ir_table->base[index]; |
192 | 229 | ||
193 | set_64bit((unsigned long *)irte, irte_modified->low | (1 << 1)); | 230 | set_64bit((unsigned long *)irte, irte_modified->low | (1 << 1)); |
@@ -203,18 +240,20 @@ int flush_irte(int irq) | |||
203 | { | 240 | { |
204 | int index; | 241 | int index; |
205 | struct intel_iommu *iommu; | 242 | struct intel_iommu *iommu; |
243 | struct irq_2_iommu *irq_iommu; | ||
206 | 244 | ||
207 | spin_lock(&irq_2_ir_lock); | 245 | spin_lock(&irq_2_ir_lock); |
208 | if (irq >= NR_IRQS || !irq_2_iommu[irq].iommu) { | 246 | irq_iommu = valid_irq_2_iommu(irq); |
247 | if (!irq_iommu) { | ||
209 | spin_unlock(&irq_2_ir_lock); | 248 | spin_unlock(&irq_2_ir_lock); |
210 | return -1; | 249 | return -1; |
211 | } | 250 | } |
212 | 251 | ||
213 | iommu = irq_2_iommu[irq].iommu; | 252 | iommu = irq_iommu->iommu; |
214 | 253 | ||
215 | index = irq_2_iommu[irq].irte_index + irq_2_iommu[irq].sub_handle; | 254 | index = irq_iommu->irte_index + irq_iommu->sub_handle; |
216 | 255 | ||
217 | qi_flush_iec(iommu, index, irq_2_iommu[irq].irte_mask); | 256 | qi_flush_iec(iommu, index, irq_iommu->irte_mask); |
218 | spin_unlock(&irq_2_ir_lock); | 257 | spin_unlock(&irq_2_ir_lock); |
219 | 258 | ||
220 | return 0; | 259 | return 0; |
@@ -246,28 +285,30 @@ int free_irte(int irq) | |||
246 | int index, i; | 285 | int index, i; |
247 | struct irte *irte; | 286 | struct irte *irte; |
248 | struct intel_iommu *iommu; | 287 | struct intel_iommu *iommu; |
288 | struct irq_2_iommu *irq_iommu; | ||
249 | 289 | ||
250 | spin_lock(&irq_2_ir_lock); | 290 | spin_lock(&irq_2_ir_lock); |
251 | if (irq >= NR_IRQS || !irq_2_iommu[irq].iommu) { | 291 | irq_iommu = valid_irq_2_iommu(irq); |
292 | if (!irq_iommu) { | ||
252 | spin_unlock(&irq_2_ir_lock); | 293 | spin_unlock(&irq_2_ir_lock); |
253 | return -1; | 294 | return -1; |
254 | } | 295 | } |
255 | 296 | ||
256 | iommu = irq_2_iommu[irq].iommu; | 297 | iommu = irq_iommu->iommu; |
257 | 298 | ||
258 | index = irq_2_iommu[irq].irte_index + irq_2_iommu[irq].sub_handle; | 299 | index = irq_iommu->irte_index + irq_iommu->sub_handle; |
259 | irte = &iommu->ir_table->base[index]; | 300 | irte = &iommu->ir_table->base[index]; |
260 | 301 | ||
261 | if (!irq_2_iommu[irq].sub_handle) { | 302 | if (!irq_iommu->sub_handle) { |
262 | for (i = 0; i < (1 << irq_2_iommu[irq].irte_mask); i++) | 303 | for (i = 0; i < (1 << irq_iommu->irte_mask); i++) |
263 | set_64bit((unsigned long *)irte, 0); | 304 | set_64bit((unsigned long *)irte, 0); |
264 | qi_flush_iec(iommu, index, irq_2_iommu[irq].irte_mask); | 305 | qi_flush_iec(iommu, index, irq_iommu->irte_mask); |
265 | } | 306 | } |
266 | 307 | ||
267 | irq_2_iommu[irq].iommu = NULL; | 308 | irq_iommu->iommu = NULL; |
268 | irq_2_iommu[irq].irte_index = 0; | 309 | irq_iommu->irte_index = 0; |
269 | irq_2_iommu[irq].sub_handle = 0; | 310 | irq_iommu->sub_handle = 0; |
270 | irq_2_iommu[irq].irte_mask = 0; | 311 | irq_iommu->irte_mask = 0; |
271 | 312 | ||
272 | spin_unlock(&irq_2_ir_lock); | 313 | spin_unlock(&irq_2_ir_lock); |
273 | 314 | ||
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c new file mode 100644 index 00000000000..6441dfa969a --- /dev/null +++ b/drivers/pci/irq.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * PCI IRQ failure handing code | ||
3 | * | ||
4 | * Copyright (c) 2008 James Bottomley <James.Bottomley@HansenPartnership.com> | ||
5 | */ | ||
6 | |||
7 | #include <linux/acpi.h> | ||
8 | #include <linux/device.h> | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/pci.h> | ||
11 | |||
12 | static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason) | ||
13 | { | ||
14 | struct pci_dev *parent = to_pci_dev(pdev->dev.parent); | ||
15 | |||
16 | dev_printk(KERN_ERR, &pdev->dev, | ||
17 | "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", | ||
18 | parent->dev.bus_id, parent->vendor, parent->device); | ||
19 | dev_printk(KERN_ERR, &pdev->dev, "%s\n", reason); | ||
20 | dev_printk(KERN_ERR, &pdev->dev, "Please report to linux-kernel@vger.kernel.org\n"); | ||
21 | WARN_ON(1); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * pci_lost_interrupt - reports a lost PCI interrupt | ||
26 | * @pdev: device whose interrupt is lost | ||
27 | * | ||
28 | * The primary function of this routine is to report a lost interrupt | ||
29 | * in a standard way which users can recognise (instead of blaming the | ||
30 | * driver). | ||
31 | * | ||
32 | * Returns: | ||
33 | * a suggestion for fixing it (although the driver is not required to | ||
34 | * act on this). | ||
35 | */ | ||
36 | enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *pdev) | ||
37 | { | ||
38 | if (pdev->msi_enabled || pdev->msix_enabled) { | ||
39 | enum pci_lost_interrupt_reason ret; | ||
40 | |||
41 | if (pdev->msix_enabled) { | ||
42 | pci_note_irq_problem(pdev, "MSIX routing failure"); | ||
43 | ret = PCI_LOST_IRQ_DISABLE_MSIX; | ||
44 | } else { | ||
45 | pci_note_irq_problem(pdev, "MSI routing failure"); | ||
46 | ret = PCI_LOST_IRQ_DISABLE_MSI; | ||
47 | } | ||
48 | return ret; | ||
49 | } | ||
50 | #ifdef CONFIG_ACPI | ||
51 | if (!(acpi_disabled || acpi_noirq)) { | ||
52 | pci_note_irq_problem(pdev, "Potential ACPI misrouting please reboot with acpi=noirq"); | ||
53 | /* currently no way to fix acpi on the fly */ | ||
54 | return PCI_LOST_IRQ_DISABLE_ACPI; | ||
55 | } | ||
56 | #endif | ||
57 | pci_note_irq_problem(pdev, "unknown cause (not MSI or ACPI)"); | ||
58 | return PCI_LOST_IRQ_NO_INFORMATION; | ||
59 | } | ||
60 | EXPORT_SYMBOL(pci_lost_interrupt); | ||
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 4a10b5624f7..74801f7df9c 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -378,23 +378,21 @@ static int msi_capability_init(struct pci_dev *dev) | |||
378 | entry->msi_attrib.masked = 1; | 378 | entry->msi_attrib.masked = 1; |
379 | entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ | 379 | entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ |
380 | entry->msi_attrib.pos = pos; | 380 | entry->msi_attrib.pos = pos; |
381 | if (is_mask_bit_support(control)) { | 381 | if (entry->msi_attrib.maskbit) { |
382 | entry->mask_base = (void __iomem *)(long)msi_mask_bits_reg(pos, | 382 | entry->mask_base = (void __iomem *)(long)msi_mask_bits_reg(pos, |
383 | is_64bit_address(control)); | 383 | entry->msi_attrib.is_64); |
384 | } | 384 | } |
385 | entry->dev = dev; | 385 | entry->dev = dev; |
386 | if (entry->msi_attrib.maskbit) { | 386 | if (entry->msi_attrib.maskbit) { |
387 | unsigned int maskbits, temp; | 387 | unsigned int maskbits, temp; |
388 | /* All MSIs are unmasked by default, Mask them all */ | 388 | /* All MSIs are unmasked by default, Mask them all */ |
389 | pci_read_config_dword(dev, | 389 | pci_read_config_dword(dev, |
390 | msi_mask_bits_reg(pos, is_64bit_address(control)), | 390 | msi_mask_bits_reg(pos, entry->msi_attrib.is_64), |
391 | &maskbits); | 391 | &maskbits); |
392 | temp = (1 << multi_msi_capable(control)); | 392 | temp = (1 << multi_msi_capable(control)); |
393 | temp = ((temp - 1) & ~temp); | 393 | temp = ((temp - 1) & ~temp); |
394 | maskbits |= temp; | 394 | maskbits |= temp; |
395 | pci_write_config_dword(dev, | 395 | pci_write_config_dword(dev, entry->msi_attrib.is_64, maskbits); |
396 | msi_mask_bits_reg(pos, is_64bit_address(control)), | ||
397 | maskbits); | ||
398 | entry->msi_attrib.maskbits_mask = temp; | 396 | entry->msi_attrib.maskbits_mask = temp; |
399 | } | 397 | } |
400 | list_add_tail(&entry->list, &dev->msi_list); | 398 | list_add_tail(&entry->list, &dev->msi_list); |
@@ -761,3 +759,24 @@ void pci_msi_init_pci_dev(struct pci_dev *dev) | |||
761 | { | 759 | { |
762 | INIT_LIST_HEAD(&dev->msi_list); | 760 | INIT_LIST_HEAD(&dev->msi_list); |
763 | } | 761 | } |
762 | |||
763 | #ifdef CONFIG_ACPI | ||
764 | #include <linux/acpi.h> | ||
765 | #include <linux/pci-acpi.h> | ||
766 | static void __devinit msi_acpi_init(void) | ||
767 | { | ||
768 | if (acpi_pci_disabled) | ||
769 | return; | ||
770 | pci_osc_support_set(OSC_MSI_SUPPORT); | ||
771 | pcie_osc_support_set(OSC_MSI_SUPPORT); | ||
772 | } | ||
773 | #else | ||
774 | static inline void msi_acpi_init(void) { } | ||
775 | #endif /* CONFIG_ACPI */ | ||
776 | |||
777 | void __devinit msi_init(void) | ||
778 | { | ||
779 | if (!pci_msi_enable) | ||
780 | return; | ||
781 | msi_acpi_init(); | ||
782 | } | ||
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 89a2f0fa10f..b3a63edb690 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -24,17 +24,17 @@ struct acpi_osc_data { | |||
24 | acpi_handle handle; | 24 | acpi_handle handle; |
25 | u32 support_set; | 25 | u32 support_set; |
26 | u32 control_set; | 26 | u32 control_set; |
27 | int is_queried; | ||
28 | u32 query_result; | ||
29 | struct list_head sibiling; | 27 | struct list_head sibiling; |
30 | }; | 28 | }; |
31 | static LIST_HEAD(acpi_osc_data_list); | 29 | static LIST_HEAD(acpi_osc_data_list); |
32 | 30 | ||
33 | struct acpi_osc_args { | 31 | struct acpi_osc_args { |
34 | u32 capbuf[3]; | 32 | u32 capbuf[3]; |
35 | u32 query_result; | 33 | u32 ctrl_result; |
36 | }; | 34 | }; |
37 | 35 | ||
36 | static DEFINE_MUTEX(pci_acpi_lock); | ||
37 | |||
38 | static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle) | 38 | static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle) |
39 | { | 39 | { |
40 | struct acpi_osc_data *data; | 40 | struct acpi_osc_data *data; |
@@ -83,6 +83,9 @@ static acpi_status acpi_run_osc(acpi_handle handle, | |||
83 | if (ACPI_FAILURE(status)) | 83 | if (ACPI_FAILURE(status)) |
84 | return status; | 84 | return status; |
85 | 85 | ||
86 | if (!output.length) | ||
87 | return AE_NULL_OBJECT; | ||
88 | |||
86 | out_obj = output.pointer; | 89 | out_obj = output.pointer; |
87 | if (out_obj->type != ACPI_TYPE_BUFFER) { | 90 | if (out_obj->type != ACPI_TYPE_BUFFER) { |
88 | printk(KERN_DEBUG "Evaluate _OSC returns wrong type\n"); | 91 | printk(KERN_DEBUG "Evaluate _OSC returns wrong type\n"); |
@@ -108,9 +111,8 @@ static acpi_status acpi_run_osc(acpi_handle handle, | |||
108 | goto out_kfree; | 111 | goto out_kfree; |
109 | } | 112 | } |
110 | out_success: | 113 | out_success: |
111 | if (flags & OSC_QUERY_ENABLE) | 114 | osc_args->ctrl_result = |
112 | osc_args->query_result = | 115 | *((u32 *)(out_obj->buffer.pointer + 8)); |
113 | *((u32 *)(out_obj->buffer.pointer + 8)); | ||
114 | status = AE_OK; | 116 | status = AE_OK; |
115 | 117 | ||
116 | out_kfree: | 118 | out_kfree: |
@@ -118,41 +120,53 @@ out_kfree: | |||
118 | return status; | 120 | return status; |
119 | } | 121 | } |
120 | 122 | ||
121 | static acpi_status acpi_query_osc(acpi_handle handle, | 123 | static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data, |
122 | u32 level, void *context, void **retval) | 124 | u32 *result) |
123 | { | 125 | { |
124 | acpi_status status; | 126 | acpi_status status; |
125 | struct acpi_osc_data *osc_data; | 127 | u32 support_set; |
126 | u32 flags = (unsigned long)context, support_set; | ||
127 | acpi_handle tmp; | ||
128 | struct acpi_osc_args osc_args; | 128 | struct acpi_osc_args osc_args; |
129 | 129 | ||
130 | status = acpi_get_handle(handle, "_OSC", &tmp); | ||
131 | if (ACPI_FAILURE(status)) | ||
132 | return status; | ||
133 | |||
134 | osc_data = acpi_get_osc_data(handle); | ||
135 | if (!osc_data) { | ||
136 | printk(KERN_ERR "acpi osc data array is full\n"); | ||
137 | return AE_ERROR; | ||
138 | } | ||
139 | |||
140 | /* do _OSC query for all possible controls */ | 130 | /* do _OSC query for all possible controls */ |
141 | support_set = osc_data->support_set | (flags & OSC_SUPPORT_MASKS); | 131 | support_set = osc_data->support_set | (flags & OSC_SUPPORT_MASKS); |
142 | osc_args.capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; | 132 | osc_args.capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; |
143 | osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set; | 133 | osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set; |
144 | osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; | 134 | osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; |
145 | 135 | ||
146 | status = acpi_run_osc(handle, &osc_args); | 136 | status = acpi_run_osc(osc_data->handle, &osc_args); |
147 | if (ACPI_SUCCESS(status)) { | 137 | if (ACPI_SUCCESS(status)) { |
148 | osc_data->support_set = support_set; | 138 | osc_data->support_set = support_set; |
149 | osc_data->query_result = osc_args.query_result; | 139 | *result = osc_args.ctrl_result; |
150 | osc_data->is_queried = 1; | ||
151 | } | 140 | } |
152 | 141 | ||
153 | return status; | 142 | return status; |
154 | } | 143 | } |
155 | 144 | ||
145 | static acpi_status acpi_query_osc(acpi_handle handle, | ||
146 | u32 level, void *context, void **retval) | ||
147 | { | ||
148 | acpi_status status; | ||
149 | struct acpi_osc_data *osc_data; | ||
150 | u32 flags = (unsigned long)context, dummy; | ||
151 | acpi_handle tmp; | ||
152 | |||
153 | status = acpi_get_handle(handle, "_OSC", &tmp); | ||
154 | if (ACPI_FAILURE(status)) | ||
155 | return AE_OK; | ||
156 | |||
157 | mutex_lock(&pci_acpi_lock); | ||
158 | osc_data = acpi_get_osc_data(handle); | ||
159 | if (!osc_data) { | ||
160 | printk(KERN_ERR "acpi osc data array is full\n"); | ||
161 | goto out; | ||
162 | } | ||
163 | |||
164 | __acpi_query_osc(flags, osc_data, &dummy); | ||
165 | out: | ||
166 | mutex_unlock(&pci_acpi_lock); | ||
167 | return AE_OK; | ||
168 | } | ||
169 | |||
156 | /** | 170 | /** |
157 | * __pci_osc_support_set - register OS support to Firmware | 171 | * __pci_osc_support_set - register OS support to Firmware |
158 | * @flags: OS support bits | 172 | * @flags: OS support bits |
@@ -181,7 +195,7 @@ acpi_status __pci_osc_support_set(u32 flags, const char *hid) | |||
181 | acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) | 195 | acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) |
182 | { | 196 | { |
183 | acpi_status status; | 197 | acpi_status status; |
184 | u32 ctrlset, control_set; | 198 | u32 ctrlset, control_set, result; |
185 | acpi_handle tmp; | 199 | acpi_handle tmp; |
186 | struct acpi_osc_data *osc_data; | 200 | struct acpi_osc_data *osc_data; |
187 | struct acpi_osc_args osc_args; | 201 | struct acpi_osc_args osc_args; |
@@ -190,19 +204,28 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) | |||
190 | if (ACPI_FAILURE(status)) | 204 | if (ACPI_FAILURE(status)) |
191 | return status; | 205 | return status; |
192 | 206 | ||
207 | mutex_lock(&pci_acpi_lock); | ||
193 | osc_data = acpi_get_osc_data(handle); | 208 | osc_data = acpi_get_osc_data(handle); |
194 | if (!osc_data) { | 209 | if (!osc_data) { |
195 | printk(KERN_ERR "acpi osc data array is full\n"); | 210 | printk(KERN_ERR "acpi osc data array is full\n"); |
196 | return AE_ERROR; | 211 | status = AE_ERROR; |
212 | goto out; | ||
197 | } | 213 | } |
198 | 214 | ||
199 | ctrlset = (flags & OSC_CONTROL_MASKS); | 215 | ctrlset = (flags & OSC_CONTROL_MASKS); |
200 | if (!ctrlset) | 216 | if (!ctrlset) { |
201 | return AE_TYPE; | 217 | status = AE_TYPE; |
218 | goto out; | ||
219 | } | ||
202 | 220 | ||
203 | if (osc_data->is_queried && | 221 | status = __acpi_query_osc(osc_data->support_set, osc_data, &result); |
204 | ((osc_data->query_result & ctrlset) != ctrlset)) | 222 | if (ACPI_FAILURE(status)) |
205 | return AE_SUPPORT; | 223 | goto out; |
224 | |||
225 | if ((result & ctrlset) != ctrlset) { | ||
226 | status = AE_SUPPORT; | ||
227 | goto out; | ||
228 | } | ||
206 | 229 | ||
207 | control_set = osc_data->control_set | ctrlset; | 230 | control_set = osc_data->control_set | ctrlset; |
208 | osc_args.capbuf[OSC_QUERY_TYPE] = 0; | 231 | osc_args.capbuf[OSC_QUERY_TYPE] = 0; |
@@ -211,7 +234,8 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) | |||
211 | status = acpi_run_osc(handle, &osc_args); | 234 | status = acpi_run_osc(handle, &osc_args); |
212 | if (ACPI_SUCCESS(status)) | 235 | if (ACPI_SUCCESS(status)) |
213 | osc_data->control_set = control_set; | 236 | osc_data->control_set = control_set; |
214 | 237 | out: | |
238 | mutex_unlock(&pci_acpi_lock); | ||
215 | return status; | 239 | return status; |
216 | } | 240 | } |
217 | EXPORT_SYMBOL(pci_osc_control_set); | 241 | EXPORT_SYMBOL(pci_osc_control_set); |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index a13f5348611..b4cdd690ae7 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -43,18 +43,32 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) | |||
43 | { | 43 | { |
44 | struct pci_dynid *dynid; | 44 | struct pci_dynid *dynid; |
45 | struct pci_driver *pdrv = to_pci_driver(driver); | 45 | struct pci_driver *pdrv = to_pci_driver(driver); |
46 | const struct pci_device_id *ids = pdrv->id_table; | ||
46 | __u32 vendor, device, subvendor=PCI_ANY_ID, | 47 | __u32 vendor, device, subvendor=PCI_ANY_ID, |
47 | subdevice=PCI_ANY_ID, class=0, class_mask=0; | 48 | subdevice=PCI_ANY_ID, class=0, class_mask=0; |
48 | unsigned long driver_data=0; | 49 | unsigned long driver_data=0; |
49 | int fields=0; | 50 | int fields=0; |
50 | int retval = 0; | 51 | int retval; |
51 | 52 | ||
52 | fields = sscanf(buf, "%x %x %x %x %x %x %lux", | 53 | fields = sscanf(buf, "%x %x %x %x %x %x %lx", |
53 | &vendor, &device, &subvendor, &subdevice, | 54 | &vendor, &device, &subvendor, &subdevice, |
54 | &class, &class_mask, &driver_data); | 55 | &class, &class_mask, &driver_data); |
55 | if (fields < 2) | 56 | if (fields < 2) |
56 | return -EINVAL; | 57 | return -EINVAL; |
57 | 58 | ||
59 | /* Only accept driver_data values that match an existing id_table | ||
60 | entry */ | ||
61 | retval = -EINVAL; | ||
62 | while (ids->vendor || ids->subvendor || ids->class_mask) { | ||
63 | if (driver_data == ids->driver_data) { | ||
64 | retval = 0; | ||
65 | break; | ||
66 | } | ||
67 | ids++; | ||
68 | } | ||
69 | if (retval) /* No match */ | ||
70 | return retval; | ||
71 | |||
58 | dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); | 72 | dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); |
59 | if (!dynid) | 73 | if (!dynid) |
60 | return -ENOMEM; | 74 | return -ENOMEM; |
@@ -65,8 +79,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) | |||
65 | dynid->id.subdevice = subdevice; | 79 | dynid->id.subdevice = subdevice; |
66 | dynid->id.class = class; | 80 | dynid->id.class = class; |
67 | dynid->id.class_mask = class_mask; | 81 | dynid->id.class_mask = class_mask; |
68 | dynid->id.driver_data = pdrv->dynids.use_driver_data ? | 82 | dynid->id.driver_data = driver_data; |
69 | driver_data : 0UL; | ||
70 | 83 | ||
71 | spin_lock(&pdrv->dynids.lock); | 84 | spin_lock(&pdrv->dynids.lock); |
72 | list_add_tail(&dynid->node, &pdrv->dynids.list); | 85 | list_add_tail(&dynid->node, &pdrv->dynids.list); |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 77baff022f7..5d72866897a 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -423,7 +423,7 @@ pci_write_vpd(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
423 | * Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific | 423 | * Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific |
424 | * callback routine (pci_legacy_read). | 424 | * callback routine (pci_legacy_read). |
425 | */ | 425 | */ |
426 | ssize_t | 426 | static ssize_t |
427 | pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | 427 | pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, |
428 | char *buf, loff_t off, size_t count) | 428 | char *buf, loff_t off, size_t count) |
429 | { | 429 | { |
@@ -448,7 +448,7 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
448 | * Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific | 448 | * Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific |
449 | * callback routine (pci_legacy_write). | 449 | * callback routine (pci_legacy_write). |
450 | */ | 450 | */ |
451 | ssize_t | 451 | static ssize_t |
452 | pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | 452 | pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, |
453 | char *buf, loff_t off, size_t count) | 453 | char *buf, loff_t off, size_t count) |
454 | { | 454 | { |
@@ -468,11 +468,11 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
468 | * @attr: struct bin_attribute for this file | 468 | * @attr: struct bin_attribute for this file |
469 | * @vma: struct vm_area_struct passed to mmap | 469 | * @vma: struct vm_area_struct passed to mmap |
470 | * | 470 | * |
471 | * Uses an arch specific callback, pci_mmap_legacy_page_range, to mmap | 471 | * Uses an arch specific callback, pci_mmap_legacy_mem_page_range, to mmap |
472 | * legacy memory space (first meg of bus space) into application virtual | 472 | * legacy memory space (first meg of bus space) into application virtual |
473 | * memory space. | 473 | * memory space. |
474 | */ | 474 | */ |
475 | int | 475 | static int |
476 | pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | 476 | pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, |
477 | struct vm_area_struct *vma) | 477 | struct vm_area_struct *vma) |
478 | { | 478 | { |
@@ -480,7 +480,90 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
480 | struct device, | 480 | struct device, |
481 | kobj)); | 481 | kobj)); |
482 | 482 | ||
483 | return pci_mmap_legacy_page_range(bus, vma); | 483 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem); |
484 | } | ||
485 | |||
486 | /** | ||
487 | * pci_mmap_legacy_io - map legacy PCI IO into user memory space | ||
488 | * @kobj: kobject corresponding to device to be mapped | ||
489 | * @attr: struct bin_attribute for this file | ||
490 | * @vma: struct vm_area_struct passed to mmap | ||
491 | * | ||
492 | * Uses an arch specific callback, pci_mmap_legacy_io_page_range, to mmap | ||
493 | * legacy IO space (first meg of bus space) into application virtual | ||
494 | * memory space. Returns -ENOSYS if the operation isn't supported | ||
495 | */ | ||
496 | static int | ||
497 | pci_mmap_legacy_io(struct kobject *kobj, struct bin_attribute *attr, | ||
498 | struct vm_area_struct *vma) | ||
499 | { | ||
500 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | ||
501 | struct device, | ||
502 | kobj)); | ||
503 | |||
504 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * pci_create_legacy_files - create legacy I/O port and memory files | ||
509 | * @b: bus to create files under | ||
510 | * | ||
511 | * Some platforms allow access to legacy I/O port and ISA memory space on | ||
512 | * a per-bus basis. This routine creates the files and ties them into | ||
513 | * their associated read, write and mmap files from pci-sysfs.c | ||
514 | * | ||
515 | * On error unwind, but don't propogate the error to the caller | ||
516 | * as it is ok to set up the PCI bus without these files. | ||
517 | */ | ||
518 | void pci_create_legacy_files(struct pci_bus *b) | ||
519 | { | ||
520 | int error; | ||
521 | |||
522 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, | ||
523 | GFP_ATOMIC); | ||
524 | if (!b->legacy_io) | ||
525 | goto kzalloc_err; | ||
526 | |||
527 | b->legacy_io->attr.name = "legacy_io"; | ||
528 | b->legacy_io->size = 0xffff; | ||
529 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | ||
530 | b->legacy_io->read = pci_read_legacy_io; | ||
531 | b->legacy_io->write = pci_write_legacy_io; | ||
532 | b->legacy_io->mmap = pci_mmap_legacy_io; | ||
533 | error = device_create_bin_file(&b->dev, b->legacy_io); | ||
534 | if (error) | ||
535 | goto legacy_io_err; | ||
536 | |||
537 | /* Allocated above after the legacy_io struct */ | ||
538 | b->legacy_mem = b->legacy_io + 1; | ||
539 | b->legacy_mem->attr.name = "legacy_mem"; | ||
540 | b->legacy_mem->size = 1024*1024; | ||
541 | b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR; | ||
542 | b->legacy_mem->mmap = pci_mmap_legacy_mem; | ||
543 | error = device_create_bin_file(&b->dev, b->legacy_mem); | ||
544 | if (error) | ||
545 | goto legacy_mem_err; | ||
546 | |||
547 | return; | ||
548 | |||
549 | legacy_mem_err: | ||
550 | device_remove_bin_file(&b->dev, b->legacy_io); | ||
551 | legacy_io_err: | ||
552 | kfree(b->legacy_io); | ||
553 | b->legacy_io = NULL; | ||
554 | kzalloc_err: | ||
555 | printk(KERN_WARNING "pci: warning: could not create legacy I/O port " | ||
556 | "and ISA memory resources to sysfs\n"); | ||
557 | return; | ||
558 | } | ||
559 | |||
560 | void pci_remove_legacy_files(struct pci_bus *b) | ||
561 | { | ||
562 | if (b->legacy_io) { | ||
563 | device_remove_bin_file(&b->dev, b->legacy_io); | ||
564 | device_remove_bin_file(&b->dev, b->legacy_mem); | ||
565 | kfree(b->legacy_io); /* both are allocated here */ | ||
566 | } | ||
484 | } | 567 | } |
485 | #endif /* HAVE_PCI_LEGACY */ | 568 | #endif /* HAVE_PCI_LEGACY */ |
486 | 569 | ||
@@ -492,7 +575,7 @@ static int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct | |||
492 | 575 | ||
493 | nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 576 | nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; |
494 | start = vma->vm_pgoff; | 577 | start = vma->vm_pgoff; |
495 | size = pci_resource_len(pdev, resno) >> PAGE_SHIFT; | 578 | size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1; |
496 | if (start < size && size - start >= nr) | 579 | if (start < size && size - start >= nr) |
497 | return 1; | 580 | return 1; |
498 | WARN(1, "process \"%s\" tried to map 0x%08lx-0x%08lx on %s BAR %d (size 0x%08lx)\n", | 581 | WARN(1, "process \"%s\" tried to map 0x%08lx-0x%08lx on %s BAR %d (size 0x%08lx)\n", |
@@ -715,7 +798,7 @@ static struct bin_attribute pci_config_attr = { | |||
715 | .name = "config", | 798 | .name = "config", |
716 | .mode = S_IRUGO | S_IWUSR, | 799 | .mode = S_IRUGO | S_IWUSR, |
717 | }, | 800 | }, |
718 | .size = 256, | 801 | .size = PCI_CFG_SPACE_SIZE, |
719 | .read = pci_read_config, | 802 | .read = pci_read_config, |
720 | .write = pci_write_config, | 803 | .write = pci_write_config, |
721 | }; | 804 | }; |
@@ -725,7 +808,7 @@ static struct bin_attribute pcie_config_attr = { | |||
725 | .name = "config", | 808 | .name = "config", |
726 | .mode = S_IRUGO | S_IWUSR, | 809 | .mode = S_IRUGO | S_IWUSR, |
727 | }, | 810 | }, |
728 | .size = 4096, | 811 | .size = PCI_CFG_SPACE_EXP_SIZE, |
729 | .read = pci_read_config, | 812 | .read = pci_read_config, |
730 | .write = pci_write_config, | 813 | .write = pci_write_config, |
731 | }; | 814 | }; |
@@ -735,86 +818,103 @@ int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev) | |||
735 | return 0; | 818 | return 0; |
736 | } | 819 | } |
737 | 820 | ||
821 | static int pci_create_capabilities_sysfs(struct pci_dev *dev) | ||
822 | { | ||
823 | int retval; | ||
824 | struct bin_attribute *attr; | ||
825 | |||
826 | /* If the device has VPD, try to expose it in sysfs. */ | ||
827 | if (dev->vpd) { | ||
828 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); | ||
829 | if (!attr) | ||
830 | return -ENOMEM; | ||
831 | |||
832 | attr->size = dev->vpd->len; | ||
833 | attr->attr.name = "vpd"; | ||
834 | attr->attr.mode = S_IRUSR | S_IWUSR; | ||
835 | attr->read = pci_read_vpd; | ||
836 | attr->write = pci_write_vpd; | ||
837 | retval = sysfs_create_bin_file(&dev->dev.kobj, attr); | ||
838 | if (retval) { | ||
839 | kfree(dev->vpd->attr); | ||
840 | return retval; | ||
841 | } | ||
842 | dev->vpd->attr = attr; | ||
843 | } | ||
844 | |||
845 | /* Active State Power Management */ | ||
846 | pcie_aspm_create_sysfs_dev_files(dev); | ||
847 | |||
848 | return 0; | ||
849 | } | ||
850 | |||
738 | int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | 851 | int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) |
739 | { | 852 | { |
740 | struct bin_attribute *attr = NULL; | ||
741 | int retval; | 853 | int retval; |
854 | int rom_size = 0; | ||
855 | struct bin_attribute *attr; | ||
742 | 856 | ||
743 | if (!sysfs_initialized) | 857 | if (!sysfs_initialized) |
744 | return -EACCES; | 858 | return -EACCES; |
745 | 859 | ||
746 | if (pdev->cfg_size < 4096) | 860 | if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) |
747 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); | 861 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); |
748 | else | 862 | else |
749 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); | 863 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
750 | if (retval) | 864 | if (retval) |
751 | goto err; | 865 | goto err; |
752 | 866 | ||
753 | /* If the device has VPD, try to expose it in sysfs. */ | ||
754 | if (pdev->vpd) { | ||
755 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); | ||
756 | if (attr) { | ||
757 | pdev->vpd->attr = attr; | ||
758 | attr->size = pdev->vpd->len; | ||
759 | attr->attr.name = "vpd"; | ||
760 | attr->attr.mode = S_IRUSR | S_IWUSR; | ||
761 | attr->read = pci_read_vpd; | ||
762 | attr->write = pci_write_vpd; | ||
763 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); | ||
764 | if (retval) | ||
765 | goto err_vpd; | ||
766 | } else { | ||
767 | retval = -ENOMEM; | ||
768 | goto err_config_file; | ||
769 | } | ||
770 | } | ||
771 | |||
772 | retval = pci_create_resource_files(pdev); | 867 | retval = pci_create_resource_files(pdev); |
773 | if (retval) | 868 | if (retval) |
774 | goto err_vpd_file; | 869 | goto err_config_file; |
870 | |||
871 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) | ||
872 | rom_size = pci_resource_len(pdev, PCI_ROM_RESOURCE); | ||
873 | else if (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) | ||
874 | rom_size = 0x20000; | ||
775 | 875 | ||
776 | /* If the device has a ROM, try to expose it in sysfs. */ | 876 | /* If the device has a ROM, try to expose it in sysfs. */ |
777 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE) || | 877 | if (rom_size) { |
778 | (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)) { | ||
779 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); | 878 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); |
780 | if (attr) { | 879 | if (!attr) { |
781 | pdev->rom_attr = attr; | ||
782 | attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE); | ||
783 | attr->attr.name = "rom"; | ||
784 | attr->attr.mode = S_IRUSR; | ||
785 | attr->read = pci_read_rom; | ||
786 | attr->write = pci_write_rom; | ||
787 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); | ||
788 | if (retval) | ||
789 | goto err_rom; | ||
790 | } else { | ||
791 | retval = -ENOMEM; | 880 | retval = -ENOMEM; |
792 | goto err_resource_files; | 881 | goto err_resource_files; |
793 | } | 882 | } |
883 | attr->size = rom_size; | ||
884 | attr->attr.name = "rom"; | ||
885 | attr->attr.mode = S_IRUSR; | ||
886 | attr->read = pci_read_rom; | ||
887 | attr->write = pci_write_rom; | ||
888 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); | ||
889 | if (retval) { | ||
890 | kfree(attr); | ||
891 | goto err_resource_files; | ||
892 | } | ||
893 | pdev->rom_attr = attr; | ||
794 | } | 894 | } |
895 | |||
795 | /* add platform-specific attributes */ | 896 | /* add platform-specific attributes */ |
796 | if (pcibios_add_platform_entries(pdev)) | 897 | retval = pcibios_add_platform_entries(pdev); |
898 | if (retval) | ||
797 | goto err_rom_file; | 899 | goto err_rom_file; |
798 | 900 | ||
799 | pcie_aspm_create_sysfs_dev_files(pdev); | 901 | /* add sysfs entries for various capabilities */ |
902 | retval = pci_create_capabilities_sysfs(pdev); | ||
903 | if (retval) | ||
904 | goto err_rom_file; | ||
800 | 905 | ||
801 | return 0; | 906 | return 0; |
802 | 907 | ||
803 | err_rom_file: | 908 | err_rom_file: |
804 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) | 909 | if (rom_size) { |
805 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); | 910 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); |
806 | err_rom: | 911 | kfree(pdev->rom_attr); |
807 | kfree(pdev->rom_attr); | 912 | pdev->rom_attr = NULL; |
913 | } | ||
808 | err_resource_files: | 914 | err_resource_files: |
809 | pci_remove_resource_files(pdev); | 915 | pci_remove_resource_files(pdev); |
810 | err_vpd_file: | ||
811 | if (pdev->vpd) { | ||
812 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->vpd->attr); | ||
813 | err_vpd: | ||
814 | kfree(pdev->vpd->attr); | ||
815 | } | ||
816 | err_config_file: | 916 | err_config_file: |
817 | if (pdev->cfg_size < 4096) | 917 | if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) |
818 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); | 918 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); |
819 | else | 919 | else |
820 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); | 920 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
@@ -822,6 +922,16 @@ err: | |||
822 | return retval; | 922 | return retval; |
823 | } | 923 | } |
824 | 924 | ||
925 | static void pci_remove_capabilities_sysfs(struct pci_dev *dev) | ||
926 | { | ||
927 | if (dev->vpd && dev->vpd->attr) { | ||
928 | sysfs_remove_bin_file(&dev->dev.kobj, dev->vpd->attr); | ||
929 | kfree(dev->vpd->attr); | ||
930 | } | ||
931 | |||
932 | pcie_aspm_remove_sysfs_dev_files(dev); | ||
933 | } | ||
934 | |||
825 | /** | 935 | /** |
826 | * pci_remove_sysfs_dev_files - cleanup PCI specific sysfs files | 936 | * pci_remove_sysfs_dev_files - cleanup PCI specific sysfs files |
827 | * @pdev: device whose entries we should free | 937 | * @pdev: device whose entries we should free |
@@ -830,27 +940,28 @@ err: | |||
830 | */ | 940 | */ |
831 | void pci_remove_sysfs_dev_files(struct pci_dev *pdev) | 941 | void pci_remove_sysfs_dev_files(struct pci_dev *pdev) |
832 | { | 942 | { |
943 | int rom_size = 0; | ||
944 | |||
833 | if (!sysfs_initialized) | 945 | if (!sysfs_initialized) |
834 | return; | 946 | return; |
835 | 947 | ||
836 | pcie_aspm_remove_sysfs_dev_files(pdev); | 948 | pci_remove_capabilities_sysfs(pdev); |
837 | 949 | ||
838 | if (pdev->vpd) { | 950 | if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) |
839 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->vpd->attr); | ||
840 | kfree(pdev->vpd->attr); | ||
841 | } | ||
842 | if (pdev->cfg_size < 4096) | ||
843 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); | 951 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); |
844 | else | 952 | else |
845 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); | 953 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
846 | 954 | ||
847 | pci_remove_resource_files(pdev); | 955 | pci_remove_resource_files(pdev); |
848 | 956 | ||
849 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { | 957 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) |
850 | if (pdev->rom_attr) { | 958 | rom_size = pci_resource_len(pdev, PCI_ROM_RESOURCE); |
851 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); | 959 | else if (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) |
852 | kfree(pdev->rom_attr); | 960 | rom_size = 0x20000; |
853 | } | 961 | |
962 | if (rom_size && pdev->rom_attr) { | ||
963 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); | ||
964 | kfree(pdev->rom_attr); | ||
854 | } | 965 | } |
855 | } | 966 | } |
856 | 967 | ||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c9884bba22d..21f2ac639ca 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/log2.h> | 18 | #include <linux/log2.h> |
19 | #include <linux/pci-aspm.h> | 19 | #include <linux/pci-aspm.h> |
20 | #include <linux/pm_wakeup.h> | 20 | #include <linux/pm_wakeup.h> |
21 | #include <linux/interrupt.h> | ||
21 | #include <asm/dma.h> /* isa_dma_bridge_buggy */ | 22 | #include <asm/dma.h> /* isa_dma_bridge_buggy */ |
22 | #include "pci.h" | 23 | #include "pci.h" |
23 | 24 | ||
@@ -213,10 +214,13 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap) | |||
213 | int pci_find_ext_capability(struct pci_dev *dev, int cap) | 214 | int pci_find_ext_capability(struct pci_dev *dev, int cap) |
214 | { | 215 | { |
215 | u32 header; | 216 | u32 header; |
216 | int ttl = 480; /* 3840 bytes, minimum 8 bytes per capability */ | 217 | int ttl; |
217 | int pos = 0x100; | 218 | int pos = PCI_CFG_SPACE_SIZE; |
218 | 219 | ||
219 | if (dev->cfg_size <= 256) | 220 | /* minimum 8 bytes per capability */ |
221 | ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; | ||
222 | |||
223 | if (dev->cfg_size <= PCI_CFG_SPACE_SIZE) | ||
220 | return 0; | 224 | return 0; |
221 | 225 | ||
222 | if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) | 226 | if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) |
@@ -234,7 +238,7 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap) | |||
234 | return pos; | 238 | return pos; |
235 | 239 | ||
236 | pos = PCI_EXT_CAP_NEXT(header); | 240 | pos = PCI_EXT_CAP_NEXT(header); |
237 | if (pos < 0x100) | 241 | if (pos < PCI_CFG_SPACE_SIZE) |
238 | break; | 242 | break; |
239 | 243 | ||
240 | if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) | 244 | if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) |
@@ -1127,6 +1131,27 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) | |||
1127 | } | 1131 | } |
1128 | 1132 | ||
1129 | /** | 1133 | /** |
1134 | * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold | ||
1135 | * @dev: PCI device to prepare | ||
1136 | * @enable: True to enable wake-up event generation; false to disable | ||
1137 | * | ||
1138 | * Many drivers want the device to wake up the system from D3_hot or D3_cold | ||
1139 | * and this function allows them to set that up cleanly - pci_enable_wake() | ||
1140 | * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI | ||
1141 | * ordering constraints. | ||
1142 | * | ||
1143 | * This function only returns error code if the device is not capable of | ||
1144 | * generating PME# from both D3_hot and D3_cold, and the platform is unable to | ||
1145 | * enable wake-up power for it. | ||
1146 | */ | ||
1147 | int pci_wake_from_d3(struct pci_dev *dev, bool enable) | ||
1148 | { | ||
1149 | return pci_pme_capable(dev, PCI_D3cold) ? | ||
1150 | pci_enable_wake(dev, PCI_D3cold, enable) : | ||
1151 | pci_enable_wake(dev, PCI_D3hot, enable); | ||
1152 | } | ||
1153 | |||
1154 | /** | ||
1130 | * pci_target_state - find an appropriate low power state for a given PCI dev | 1155 | * pci_target_state - find an appropriate low power state for a given PCI dev |
1131 | * @dev: PCI device | 1156 | * @dev: PCI device |
1132 | * | 1157 | * |
@@ -1242,25 +1267,25 @@ void pci_pm_init(struct pci_dev *dev) | |||
1242 | dev->d1_support = false; | 1267 | dev->d1_support = false; |
1243 | dev->d2_support = false; | 1268 | dev->d2_support = false; |
1244 | if (!pci_no_d1d2(dev)) { | 1269 | if (!pci_no_d1d2(dev)) { |
1245 | if (pmc & PCI_PM_CAP_D1) { | 1270 | if (pmc & PCI_PM_CAP_D1) |
1246 | dev_printk(KERN_DEBUG, &dev->dev, "supports D1\n"); | ||
1247 | dev->d1_support = true; | 1271 | dev->d1_support = true; |
1248 | } | 1272 | if (pmc & PCI_PM_CAP_D2) |
1249 | if (pmc & PCI_PM_CAP_D2) { | ||
1250 | dev_printk(KERN_DEBUG, &dev->dev, "supports D2\n"); | ||
1251 | dev->d2_support = true; | 1273 | dev->d2_support = true; |
1252 | } | 1274 | |
1275 | if (dev->d1_support || dev->d2_support) | ||
1276 | dev_printk(KERN_DEBUG, &dev->dev, "supports%s%s\n", | ||
1277 | dev->d1_support ? " D1" : "", | ||
1278 | dev->d2_support ? " D2" : ""); | ||
1253 | } | 1279 | } |
1254 | 1280 | ||
1255 | pmc &= PCI_PM_CAP_PME_MASK; | 1281 | pmc &= PCI_PM_CAP_PME_MASK; |
1256 | if (pmc) { | 1282 | if (pmc) { |
1257 | dev_printk(KERN_INFO, &dev->dev, | 1283 | dev_info(&dev->dev, "PME# supported from%s%s%s%s%s\n", |
1258 | "PME# supported from%s%s%s%s%s\n", | 1284 | (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "", |
1259 | (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "", | 1285 | (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "", |
1260 | (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "", | 1286 | (pmc & PCI_PM_CAP_PME_D2) ? " D2" : "", |
1261 | (pmc & PCI_PM_CAP_PME_D2) ? " D2" : "", | 1287 | (pmc & PCI_PM_CAP_PME_D3) ? " D3hot" : "", |
1262 | (pmc & PCI_PM_CAP_PME_D3) ? " D3hot" : "", | 1288 | (pmc & PCI_PM_CAP_PME_D3cold) ? " D3cold" : ""); |
1263 | (pmc & PCI_PM_CAP_PME_D3cold) ? " D3cold" : ""); | ||
1264 | dev->pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; | 1289 | dev->pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; |
1265 | /* | 1290 | /* |
1266 | * Make device's PM flags reflect the wake-up capability, but | 1291 | * Make device's PM flags reflect the wake-up capability, but |
@@ -1275,6 +1300,43 @@ void pci_pm_init(struct pci_dev *dev) | |||
1275 | } | 1300 | } |
1276 | } | 1301 | } |
1277 | 1302 | ||
1303 | /** | ||
1304 | * pci_enable_ari - enable ARI forwarding if hardware support it | ||
1305 | * @dev: the PCI device | ||
1306 | */ | ||
1307 | void pci_enable_ari(struct pci_dev *dev) | ||
1308 | { | ||
1309 | int pos; | ||
1310 | u32 cap; | ||
1311 | u16 ctrl; | ||
1312 | struct pci_dev *bridge; | ||
1313 | |||
1314 | if (!dev->is_pcie || dev->devfn) | ||
1315 | return; | ||
1316 | |||
1317 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); | ||
1318 | if (!pos) | ||
1319 | return; | ||
1320 | |||
1321 | bridge = dev->bus->self; | ||
1322 | if (!bridge || !bridge->is_pcie) | ||
1323 | return; | ||
1324 | |||
1325 | pos = pci_find_capability(bridge, PCI_CAP_ID_EXP); | ||
1326 | if (!pos) | ||
1327 | return; | ||
1328 | |||
1329 | pci_read_config_dword(bridge, pos + PCI_EXP_DEVCAP2, &cap); | ||
1330 | if (!(cap & PCI_EXP_DEVCAP2_ARI)) | ||
1331 | return; | ||
1332 | |||
1333 | pci_read_config_word(bridge, pos + PCI_EXP_DEVCTL2, &ctrl); | ||
1334 | ctrl |= PCI_EXP_DEVCTL2_ARI; | ||
1335 | pci_write_config_word(bridge, pos + PCI_EXP_DEVCTL2, ctrl); | ||
1336 | |||
1337 | bridge->ari_enabled = 1; | ||
1338 | } | ||
1339 | |||
1278 | int | 1340 | int |
1279 | pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge) | 1341 | pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge) |
1280 | { | 1342 | { |
@@ -1358,11 +1420,10 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) | |||
1358 | return 0; | 1420 | return 0; |
1359 | 1421 | ||
1360 | err_out: | 1422 | err_out: |
1361 | dev_warn(&pdev->dev, "BAR %d: can't reserve %s region [%#llx-%#llx]\n", | 1423 | dev_warn(&pdev->dev, "BAR %d: can't reserve %s region %pR\n", |
1362 | bar, | 1424 | bar, |
1363 | pci_resource_flags(pdev, bar) & IORESOURCE_IO ? "I/O" : "mem", | 1425 | pci_resource_flags(pdev, bar) & IORESOURCE_IO ? "I/O" : "mem", |
1364 | (unsigned long long)pci_resource_start(pdev, bar), | 1426 | &pdev->resource[bar]); |
1365 | (unsigned long long)pci_resource_end(pdev, bar)); | ||
1366 | return -EBUSY; | 1427 | return -EBUSY; |
1367 | } | 1428 | } |
1368 | 1429 | ||
@@ -1691,6 +1752,103 @@ EXPORT_SYMBOL(pci_set_dma_seg_boundary); | |||
1691 | #endif | 1752 | #endif |
1692 | 1753 | ||
1693 | /** | 1754 | /** |
1755 | * pci_execute_reset_function() - Reset a PCI device function | ||
1756 | * @dev: Device function to reset | ||
1757 | * | ||
1758 | * Some devices allow an individual function to be reset without affecting | ||
1759 | * other functions in the same device. The PCI device must be responsive | ||
1760 | * to PCI config space in order to use this function. | ||
1761 | * | ||
1762 | * The device function is presumed to be unused when this function is called. | ||
1763 | * Resetting the device will make the contents of PCI configuration space | ||
1764 | * random, so any caller of this must be prepared to reinitialise the | ||
1765 | * device including MSI, bus mastering, BARs, decoding IO and memory spaces, | ||
1766 | * etc. | ||
1767 | * | ||
1768 | * Returns 0 if the device function was successfully reset or -ENOTTY if the | ||
1769 | * device doesn't support resetting a single function. | ||
1770 | */ | ||
1771 | int pci_execute_reset_function(struct pci_dev *dev) | ||
1772 | { | ||
1773 | u16 status; | ||
1774 | u32 cap; | ||
1775 | int exppos = pci_find_capability(dev, PCI_CAP_ID_EXP); | ||
1776 | |||
1777 | if (!exppos) | ||
1778 | return -ENOTTY; | ||
1779 | pci_read_config_dword(dev, exppos + PCI_EXP_DEVCAP, &cap); | ||
1780 | if (!(cap & PCI_EXP_DEVCAP_FLR)) | ||
1781 | return -ENOTTY; | ||
1782 | |||
1783 | pci_block_user_cfg_access(dev); | ||
1784 | |||
1785 | /* Wait for Transaction Pending bit clean */ | ||
1786 | msleep(100); | ||
1787 | pci_read_config_word(dev, exppos + PCI_EXP_DEVSTA, &status); | ||
1788 | if (status & PCI_EXP_DEVSTA_TRPND) { | ||
1789 | dev_info(&dev->dev, "Busy after 100ms while trying to reset; " | ||
1790 | "sleeping for 1 second\n"); | ||
1791 | ssleep(1); | ||
1792 | pci_read_config_word(dev, exppos + PCI_EXP_DEVSTA, &status); | ||
1793 | if (status & PCI_EXP_DEVSTA_TRPND) | ||
1794 | dev_info(&dev->dev, "Still busy after 1s; " | ||
1795 | "proceeding with reset anyway\n"); | ||
1796 | } | ||
1797 | |||
1798 | pci_write_config_word(dev, exppos + PCI_EXP_DEVCTL, | ||
1799 | PCI_EXP_DEVCTL_BCR_FLR); | ||
1800 | mdelay(100); | ||
1801 | |||
1802 | pci_unblock_user_cfg_access(dev); | ||
1803 | return 0; | ||
1804 | } | ||
1805 | EXPORT_SYMBOL_GPL(pci_execute_reset_function); | ||
1806 | |||
1807 | /** | ||
1808 | * pci_reset_function() - quiesce and reset a PCI device function | ||
1809 | * @dev: Device function to reset | ||
1810 | * | ||
1811 | * Some devices allow an individual function to be reset without affecting | ||
1812 | * other functions in the same device. The PCI device must be responsive | ||
1813 | * to PCI config space in order to use this function. | ||
1814 | * | ||
1815 | * This function does not just reset the PCI portion of a device, but | ||
1816 | * clears all the state associated with the device. This function differs | ||
1817 | * from pci_execute_reset_function in that it saves and restores device state | ||
1818 | * over the reset. | ||
1819 | * | ||
1820 | * Returns 0 if the device function was successfully reset or -ENOTTY if the | ||
1821 | * device doesn't support resetting a single function. | ||
1822 | */ | ||
1823 | int pci_reset_function(struct pci_dev *dev) | ||
1824 | { | ||
1825 | u32 cap; | ||
1826 | int exppos = pci_find_capability(dev, PCI_CAP_ID_EXP); | ||
1827 | int r; | ||
1828 | |||
1829 | if (!exppos) | ||
1830 | return -ENOTTY; | ||
1831 | pci_read_config_dword(dev, exppos + PCI_EXP_DEVCAP, &cap); | ||
1832 | if (!(cap & PCI_EXP_DEVCAP_FLR)) | ||
1833 | return -ENOTTY; | ||
1834 | |||
1835 | if (!dev->msi_enabled && !dev->msix_enabled) | ||
1836 | disable_irq(dev->irq); | ||
1837 | pci_save_state(dev); | ||
1838 | |||
1839 | pci_write_config_word(dev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE); | ||
1840 | |||
1841 | r = pci_execute_reset_function(dev); | ||
1842 | |||
1843 | pci_restore_state(dev); | ||
1844 | if (!dev->msi_enabled && !dev->msix_enabled) | ||
1845 | enable_irq(dev->irq); | ||
1846 | |||
1847 | return r; | ||
1848 | } | ||
1849 | EXPORT_SYMBOL_GPL(pci_reset_function); | ||
1850 | |||
1851 | /** | ||
1694 | * pcix_get_max_mmrbc - get PCI-X maximum designed memory read byte count | 1852 | * pcix_get_max_mmrbc - get PCI-X maximum designed memory read byte count |
1695 | * @dev: PCI device to query | 1853 | * @dev: PCI device to query |
1696 | * | 1854 | * |
@@ -1878,6 +2036,9 @@ static int __devinit pci_init(void) | |||
1878 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 2036 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { |
1879 | pci_fixup_device(pci_fixup_final, dev); | 2037 | pci_fixup_device(pci_fixup_final, dev); |
1880 | } | 2038 | } |
2039 | |||
2040 | msi_init(); | ||
2041 | |||
1881 | return 0; | 2042 | return 0; |
1882 | } | 2043 | } |
1883 | 2044 | ||
@@ -1943,6 +2104,7 @@ EXPORT_SYMBOL(pci_restore_state); | |||
1943 | EXPORT_SYMBOL(pci_pme_capable); | 2104 | EXPORT_SYMBOL(pci_pme_capable); |
1944 | EXPORT_SYMBOL(pci_pme_active); | 2105 | EXPORT_SYMBOL(pci_pme_active); |
1945 | EXPORT_SYMBOL(pci_enable_wake); | 2106 | EXPORT_SYMBOL(pci_enable_wake); |
2107 | EXPORT_SYMBOL(pci_wake_from_d3); | ||
1946 | EXPORT_SYMBOL(pci_target_state); | 2108 | EXPORT_SYMBOL(pci_target_state); |
1947 | EXPORT_SYMBOL(pci_prepare_to_sleep); | 2109 | EXPORT_SYMBOL(pci_prepare_to_sleep); |
1948 | EXPORT_SYMBOL(pci_back_from_sleep); | 2110 | EXPORT_SYMBOL(pci_back_from_sleep); |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index d807cd786f2..9de87e9f98f 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -1,3 +1,9 @@ | |||
1 | #ifndef DRIVERS_PCI_H | ||
2 | #define DRIVERS_PCI_H | ||
3 | |||
4 | #define PCI_CFG_SPACE_SIZE 256 | ||
5 | #define PCI_CFG_SPACE_EXP_SIZE 4096 | ||
6 | |||
1 | /* Functions internal to the PCI core code */ | 7 | /* Functions internal to the PCI core code */ |
2 | 8 | ||
3 | extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env); | 9 | extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env); |
@@ -76,7 +82,13 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } | |||
76 | /* Functions for PCI Hotplug drivers to use */ | 82 | /* Functions for PCI Hotplug drivers to use */ |
77 | extern unsigned int pci_do_scan_bus(struct pci_bus *bus); | 83 | extern unsigned int pci_do_scan_bus(struct pci_bus *bus); |
78 | 84 | ||
85 | #ifdef HAVE_PCI_LEGACY | ||
86 | extern void pci_create_legacy_files(struct pci_bus *bus); | ||
79 | extern void pci_remove_legacy_files(struct pci_bus *bus); | 87 | extern void pci_remove_legacy_files(struct pci_bus *bus); |
88 | #else | ||
89 | static inline void pci_create_legacy_files(struct pci_bus *bus) { return; } | ||
90 | static inline void pci_remove_legacy_files(struct pci_bus *bus) { return; } | ||
91 | #endif | ||
80 | 92 | ||
81 | /* Lock for read/write access to pci device and bus lists */ | 93 | /* Lock for read/write access to pci device and bus lists */ |
82 | extern struct rw_semaphore pci_bus_sem; | 94 | extern struct rw_semaphore pci_bus_sem; |
@@ -86,9 +98,11 @@ extern unsigned int pci_pm_d3_delay; | |||
86 | #ifdef CONFIG_PCI_MSI | 98 | #ifdef CONFIG_PCI_MSI |
87 | void pci_no_msi(void); | 99 | void pci_no_msi(void); |
88 | extern void pci_msi_init_pci_dev(struct pci_dev *dev); | 100 | extern void pci_msi_init_pci_dev(struct pci_dev *dev); |
101 | extern void __devinit msi_init(void); | ||
89 | #else | 102 | #else |
90 | static inline void pci_no_msi(void) { } | 103 | static inline void pci_no_msi(void) { } |
91 | static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } | 104 | static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } |
105 | static inline void msi_init(void) { } | ||
92 | #endif | 106 | #endif |
93 | 107 | ||
94 | #ifdef CONFIG_PCIEAER | 108 | #ifdef CONFIG_PCIEAER |
@@ -109,6 +123,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev) | |||
109 | extern int pcie_mch_quirk; | 123 | extern int pcie_mch_quirk; |
110 | extern struct device_attribute pci_dev_attrs[]; | 124 | extern struct device_attribute pci_dev_attrs[]; |
111 | extern struct device_attribute dev_attr_cpuaffinity; | 125 | extern struct device_attribute dev_attr_cpuaffinity; |
126 | extern struct device_attribute dev_attr_cpulistaffinity; | ||
112 | 127 | ||
113 | /** | 128 | /** |
114 | * pci_match_one_device - Tell if a PCI device structure has a matching | 129 | * pci_match_one_device - Tell if a PCI device structure has a matching |
@@ -144,3 +159,16 @@ struct pci_slot_attribute { | |||
144 | }; | 159 | }; |
145 | #define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr) | 160 | #define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr) |
146 | 161 | ||
162 | extern void pci_enable_ari(struct pci_dev *dev); | ||
163 | /** | ||
164 | * pci_ari_enabled - query ARI forwarding status | ||
165 | * @dev: the PCI device | ||
166 | * | ||
167 | * Returns 1 if ARI forwarding is enabled, or 0 if not enabled; | ||
168 | */ | ||
169 | static inline int pci_ari_enabled(struct pci_dev *dev) | ||
170 | { | ||
171 | return dev->ari_enabled; | ||
172 | } | ||
173 | |||
174 | #endif /* DRIVERS_PCI_H */ | ||
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 77036f46acf..e390707661d 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -105,7 +105,7 @@ static irqreturn_t aer_irq(int irq, void *context) | |||
105 | unsigned long flags; | 105 | unsigned long flags; |
106 | int pos; | 106 | int pos; |
107 | 107 | ||
108 | pos = pci_find_aer_capability(pdev->port); | 108 | pos = pci_find_ext_capability(pdev->port, PCI_EXT_CAP_ID_ERR); |
109 | /* | 109 | /* |
110 | * Must lock access to Root Error Status Reg, Root Error ID Reg, | 110 | * Must lock access to Root Error Status Reg, Root Error ID Reg, |
111 | * and Root error producer/consumer index | 111 | * and Root error producer/consumer index |
@@ -252,7 +252,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev) | |||
252 | u32 status; | 252 | u32 status; |
253 | int pos; | 253 | int pos; |
254 | 254 | ||
255 | pos = pci_find_aer_capability(dev); | 255 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
256 | 256 | ||
257 | /* Disable Root's interrupt in response to error messages */ | 257 | /* Disable Root's interrupt in response to error messages */ |
258 | pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, 0); | 258 | pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, 0); |
@@ -316,7 +316,7 @@ static void aer_error_resume(struct pci_dev *dev) | |||
316 | pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, reg16); | 316 | pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, reg16); |
317 | 317 | ||
318 | /* Clean AER Root Error Status */ | 318 | /* Clean AER Root Error Status */ |
319 | pos = pci_find_aer_capability(dev); | 319 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
320 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status); | 320 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status); |
321 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask); | 321 | pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask); |
322 | if (dev->error_state == pci_channel_io_normal) | 322 | if (dev->error_state == pci_channel_io_normal) |
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index ee5e7b5176d..dfc63d01f20 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -28,41 +28,15 @@ | |||
28 | static int forceload; | 28 | static int forceload; |
29 | module_param(forceload, bool, 0); | 29 | module_param(forceload, bool, 0); |
30 | 30 | ||
31 | #define PCI_CFG_SPACE_SIZE (0x100) | ||
32 | int pci_find_aer_capability(struct pci_dev *dev) | ||
33 | { | ||
34 | int pos; | ||
35 | u32 reg32 = 0; | ||
36 | |||
37 | /* Check if it's a pci-express device */ | ||
38 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); | ||
39 | if (!pos) | ||
40 | return 0; | ||
41 | |||
42 | /* Check if it supports pci-express AER */ | ||
43 | pos = PCI_CFG_SPACE_SIZE; | ||
44 | while (pos) { | ||
45 | if (pci_read_config_dword(dev, pos, ®32)) | ||
46 | return 0; | ||
47 | |||
48 | /* some broken boards return ~0 */ | ||
49 | if (reg32 == 0xffffffff) | ||
50 | return 0; | ||
51 | |||
52 | if (PCI_EXT_CAP_ID(reg32) == PCI_EXT_CAP_ID_ERR) | ||
53 | break; | ||
54 | |||
55 | pos = reg32 >> 20; | ||
56 | } | ||
57 | |||
58 | return pos; | ||
59 | } | ||
60 | |||
61 | int pci_enable_pcie_error_reporting(struct pci_dev *dev) | 31 | int pci_enable_pcie_error_reporting(struct pci_dev *dev) |
62 | { | 32 | { |
63 | u16 reg16 = 0; | 33 | u16 reg16 = 0; |
64 | int pos; | 34 | int pos; |
65 | 35 | ||
36 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | ||
37 | if (!pos) | ||
38 | return -EIO; | ||
39 | |||
66 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); | 40 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); |
67 | if (!pos) | 41 | if (!pos) |
68 | return -EIO; | 42 | return -EIO; |
@@ -102,7 +76,7 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) | |||
102 | int pos; | 76 | int pos; |
103 | u32 status, mask; | 77 | u32 status, mask; |
104 | 78 | ||
105 | pos = pci_find_aer_capability(dev); | 79 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
106 | if (!pos) | 80 | if (!pos) |
107 | return -EIO; | 81 | return -EIO; |
108 | 82 | ||
@@ -123,7 +97,7 @@ int pci_cleanup_aer_correct_error_status(struct pci_dev *dev) | |||
123 | int pos; | 97 | int pos; |
124 | u32 status; | 98 | u32 status; |
125 | 99 | ||
126 | pos = pci_find_aer_capability(dev); | 100 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
127 | if (!pos) | 101 | if (!pos) |
128 | return -EIO; | 102 | return -EIO; |
129 | 103 | ||
@@ -502,7 +476,7 @@ static void handle_error_source(struct pcie_device * aerdev, | |||
502 | * Correctable error does not need software intevention. | 476 | * Correctable error does not need software intevention. |
503 | * No need to go through error recovery process. | 477 | * No need to go through error recovery process. |
504 | */ | 478 | */ |
505 | pos = pci_find_aer_capability(dev); | 479 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
506 | if (pos) | 480 | if (pos) |
507 | pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, | 481 | pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, |
508 | info.status); | 482 | info.status); |
@@ -542,7 +516,7 @@ void aer_enable_rootport(struct aer_rpc *rpc) | |||
542 | reg16 &= ~(SYSTEM_ERROR_INTR_ON_MESG_MASK); | 516 | reg16 &= ~(SYSTEM_ERROR_INTR_ON_MESG_MASK); |
543 | pci_write_config_word(pdev, pos + PCI_EXP_RTCTL, reg16); | 517 | pci_write_config_word(pdev, pos + PCI_EXP_RTCTL, reg16); |
544 | 518 | ||
545 | aer_pos = pci_find_aer_capability(pdev); | 519 | aer_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); |
546 | /* Clear error status */ | 520 | /* Clear error status */ |
547 | pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, ®32); | 521 | pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, ®32); |
548 | pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, reg32); | 522 | pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, reg32); |
@@ -579,7 +553,7 @@ static void disable_root_aer(struct aer_rpc *rpc) | |||
579 | u32 reg32; | 553 | u32 reg32; |
580 | int pos; | 554 | int pos; |
581 | 555 | ||
582 | pos = pci_find_aer_capability(pdev); | 556 | pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); |
583 | /* Disable Root's interrupt in response to error messages */ | 557 | /* Disable Root's interrupt in response to error messages */ |
584 | pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, 0); | 558 | pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, 0); |
585 | 559 | ||
@@ -618,7 +592,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) | |||
618 | { | 592 | { |
619 | int pos; | 593 | int pos; |
620 | 594 | ||
621 | pos = pci_find_aer_capability(dev); | 595 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
622 | 596 | ||
623 | /* The device might not support AER */ | 597 | /* The device might not support AER */ |
624 | if (!pos) | 598 | if (!pos) |
@@ -755,7 +729,6 @@ int aer_init(struct pcie_device *dev) | |||
755 | return AER_SUCCESS; | 729 | return AER_SUCCESS; |
756 | } | 730 | } |
757 | 731 | ||
758 | EXPORT_SYMBOL_GPL(pci_find_aer_capability); | ||
759 | EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); | 732 | EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); |
760 | EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); | 733 | EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); |
761 | EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status); | 734 | EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status); |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 851f5b83cdb..8f63f4c6b85 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -528,9 +528,9 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) | |||
528 | pci_read_config_dword(child_dev, child_pos + PCI_EXP_DEVCAP, | 528 | pci_read_config_dword(child_dev, child_pos + PCI_EXP_DEVCAP, |
529 | ®32); | 529 | ®32); |
530 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { | 530 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { |
531 | printk("Pre-1.1 PCIe device detected, " | 531 | dev_printk(KERN_INFO, &child_dev->dev, "disabling ASPM" |
532 | "disable ASPM for %s. It can be enabled forcedly" | 532 | " on pre-1.1 PCIe device. You can enable it" |
533 | " with 'pcie_aspm=force'\n", pci_name(pdev)); | 533 | " with 'pcie_aspm=force'\n"); |
534 | return -EINVAL; | 534 | return -EINVAL; |
535 | } | 535 | } |
536 | } | 536 | } |
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index 3656e0349dd..2529f3f2ea5 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h | |||
@@ -25,7 +25,6 @@ | |||
25 | #define PCIE_CAPABILITIES_REG 0x2 | 25 | #define PCIE_CAPABILITIES_REG 0x2 |
26 | #define PCIE_SLOT_CAPABILITIES_REG 0x14 | 26 | #define PCIE_SLOT_CAPABILITIES_REG 0x14 |
27 | #define PCIE_PORT_DEVICE_MAXSERVICES 4 | 27 | #define PCIE_PORT_DEVICE_MAXSERVICES 4 |
28 | #define PCI_CFG_SPACE_SIZE 256 | ||
29 | 28 | ||
30 | #define get_descriptor_id(type, service) (((type - 4) << 4) | service) | 29 | #define get_descriptor_id(type, service) (((type - 4) << 4) | service) |
31 | 30 | ||
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 890f0d2b370..2e091e01482 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -195,24 +195,11 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
195 | /* PME Capable - root port capability */ | 195 | /* PME Capable - root port capability */ |
196 | if (((reg16 >> 4) & PORT_TYPE_MASK) == PCIE_RC_PORT) | 196 | if (((reg16 >> 4) & PORT_TYPE_MASK) == PCIE_RC_PORT) |
197 | services |= PCIE_PORT_SERVICE_PME; | 197 | services |= PCIE_PORT_SERVICE_PME; |
198 | 198 | ||
199 | pos = PCI_CFG_SPACE_SIZE; | 199 | if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR)) |
200 | while (pos) { | 200 | services |= PCIE_PORT_SERVICE_AER; |
201 | pci_read_config_dword(dev, pos, ®32); | 201 | if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_VC)) |
202 | switch (reg32 & 0xffff) { | 202 | services |= PCIE_PORT_SERVICE_VC; |
203 | case PCI_EXT_CAP_ID_ERR: | ||
204 | services |= PCIE_PORT_SERVICE_AER; | ||
205 | pos = reg32 >> 20; | ||
206 | break; | ||
207 | case PCI_EXT_CAP_ID_VC: | ||
208 | services |= PCIE_PORT_SERVICE_VC; | ||
209 | pos = reg32 >> 20; | ||
210 | break; | ||
211 | default: | ||
212 | pos = 0; | ||
213 | break; | ||
214 | } | ||
215 | } | ||
216 | 203 | ||
217 | return services; | 204 | return services; |
218 | } | 205 | } |
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 367c9c20000..584422da8d8 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c | |||
@@ -91,7 +91,7 @@ static int __devinit pcie_portdrv_probe (struct pci_dev *dev, | |||
91 | 91 | ||
92 | pci_set_master(dev); | 92 | pci_set_master(dev); |
93 | if (!dev->irq && dev->pin) { | 93 | if (!dev->irq && dev->pin) { |
94 | dev_warn(&dev->dev, "device [%04x/%04x] has invalid IRQ; " | 94 | dev_warn(&dev->dev, "device [%04x:%04x] has invalid IRQ; " |
95 | "check vendor BIOS\n", dev->vendor, dev->device); | 95 | "check vendor BIOS\n", dev->vendor, dev->device); |
96 | } | 96 | } |
97 | if (pcie_port_device_register(dev)) { | 97 | if (pcie_port_device_register(dev)) { |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index dd9161a054e..003a9b3c293 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -14,8 +14,6 @@ | |||
14 | 14 | ||
15 | #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ | 15 | #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ |
16 | #define CARDBUS_RESERVE_BUSNR 3 | 16 | #define CARDBUS_RESERVE_BUSNR 3 |
17 | #define PCI_CFG_SPACE_SIZE 256 | ||
18 | #define PCI_CFG_SPACE_EXP_SIZE 4096 | ||
19 | 17 | ||
20 | /* Ugh. Need to stop exporting this to modules. */ | 18 | /* Ugh. Need to stop exporting this to modules. */ |
21 | LIST_HEAD(pci_root_buses); | 19 | LIST_HEAD(pci_root_buses); |
@@ -44,72 +42,6 @@ int no_pci_devices(void) | |||
44 | } | 42 | } |
45 | EXPORT_SYMBOL(no_pci_devices); | 43 | EXPORT_SYMBOL(no_pci_devices); |
46 | 44 | ||
47 | #ifdef HAVE_PCI_LEGACY | ||
48 | /** | ||
49 | * pci_create_legacy_files - create legacy I/O port and memory files | ||
50 | * @b: bus to create files under | ||
51 | * | ||
52 | * Some platforms allow access to legacy I/O port and ISA memory space on | ||
53 | * a per-bus basis. This routine creates the files and ties them into | ||
54 | * their associated read, write and mmap files from pci-sysfs.c | ||
55 | * | ||
56 | * On error unwind, but don't propogate the error to the caller | ||
57 | * as it is ok to set up the PCI bus without these files. | ||
58 | */ | ||
59 | static void pci_create_legacy_files(struct pci_bus *b) | ||
60 | { | ||
61 | int error; | ||
62 | |||
63 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, | ||
64 | GFP_ATOMIC); | ||
65 | if (!b->legacy_io) | ||
66 | goto kzalloc_err; | ||
67 | |||
68 | b->legacy_io->attr.name = "legacy_io"; | ||
69 | b->legacy_io->size = 0xffff; | ||
70 | b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; | ||
71 | b->legacy_io->read = pci_read_legacy_io; | ||
72 | b->legacy_io->write = pci_write_legacy_io; | ||
73 | error = device_create_bin_file(&b->dev, b->legacy_io); | ||
74 | if (error) | ||
75 | goto legacy_io_err; | ||
76 | |||
77 | /* Allocated above after the legacy_io struct */ | ||
78 | b->legacy_mem = b->legacy_io + 1; | ||
79 | b->legacy_mem->attr.name = "legacy_mem"; | ||
80 | b->legacy_mem->size = 1024*1024; | ||
81 | b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR; | ||
82 | b->legacy_mem->mmap = pci_mmap_legacy_mem; | ||
83 | error = device_create_bin_file(&b->dev, b->legacy_mem); | ||
84 | if (error) | ||
85 | goto legacy_mem_err; | ||
86 | |||
87 | return; | ||
88 | |||
89 | legacy_mem_err: | ||
90 | device_remove_bin_file(&b->dev, b->legacy_io); | ||
91 | legacy_io_err: | ||
92 | kfree(b->legacy_io); | ||
93 | b->legacy_io = NULL; | ||
94 | kzalloc_err: | ||
95 | printk(KERN_WARNING "pci: warning: could not create legacy I/O port " | ||
96 | "and ISA memory resources to sysfs\n"); | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | void pci_remove_legacy_files(struct pci_bus *b) | ||
101 | { | ||
102 | if (b->legacy_io) { | ||
103 | device_remove_bin_file(&b->dev, b->legacy_io); | ||
104 | device_remove_bin_file(&b->dev, b->legacy_mem); | ||
105 | kfree(b->legacy_io); /* both are allocated here */ | ||
106 | } | ||
107 | } | ||
108 | #else /* !HAVE_PCI_LEGACY */ | ||
109 | static inline void pci_create_legacy_files(struct pci_bus *bus) { return; } | ||
110 | void pci_remove_legacy_files(struct pci_bus *bus) { return; } | ||
111 | #endif /* HAVE_PCI_LEGACY */ | ||
112 | |||
113 | /* | 45 | /* |
114 | * PCI Bus Class Devices | 46 | * PCI Bus Class Devices |
115 | */ | 47 | */ |
@@ -219,7 +151,7 @@ static inline enum pci_bar_type decode_bar(struct resource *res, u32 bar) | |||
219 | 151 | ||
220 | res->flags = bar & ~PCI_BASE_ADDRESS_MEM_MASK; | 152 | res->flags = bar & ~PCI_BASE_ADDRESS_MEM_MASK; |
221 | 153 | ||
222 | if (res->flags == PCI_BASE_ADDRESS_MEM_TYPE_64) | 154 | if (res->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) |
223 | return pci_bar_mem64; | 155 | return pci_bar_mem64; |
224 | return pci_bar_mem32; | 156 | return pci_bar_mem32; |
225 | } | 157 | } |
@@ -304,9 +236,8 @@ static int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
304 | } else { | 236 | } else { |
305 | res->start = l64; | 237 | res->start = l64; |
306 | res->end = l64 + sz64; | 238 | res->end = l64 + sz64; |
307 | printk(KERN_DEBUG "PCI: %s reg %x 64bit mmio: [%llx, %llx]\n", | 239 | dev_printk(KERN_DEBUG, &dev->dev, |
308 | pci_name(dev), pos, (unsigned long long)res->start, | 240 | "reg %x 64bit mmio: %pR\n", pos, res); |
309 | (unsigned long long)res->end); | ||
310 | } | 241 | } |
311 | } else { | 242 | } else { |
312 | sz = pci_size(l, sz, mask); | 243 | sz = pci_size(l, sz, mask); |
@@ -316,9 +247,10 @@ static int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
316 | 247 | ||
317 | res->start = l; | 248 | res->start = l; |
318 | res->end = l + sz; | 249 | res->end = l + sz; |
319 | printk(KERN_DEBUG "PCI: %s reg %x %s: [%llx, %llx]\n", pci_name(dev), | 250 | |
320 | pos, (res->flags & IORESOURCE_IO) ? "io port":"32bit mmio", | 251 | dev_printk(KERN_DEBUG, &dev->dev, "reg %x %s: %pR\n", pos, |
321 | (unsigned long long)res->start, (unsigned long long)res->end); | 252 | (res->flags & IORESOURCE_IO) ? "io port" : "32bit mmio", |
253 | res); | ||
322 | } | 254 | } |
323 | 255 | ||
324 | out: | 256 | out: |
@@ -366,9 +298,6 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) | |||
366 | child->resource[i] = child->parent->resource[i - 3]; | 298 | child->resource[i] = child->parent->resource[i - 3]; |
367 | } | 299 | } |
368 | 300 | ||
369 | for(i=0; i<3; i++) | ||
370 | child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i]; | ||
371 | |||
372 | res = child->resource[0]; | 301 | res = child->resource[0]; |
373 | pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); | 302 | pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); |
374 | pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); | 303 | pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); |
@@ -389,9 +318,7 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) | |||
389 | res->start = base; | 318 | res->start = base; |
390 | if (!res->end) | 319 | if (!res->end) |
391 | res->end = limit + 0xfff; | 320 | res->end = limit + 0xfff; |
392 | printk(KERN_DEBUG "PCI: bridge %s io port: [%llx, %llx]\n", | 321 | dev_printk(KERN_DEBUG, &dev->dev, "bridge io port: %pR\n", res); |
393 | pci_name(dev), (unsigned long long) res->start, | ||
394 | (unsigned long long) res->end); | ||
395 | } | 322 | } |
396 | 323 | ||
397 | res = child->resource[1]; | 324 | res = child->resource[1]; |
@@ -403,9 +330,8 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) | |||
403 | res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM; | 330 | res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM; |
404 | res->start = base; | 331 | res->start = base; |
405 | res->end = limit + 0xfffff; | 332 | res->end = limit + 0xfffff; |
406 | printk(KERN_DEBUG "PCI: bridge %s 32bit mmio: [%llx, %llx]\n", | 333 | dev_printk(KERN_DEBUG, &dev->dev, "bridge 32bit mmio: %pR\n", |
407 | pci_name(dev), (unsigned long long) res->start, | 334 | res); |
408 | (unsigned long long) res->end); | ||
409 | } | 335 | } |
410 | 336 | ||
411 | res = child->resource[2]; | 337 | res = child->resource[2]; |
@@ -441,9 +367,9 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) | |||
441 | res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH; | 367 | res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH; |
442 | res->start = base; | 368 | res->start = base; |
443 | res->end = limit + 0xfffff; | 369 | res->end = limit + 0xfffff; |
444 | printk(KERN_DEBUG "PCI: bridge %s %sbit mmio pref: [%llx, %llx]\n", | 370 | dev_printk(KERN_DEBUG, &dev->dev, "bridge %sbit mmio pref: %pR\n", |
445 | pci_name(dev), (res->flags & PCI_PREF_RANGE_TYPE_64) ? "64" : "32", | 371 | (res->flags & PCI_PREF_RANGE_TYPE_64) ? "64" : "32", |
446 | (unsigned long long) res->start, (unsigned long long) res->end); | 372 | res); |
447 | } | 373 | } |
448 | } | 374 | } |
449 | 375 | ||
@@ -551,19 +477,27 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
551 | int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); | 477 | int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); |
552 | u32 buses, i, j = 0; | 478 | u32 buses, i, j = 0; |
553 | u16 bctl; | 479 | u16 bctl; |
480 | int broken = 0; | ||
554 | 481 | ||
555 | pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); | 482 | pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); |
556 | 483 | ||
557 | dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n", | 484 | dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n", |
558 | buses & 0xffffff, pass); | 485 | buses & 0xffffff, pass); |
559 | 486 | ||
487 | /* Check if setup is sensible at all */ | ||
488 | if (!pass && | ||
489 | ((buses & 0xff) != bus->number || ((buses >> 8) & 0xff) <= bus->number)) { | ||
490 | dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n"); | ||
491 | broken = 1; | ||
492 | } | ||
493 | |||
560 | /* Disable MasterAbortMode during probing to avoid reporting | 494 | /* Disable MasterAbortMode during probing to avoid reporting |
561 | of bus errors (in some architectures) */ | 495 | of bus errors (in some architectures) */ |
562 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl); | 496 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl); |
563 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, | 497 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, |
564 | bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); | 498 | bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); |
565 | 499 | ||
566 | if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus) { | 500 | if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus && !broken) { |
567 | unsigned int cmax, busnr; | 501 | unsigned int cmax, busnr; |
568 | /* | 502 | /* |
569 | * Bus already configured by firmware, process it in the first | 503 | * Bus already configured by firmware, process it in the first |
@@ -601,7 +535,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, | |||
601 | * do in the second pass. | 535 | * do in the second pass. |
602 | */ | 536 | */ |
603 | if (!pass) { | 537 | if (!pass) { |
604 | if (pcibios_assign_all_busses()) | 538 | if (pcibios_assign_all_busses() || broken) |
605 | /* Temporarily disable forwarding of the | 539 | /* Temporarily disable forwarding of the |
606 | configuration cycles on all bridges in | 540 | configuration cycles on all bridges in |
607 | this bus segment to avoid possible | 541 | this bus segment to avoid possible |
@@ -764,7 +698,7 @@ static int pci_setup_device(struct pci_dev * dev) | |||
764 | dev->class = class; | 698 | dev->class = class; |
765 | class >>= 8; | 699 | class >>= 8; |
766 | 700 | ||
767 | dev_dbg(&dev->dev, "found [%04x/%04x] class %06x header type %02x\n", | 701 | dev_dbg(&dev->dev, "found [%04x:%04x] class %06x header type %02x\n", |
768 | dev->vendor, dev->device, class, dev->hdr_type); | 702 | dev->vendor, dev->device, class, dev->hdr_type); |
769 | 703 | ||
770 | /* "Unknown power state" */ | 704 | /* "Unknown power state" */ |
@@ -846,6 +780,11 @@ static int pci_setup_device(struct pci_dev * dev) | |||
846 | return 0; | 780 | return 0; |
847 | } | 781 | } |
848 | 782 | ||
783 | static void pci_release_capabilities(struct pci_dev *dev) | ||
784 | { | ||
785 | pci_vpd_release(dev); | ||
786 | } | ||
787 | |||
849 | /** | 788 | /** |
850 | * pci_release_dev - free a pci device structure when all users of it are finished. | 789 | * pci_release_dev - free a pci device structure when all users of it are finished. |
851 | * @dev: device that's been disconnected | 790 | * @dev: device that's been disconnected |
@@ -858,7 +797,7 @@ static void pci_release_dev(struct device *dev) | |||
858 | struct pci_dev *pci_dev; | 797 | struct pci_dev *pci_dev; |
859 | 798 | ||
860 | pci_dev = to_pci_dev(dev); | 799 | pci_dev = to_pci_dev(dev); |
861 | pci_vpd_release(pci_dev); | 800 | pci_release_capabilities(pci_dev); |
862 | kfree(pci_dev); | 801 | kfree(pci_dev); |
863 | } | 802 | } |
864 | 803 | ||
@@ -889,8 +828,9 @@ static void set_pcie_port_type(struct pci_dev *pdev) | |||
889 | int pci_cfg_space_size_ext(struct pci_dev *dev) | 828 | int pci_cfg_space_size_ext(struct pci_dev *dev) |
890 | { | 829 | { |
891 | u32 status; | 830 | u32 status; |
831 | int pos = PCI_CFG_SPACE_SIZE; | ||
892 | 832 | ||
893 | if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) | 833 | if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL) |
894 | goto fail; | 834 | goto fail; |
895 | if (status == 0xffffffff) | 835 | if (status == 0xffffffff) |
896 | goto fail; | 836 | goto fail; |
@@ -938,8 +878,6 @@ struct pci_dev *alloc_pci_dev(void) | |||
938 | 878 | ||
939 | INIT_LIST_HEAD(&dev->bus_list); | 879 | INIT_LIST_HEAD(&dev->bus_list); |
940 | 880 | ||
941 | pci_msi_init_pci_dev(dev); | ||
942 | |||
943 | return dev; | 881 | return dev; |
944 | } | 882 | } |
945 | EXPORT_SYMBOL(alloc_pci_dev); | 883 | EXPORT_SYMBOL(alloc_pci_dev); |
@@ -951,6 +889,7 @@ EXPORT_SYMBOL(alloc_pci_dev); | |||
951 | static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) | 889 | static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) |
952 | { | 890 | { |
953 | struct pci_dev *dev; | 891 | struct pci_dev *dev; |
892 | struct pci_slot *slot; | ||
954 | u32 l; | 893 | u32 l; |
955 | u8 hdr_type; | 894 | u8 hdr_type; |
956 | int delay = 1; | 895 | int delay = 1; |
@@ -999,6 +938,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) | |||
999 | dev->error_state = pci_channel_io_normal; | 938 | dev->error_state = pci_channel_io_normal; |
1000 | set_pcie_port_type(dev); | 939 | set_pcie_port_type(dev); |
1001 | 940 | ||
941 | list_for_each_entry(slot, &bus->slots, list) | ||
942 | if (PCI_SLOT(devfn) == slot->number) | ||
943 | dev->slot = slot; | ||
944 | |||
1002 | /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) | 945 | /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) |
1003 | set this higher, assuming the system even supports it. */ | 946 | set this higher, assuming the system even supports it. */ |
1004 | dev->dma_mask = 0xffffffff; | 947 | dev->dma_mask = 0xffffffff; |
@@ -1007,9 +950,22 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) | |||
1007 | return NULL; | 950 | return NULL; |
1008 | } | 951 | } |
1009 | 952 | ||
953 | return dev; | ||
954 | } | ||
955 | |||
956 | static void pci_init_capabilities(struct pci_dev *dev) | ||
957 | { | ||
958 | /* MSI/MSI-X list */ | ||
959 | pci_msi_init_pci_dev(dev); | ||
960 | |||
961 | /* Power Management */ | ||
962 | pci_pm_init(dev); | ||
963 | |||
964 | /* Vital Product Data */ | ||
1010 | pci_vpd_pci22_init(dev); | 965 | pci_vpd_pci22_init(dev); |
1011 | 966 | ||
1012 | return dev; | 967 | /* Alternative Routing-ID Forwarding */ |
968 | pci_enable_ari(dev); | ||
1013 | } | 969 | } |
1014 | 970 | ||
1015 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | 971 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) |
@@ -1028,8 +984,8 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | |||
1028 | /* Fix up broken headers */ | 984 | /* Fix up broken headers */ |
1029 | pci_fixup_device(pci_fixup_header, dev); | 985 | pci_fixup_device(pci_fixup_header, dev); |
1030 | 986 | ||
1031 | /* Initialize power management of the device */ | 987 | /* Initialize various capabilities */ |
1032 | pci_pm_init(dev); | 988 | pci_init_capabilities(dev); |
1033 | 989 | ||
1034 | /* | 990 | /* |
1035 | * Add the device to our list of discovered devices | 991 | * Add the device to our list of discovered devices |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index e872ac925b4..5049a47030a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -24,6 +24,14 @@ | |||
24 | #include <linux/kallsyms.h> | 24 | #include <linux/kallsyms.h> |
25 | #include "pci.h" | 25 | #include "pci.h" |
26 | 26 | ||
27 | int isa_dma_bridge_buggy; | ||
28 | EXPORT_SYMBOL(isa_dma_bridge_buggy); | ||
29 | int pci_pci_problems; | ||
30 | EXPORT_SYMBOL(pci_pci_problems); | ||
31 | int pcie_mch_quirk; | ||
32 | EXPORT_SYMBOL(pcie_mch_quirk); | ||
33 | |||
34 | #ifdef CONFIG_PCI_QUIRKS | ||
27 | /* The Mellanox Tavor device gives false positive parity errors | 35 | /* The Mellanox Tavor device gives false positive parity errors |
28 | * Mark this device with a broken_parity_status, to allow | 36 | * Mark this device with a broken_parity_status, to allow |
29 | * PCI scanning code to "skip" this now blacklisted device. | 37 | * PCI scanning code to "skip" this now blacklisted device. |
@@ -62,8 +70,6 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, quirk_p | |||
62 | 70 | ||
63 | This appears to be BIOS not version dependent. So presumably there is a | 71 | This appears to be BIOS not version dependent. So presumably there is a |
64 | chipset level fix */ | 72 | chipset level fix */ |
65 | int isa_dma_bridge_buggy; | ||
66 | EXPORT_SYMBOL(isa_dma_bridge_buggy); | ||
67 | 73 | ||
68 | static void __devinit quirk_isa_dma_hangs(struct pci_dev *dev) | 74 | static void __devinit quirk_isa_dma_hangs(struct pci_dev *dev) |
69 | { | 75 | { |
@@ -84,9 +90,6 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_1, quirk_isa_d | |||
84 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_2, quirk_isa_dma_hangs); | 90 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_2, quirk_isa_dma_hangs); |
85 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_3, quirk_isa_dma_hangs); | 91 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_3, quirk_isa_dma_hangs); |
86 | 92 | ||
87 | int pci_pci_problems; | ||
88 | EXPORT_SYMBOL(pci_pci_problems); | ||
89 | |||
90 | /* | 93 | /* |
91 | * Chipsets where PCI->PCI transfers vanish or hang | 94 | * Chipsets where PCI->PCI transfers vanish or hang |
92 | */ | 95 | */ |
@@ -1362,9 +1365,6 @@ static void __init quirk_alder_ioapic(struct pci_dev *pdev) | |||
1362 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic); | 1365 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic); |
1363 | #endif | 1366 | #endif |
1364 | 1367 | ||
1365 | int pcie_mch_quirk; | ||
1366 | EXPORT_SYMBOL(pcie_mch_quirk); | ||
1367 | |||
1368 | static void __devinit quirk_pcie_mch(struct pci_dev *pdev) | 1368 | static void __devinit quirk_pcie_mch(struct pci_dev *pdev) |
1369 | { | 1369 | { |
1370 | pcie_mch_quirk = 1; | 1370 | pcie_mch_quirk = 1; |
@@ -1555,84 +1555,6 @@ static void __devinit fixup_rev1_53c810(struct pci_dev* dev) | |||
1555 | } | 1555 | } |
1556 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); | 1556 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); |
1557 | 1557 | ||
1558 | static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end) | ||
1559 | { | ||
1560 | while (f < end) { | ||
1561 | if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) && | ||
1562 | (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) { | ||
1563 | #ifdef DEBUG | ||
1564 | dev_dbg(&dev->dev, "calling %pF\n", f->hook); | ||
1565 | #endif | ||
1566 | f->hook(dev); | ||
1567 | } | ||
1568 | f++; | ||
1569 | } | ||
1570 | } | ||
1571 | |||
1572 | extern struct pci_fixup __start_pci_fixups_early[]; | ||
1573 | extern struct pci_fixup __end_pci_fixups_early[]; | ||
1574 | extern struct pci_fixup __start_pci_fixups_header[]; | ||
1575 | extern struct pci_fixup __end_pci_fixups_header[]; | ||
1576 | extern struct pci_fixup __start_pci_fixups_final[]; | ||
1577 | extern struct pci_fixup __end_pci_fixups_final[]; | ||
1578 | extern struct pci_fixup __start_pci_fixups_enable[]; | ||
1579 | extern struct pci_fixup __end_pci_fixups_enable[]; | ||
1580 | extern struct pci_fixup __start_pci_fixups_resume[]; | ||
1581 | extern struct pci_fixup __end_pci_fixups_resume[]; | ||
1582 | extern struct pci_fixup __start_pci_fixups_resume_early[]; | ||
1583 | extern struct pci_fixup __end_pci_fixups_resume_early[]; | ||
1584 | extern struct pci_fixup __start_pci_fixups_suspend[]; | ||
1585 | extern struct pci_fixup __end_pci_fixups_suspend[]; | ||
1586 | |||
1587 | |||
1588 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) | ||
1589 | { | ||
1590 | struct pci_fixup *start, *end; | ||
1591 | |||
1592 | switch(pass) { | ||
1593 | case pci_fixup_early: | ||
1594 | start = __start_pci_fixups_early; | ||
1595 | end = __end_pci_fixups_early; | ||
1596 | break; | ||
1597 | |||
1598 | case pci_fixup_header: | ||
1599 | start = __start_pci_fixups_header; | ||
1600 | end = __end_pci_fixups_header; | ||
1601 | break; | ||
1602 | |||
1603 | case pci_fixup_final: | ||
1604 | start = __start_pci_fixups_final; | ||
1605 | end = __end_pci_fixups_final; | ||
1606 | break; | ||
1607 | |||
1608 | case pci_fixup_enable: | ||
1609 | start = __start_pci_fixups_enable; | ||
1610 | end = __end_pci_fixups_enable; | ||
1611 | break; | ||
1612 | |||
1613 | case pci_fixup_resume: | ||
1614 | start = __start_pci_fixups_resume; | ||
1615 | end = __end_pci_fixups_resume; | ||
1616 | break; | ||
1617 | |||
1618 | case pci_fixup_resume_early: | ||
1619 | start = __start_pci_fixups_resume_early; | ||
1620 | end = __end_pci_fixups_resume_early; | ||
1621 | break; | ||
1622 | |||
1623 | case pci_fixup_suspend: | ||
1624 | start = __start_pci_fixups_suspend; | ||
1625 | end = __end_pci_fixups_suspend; | ||
1626 | break; | ||
1627 | |||
1628 | default: | ||
1629 | /* stupid compiler warning, you would think with an enum... */ | ||
1630 | return; | ||
1631 | } | ||
1632 | pci_do_fixups(dev, start, end); | ||
1633 | } | ||
1634 | EXPORT_SYMBOL(pci_fixup_device); | ||
1635 | |||
1636 | /* Enable 1k I/O space granularity on the Intel P64H2 */ | 1558 | /* Enable 1k I/O space granularity on the Intel P64H2 */ |
1637 | static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev) | 1559 | static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev) |
1638 | { | 1560 | { |
@@ -1770,24 +1692,24 @@ static void __devinit quirk_brcm_570x_limit_vpd(struct pci_dev *dev) | |||
1770 | } | 1692 | } |
1771 | } | 1693 | } |
1772 | 1694 | ||
1773 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | 1695 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, |
1774 | PCI_DEVICE_ID_NX2_5706, | 1696 | PCI_DEVICE_ID_NX2_5706, |
1775 | quirk_brcm_570x_limit_vpd); | 1697 | quirk_brcm_570x_limit_vpd); |
1776 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | 1698 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, |
1777 | PCI_DEVICE_ID_NX2_5706S, | 1699 | PCI_DEVICE_ID_NX2_5706S, |
1778 | quirk_brcm_570x_limit_vpd); | 1700 | quirk_brcm_570x_limit_vpd); |
1779 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | 1701 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, |
1780 | PCI_DEVICE_ID_NX2_5708, | 1702 | PCI_DEVICE_ID_NX2_5708, |
1781 | quirk_brcm_570x_limit_vpd); | 1703 | quirk_brcm_570x_limit_vpd); |
1782 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | 1704 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, |
1783 | PCI_DEVICE_ID_NX2_5708S, | 1705 | PCI_DEVICE_ID_NX2_5708S, |
1784 | quirk_brcm_570x_limit_vpd); | 1706 | quirk_brcm_570x_limit_vpd); |
1785 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | 1707 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, |
1786 | PCI_DEVICE_ID_NX2_5709, | 1708 | PCI_DEVICE_ID_NX2_5709, |
1787 | quirk_brcm_570x_limit_vpd); | 1709 | quirk_brcm_570x_limit_vpd); |
1788 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | 1710 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, |
1789 | PCI_DEVICE_ID_NX2_5709S, | 1711 | PCI_DEVICE_ID_NX2_5709S, |
1790 | quirk_brcm_570x_limit_vpd); | 1712 | quirk_brcm_570x_limit_vpd); |
1791 | 1713 | ||
1792 | #ifdef CONFIG_PCI_MSI | 1714 | #ifdef CONFIG_PCI_MSI |
1793 | /* Some chipsets do not support MSI. We cannot easily rely on setting | 1715 | /* Some chipsets do not support MSI. We cannot easily rely on setting |
@@ -2006,3 +1928,82 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4375, | |||
2006 | quirk_msi_intx_disable_bug); | 1928 | quirk_msi_intx_disable_bug); |
2007 | 1929 | ||
2008 | #endif /* CONFIG_PCI_MSI */ | 1930 | #endif /* CONFIG_PCI_MSI */ |
1931 | |||
1932 | static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end) | ||
1933 | { | ||
1934 | while (f < end) { | ||
1935 | if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) && | ||
1936 | (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) { | ||
1937 | dev_dbg(&dev->dev, "calling %pF\n", f->hook); | ||
1938 | f->hook(dev); | ||
1939 | } | ||
1940 | f++; | ||
1941 | } | ||
1942 | } | ||
1943 | |||
1944 | extern struct pci_fixup __start_pci_fixups_early[]; | ||
1945 | extern struct pci_fixup __end_pci_fixups_early[]; | ||
1946 | extern struct pci_fixup __start_pci_fixups_header[]; | ||
1947 | extern struct pci_fixup __end_pci_fixups_header[]; | ||
1948 | extern struct pci_fixup __start_pci_fixups_final[]; | ||
1949 | extern struct pci_fixup __end_pci_fixups_final[]; | ||
1950 | extern struct pci_fixup __start_pci_fixups_enable[]; | ||
1951 | extern struct pci_fixup __end_pci_fixups_enable[]; | ||
1952 | extern struct pci_fixup __start_pci_fixups_resume[]; | ||
1953 | extern struct pci_fixup __end_pci_fixups_resume[]; | ||
1954 | extern struct pci_fixup __start_pci_fixups_resume_early[]; | ||
1955 | extern struct pci_fixup __end_pci_fixups_resume_early[]; | ||
1956 | extern struct pci_fixup __start_pci_fixups_suspend[]; | ||
1957 | extern struct pci_fixup __end_pci_fixups_suspend[]; | ||
1958 | |||
1959 | |||
1960 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) | ||
1961 | { | ||
1962 | struct pci_fixup *start, *end; | ||
1963 | |||
1964 | switch(pass) { | ||
1965 | case pci_fixup_early: | ||
1966 | start = __start_pci_fixups_early; | ||
1967 | end = __end_pci_fixups_early; | ||
1968 | break; | ||
1969 | |||
1970 | case pci_fixup_header: | ||
1971 | start = __start_pci_fixups_header; | ||
1972 | end = __end_pci_fixups_header; | ||
1973 | break; | ||
1974 | |||
1975 | case pci_fixup_final: | ||
1976 | start = __start_pci_fixups_final; | ||
1977 | end = __end_pci_fixups_final; | ||
1978 | break; | ||
1979 | |||
1980 | case pci_fixup_enable: | ||
1981 | start = __start_pci_fixups_enable; | ||
1982 | end = __end_pci_fixups_enable; | ||
1983 | break; | ||
1984 | |||
1985 | case pci_fixup_resume: | ||
1986 | start = __start_pci_fixups_resume; | ||
1987 | end = __end_pci_fixups_resume; | ||
1988 | break; | ||
1989 | |||
1990 | case pci_fixup_resume_early: | ||
1991 | start = __start_pci_fixups_resume_early; | ||
1992 | end = __end_pci_fixups_resume_early; | ||
1993 | break; | ||
1994 | |||
1995 | case pci_fixup_suspend: | ||
1996 | start = __start_pci_fixups_suspend; | ||
1997 | end = __end_pci_fixups_suspend; | ||
1998 | break; | ||
1999 | |||
2000 | default: | ||
2001 | /* stupid compiler warning, you would think with an enum... */ | ||
2002 | return; | ||
2003 | } | ||
2004 | pci_do_fixups(dev, start, end); | ||
2005 | } | ||
2006 | #else | ||
2007 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {} | ||
2008 | #endif | ||
2009 | EXPORT_SYMBOL(pci_fixup_device); | ||
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index bdc2a44d68e..042e0892442 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -73,6 +73,7 @@ void pci_remove_bus(struct pci_bus *pci_bus) | |||
73 | up_write(&pci_bus_sem); | 73 | up_write(&pci_bus_sem); |
74 | pci_remove_legacy_files(pci_bus); | 74 | pci_remove_legacy_files(pci_bus); |
75 | device_remove_file(&pci_bus->dev, &dev_attr_cpuaffinity); | 75 | device_remove_file(&pci_bus->dev, &dev_attr_cpuaffinity); |
76 | device_remove_file(&pci_bus->dev, &dev_attr_cpulistaffinity); | ||
76 | device_unregister(&pci_bus->dev); | 77 | device_unregister(&pci_bus->dev); |
77 | } | 78 | } |
78 | EXPORT_SYMBOL(pci_remove_bus); | 79 | EXPORT_SYMBOL(pci_remove_bus); |
@@ -114,13 +115,9 @@ void pci_remove_behind_bridge(struct pci_dev *dev) | |||
114 | { | 115 | { |
115 | struct list_head *l, *n; | 116 | struct list_head *l, *n; |
116 | 117 | ||
117 | if (dev->subordinate) { | 118 | if (dev->subordinate) |
118 | list_for_each_safe(l, n, &dev->subordinate->devices) { | 119 | list_for_each_safe(l, n, &dev->subordinate->devices) |
119 | struct pci_dev *dev = pci_dev_b(l); | 120 | pci_remove_bus_device(pci_dev_b(l)); |
120 | |||
121 | pci_remove_bus_device(dev); | ||
122 | } | ||
123 | } | ||
124 | } | 121 | } |
125 | 122 | ||
126 | static void pci_stop_bus_devices(struct pci_bus *bus) | 123 | static void pci_stop_bus_devices(struct pci_bus *bus) |
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index bd5c0e03139..132a78159b6 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * between the ROM and other resources, so enabling it may disable access | 21 | * between the ROM and other resources, so enabling it may disable access |
22 | * to MMIO registers or other card memory. | 22 | * to MMIO registers or other card memory. |
23 | */ | 23 | */ |
24 | static int pci_enable_rom(struct pci_dev *pdev) | 24 | int pci_enable_rom(struct pci_dev *pdev) |
25 | { | 25 | { |
26 | struct resource *res = pdev->resource + PCI_ROM_RESOURCE; | 26 | struct resource *res = pdev->resource + PCI_ROM_RESOURCE; |
27 | struct pci_bus_region region; | 27 | struct pci_bus_region region; |
@@ -45,7 +45,7 @@ static int pci_enable_rom(struct pci_dev *pdev) | |||
45 | * Disable ROM decoding on a PCI device by turning off the last bit in the | 45 | * Disable ROM decoding on a PCI device by turning off the last bit in the |
46 | * ROM BAR. | 46 | * ROM BAR. |
47 | */ | 47 | */ |
48 | static void pci_disable_rom(struct pci_dev *pdev) | 48 | void pci_disable_rom(struct pci_dev *pdev) |
49 | { | 49 | { |
50 | u32 rom_addr; | 50 | u32 rom_addr; |
51 | pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr); | 51 | pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr); |
@@ -100,7 +100,8 @@ size_t pci_get_rom_size(void __iomem *rom, size_t size) | |||
100 | * pci_map_rom - map a PCI ROM to kernel space | 100 | * pci_map_rom - map a PCI ROM to kernel space |
101 | * @pdev: pointer to pci device struct | 101 | * @pdev: pointer to pci device struct |
102 | * @size: pointer to receive size of pci window over ROM | 102 | * @size: pointer to receive size of pci window over ROM |
103 | * @return: kernel virtual pointer to image of ROM | 103 | * |
104 | * Return: kernel virtual pointer to image of ROM | ||
104 | * | 105 | * |
105 | * Map a PCI ROM into kernel space. If ROM is boot video ROM, | 106 | * Map a PCI ROM into kernel space. If ROM is boot video ROM, |
106 | * the shadow BIOS copy will be returned instead of the | 107 | * the shadow BIOS copy will be returned instead of the |
@@ -167,7 +168,8 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size) | |||
167 | * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy | 168 | * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy |
168 | * @pdev: pointer to pci device struct | 169 | * @pdev: pointer to pci device struct |
169 | * @size: pointer to receive size of pci window over ROM | 170 | * @size: pointer to receive size of pci window over ROM |
170 | * @return: kernel virtual pointer to image of ROM | 171 | * |
172 | * Return: kernel virtual pointer to image of ROM | ||
171 | * | 173 | * |
172 | * Map a PCI ROM into kernel space. If ROM is boot video ROM, | 174 | * Map a PCI ROM into kernel space. If ROM is boot video ROM, |
173 | * the shadow BIOS copy will be returned instead of the | 175 | * the shadow BIOS copy will be returned instead of the |
@@ -260,3 +262,5 @@ void pci_cleanup_rom(struct pci_dev *pdev) | |||
260 | 262 | ||
261 | EXPORT_SYMBOL(pci_map_rom); | 263 | EXPORT_SYMBOL(pci_map_rom); |
262 | EXPORT_SYMBOL(pci_unmap_rom); | 264 | EXPORT_SYMBOL(pci_unmap_rom); |
265 | EXPORT_SYMBOL_GPL(pci_enable_rom); | ||
266 | EXPORT_SYMBOL_GPL(pci_disable_rom); | ||
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 4edfc4731bd..5af8bd53814 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -166,6 +166,7 @@ struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, | |||
166 | { | 166 | { |
167 | struct pci_dev *pdev; | 167 | struct pci_dev *pdev; |
168 | 168 | ||
169 | pci_dev_get(from); | ||
169 | pdev = pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from); | 170 | pdev = pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from); |
170 | pci_dev_put(pdev); | 171 | pci_dev_put(pdev); |
171 | return pdev; | 172 | return pdev; |
@@ -270,12 +271,8 @@ static struct pci_dev *pci_get_dev_by_id(const struct pci_device_id *id, | |||
270 | struct pci_dev *pdev = NULL; | 271 | struct pci_dev *pdev = NULL; |
271 | 272 | ||
272 | WARN_ON(in_interrupt()); | 273 | WARN_ON(in_interrupt()); |
273 | if (from) { | 274 | if (from) |
274 | /* FIXME | 275 | dev_start = &from->dev; |
275 | * take the cast off, when bus_find_device is made const. | ||
276 | */ | ||
277 | dev_start = (struct device *)&from->dev; | ||
278 | } | ||
279 | dev = bus_find_device(&pci_bus_type, dev_start, (void *)id, | 276 | dev = bus_find_device(&pci_bus_type, dev_start, (void *)id, |
280 | match_pci_dev_by_id); | 277 | match_pci_dev_by_id); |
281 | if (dev) | 278 | if (dev) |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index d5e2106760f..ea979f2bc6d 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -299,7 +299,7 @@ static void pbus_size_io(struct pci_bus *bus) | |||
299 | 299 | ||
300 | if (r->parent || !(r->flags & IORESOURCE_IO)) | 300 | if (r->parent || !(r->flags & IORESOURCE_IO)) |
301 | continue; | 301 | continue; |
302 | r_size = r->end - r->start + 1; | 302 | r_size = resource_size(r); |
303 | 303 | ||
304 | if (r_size < 0x400) | 304 | if (r_size < 0x400) |
305 | /* Might be re-aligned for ISA */ | 305 | /* Might be re-aligned for ISA */ |
@@ -350,16 +350,13 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long | |||
350 | 350 | ||
351 | if (r->parent || (r->flags & mask) != type) | 351 | if (r->parent || (r->flags & mask) != type) |
352 | continue; | 352 | continue; |
353 | r_size = r->end - r->start + 1; | 353 | r_size = resource_size(r); |
354 | /* For bridges size != alignment */ | 354 | /* For bridges size != alignment */ |
355 | align = resource_alignment(r); | 355 | align = resource_alignment(r); |
356 | order = __ffs(align) - 20; | 356 | order = __ffs(align) - 20; |
357 | if (order > 11) { | 357 | if (order > 11) { |
358 | dev_warn(&dev->dev, "BAR %d bad alignment %llx: " | 358 | dev_warn(&dev->dev, "BAR %d bad alignment %llx: " |
359 | "%#016llx-%#016llx\n", i, | 359 | "%pR\n", i, (unsigned long long)align, r); |
360 | (unsigned long long)align, | ||
361 | (unsigned long long)r->start, | ||
362 | (unsigned long long)r->end); | ||
363 | r->flags = 0; | 360 | r->flags = 0; |
364 | continue; | 361 | continue; |
365 | } | 362 | } |
@@ -539,11 +536,9 @@ static void pci_bus_dump_res(struct pci_bus *bus) | |||
539 | if (!res) | 536 | if (!res) |
540 | continue; | 537 | continue; |
541 | 538 | ||
542 | printk(KERN_INFO "bus: %02x index %x %s: [%llx, %llx]\n", | 539 | printk(KERN_INFO "bus: %02x index %x %s: %pR\n", |
543 | bus->number, i, | 540 | bus->number, i, |
544 | (res->flags & IORESOURCE_IO) ? "io port" : "mmio", | 541 | (res->flags & IORESOURCE_IO) ? "io port" : "mmio", res); |
545 | (unsigned long long) res->start, | ||
546 | (unsigned long long) res->end); | ||
547 | } | 542 | } |
548 | } | 543 | } |
549 | 544 | ||
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 1a5fc83c71b..2dbd96cce2d 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c | |||
@@ -49,10 +49,8 @@ void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno) | |||
49 | 49 | ||
50 | pcibios_resource_to_bus(dev, ®ion, res); | 50 | pcibios_resource_to_bus(dev, ®ion, res); |
51 | 51 | ||
52 | dev_dbg(&dev->dev, "BAR %d: got res [%#llx-%#llx] bus [%#llx-%#llx] " | 52 | dev_dbg(&dev->dev, "BAR %d: got res %pR bus [%#llx-%#llx] " |
53 | "flags %#lx\n", resno, | 53 | "flags %#lx\n", resno, res, |
54 | (unsigned long long)res->start, | ||
55 | (unsigned long long)res->end, | ||
56 | (unsigned long long)region.start, | 54 | (unsigned long long)region.start, |
57 | (unsigned long long)region.end, | 55 | (unsigned long long)region.end, |
58 | (unsigned long)res->flags); | 56 | (unsigned long)res->flags); |
@@ -114,13 +112,11 @@ int pci_claim_resource(struct pci_dev *dev, int resource) | |||
114 | err = insert_resource(root, res); | 112 | err = insert_resource(root, res); |
115 | 113 | ||
116 | if (err) { | 114 | if (err) { |
117 | dev_err(&dev->dev, "BAR %d: %s of %s [%#llx-%#llx]\n", | 115 | dev_err(&dev->dev, "BAR %d: %s of %s %pR\n", |
118 | resource, | 116 | resource, |
119 | root ? "address space collision on" : | 117 | root ? "address space collision on" : |
120 | "no parent found for", | 118 | "no parent found for", |
121 | dtype, | 119 | dtype, res); |
122 | (unsigned long long)res->start, | ||
123 | (unsigned long long)res->end); | ||
124 | } | 120 | } |
125 | 121 | ||
126 | return err; | 122 | return err; |
@@ -133,15 +129,14 @@ int pci_assign_resource(struct pci_dev *dev, int resno) | |||
133 | resource_size_t size, min, align; | 129 | resource_size_t size, min, align; |
134 | int ret; | 130 | int ret; |
135 | 131 | ||
136 | size = res->end - res->start + 1; | 132 | size = resource_size(res); |
137 | min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; | 133 | min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; |
138 | 134 | ||
139 | align = resource_alignment(res); | 135 | align = resource_alignment(res); |
140 | if (!align) { | 136 | if (!align) { |
141 | dev_err(&dev->dev, "BAR %d: can't allocate resource (bogus " | 137 | dev_err(&dev->dev, "BAR %d: can't allocate resource (bogus " |
142 | "alignment) [%#llx-%#llx] flags %#lx\n", | 138 | "alignment) %pR flags %#lx\n", |
143 | resno, (unsigned long long)res->start, | 139 | resno, res, res->flags); |
144 | (unsigned long long)res->end, res->flags); | ||
145 | return -EINVAL; | 140 | return -EINVAL; |
146 | } | 141 | } |
147 | 142 | ||
@@ -162,11 +157,8 @@ int pci_assign_resource(struct pci_dev *dev, int resno) | |||
162 | } | 157 | } |
163 | 158 | ||
164 | if (ret) { | 159 | if (ret) { |
165 | dev_err(&dev->dev, "BAR %d: can't allocate %s resource " | 160 | dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n", |
166 | "[%#llx-%#llx]\n", resno, | 161 | resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res); |
167 | res->flags & IORESOURCE_IO ? "I/O" : "mem", | ||
168 | (unsigned long long)res->start, | ||
169 | (unsigned long long)res->end); | ||
170 | } else { | 162 | } else { |
171 | res->flags &= ~IORESOURCE_STARTALIGN; | 163 | res->flags &= ~IORESOURCE_STARTALIGN; |
172 | if (resno < PCI_BRIDGE_RESOURCES) | 164 | if (resno < PCI_BRIDGE_RESOURCES) |
@@ -202,11 +194,8 @@ int pci_assign_resource_fixed(struct pci_dev *dev, int resno) | |||
202 | } | 194 | } |
203 | 195 | ||
204 | if (ret) { | 196 | if (ret) { |
205 | dev_err(&dev->dev, "BAR %d: can't allocate %s resource " | 197 | dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n", |
206 | "[%#llx-%#llx\n]", resno, | 198 | resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res); |
207 | res->flags & IORESOURCE_IO ? "I/O" : "mem", | ||
208 | (unsigned long long)res->start, | ||
209 | (unsigned long long)res->end); | ||
210 | } else if (resno < PCI_BRIDGE_RESOURCES) { | 199 | } else if (resno < PCI_BRIDGE_RESOURCES) { |
211 | pci_update_resource(dev, res, resno); | 200 | pci_update_resource(dev, res, resno); |
212 | } | 201 | } |
@@ -237,9 +226,8 @@ void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head) | |||
237 | r_align = resource_alignment(r); | 226 | r_align = resource_alignment(r); |
238 | if (!r_align) { | 227 | if (!r_align) { |
239 | dev_warn(&dev->dev, "BAR %d: bogus alignment " | 228 | dev_warn(&dev->dev, "BAR %d: bogus alignment " |
240 | "[%#llx-%#llx] flags %#lx\n", | 229 | "%pR flags %#lx\n", |
241 | i, (unsigned long long)r->start, | 230 | i, r, r->flags); |
242 | (unsigned long long)r->end, r->flags); | ||
243 | continue; | 231 | continue; |
244 | } | 232 | } |
245 | for (list = head; ; list = list->next) { | 233 | for (list = head; ; list = list->next) { |
@@ -287,9 +275,7 @@ int pci_enable_resources(struct pci_dev *dev, int mask) | |||
287 | 275 | ||
288 | if (!r->parent) { | 276 | if (!r->parent) { |
289 | dev_err(&dev->dev, "device not available because of " | 277 | dev_err(&dev->dev, "device not available because of " |
290 | "BAR %d [%#llx-%#llx] collisions\n", i, | 278 | "BAR %d %pR collisions\n", i, r); |
291 | (unsigned long long) r->start, | ||
292 | (unsigned long long) r->end); | ||
293 | return -EINVAL; | 279 | return -EINVAL; |
294 | } | 280 | } |
295 | 281 | ||
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c index 7e5b85cbd94..4dd1c3e157a 100644 --- a/drivers/pci/slot.c +++ b/drivers/pci/slot.c | |||
@@ -49,11 +49,16 @@ static ssize_t address_read_file(struct pci_slot *slot, char *buf) | |||
49 | 49 | ||
50 | static void pci_slot_release(struct kobject *kobj) | 50 | static void pci_slot_release(struct kobject *kobj) |
51 | { | 51 | { |
52 | struct pci_dev *dev; | ||
52 | struct pci_slot *slot = to_pci_slot(kobj); | 53 | struct pci_slot *slot = to_pci_slot(kobj); |
53 | 54 | ||
54 | pr_debug("%s: releasing pci_slot on %x:%d\n", __func__, | 55 | pr_debug("%s: releasing pci_slot on %x:%d\n", __func__, |
55 | slot->bus->number, slot->number); | 56 | slot->bus->number, slot->number); |
56 | 57 | ||
58 | list_for_each_entry(dev, &slot->bus->devices, bus_list) | ||
59 | if (PCI_SLOT(dev->devfn) == slot->number) | ||
60 | dev->slot = NULL; | ||
61 | |||
57 | list_del(&slot->list); | 62 | list_del(&slot->list); |
58 | 63 | ||
59 | kfree(slot); | 64 | kfree(slot); |
@@ -73,18 +78,100 @@ static struct kobj_type pci_slot_ktype = { | |||
73 | .default_attrs = pci_slot_default_attrs, | 78 | .default_attrs = pci_slot_default_attrs, |
74 | }; | 79 | }; |
75 | 80 | ||
81 | static char *make_slot_name(const char *name) | ||
82 | { | ||
83 | char *new_name; | ||
84 | int len, max, dup; | ||
85 | |||
86 | new_name = kstrdup(name, GFP_KERNEL); | ||
87 | if (!new_name) | ||
88 | return NULL; | ||
89 | |||
90 | /* | ||
91 | * Make sure we hit the realloc case the first time through the | ||
92 | * loop. 'len' will be strlen(name) + 3 at that point which is | ||
93 | * enough space for "name-X" and the trailing NUL. | ||
94 | */ | ||
95 | len = strlen(name) + 2; | ||
96 | max = 1; | ||
97 | dup = 1; | ||
98 | |||
99 | for (;;) { | ||
100 | struct kobject *dup_slot; | ||
101 | dup_slot = kset_find_obj(pci_slots_kset, new_name); | ||
102 | if (!dup_slot) | ||
103 | break; | ||
104 | kobject_put(dup_slot); | ||
105 | if (dup == max) { | ||
106 | len++; | ||
107 | max *= 10; | ||
108 | kfree(new_name); | ||
109 | new_name = kmalloc(len, GFP_KERNEL); | ||
110 | if (!new_name) | ||
111 | break; | ||
112 | } | ||
113 | sprintf(new_name, "%s-%d", name, dup++); | ||
114 | } | ||
115 | |||
116 | return new_name; | ||
117 | } | ||
118 | |||
119 | static int rename_slot(struct pci_slot *slot, const char *name) | ||
120 | { | ||
121 | int result = 0; | ||
122 | char *slot_name; | ||
123 | |||
124 | if (strcmp(pci_slot_name(slot), name) == 0) | ||
125 | return result; | ||
126 | |||
127 | slot_name = make_slot_name(name); | ||
128 | if (!slot_name) | ||
129 | return -ENOMEM; | ||
130 | |||
131 | result = kobject_rename(&slot->kobj, slot_name); | ||
132 | kfree(slot_name); | ||
133 | |||
134 | return result; | ||
135 | } | ||
136 | |||
137 | static struct pci_slot *get_slot(struct pci_bus *parent, int slot_nr) | ||
138 | { | ||
139 | struct pci_slot *slot; | ||
140 | /* | ||
141 | * We already hold pci_bus_sem so don't worry | ||
142 | */ | ||
143 | list_for_each_entry(slot, &parent->slots, list) | ||
144 | if (slot->number == slot_nr) { | ||
145 | kobject_get(&slot->kobj); | ||
146 | return slot; | ||
147 | } | ||
148 | |||
149 | return NULL; | ||
150 | } | ||
151 | |||
76 | /** | 152 | /** |
77 | * pci_create_slot - create or increment refcount for physical PCI slot | 153 | * pci_create_slot - create or increment refcount for physical PCI slot |
78 | * @parent: struct pci_bus of parent bridge | 154 | * @parent: struct pci_bus of parent bridge |
79 | * @slot_nr: PCI_SLOT(pci_dev->devfn) or -1 for placeholder | 155 | * @slot_nr: PCI_SLOT(pci_dev->devfn) or -1 for placeholder |
80 | * @name: user visible string presented in /sys/bus/pci/slots/<name> | 156 | * @name: user visible string presented in /sys/bus/pci/slots/<name> |
157 | * @hotplug: set if caller is hotplug driver, NULL otherwise | ||
81 | * | 158 | * |
82 | * PCI slots have first class attributes such as address, speed, width, | 159 | * PCI slots have first class attributes such as address, speed, width, |
83 | * and a &struct pci_slot is used to manage them. This interface will | 160 | * and a &struct pci_slot is used to manage them. This interface will |
84 | * either return a new &struct pci_slot to the caller, or if the pci_slot | 161 | * either return a new &struct pci_slot to the caller, or if the pci_slot |
85 | * already exists, its refcount will be incremented. | 162 | * already exists, its refcount will be incremented. |
86 | * | 163 | * |
87 | * Slots are uniquely identified by a @pci_bus, @slot_nr, @name tuple. | 164 | * Slots are uniquely identified by a @pci_bus, @slot_nr tuple. |
165 | * | ||
166 | * There are known platforms with broken firmware that assign the same | ||
167 | * name to multiple slots. Workaround these broken platforms by renaming | ||
168 | * the slots on behalf of the caller. If firmware assigns name N to | ||
169 | * multiple slots: | ||
170 | * | ||
171 | * The first slot is assigned N | ||
172 | * The second slot is assigned N-1 | ||
173 | * The third slot is assigned N-2 | ||
174 | * etc. | ||
88 | * | 175 | * |
89 | * Placeholder slots: | 176 | * Placeholder slots: |
90 | * In most cases, @pci_bus, @slot_nr will be sufficient to uniquely identify | 177 | * In most cases, @pci_bus, @slot_nr will be sufficient to uniquely identify |
@@ -93,71 +180,82 @@ static struct kobj_type pci_slot_ktype = { | |||
93 | * the slot. In this scenario, the caller may pass -1 for @slot_nr. | 180 | * the slot. In this scenario, the caller may pass -1 for @slot_nr. |
94 | * | 181 | * |
95 | * The following semantics are imposed when the caller passes @slot_nr == | 182 | * The following semantics are imposed when the caller passes @slot_nr == |
96 | * -1. First, the check for existing %struct pci_slot is skipped, as the | 183 | * -1. First, we no longer check for an existing %struct pci_slot, as there |
97 | * caller may know about several unpopulated slots on a given %struct | 184 | * may be many slots with @slot_nr of -1. The other change in semantics is |
98 | * pci_bus, and each slot would have a @slot_nr of -1. Uniqueness for | ||
99 | * these slots is then determined by the @name parameter. We expect | ||
100 | * kobject_init_and_add() to warn us if the caller attempts to create | ||
101 | * multiple slots with the same name. The other change in semantics is | ||
102 | * user-visible, which is the 'address' parameter presented in sysfs will | 185 | * user-visible, which is the 'address' parameter presented in sysfs will |
103 | * consist solely of a dddd:bb tuple, where dddd is the PCI domain of the | 186 | * consist solely of a dddd:bb tuple, where dddd is the PCI domain of the |
104 | * %struct pci_bus and bb is the bus number. In other words, the devfn of | 187 | * %struct pci_bus and bb is the bus number. In other words, the devfn of |
105 | * the 'placeholder' slot will not be displayed. | 188 | * the 'placeholder' slot will not be displayed. |
106 | */ | 189 | */ |
107 | |||
108 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | 190 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, |
109 | const char *name) | 191 | const char *name, |
192 | struct hotplug_slot *hotplug) | ||
110 | { | 193 | { |
194 | struct pci_dev *dev; | ||
111 | struct pci_slot *slot; | 195 | struct pci_slot *slot; |
112 | int err; | 196 | int err = 0; |
197 | char *slot_name = NULL; | ||
113 | 198 | ||
114 | down_write(&pci_bus_sem); | 199 | down_write(&pci_bus_sem); |
115 | 200 | ||
116 | if (slot_nr == -1) | 201 | if (slot_nr == -1) |
117 | goto placeholder; | 202 | goto placeholder; |
118 | 203 | ||
119 | /* If we've already created this slot, bump refcount and return. */ | 204 | /* |
120 | list_for_each_entry(slot, &parent->slots, list) { | 205 | * Hotplug drivers are allowed to rename an existing slot, |
121 | if (slot->number == slot_nr) { | 206 | * but only if not already claimed. |
122 | kobject_get(&slot->kobj); | 207 | */ |
123 | pr_debug("%s: inc refcount to %d on %04x:%02x:%02x\n", | 208 | slot = get_slot(parent, slot_nr); |
124 | __func__, | 209 | if (slot) { |
125 | atomic_read(&slot->kobj.kref.refcount), | 210 | if (hotplug) { |
126 | pci_domain_nr(parent), parent->number, | 211 | if ((err = slot->hotplug ? -EBUSY : 0) |
127 | slot_nr); | 212 | || (err = rename_slot(slot, name))) { |
128 | goto out; | 213 | kobject_put(&slot->kobj); |
214 | slot = NULL; | ||
215 | goto err; | ||
216 | } | ||
129 | } | 217 | } |
218 | goto out; | ||
130 | } | 219 | } |
131 | 220 | ||
132 | placeholder: | 221 | placeholder: |
133 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | 222 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
134 | if (!slot) { | 223 | if (!slot) { |
135 | slot = ERR_PTR(-ENOMEM); | 224 | err = -ENOMEM; |
136 | goto out; | 225 | goto err; |
137 | } | 226 | } |
138 | 227 | ||
139 | slot->bus = parent; | 228 | slot->bus = parent; |
140 | slot->number = slot_nr; | 229 | slot->number = slot_nr; |
141 | 230 | ||
142 | slot->kobj.kset = pci_slots_kset; | 231 | slot->kobj.kset = pci_slots_kset; |
143 | err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL, | 232 | |
144 | "%s", name); | 233 | slot_name = make_slot_name(name); |
145 | if (err) { | 234 | if (!slot_name) { |
146 | printk(KERN_ERR "Unable to register kobject %s\n", name); | 235 | err = -ENOMEM; |
147 | goto err; | 236 | goto err; |
148 | } | 237 | } |
149 | 238 | ||
239 | err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL, | ||
240 | "%s", slot_name); | ||
241 | if (err) | ||
242 | goto err; | ||
243 | |||
150 | INIT_LIST_HEAD(&slot->list); | 244 | INIT_LIST_HEAD(&slot->list); |
151 | list_add(&slot->list, &parent->slots); | 245 | list_add(&slot->list, &parent->slots); |
152 | 246 | ||
247 | list_for_each_entry(dev, &parent->devices, bus_list) | ||
248 | if (PCI_SLOT(dev->devfn) == slot_nr) | ||
249 | dev->slot = slot; | ||
250 | |||
153 | /* Don't care if debug printk has a -1 for slot_nr */ | 251 | /* Don't care if debug printk has a -1 for slot_nr */ |
154 | pr_debug("%s: created pci_slot on %04x:%02x:%02x\n", | 252 | pr_debug("%s: created pci_slot on %04x:%02x:%02x\n", |
155 | __func__, pci_domain_nr(parent), parent->number, slot_nr); | 253 | __func__, pci_domain_nr(parent), parent->number, slot_nr); |
156 | 254 | ||
157 | out: | 255 | out: |
158 | up_write(&pci_bus_sem); | 256 | up_write(&pci_bus_sem); |
159 | return slot; | 257 | return slot; |
160 | err: | 258 | err: |
161 | kfree(slot); | 259 | kfree(slot); |
162 | slot = ERR_PTR(err); | 260 | slot = ERR_PTR(err); |
163 | goto out; | 261 | goto out; |
@@ -165,7 +263,7 @@ placeholder: | |||
165 | EXPORT_SYMBOL_GPL(pci_create_slot); | 263 | EXPORT_SYMBOL_GPL(pci_create_slot); |
166 | 264 | ||
167 | /** | 265 | /** |
168 | * pci_update_slot_number - update %struct pci_slot -> number | 266 | * pci_renumber_slot - update %struct pci_slot -> number |
169 | * @slot - %struct pci_slot to update | 267 | * @slot - %struct pci_slot to update |
170 | * @slot_nr - new number for slot | 268 | * @slot_nr - new number for slot |
171 | * | 269 | * |
@@ -173,27 +271,22 @@ EXPORT_SYMBOL_GPL(pci_create_slot); | |||
173 | * created a placeholder slot in pci_create_slot() by passing a -1 as | 271 | * created a placeholder slot in pci_create_slot() by passing a -1 as |
174 | * slot_nr, to update their %struct pci_slot with the correct @slot_nr. | 272 | * slot_nr, to update their %struct pci_slot with the correct @slot_nr. |
175 | */ | 273 | */ |
176 | 274 | void pci_renumber_slot(struct pci_slot *slot, int slot_nr) | |
177 | void pci_update_slot_number(struct pci_slot *slot, int slot_nr) | ||
178 | { | 275 | { |
179 | int name_count = 0; | ||
180 | struct pci_slot *tmp; | 276 | struct pci_slot *tmp; |
181 | 277 | ||
182 | down_write(&pci_bus_sem); | 278 | down_write(&pci_bus_sem); |
183 | 279 | ||
184 | list_for_each_entry(tmp, &slot->bus->slots, list) { | 280 | list_for_each_entry(tmp, &slot->bus->slots, list) { |
185 | WARN_ON(tmp->number == slot_nr); | 281 | WARN_ON(tmp->number == slot_nr); |
186 | if (!strcmp(kobject_name(&tmp->kobj), kobject_name(&slot->kobj))) | 282 | goto out; |
187 | name_count++; | ||
188 | } | 283 | } |
189 | 284 | ||
190 | if (name_count > 1) | ||
191 | printk(KERN_WARNING "pci_update_slot_number found %d slots with the same name: %s\n", name_count, kobject_name(&slot->kobj)); | ||
192 | |||
193 | slot->number = slot_nr; | 285 | slot->number = slot_nr; |
286 | out: | ||
194 | up_write(&pci_bus_sem); | 287 | up_write(&pci_bus_sem); |
195 | } | 288 | } |
196 | EXPORT_SYMBOL_GPL(pci_update_slot_number); | 289 | EXPORT_SYMBOL_GPL(pci_renumber_slot); |
197 | 290 | ||
198 | /** | 291 | /** |
199 | * pci_destroy_slot - decrement refcount for physical PCI slot | 292 | * pci_destroy_slot - decrement refcount for physical PCI slot |
@@ -203,7 +296,6 @@ EXPORT_SYMBOL_GPL(pci_update_slot_number); | |||
203 | * just call kobject_put on its kobj and let our release methods do the | 296 | * just call kobject_put on its kobj and let our release methods do the |
204 | * rest. | 297 | * rest. |
205 | */ | 298 | */ |
206 | |||
207 | void pci_destroy_slot(struct pci_slot *slot) | 299 | void pci_destroy_slot(struct pci_slot *slot) |
208 | { | 300 | { |
209 | pr_debug("%s: dec refcount to %d on %04x:%02x:%02x\n", __func__, | 301 | pr_debug("%s: dec refcount to %d on %04x:%02x:%02x\n", __func__, |