Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: use pci_find_ext_capability everywhere

Remove some open coded (and buggy) versions of pci_find_ext_capability
in favor of the real routine in the PCI core.

Tested-by: Tomasz Czernecki <czernecki@gmail.com>
Acked-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

+20 -65
+3 -3
drivers/pci/pcie/aer/aerdrv.c
··· 105 105 unsigned long flags; 106 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 110 * Must lock access to Root Error Status Reg, Root Error ID Reg, 111 111 * and Root error producer/consumer index ··· 252 252 u32 status; 253 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 257 /* Disable Root's interrupt in response to error messages */ 258 258 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, 0); ··· 316 316 pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, reg16); 317 317 318 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 320 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status); 321 321 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask); 322 322 if (dev->error_state == pci_channel_io_normal)
+10 -37
drivers/pci/pcie/aer/aerdrv_core.c
··· 28 28 static int forceload; 29 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, &reg32)) 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 31 int pci_enable_pcie_error_reporting(struct pci_dev *dev) 62 32 { 63 33 u16 reg16 = 0; 64 34 int pos; 65 35 66 36 pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 37 + if (!pos) 38 + return -EIO; 39 + 40 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 67 41 if (!pos) 68 42 return -EIO; 69 43 ··· 76 102 int pos; 77 103 u32 status, mask; 78 104 79 - pos = pci_find_aer_capability(dev); 105 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 80 106 if (!pos) 81 107 return -EIO; 82 108 ··· 97 123 int pos; 98 124 u32 status; 99 125 100 - pos = pci_find_aer_capability(dev); 126 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 101 127 if (!pos) 102 128 return -EIO; 103 129 ··· 476 502 * Correctable error does not need software intevention. 477 503 * No need to go through error recovery process. 478 504 */ 479 - pos = pci_find_aer_capability(dev); 505 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 480 506 if (pos) 481 507 pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, 482 508 info.status); ··· 516 542 reg16 &= ~(SYSTEM_ERROR_INTR_ON_MESG_MASK); 517 543 pci_write_config_word(pdev, pos + PCI_EXP_RTCTL, reg16); 518 544 519 - aer_pos = pci_find_aer_capability(pdev); 545 + aer_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); 520 546 /* Clear error status */ 521 547 pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, &reg32); 522 548 pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, reg32); ··· 553 579 u32 reg32; 554 580 int pos; 555 581 556 - pos = pci_find_aer_capability(pdev); 582 + pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); 557 583 /* Disable Root's interrupt in response to error messages */ 558 584 pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, 0); 559 585 ··· 592 618 { 593 619 int pos; 594 620 595 - pos = pci_find_aer_capability(dev); 621 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 596 622 597 623 /* The device might not support AER */ 598 624 if (!pos) ··· 729 755 return AER_SUCCESS; 730 756 } 731 757 732 - EXPORT_SYMBOL_GPL(pci_find_aer_capability); 733 758 EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); 734 759 EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); 735 760 EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
+5 -18
drivers/pci/pcie/portdrv_core.c
··· 195 195 /* PME Capable - root port capability */ 196 196 if (((reg16 >> 4) & PORT_TYPE_MASK) == PCIE_RC_PORT) 197 197 services |= PCIE_PORT_SERVICE_PME; 198 - 199 - pos = PCI_CFG_SPACE_SIZE; 200 - while (pos) { 201 - pci_read_config_dword(dev, pos, &reg32); 202 - switch (reg32 & 0xffff) { 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 - } 198 + 199 + if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR)) 200 + services |= PCIE_PORT_SERVICE_AER; 201 + if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_VC)) 202 + services |= PCIE_PORT_SERVICE_VC; 216 203 217 204 return services; 218 205 }
+2 -3
drivers/scsi/qla2xxx/qla_os.c
··· 1566 1566 goto probe_out; 1567 1567 } 1568 1568 1569 - if (pci_find_aer_capability(pdev)) 1570 - if (pci_enable_pcie_error_reporting(pdev)) 1571 - goto probe_out; 1569 + /* This may fail but that's ok */ 1570 + pci_enable_pcie_error_reporting(pdev); 1572 1571 1573 1572 host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); 1574 1573 if (host == NULL) {
-4
include/linux/aer.h
··· 18 18 { 19 19 return -EINVAL; 20 20 } 21 - static inline int pci_find_aer_capability(struct pci_dev *dev) 22 - { 23 - return 0; 24 - } 25 21 static inline int pci_disable_pcie_error_reporting(struct pci_dev *dev) 26 22 { 27 23 return -EINVAL;