diff options
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/access.c | 14 | ||||
-rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 17 | ||||
-rw-r--r-- | drivers/pci/pci-driver.c | 2 | ||||
-rw-r--r-- | drivers/pci/pci-sysfs.c | 89 | ||||
-rw-r--r-- | drivers/pci/pci.h | 2 | ||||
-rw-r--r-- | drivers/pci/quirks.c | 42 |
6 files changed, 126 insertions, 40 deletions
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index ec8f7002b09d..39bb96b413ef 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -178,8 +178,7 @@ static int pci_vpd_pci22_read(struct pci_dev *dev, int pos, int size, | |||
178 | int ret; | 178 | int ret; |
179 | int begin, end, i; | 179 | int begin, end, i; |
180 | 180 | ||
181 | if (pos < 0 || pos > PCI_VPD_PCI22_SIZE || | 181 | if (pos < 0 || pos > vpd->base.len || size > vpd->base.len - pos) |
182 | size > PCI_VPD_PCI22_SIZE - pos) | ||
183 | return -EINVAL; | 182 | return -EINVAL; |
184 | if (size == 0) | 183 | if (size == 0) |
185 | return 0; | 184 | return 0; |
@@ -223,8 +222,8 @@ static int pci_vpd_pci22_write(struct pci_dev *dev, int pos, int size, | |||
223 | u32 val; | 222 | u32 val; |
224 | int ret; | 223 | int ret; |
225 | 224 | ||
226 | if (pos < 0 || pos > PCI_VPD_PCI22_SIZE || pos & 3 || | 225 | if (pos < 0 || pos > vpd->base.len || pos & 3 || |
227 | size > PCI_VPD_PCI22_SIZE - pos || size < 4) | 226 | size > vpd->base.len - pos || size < 4) |
228 | return -EINVAL; | 227 | return -EINVAL; |
229 | 228 | ||
230 | val = (u8) *buf++; | 229 | val = (u8) *buf++; |
@@ -255,11 +254,6 @@ out: | |||
255 | return 4; | 254 | return 4; |
256 | } | 255 | } |
257 | 256 | ||
258 | static int pci_vpd_pci22_get_size(struct pci_dev *dev) | ||
259 | { | ||
260 | return PCI_VPD_PCI22_SIZE; | ||
261 | } | ||
262 | |||
263 | static void pci_vpd_pci22_release(struct pci_dev *dev) | 257 | static void pci_vpd_pci22_release(struct pci_dev *dev) |
264 | { | 258 | { |
265 | kfree(container_of(dev->vpd, struct pci_vpd_pci22, base)); | 259 | kfree(container_of(dev->vpd, struct pci_vpd_pci22, base)); |
@@ -268,7 +262,6 @@ static void pci_vpd_pci22_release(struct pci_dev *dev) | |||
268 | static struct pci_vpd_ops pci_vpd_pci22_ops = { | 262 | static struct pci_vpd_ops pci_vpd_pci22_ops = { |
269 | .read = pci_vpd_pci22_read, | 263 | .read = pci_vpd_pci22_read, |
270 | .write = pci_vpd_pci22_write, | 264 | .write = pci_vpd_pci22_write, |
271 | .get_size = pci_vpd_pci22_get_size, | ||
272 | .release = pci_vpd_pci22_release, | 265 | .release = pci_vpd_pci22_release, |
273 | }; | 266 | }; |
274 | 267 | ||
@@ -284,6 +277,7 @@ int pci_vpd_pci22_init(struct pci_dev *dev) | |||
284 | if (!vpd) | 277 | if (!vpd) |
285 | return -ENOMEM; | 278 | return -ENOMEM; |
286 | 279 | ||
280 | vpd->base.len = PCI_VPD_PCI22_SIZE; | ||
287 | vpd->base.ops = &pci_vpd_pci22_ops; | 281 | vpd->base.ops = &pci_vpd_pci22_ops; |
288 | spin_lock_init(&vpd->lock); | 282 | spin_lock_init(&vpd->lock); |
289 | vpd->cap = cap; | 283 | vpd->cap = cap; |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 648596d469f6..91156f85a926 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -700,9 +700,10 @@ cleanup_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
700 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | 700 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, |
701 | cleanup_p2p_bridge, NULL, NULL); | 701 | cleanup_p2p_bridge, NULL, NULL); |
702 | 702 | ||
703 | if (!(bridge = acpiphp_handle_to_bridge(handle))) | 703 | bridge = acpiphp_handle_to_bridge(handle); |
704 | return AE_OK; | 704 | if (bridge) |
705 | cleanup_bridge(bridge); | 705 | cleanup_bridge(bridge); |
706 | |||
706 | return AE_OK; | 707 | return AE_OK; |
707 | } | 708 | } |
708 | 709 | ||
@@ -715,9 +716,19 @@ static void remove_bridge(acpi_handle handle) | |||
715 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | 716 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, |
716 | (u32)1, cleanup_p2p_bridge, NULL, NULL); | 717 | (u32)1, cleanup_p2p_bridge, NULL, NULL); |
717 | 718 | ||
719 | /* | ||
720 | * On root bridges with hotplug slots directly underneath (ie, | ||
721 | * no p2p bridge inbetween), we call cleanup_bridge(). | ||
722 | * | ||
723 | * The else clause cleans up root bridges that either had no | ||
724 | * hotplug slots at all, or had a p2p bridge underneath. | ||
725 | */ | ||
718 | bridge = acpiphp_handle_to_bridge(handle); | 726 | bridge = acpiphp_handle_to_bridge(handle); |
719 | if (bridge) | 727 | if (bridge) |
720 | cleanup_bridge(bridge); | 728 | cleanup_bridge(bridge); |
729 | else | ||
730 | acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
731 | handle_hotplug_event_bridge); | ||
721 | } | 732 | } |
722 | 733 | ||
723 | static struct pci_dev * get_apic_pci_info(acpi_handle handle) | 734 | static struct pci_dev * get_apic_pci_info(acpi_handle handle) |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 72cf61ed8f96..e1637bd82b8e 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -181,7 +181,7 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, | |||
181 | any need to change it. */ | 181 | any need to change it. */ |
182 | struct mempolicy *oldpol; | 182 | struct mempolicy *oldpol; |
183 | cpumask_t oldmask = current->cpus_allowed; | 183 | cpumask_t oldmask = current->cpus_allowed; |
184 | int node = pcibus_to_node(dev->bus); | 184 | int node = dev_to_node(&dev->dev); |
185 | 185 | ||
186 | if (node >= 0) { | 186 | if (node >= 0) { |
187 | node_to_cpumask_ptr(nodecpumask, node); | 187 | node_to_cpumask_ptr(nodecpumask, node); |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 271d41cc05ab..9c718583a237 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -489,13 +489,13 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
489 | * @kobj: kobject for mapping | 489 | * @kobj: kobject for mapping |
490 | * @attr: struct bin_attribute for the file being mapped | 490 | * @attr: struct bin_attribute for the file being mapped |
491 | * @vma: struct vm_area_struct passed into the mmap | 491 | * @vma: struct vm_area_struct passed into the mmap |
492 | * @write_combine: 1 for write_combine mapping | ||
492 | * | 493 | * |
493 | * Use the regular PCI mapping routines to map a PCI resource into userspace. | 494 | * Use the regular PCI mapping routines to map a PCI resource into userspace. |
494 | * FIXME: write combining? maybe automatic for prefetchable regions? | ||
495 | */ | 495 | */ |
496 | static int | 496 | static int |
497 | pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | 497 | pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, |
498 | struct vm_area_struct *vma) | 498 | struct vm_area_struct *vma, int write_combine) |
499 | { | 499 | { |
500 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, | 500 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, |
501 | struct device, kobj)); | 501 | struct device, kobj)); |
@@ -518,7 +518,21 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | |||
518 | vma->vm_pgoff += start >> PAGE_SHIFT; | 518 | vma->vm_pgoff += start >> PAGE_SHIFT; |
519 | mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; | 519 | mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; |
520 | 520 | ||
521 | return pci_mmap_page_range(pdev, vma, mmap_type, 0); | 521 | return pci_mmap_page_range(pdev, vma, mmap_type, write_combine); |
522 | } | ||
523 | |||
524 | static int | ||
525 | pci_mmap_resource_uc(struct kobject *kobj, struct bin_attribute *attr, | ||
526 | struct vm_area_struct *vma) | ||
527 | { | ||
528 | return pci_mmap_resource(kobj, attr, vma, 0); | ||
529 | } | ||
530 | |||
531 | static int | ||
532 | pci_mmap_resource_wc(struct kobject *kobj, struct bin_attribute *attr, | ||
533 | struct vm_area_struct *vma) | ||
534 | { | ||
535 | return pci_mmap_resource(kobj, attr, vma, 1); | ||
522 | } | 536 | } |
523 | 537 | ||
524 | /** | 538 | /** |
@@ -541,9 +555,46 @@ pci_remove_resource_files(struct pci_dev *pdev) | |||
541 | sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); | 555 | sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); |
542 | kfree(res_attr); | 556 | kfree(res_attr); |
543 | } | 557 | } |
558 | |||
559 | res_attr = pdev->res_attr_wc[i]; | ||
560 | if (res_attr) { | ||
561 | sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); | ||
562 | kfree(res_attr); | ||
563 | } | ||
544 | } | 564 | } |
545 | } | 565 | } |
546 | 566 | ||
567 | static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine) | ||
568 | { | ||
569 | /* allocate attribute structure, piggyback attribute name */ | ||
570 | int name_len = write_combine ? 13 : 10; | ||
571 | struct bin_attribute *res_attr; | ||
572 | int retval; | ||
573 | |||
574 | res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC); | ||
575 | if (res_attr) { | ||
576 | char *res_attr_name = (char *)(res_attr + 1); | ||
577 | |||
578 | if (write_combine) { | ||
579 | pdev->res_attr_wc[num] = res_attr; | ||
580 | sprintf(res_attr_name, "resource%d_wc", num); | ||
581 | res_attr->mmap = pci_mmap_resource_wc; | ||
582 | } else { | ||
583 | pdev->res_attr[num] = res_attr; | ||
584 | sprintf(res_attr_name, "resource%d", num); | ||
585 | res_attr->mmap = pci_mmap_resource_uc; | ||
586 | } | ||
587 | res_attr->attr.name = res_attr_name; | ||
588 | res_attr->attr.mode = S_IRUSR | S_IWUSR; | ||
589 | res_attr->size = pci_resource_len(pdev, num); | ||
590 | res_attr->private = &pdev->resource[num]; | ||
591 | retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); | ||
592 | } else | ||
593 | retval = -ENOMEM; | ||
594 | |||
595 | return retval; | ||
596 | } | ||
597 | |||
547 | /** | 598 | /** |
548 | * pci_create_resource_files - create resource files in sysfs for @dev | 599 | * pci_create_resource_files - create resource files in sysfs for @dev |
549 | * @dev: dev in question | 600 | * @dev: dev in question |
@@ -557,31 +608,19 @@ static int pci_create_resource_files(struct pci_dev *pdev) | |||
557 | 608 | ||
558 | /* Expose the PCI resources from this device as files */ | 609 | /* Expose the PCI resources from this device as files */ |
559 | for (i = 0; i < PCI_ROM_RESOURCE; i++) { | 610 | for (i = 0; i < PCI_ROM_RESOURCE; i++) { |
560 | struct bin_attribute *res_attr; | ||
561 | 611 | ||
562 | /* skip empty resources */ | 612 | /* skip empty resources */ |
563 | if (!pci_resource_len(pdev, i)) | 613 | if (!pci_resource_len(pdev, i)) |
564 | continue; | 614 | continue; |
565 | 615 | ||
566 | /* allocate attribute structure, piggyback attribute name */ | 616 | retval = pci_create_attr(pdev, i, 0); |
567 | res_attr = kzalloc(sizeof(*res_attr) + 10, GFP_ATOMIC); | 617 | /* for prefetchable resources, create a WC mappable file */ |
568 | if (res_attr) { | 618 | if (!retval && pdev->resource[i].flags & IORESOURCE_PREFETCH) |
569 | char *res_attr_name = (char *)(res_attr + 1); | 619 | retval = pci_create_attr(pdev, i, 1); |
570 | 620 | ||
571 | pdev->res_attr[i] = res_attr; | 621 | if (retval) { |
572 | sprintf(res_attr_name, "resource%d", i); | 622 | pci_remove_resource_files(pdev); |
573 | res_attr->attr.name = res_attr_name; | 623 | return retval; |
574 | res_attr->attr.mode = S_IRUSR | S_IWUSR; | ||
575 | res_attr->size = pci_resource_len(pdev, i); | ||
576 | res_attr->mmap = pci_mmap_resource; | ||
577 | res_attr->private = &pdev->resource[i]; | ||
578 | retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); | ||
579 | if (retval) { | ||
580 | pci_remove_resource_files(pdev); | ||
581 | return retval; | ||
582 | } | ||
583 | } else { | ||
584 | return -ENOMEM; | ||
585 | } | 624 | } |
586 | } | 625 | } |
587 | return 0; | 626 | return 0; |
@@ -697,9 +736,9 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
697 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); | 736 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); |
698 | if (attr) { | 737 | if (attr) { |
699 | pdev->vpd->attr = attr; | 738 | pdev->vpd->attr = attr; |
700 | attr->size = pdev->vpd->ops->get_size(pdev); | 739 | attr->size = pdev->vpd->len; |
701 | attr->attr.name = "vpd"; | 740 | attr->attr.name = "vpd"; |
702 | attr->attr.mode = S_IRUGO | S_IWUSR; | 741 | attr->attr.mode = S_IRUSR | S_IWUSR; |
703 | attr->read = pci_read_vpd; | 742 | attr->read = pci_read_vpd; |
704 | attr->write = pci_write_vpd; | 743 | attr->write = pci_write_vpd; |
705 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); | 744 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 0a497c1b4227..00408c97e5fc 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -21,11 +21,11 @@ extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val); | |||
21 | struct pci_vpd_ops { | 21 | struct pci_vpd_ops { |
22 | int (*read)(struct pci_dev *dev, int pos, int size, char *buf); | 22 | int (*read)(struct pci_dev *dev, int pos, int size, char *buf); |
23 | int (*write)(struct pci_dev *dev, int pos, int size, const char *buf); | 23 | int (*write)(struct pci_dev *dev, int pos, int size, const char *buf); |
24 | int (*get_size)(struct pci_dev *dev); | ||
25 | void (*release)(struct pci_dev *dev); | 24 | void (*release)(struct pci_dev *dev); |
26 | }; | 25 | }; |
27 | 26 | ||
28 | struct pci_vpd { | 27 | struct pci_vpd { |
28 | unsigned int len; | ||
29 | struct pci_vpd_ops *ops; | 29 | struct pci_vpd_ops *ops; |
30 | struct bin_attribute *attr; /* descriptor for sysfs VPD entry */ | 30 | struct bin_attribute *attr; /* descriptor for sysfs VPD entry */ |
31 | }; | 31 | }; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dabb563f51d9..a3497dc6ebcf 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -1670,6 +1670,48 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) | |||
1670 | } | 1670 | } |
1671 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); | 1671 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); |
1672 | 1672 | ||
1673 | /* | ||
1674 | * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the | ||
1675 | * VPD end tag will hang the device. This problem was initially | ||
1676 | * observed when a vpd entry was created in sysfs | ||
1677 | * ('/sys/bus/pci/devices/<id>/vpd'). A read to this sysfs entry | ||
1678 | * will dump 32k of data. Reading a full 32k will cause an access | ||
1679 | * beyond the VPD end tag causing the device to hang. Once the device | ||
1680 | * is hung, the bnx2 driver will not be able to reset the device. | ||
1681 | * We believe that it is legal to read beyond the end tag and | ||
1682 | * therefore the solution is to limit the read/write length. | ||
1683 | */ | ||
1684 | static void __devinit quirk_brcm_570x_limit_vpd(struct pci_dev *dev) | ||
1685 | { | ||
1686 | /* Only disable the VPD capability for 5706, 5708, and 5709 rev. A */ | ||
1687 | if ((dev->device == PCI_DEVICE_ID_NX2_5706) || | ||
1688 | (dev->device == PCI_DEVICE_ID_NX2_5708) || | ||
1689 | ((dev->device == PCI_DEVICE_ID_NX2_5709) && | ||
1690 | (dev->revision & 0xf0) == 0x0)) { | ||
1691 | if (dev->vpd) | ||
1692 | dev->vpd->len = 0x80; | ||
1693 | } | ||
1694 | } | ||
1695 | |||
1696 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1697 | PCI_DEVICE_ID_NX2_5706, | ||
1698 | quirk_brcm_570x_limit_vpd); | ||
1699 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1700 | PCI_DEVICE_ID_NX2_5706S, | ||
1701 | quirk_brcm_570x_limit_vpd); | ||
1702 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1703 | PCI_DEVICE_ID_NX2_5708, | ||
1704 | quirk_brcm_570x_limit_vpd); | ||
1705 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1706 | PCI_DEVICE_ID_NX2_5708S, | ||
1707 | quirk_brcm_570x_limit_vpd); | ||
1708 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1709 | PCI_DEVICE_ID_NX2_5709, | ||
1710 | quirk_brcm_570x_limit_vpd); | ||
1711 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1712 | PCI_DEVICE_ID_NX2_5709S, | ||
1713 | quirk_brcm_570x_limit_vpd); | ||
1714 | |||
1673 | #ifdef CONFIG_PCI_MSI | 1715 | #ifdef CONFIG_PCI_MSI |
1674 | /* Some chipsets do not support MSI. We cannot easily rely on setting | 1716 | /* Some chipsets do not support MSI. We cannot easily rely on setting |
1675 | * PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually | 1717 | * PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually |