diff options
Diffstat (limited to 'drivers/pci/quirks.c')
-rw-r--r-- | drivers/pci/quirks.c | 147 |
1 files changed, 131 insertions, 16 deletions
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index e85d23044ae0..f6c31fabf3af 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -3126,9 +3126,6 @@ static int reset_intel_generic_dev(struct pci_dev *dev, int probe) | |||
3126 | 3126 | ||
3127 | static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe) | 3127 | static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe) |
3128 | { | 3128 | { |
3129 | int i; | ||
3130 | u16 status; | ||
3131 | |||
3132 | /* | 3129 | /* |
3133 | * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf | 3130 | * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf |
3134 | * | 3131 | * |
@@ -3140,20 +3137,9 @@ static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe) | |||
3140 | if (probe) | 3137 | if (probe) |
3141 | return 0; | 3138 | return 0; |
3142 | 3139 | ||
3143 | /* Wait for Transaction Pending bit clean */ | 3140 | if (!pci_wait_for_pending_transaction(dev)) |
3144 | for (i = 0; i < 4; i++) { | 3141 | dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n"); |
3145 | if (i) | ||
3146 | msleep((1 << (i - 1)) * 100); | ||
3147 | |||
3148 | pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status); | ||
3149 | if (!(status & PCI_EXP_DEVSTA_TRPND)) | ||
3150 | goto clear; | ||
3151 | } | ||
3152 | |||
3153 | dev_err(&dev->dev, "transaction is not cleared; " | ||
3154 | "proceeding with reset anyway\n"); | ||
3155 | 3142 | ||
3156 | clear: | ||
3157 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); | 3143 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); |
3158 | 3144 | ||
3159 | msleep(100); | 3145 | msleep(100); |
@@ -3208,6 +3194,83 @@ reset_complete: | |||
3208 | return 0; | 3194 | return 0; |
3209 | } | 3195 | } |
3210 | 3196 | ||
3197 | /* | ||
3198 | * Device-specific reset method for Chelsio T4-based adapters. | ||
3199 | */ | ||
3200 | static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe) | ||
3201 | { | ||
3202 | u16 old_command; | ||
3203 | u16 msix_flags; | ||
3204 | |||
3205 | /* | ||
3206 | * If this isn't a Chelsio T4-based device, return -ENOTTY indicating | ||
3207 | * that we have no device-specific reset method. | ||
3208 | */ | ||
3209 | if ((dev->device & 0xf000) != 0x4000) | ||
3210 | return -ENOTTY; | ||
3211 | |||
3212 | /* | ||
3213 | * If this is the "probe" phase, return 0 indicating that we can | ||
3214 | * reset this device. | ||
3215 | */ | ||
3216 | if (probe) | ||
3217 | return 0; | ||
3218 | |||
3219 | /* | ||
3220 | * T4 can wedge if there are DMAs in flight within the chip and Bus | ||
3221 | * Master has been disabled. We need to have it on till the Function | ||
3222 | * Level Reset completes. (BUS_MASTER is disabled in | ||
3223 | * pci_reset_function()). | ||
3224 | */ | ||
3225 | pci_read_config_word(dev, PCI_COMMAND, &old_command); | ||
3226 | pci_write_config_word(dev, PCI_COMMAND, | ||
3227 | old_command | PCI_COMMAND_MASTER); | ||
3228 | |||
3229 | /* | ||
3230 | * Perform the actual device function reset, saving and restoring | ||
3231 | * configuration information around the reset. | ||
3232 | */ | ||
3233 | pci_save_state(dev); | ||
3234 | |||
3235 | /* | ||
3236 | * T4 also suffers a Head-Of-Line blocking problem if MSI-X interrupts | ||
3237 | * are disabled when an MSI-X interrupt message needs to be delivered. | ||
3238 | * So we briefly re-enable MSI-X interrupts for the duration of the | ||
3239 | * FLR. The pci_restore_state() below will restore the original | ||
3240 | * MSI-X state. | ||
3241 | */ | ||
3242 | pci_read_config_word(dev, dev->msix_cap+PCI_MSIX_FLAGS, &msix_flags); | ||
3243 | if ((msix_flags & PCI_MSIX_FLAGS_ENABLE) == 0) | ||
3244 | pci_write_config_word(dev, dev->msix_cap+PCI_MSIX_FLAGS, | ||
3245 | msix_flags | | ||
3246 | PCI_MSIX_FLAGS_ENABLE | | ||
3247 | PCI_MSIX_FLAGS_MASKALL); | ||
3248 | |||
3249 | /* | ||
3250 | * Start of pcie_flr() code sequence. This reset code is a copy of | ||
3251 | * the guts of pcie_flr() because that's not an exported function. | ||
3252 | */ | ||
3253 | |||
3254 | if (!pci_wait_for_pending_transaction(dev)) | ||
3255 | dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n"); | ||
3256 | |||
3257 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); | ||
3258 | msleep(100); | ||
3259 | |||
3260 | /* | ||
3261 | * End of pcie_flr() code sequence. | ||
3262 | */ | ||
3263 | |||
3264 | /* | ||
3265 | * Restore the configuration information (BAR values, etc.) including | ||
3266 | * the original PCI Configuration Space Command word, and return | ||
3267 | * success. | ||
3268 | */ | ||
3269 | pci_restore_state(dev); | ||
3270 | pci_write_config_word(dev, PCI_COMMAND, old_command); | ||
3271 | return 0; | ||
3272 | } | ||
3273 | |||
3211 | #define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed | 3274 | #define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed |
3212 | #define PCI_DEVICE_ID_INTEL_IVB_M_VGA 0x0156 | 3275 | #define PCI_DEVICE_ID_INTEL_IVB_M_VGA 0x0156 |
3213 | #define PCI_DEVICE_ID_INTEL_IVB_M2_VGA 0x0166 | 3276 | #define PCI_DEVICE_ID_INTEL_IVB_M2_VGA 0x0166 |
@@ -3221,6 +3284,8 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { | |||
3221 | reset_ivb_igd }, | 3284 | reset_ivb_igd }, |
3222 | { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, | 3285 | { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, |
3223 | reset_intel_generic_dev }, | 3286 | reset_intel_generic_dev }, |
3287 | { PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID, | ||
3288 | reset_chelsio_generic_dev }, | ||
3224 | { 0 } | 3289 | { 0 } |
3225 | }; | 3290 | }; |
3226 | 3291 | ||
@@ -3295,11 +3360,61 @@ struct pci_dev *pci_get_dma_source(struct pci_dev *dev) | |||
3295 | return pci_dev_get(dev); | 3360 | return pci_dev_get(dev); |
3296 | } | 3361 | } |
3297 | 3362 | ||
3363 | /* | ||
3364 | * AMD has indicated that the devices below do not support peer-to-peer | ||
3365 | * in any system where they are found in the southbridge with an AMD | ||
3366 | * IOMMU in the system. Multifunction devices that do not support | ||
3367 | * peer-to-peer between functions can claim to support a subset of ACS. | ||
3368 | * Such devices effectively enable request redirect (RR) and completion | ||
3369 | * redirect (CR) since all transactions are redirected to the upstream | ||
3370 | * root complex. | ||
3371 | * | ||
3372 | * http://permalink.gmane.org/gmane.comp.emulators.kvm.devel/94086 | ||
3373 | * http://permalink.gmane.org/gmane.comp.emulators.kvm.devel/94102 | ||
3374 | * http://permalink.gmane.org/gmane.comp.emulators.kvm.devel/99402 | ||
3375 | * | ||
3376 | * 1002:4385 SBx00 SMBus Controller | ||
3377 | * 1002:439c SB7x0/SB8x0/SB9x0 IDE Controller | ||
3378 | * 1002:4383 SBx00 Azalia (Intel HDA) | ||
3379 | * 1002:439d SB7x0/SB8x0/SB9x0 LPC host controller | ||
3380 | * 1002:4384 SBx00 PCI to PCI Bridge | ||
3381 | * 1002:4399 SB7x0/SB8x0/SB9x0 USB OHCI2 Controller | ||
3382 | */ | ||
3383 | static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags) | ||
3384 | { | ||
3385 | #ifdef CONFIG_ACPI | ||
3386 | struct acpi_table_header *header = NULL; | ||
3387 | acpi_status status; | ||
3388 | |||
3389 | /* Targeting multifunction devices on the SB (appears on root bus) */ | ||
3390 | if (!dev->multifunction || !pci_is_root_bus(dev->bus)) | ||
3391 | return -ENODEV; | ||
3392 | |||
3393 | /* The IVRS table describes the AMD IOMMU */ | ||
3394 | status = acpi_get_table("IVRS", 0, &header); | ||
3395 | if (ACPI_FAILURE(status)) | ||
3396 | return -ENODEV; | ||
3397 | |||
3398 | /* Filter out flags not applicable to multifunction */ | ||
3399 | acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC | PCI_ACS_DT); | ||
3400 | |||
3401 | return acs_flags & ~(PCI_ACS_RR | PCI_ACS_CR) ? 0 : 1; | ||
3402 | #else | ||
3403 | return -ENODEV; | ||
3404 | #endif | ||
3405 | } | ||
3406 | |||
3298 | static const struct pci_dev_acs_enabled { | 3407 | static const struct pci_dev_acs_enabled { |
3299 | u16 vendor; | 3408 | u16 vendor; |
3300 | u16 device; | 3409 | u16 device; |
3301 | int (*acs_enabled)(struct pci_dev *dev, u16 acs_flags); | 3410 | int (*acs_enabled)(struct pci_dev *dev, u16 acs_flags); |
3302 | } pci_dev_acs_enabled[] = { | 3411 | } pci_dev_acs_enabled[] = { |
3412 | { PCI_VENDOR_ID_ATI, 0x4385, pci_quirk_amd_sb_acs }, | ||
3413 | { PCI_VENDOR_ID_ATI, 0x439c, pci_quirk_amd_sb_acs }, | ||
3414 | { PCI_VENDOR_ID_ATI, 0x4383, pci_quirk_amd_sb_acs }, | ||
3415 | { PCI_VENDOR_ID_ATI, 0x439d, pci_quirk_amd_sb_acs }, | ||
3416 | { PCI_VENDOR_ID_ATI, 0x4384, pci_quirk_amd_sb_acs }, | ||
3417 | { PCI_VENDOR_ID_ATI, 0x4399, pci_quirk_amd_sb_acs }, | ||
3303 | { 0 } | 3418 | { 0 } |
3304 | }; | 3419 | }; |
3305 | 3420 | ||