aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/quirks.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/quirks.c')
-rw-r--r--drivers/pci/quirks.c116
1 files changed, 107 insertions, 9 deletions
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 2a7521677541..a2d9d330a01e 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -253,7 +253,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576, quirk_vsfx)
253 * workaround applied too 253 * workaround applied too
254 * [Info kindly provided by ALi] 254 * [Info kindly provided by ALi]
255 */ 255 */
256static void __init quirk_alimagik(struct pci_dev *dev) 256static void __devinit quirk_alimagik(struct pci_dev *dev)
257{ 257{
258 if ((pci_pci_problems&PCIPCI_ALIMAGIK)==0) { 258 if ((pci_pci_problems&PCIPCI_ALIMAGIK)==0) {
259 dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); 259 dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
@@ -789,7 +789,7 @@ static void __devinit quirk_amd_ioapic(struct pci_dev *dev)
789} 789}
790DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, quirk_amd_ioapic); 790DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, quirk_amd_ioapic);
791 791
792static void __init quirk_ioapic_rmw(struct pci_dev *dev) 792static void __devinit quirk_ioapic_rmw(struct pci_dev *dev)
793{ 793{
794 if (dev->devfn == 0 && dev->bus->number == 0) 794 if (dev->devfn == 0 && dev->bus->number == 0)
795 sis_apic_bug = 1; 795 sis_apic_bug = 1;
@@ -801,7 +801,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI, PCI_ANY_ID, quirk_ioapic_rmw);
801 * Some settings of MMRBC can lead to data corruption so block changes. 801 * Some settings of MMRBC can lead to data corruption so block changes.
802 * See AMD 8131 HyperTransport PCI-X Tunnel Revision Guide 802 * See AMD 8131 HyperTransport PCI-X Tunnel Revision Guide
803 */ 803 */
804static void __init quirk_amd_8131_mmrbc(struct pci_dev *dev) 804static void __devinit quirk_amd_8131_mmrbc(struct pci_dev *dev)
805{ 805{
806 if (dev->subordinate && dev->revision <= 0x12) { 806 if (dev->subordinate && dev->revision <= 0x12) {
807 dev_info(&dev->dev, "AMD8131 rev %x detected; " 807 dev_info(&dev->dev, "AMD8131 rev %x detected; "
@@ -1082,7 +1082,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB
1082/* 1082/*
1083 * Intel 82801CAM ICH3-M datasheet says IDE modes must be the same 1083 * Intel 82801CAM ICH3-M datasheet says IDE modes must be the same
1084 */ 1084 */
1085static void __init quirk_ide_samemode(struct pci_dev *pdev) 1085static void __devinit quirk_ide_samemode(struct pci_dev *pdev)
1086{ 1086{
1087 u8 prog; 1087 u8 prog;
1088 1088
@@ -1121,7 +1121,7 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, PCI_ANY_ID,
1121/* This was originally an Alpha specific thing, but it really fits here. 1121/* This was originally an Alpha specific thing, but it really fits here.
1122 * The i82375 PCI/EISA bridge appears as non-classified. Fix that. 1122 * The i82375 PCI/EISA bridge appears as non-classified. Fix that.
1123 */ 1123 */
1124static void __init quirk_eisa_bridge(struct pci_dev *dev) 1124static void __devinit quirk_eisa_bridge(struct pci_dev *dev)
1125{ 1125{
1126 dev->class = PCI_CLASS_BRIDGE_EISA << 8; 1126 dev->class = PCI_CLASS_BRIDGE_EISA << 8;
1127} 1127}
@@ -1155,7 +1155,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82375, quirk_e
1155 */ 1155 */
1156static int asus_hides_smbus; 1156static int asus_hides_smbus;
1157 1157
1158static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev) 1158static void __devinit asus_hides_smbus_hostbridge(struct pci_dev *dev)
1159{ 1159{
1160 if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) { 1160 if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) {
1161 if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB) 1161 if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB)
@@ -1538,7 +1538,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB3
1538#endif 1538#endif
1539 1539
1540#ifdef CONFIG_X86_IO_APIC 1540#ifdef CONFIG_X86_IO_APIC
1541static void __init quirk_alder_ioapic(struct pci_dev *pdev) 1541static void __devinit quirk_alder_ioapic(struct pci_dev *pdev)
1542{ 1542{
1543 int i; 1543 int i;
1544 1544
@@ -1777,7 +1777,7 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, qui
1777 * but the PIO transfers won't work if BAR0 falls at the odd 8 bytes. 1777 * but the PIO transfers won't work if BAR0 falls at the odd 8 bytes.
1778 * Re-allocate the region if needed... 1778 * Re-allocate the region if needed...
1779 */ 1779 */
1780static void __init quirk_tc86c001_ide(struct pci_dev *dev) 1780static void __devinit quirk_tc86c001_ide(struct pci_dev *dev)
1781{ 1781{
1782 struct resource *r = &dev->resource[0]; 1782 struct resource *r = &dev->resource[0];
1783 1783
@@ -2169,7 +2169,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PLX, 0x8624, quirk_tile_plx_gen1);
2169 * aware of it. Instead of setting the flag on all busses in the 2169 * aware of it. Instead of setting the flag on all busses in the
2170 * machine, simply disable MSI globally. 2170 * machine, simply disable MSI globally.
2171 */ 2171 */
2172static void __init quirk_disable_all_msi(struct pci_dev *dev) 2172static void __devinit quirk_disable_all_msi(struct pci_dev *dev)
2173{ 2173{
2174 pci_no_msi(); 2174 pci_no_msi();
2175 dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n"); 2175 dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n");
@@ -2929,6 +2929,20 @@ static void __devinit disable_igfx_irq(struct pci_dev *dev)
2929DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq); 2929DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq);
2930DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq); 2930DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
2931 2931
2932/*
2933 * Some devices may pass our check in pci_intx_mask_supported if
2934 * PCI_COMMAND_INTX_DISABLE works though they actually do not properly
2935 * support this feature.
2936 */
2937static void __devinit quirk_broken_intx_masking(struct pci_dev *dev)
2938{
2939 dev->broken_intx_masking = 1;
2940}
2941DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CHELSIO, 0x0030,
2942 quirk_broken_intx_masking);
2943DECLARE_PCI_FIXUP_HEADER(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */
2944 quirk_broken_intx_masking);
2945
2932static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, 2946static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
2933 struct pci_fixup *end) 2947 struct pci_fixup *end)
2934{ 2948{
@@ -3179,3 +3193,87 @@ int pci_dev_specific_reset(struct pci_dev *dev, int probe)
3179 3193
3180 return -ENOTTY; 3194 return -ENOTTY;
3181} 3195}
3196
3197static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev)
3198{
3199 if (!PCI_FUNC(dev->devfn))
3200 return pci_dev_get(dev);
3201
3202 return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
3203}
3204
3205static const struct pci_dev_dma_source {
3206 u16 vendor;
3207 u16 device;
3208 struct pci_dev *(*dma_source)(struct pci_dev *dev);
3209} pci_dev_dma_source[] = {
3210 /*
3211 * https://bugzilla.redhat.com/show_bug.cgi?id=605888
3212 *
3213 * Some Ricoh devices use the function 0 source ID for DMA on
3214 * other functions of a multifunction device. The DMA devices
3215 * is therefore function 0, which will have implications of the
3216 * iommu grouping of these devices.
3217 */
3218 { PCI_VENDOR_ID_RICOH, 0xe822, pci_func_0_dma_source },
3219 { PCI_VENDOR_ID_RICOH, 0xe230, pci_func_0_dma_source },
3220 { PCI_VENDOR_ID_RICOH, 0xe832, pci_func_0_dma_source },
3221 { PCI_VENDOR_ID_RICOH, 0xe476, pci_func_0_dma_source },
3222 { 0 }
3223};
3224
3225/*
3226 * IOMMUs with isolation capabilities need to be programmed with the
3227 * correct source ID of a device. In most cases, the source ID matches
3228 * the device doing the DMA, but sometimes hardware is broken and will
3229 * tag the DMA as being sourced from a different device. This function
3230 * allows that translation. Note that the reference count of the
3231 * returned device is incremented on all paths.
3232 */
3233struct pci_dev *pci_get_dma_source(struct pci_dev *dev)
3234{
3235 const struct pci_dev_dma_source *i;
3236
3237 for (i = pci_dev_dma_source; i->dma_source; i++) {
3238 if ((i->vendor == dev->vendor ||
3239 i->vendor == (u16)PCI_ANY_ID) &&
3240 (i->device == dev->device ||
3241 i->device == (u16)PCI_ANY_ID))
3242 return i->dma_source(dev);
3243 }
3244
3245 return pci_dev_get(dev);
3246}
3247
3248static const struct pci_dev_acs_enabled {
3249 u16 vendor;
3250 u16 device;
3251 int (*acs_enabled)(struct pci_dev *dev, u16 acs_flags);
3252} pci_dev_acs_enabled[] = {
3253 { 0 }
3254};
3255
3256int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags)
3257{
3258 const struct pci_dev_acs_enabled *i;
3259 int ret;
3260
3261 /*
3262 * Allow devices that do not expose standard PCIe ACS capabilities
3263 * or control to indicate their support here. Multi-function express
3264 * devices which do not allow internal peer-to-peer between functions,
3265 * but do not implement PCIe ACS may wish to return true here.
3266 */
3267 for (i = pci_dev_acs_enabled; i->acs_enabled; i++) {
3268 if ((i->vendor == dev->vendor ||
3269 i->vendor == (u16)PCI_ANY_ID) &&
3270 (i->device == dev->device ||
3271 i->device == (u16)PCI_ANY_ID)) {
3272 ret = i->acs_enabled(dev, acs_flags);
3273 if (ret >= 0)
3274 return ret;
3275 }
3276 }
3277
3278 return -ENOTTY;
3279}