aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c2
-rw-r--r--drivers/pci/pci-driver.c2
-rw-r--r--drivers/pci/pci.c42
-rw-r--r--drivers/pci/quirks.c78
-rw-r--r--drivers/pci/rom.c7
-rw-r--r--include/linux/pci.h4
6 files changed, 124 insertions, 11 deletions
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index ff32e85e1de6..f052e951b23e 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -532,8 +532,6 @@ static void interrupt_event_handler(struct work_struct *work)
532 pciehp_green_led_off(p_slot); 532 pciehp_green_led_off(p_slot);
533 break; 533 break;
534 case INT_PRESENCE_ON: 534 case INT_PRESENCE_ON:
535 if (!HP_SUPR_RM(ctrl))
536 break;
537 ctrl_dbg(ctrl, "Surprise Insertion\n"); 535 ctrl_dbg(ctrl, "Surprise Insertion\n");
538 handle_surprise_event(p_slot); 536 handle_surprise_event(p_slot);
539 break; 537 break;
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 887e6bd95af7..09a66bad8018 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1383,7 +1383,7 @@ static int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
1383 if (add_uevent_var(env, "PCI_SLOT_NAME=%s", pci_name(pdev))) 1383 if (add_uevent_var(env, "PCI_SLOT_NAME=%s", pci_name(pdev)))
1384 return -ENOMEM; 1384 return -ENOMEM;
1385 1385
1386 if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", 1386 if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02X",
1387 pdev->vendor, pdev->device, 1387 pdev->vendor, pdev->device,
1388 pdev->subsystem_vendor, pdev->subsystem_device, 1388 pdev->subsystem_vendor, pdev->subsystem_device,
1389 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 1389 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c419554d0b4b..460d046ab6fe 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3199,7 +3199,7 @@ static int pci_pm_reset(struct pci_dev *dev, int probe)
3199{ 3199{
3200 u16 csr; 3200 u16 csr;
3201 3201
3202 if (!dev->pm_cap) 3202 if (!dev->pm_cap || dev->dev_flags & PCI_DEV_FLAGS_NO_PM_RESET)
3203 return -ENOTTY; 3203 return -ENOTTY;
3204 3204
3205 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &csr); 3205 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &csr);
@@ -3273,7 +3273,8 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe)
3273{ 3273{
3274 struct pci_dev *pdev; 3274 struct pci_dev *pdev;
3275 3275
3276 if (pci_is_root_bus(dev->bus) || dev->subordinate || !dev->bus->self) 3276 if (pci_is_root_bus(dev->bus) || dev->subordinate ||
3277 !dev->bus->self || dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
3277 return -ENOTTY; 3278 return -ENOTTY;
3278 3279
3279 list_for_each_entry(pdev, &dev->bus->devices, bus_list) 3280 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
@@ -3307,7 +3308,8 @@ static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe)
3307{ 3308{
3308 struct pci_dev *pdev; 3309 struct pci_dev *pdev;
3309 3310
3310 if (dev->subordinate || !dev->slot) 3311 if (dev->subordinate || !dev->slot ||
3312 dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
3311 return -ENOTTY; 3313 return -ENOTTY;
3312 3314
3313 list_for_each_entry(pdev, &dev->bus->devices, bus_list) 3315 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
@@ -3559,6 +3561,20 @@ int pci_try_reset_function(struct pci_dev *dev)
3559} 3561}
3560EXPORT_SYMBOL_GPL(pci_try_reset_function); 3562EXPORT_SYMBOL_GPL(pci_try_reset_function);
3561 3563
3564/* Do any devices on or below this bus prevent a bus reset? */
3565static bool pci_bus_resetable(struct pci_bus *bus)
3566{
3567 struct pci_dev *dev;
3568
3569 list_for_each_entry(dev, &bus->devices, bus_list) {
3570 if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
3571 (dev->subordinate && !pci_bus_resetable(dev->subordinate)))
3572 return false;
3573 }
3574
3575 return true;
3576}
3577
3562/* Lock devices from the top of the tree down */ 3578/* Lock devices from the top of the tree down */
3563static void pci_bus_lock(struct pci_bus *bus) 3579static void pci_bus_lock(struct pci_bus *bus)
3564{ 3580{
@@ -3609,6 +3625,22 @@ unlock:
3609 return 0; 3625 return 0;
3610} 3626}
3611 3627
3628/* Do any devices on or below this slot prevent a bus reset? */
3629static bool pci_slot_resetable(struct pci_slot *slot)
3630{
3631 struct pci_dev *dev;
3632
3633 list_for_each_entry(dev, &slot->bus->devices, bus_list) {
3634 if (!dev->slot || dev->slot != slot)
3635 continue;
3636 if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
3637 (dev->subordinate && !pci_bus_resetable(dev->subordinate)))
3638 return false;
3639 }
3640
3641 return true;
3642}
3643
3612/* Lock devices from the top of the tree down */ 3644/* Lock devices from the top of the tree down */
3613static void pci_slot_lock(struct pci_slot *slot) 3645static void pci_slot_lock(struct pci_slot *slot)
3614{ 3646{
@@ -3730,7 +3762,7 @@ static int pci_slot_reset(struct pci_slot *slot, int probe)
3730{ 3762{
3731 int rc; 3763 int rc;
3732 3764
3733 if (!slot) 3765 if (!slot || !pci_slot_resetable(slot))
3734 return -ENOTTY; 3766 return -ENOTTY;
3735 3767
3736 if (!probe) 3768 if (!probe)
@@ -3822,7 +3854,7 @@ EXPORT_SYMBOL_GPL(pci_try_reset_slot);
3822 3854
3823static int pci_bus_reset(struct pci_bus *bus, int probe) 3855static int pci_bus_reset(struct pci_bus *bus, int probe)
3824{ 3856{
3825 if (!bus->self) 3857 if (!bus->self || !pci_bus_resetable(bus))
3826 return -ENOTTY; 3858 return -ENOTTY;
3827 3859
3828 if (probe) 3860 if (probe)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index ed6f89b6efe5..e248a119f15a 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3028,6 +3028,41 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_REALTEK, 0x8169,
3028DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID, 3028DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
3029 quirk_broken_intx_masking); 3029 quirk_broken_intx_masking);
3030 3030
3031static void quirk_no_bus_reset(struct pci_dev *dev)
3032{
3033 dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET;
3034}
3035
3036/*
3037 * Atheros AR93xx chips do not behave after a bus reset. The device will
3038 * throw a Link Down error on AER-capable systems and regardless of AER,
3039 * config space of the device is never accessible again and typically
3040 * causes the system to hang or reset when access is attempted.
3041 * http://www.spinics.net/lists/linux-pci/msg34797.html
3042 */
3043DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0030, quirk_no_bus_reset);
3044
3045static void quirk_no_pm_reset(struct pci_dev *dev)
3046{
3047 /*
3048 * We can't do a bus reset on root bus devices, but an ineffective
3049 * PM reset may be better than nothing.
3050 */
3051 if (!pci_is_root_bus(dev->bus))
3052 dev->dev_flags |= PCI_DEV_FLAGS_NO_PM_RESET;
3053}
3054
3055/*
3056 * Some AMD/ATI GPUS (HD8570 - Oland) report that a D3hot->D0 transition
3057 * causes a reset (i.e., they advertise NoSoftRst-). This transition seems
3058 * to have no effect on the device: it retains the framebuffer contents and
3059 * monitor sync. Advertising this support makes other layers, like VFIO,
3060 * assume pci_reset_function() is viable for this device. Mark it as
3061 * unavailable to skip it when testing reset methods.
3062 */
3063DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
3064 PCI_CLASS_DISPLAY_VGA, 8, quirk_no_pm_reset);
3065
3031#ifdef CONFIG_ACPI 3066#ifdef CONFIG_ACPI
3032/* 3067/*
3033 * Apple: Shutdown Cactus Ridge Thunderbolt controller. 3068 * Apple: Shutdown Cactus Ridge Thunderbolt controller.
@@ -3528,6 +3563,44 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON,
3528 quirk_dma_func1_alias); 3563 quirk_dma_func1_alias);
3529 3564
3530/* 3565/*
3566 * Some devices DMA with the wrong devfn, not just the wrong function.
3567 * quirk_fixed_dma_alias() uses this table to create fixed aliases, where
3568 * the alias is "fixed" and independent of the device devfn.
3569 *
3570 * For example, the Adaptec 3405 is a PCIe card with an Intel 80333 I/O
3571 * processor. To software, this appears as a PCIe-to-PCI/X bridge with a
3572 * single device on the secondary bus. In reality, the single exposed
3573 * device at 0e.0 is the Address Translation Unit (ATU) of the controller
3574 * that provides a bridge to the internal bus of the I/O processor. The
3575 * controller supports private devices, which can be hidden from PCI config
3576 * space. In the case of the Adaptec 3405, a private device at 01.0
3577 * appears to be the DMA engine, which therefore needs to become a DMA
3578 * alias for the device.
3579 */
3580static const struct pci_device_id fixed_dma_alias_tbl[] = {
3581 { PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x0285,
3582 PCI_VENDOR_ID_ADAPTEC2, 0x02bb), /* Adaptec 3405 */
3583 .driver_data = PCI_DEVFN(1, 0) },
3584 { 0 }
3585};
3586
3587static void quirk_fixed_dma_alias(struct pci_dev *dev)
3588{
3589 const struct pci_device_id *id;
3590
3591 id = pci_match_id(fixed_dma_alias_tbl, dev);
3592 if (id) {
3593 dev->dma_alias_devfn = id->driver_data;
3594 dev->dev_flags |= PCI_DEV_FLAGS_DMA_ALIAS_DEVFN;
3595 dev_info(&dev->dev, "Enabling fixed DMA alias to %02x.%d\n",
3596 PCI_SLOT(dev->dma_alias_devfn),
3597 PCI_FUNC(dev->dma_alias_devfn));
3598 }
3599}
3600
3601DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ADAPTEC2, 0x0285, quirk_fixed_dma_alias);
3602
3603/*
3531 * A few PCIe-to-PCI bridges fail to expose a PCIe capability, resulting in 3604 * A few PCIe-to-PCI bridges fail to expose a PCIe capability, resulting in
3532 * using the wrong DMA alias for the device. Some of these devices can be 3605 * using the wrong DMA alias for the device. Some of these devices can be
3533 * used as either forward or reverse bridges, so we need to test whether the 3606 * used as either forward or reverse bridges, so we need to test whether the
@@ -3630,6 +3703,9 @@ static const u16 pci_quirk_intel_pch_acs_ids[] = {
3630 0x9c98, 0x9c99, 0x9c9a, 0x9c9b, 3703 0x9c98, 0x9c99, 0x9c9a, 0x9c9b,
3631 /* Patsburg (X79) PCH */ 3704 /* Patsburg (X79) PCH */
3632 0x1d10, 0x1d12, 0x1d14, 0x1d16, 0x1d18, 0x1d1a, 0x1d1c, 0x1d1e, 3705 0x1d10, 0x1d12, 0x1d14, 0x1d16, 0x1d18, 0x1d1a, 0x1d1c, 0x1d1e,
3706 /* Wellsburg (X99) PCH */
3707 0x8d10, 0x8d11, 0x8d12, 0x8d13, 0x8d14, 0x8d15, 0x8d16, 0x8d17,
3708 0x8d18, 0x8d19, 0x8d1a, 0x8d1b, 0x8d1c, 0x8d1d, 0x8d1e,
3633}; 3709};
3634 3710
3635static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev) 3711static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev)
@@ -3713,6 +3789,8 @@ static const struct pci_dev_acs_enabled {
3713 { PCI_VENDOR_ID_INTEL, 0x1551, pci_quirk_mf_endpoint_acs }, 3789 { PCI_VENDOR_ID_INTEL, 0x1551, pci_quirk_mf_endpoint_acs },
3714 { PCI_VENDOR_ID_INTEL, 0x1558, pci_quirk_mf_endpoint_acs }, 3790 { PCI_VENDOR_ID_INTEL, 0x1558, pci_quirk_mf_endpoint_acs },
3715 { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs }, 3791 { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs },
3792 { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */
3793 { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */
3716 { 0 } 3794 { 0 }
3717}; 3795};
3718 3796
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index f955edb9bea7..eb0ad530dc43 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -71,6 +71,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
71{ 71{
72 void __iomem *image; 72 void __iomem *image;
73 int last_image; 73 int last_image;
74 unsigned length;
74 75
75 image = rom; 76 image = rom;
76 do { 77 do {
@@ -93,9 +94,9 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
93 if (readb(pds + 3) != 'R') 94 if (readb(pds + 3) != 'R')
94 break; 95 break;
95 last_image = readb(pds + 21) & 0x80; 96 last_image = readb(pds + 21) & 0x80;
96 /* this length is reliable */ 97 length = readw(pds + 16);
97 image += readw(pds + 16) * 512; 98 image += length * 512;
98 } while (!last_image); 99 } while (length && !last_image);
99 100
100 /* never return a size larger than the PCI resource window */ 101 /* never return a size larger than the PCI resource window */
101 /* there are known ROMs that get the size wrong */ 102 /* there are known ROMs that get the size wrong */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 360a966a97a5..7bed32b3fd54 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -175,6 +175,10 @@ enum pci_dev_flags {
175 PCI_DEV_FLAGS_DMA_ALIAS_DEVFN = (__force pci_dev_flags_t) (1 << 4), 175 PCI_DEV_FLAGS_DMA_ALIAS_DEVFN = (__force pci_dev_flags_t) (1 << 4),
176 /* Use a PCIe-to-PCI bridge alias even if !pci_is_pcie */ 176 /* Use a PCIe-to-PCI bridge alias even if !pci_is_pcie */
177 PCI_DEV_FLAG_PCIE_BRIDGE_ALIAS = (__force pci_dev_flags_t) (1 << 5), 177 PCI_DEV_FLAG_PCIE_BRIDGE_ALIAS = (__force pci_dev_flags_t) (1 << 5),
178 /* Do not use bus resets for device */
179 PCI_DEV_FLAGS_NO_BUS_RESET = (__force pci_dev_flags_t) (1 << 6),
180 /* Do not use PM reset even if device advertises NoSoftRst- */
181 PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7),
178}; 182};
179 183
180enum pci_irq_reroute_variant { 184enum pci_irq_reroute_variant {