aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2013-09-23 20:00:08 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-09-23 20:00:08 -0400
commit63495fff27dfa0ce89ceb8f6350976e822398c5c (patch)
treeb453592a137b66666df3016330bd2afac5ab7fbe
parent3ba8b7c542cd06eafbd24f266a00623b89577d9d (diff)
parentf0308261b1dd5acba5c7e797159e60f94706df7d (diff)
Merge branch 'pci/yijing-pci_is_pcie-v2' into next
* pci/yijing-pci_is_pcie-v2: powerpc/pci: Use pci_is_pcie() to simplify code [SCSI] qla2xxx: Use pcie_is_pcie() to simplify code [SCSI] csiostor: Use pcie_capability_clear_and_set_word() to simplify code [SCSI] bfa: Use pcie_set()/get_readrq() to simplify code x86/pci: Use cached pci_dev->pcie_cap to simplify code PCI: Use pci_is_pcie() to simplify code
-rw-r--r--arch/powerpc/kernel/eeh.c3
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c2
-rw-r--r--arch/x86/pci/fixup.c18
-rw-r--r--drivers/pci/probe.c3
-rw-r--r--drivers/scsi/bfa/bfad.c53
-rw-r--r--drivers/scsi/csiostor/csio_hw.c22
-rw-r--r--drivers/scsi/qla2xxx/qla_mr.c6
-rw-r--r--include/uapi/linux/pci_regs.h3
8 files changed, 33 insertions, 77 deletions
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 55593ee2d5aa..6ebbe545b7a5 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -189,8 +189,7 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len)
189 } 189 }
190 190
191 /* If PCI-E capable, dump PCI-E cap 10, and the AER */ 191 /* If PCI-E capable, dump PCI-E cap 10, and the AER */
192 cap = pci_find_capability(dev, PCI_CAP_ID_EXP); 192 if (pci_is_pcie(dev)) {
193 if (cap) {
194 n += scnprintf(buf+n, len-n, "pci-e cap10:\n"); 193 n += scnprintf(buf+n, len-n, "pci-e cap10:\n");
195 printk(KERN_WARNING 194 printk(KERN_WARNING
196 "EEH: PCI-E capabilities and status follow:\n"); 195 "EEH: PCI-E capabilities and status follow:\n");
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index ccfb50ddfe38..92e7258478d8 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -45,7 +45,7 @@ static void quirk_fsl_pcie_header(struct pci_dev *dev)
45 u8 hdr_type; 45 u8 hdr_type;
46 46
47 /* if we aren't a PCIe don't bother */ 47 /* if we aren't a PCIe don't bother */
48 if (!pci_find_capability(dev, PCI_CAP_ID_EXP)) 48 if (!pci_is_pcie(dev))
49 return; 49 return;
50 50
51 /* if we aren't in host mode don't bother */ 51 /* if we aren't in host mode don't bother */
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index f5809fa2753e..b046e070e088 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -231,7 +231,7 @@ static int quirk_pcie_aspm_write(struct pci_bus *bus, unsigned int devfn, int wh
231 offset = quirk_aspm_offset[GET_INDEX(bus->self->device, devfn)]; 231 offset = quirk_aspm_offset[GET_INDEX(bus->self->device, devfn)];
232 232
233 if ((offset) && (where == offset)) 233 if ((offset) && (where == offset))
234 value = value & 0xfffffffc; 234 value = value & ~PCI_EXP_LNKCTL_ASPMC;
235 235
236 return raw_pci_write(pci_domain_nr(bus), bus->number, 236 return raw_pci_write(pci_domain_nr(bus), bus->number,
237 devfn, where, size, value); 237 devfn, where, size, value);
@@ -252,7 +252,7 @@ static struct pci_ops quirk_pcie_aspm_ops = {
252 */ 252 */
253static void pcie_rootport_aspm_quirk(struct pci_dev *pdev) 253static void pcie_rootport_aspm_quirk(struct pci_dev *pdev)
254{ 254{
255 int cap_base, i; 255 int i;
256 struct pci_bus *pbus; 256 struct pci_bus *pbus;
257 struct pci_dev *dev; 257 struct pci_dev *dev;
258 258
@@ -278,7 +278,7 @@ static void pcie_rootport_aspm_quirk(struct pci_dev *pdev)
278 for (i = GET_INDEX(pdev->device, 0); i <= GET_INDEX(pdev->device, 7); ++i) 278 for (i = GET_INDEX(pdev->device, 0); i <= GET_INDEX(pdev->device, 7); ++i)
279 quirk_aspm_offset[i] = 0; 279 quirk_aspm_offset[i] = 0;
280 280
281 pbus->ops = pbus->parent->ops; 281 pci_bus_set_ops(pbus, pbus->parent->ops);
282 } else { 282 } else {
283 /* 283 /*
284 * If devices are attached to the root port at power-up or 284 * If devices are attached to the root port at power-up or
@@ -286,13 +286,15 @@ static void pcie_rootport_aspm_quirk(struct pci_dev *pdev)
286 * each root port to save the register offsets and replace the 286 * each root port to save the register offsets and replace the
287 * bus ops. 287 * bus ops.
288 */ 288 */
289 list_for_each_entry(dev, &pbus->devices, bus_list) { 289 list_for_each_entry(dev, &pbus->devices, bus_list)
290 /* There are 0 to 8 devices attached to this bus */ 290 /* There are 0 to 8 devices attached to this bus */
291 cap_base = pci_find_capability(dev, PCI_CAP_ID_EXP); 291 quirk_aspm_offset[GET_INDEX(pdev->device, dev->devfn)] =
292 quirk_aspm_offset[GET_INDEX(pdev->device, dev->devfn)] = cap_base + 0x10; 292 dev->pcie_cap + PCI_EXP_LNKCTL;
293 } 293
294 pbus->ops = &quirk_pcie_aspm_ops; 294 pci_bus_set_ops(pbus, &quirk_pcie_aspm_ops);
295 dev_info(&pbus->dev, "writes to ASPM control bits will be ignored\n");
295 } 296 }
297
296} 298}
297DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PA, pcie_rootport_aspm_quirk); 299DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PA, pcie_rootport_aspm_quirk);
298DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PA1, pcie_rootport_aspm_quirk); 300DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PA1, pcie_rootport_aspm_quirk);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7ef0f868b3e0..c90d0f8021e7 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -641,8 +641,7 @@ static void pci_set_bus_speed(struct pci_bus *bus)
641 return; 641 return;
642 } 642 }
643 643
644 pos = pci_find_capability(bridge, PCI_CAP_ID_EXP); 644 if (pci_is_pcie(bridge)) {
645 if (pos) {
646 u32 linkcap; 645 u32 linkcap;
647 u16 linksta; 646 u16 linksta;
648 647
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index f8ca7becacca..7591fa4e28bb 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -766,49 +766,20 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
766 bfad->pcidev = pdev; 766 bfad->pcidev = pdev;
767 767
768 /* Adjust PCIe Maximum Read Request Size */ 768 /* Adjust PCIe Maximum Read Request Size */
769 if (pcie_max_read_reqsz > 0) { 769 if (pci_is_pcie(pdev) && pcie_max_read_reqsz) {
770 int pcie_cap_reg; 770 if (pcie_max_read_reqsz >= 128 &&
771 u16 pcie_dev_ctl; 771 pcie_max_read_reqsz <= 4096 &&
772 u16 mask = 0xffff; 772 is_power_of_2(pcie_max_read_reqsz)) {
773 773 int max_rq = pcie_get_readrq(pdev);
774 switch (pcie_max_read_reqsz) { 774 printk(KERN_WARNING "BFA[%s]: "
775 case 128:
776 mask = 0x0;
777 break;
778 case 256:
779 mask = 0x1000;
780 break;
781 case 512:
782 mask = 0x2000;
783 break;
784 case 1024:
785 mask = 0x3000;
786 break;
787 case 2048:
788 mask = 0x4000;
789 break;
790 case 4096:
791 mask = 0x5000;
792 break;
793 default:
794 break;
795 }
796
797 pcie_cap_reg = pci_find_capability(pdev, PCI_CAP_ID_EXP);
798 if (mask != 0xffff && pcie_cap_reg) {
799 pcie_cap_reg += 0x08;
800 pci_read_config_word(pdev, pcie_cap_reg, &pcie_dev_ctl);
801 if ((pcie_dev_ctl & 0x7000) != mask) {
802 printk(KERN_WARNING "BFA[%s]: "
803 "pcie_max_read_request_size is %d, " 775 "pcie_max_read_request_size is %d, "
804 "reset to %d\n", bfad->pci_name, 776 "reset to %d\n", bfad->pci_name, max_rq,
805 (1 << ((pcie_dev_ctl & 0x7000) >> 12)) << 7,
806 pcie_max_read_reqsz); 777 pcie_max_read_reqsz);
807 778 pcie_set_readrq(pdev, pcie_max_read_reqsz);
808 pcie_dev_ctl &= ~0x7000; 779 } else {
809 pci_write_config_word(pdev, pcie_cap_reg, 780 printk(KERN_WARNING "BFA[%s]: invalid "
810 pcie_dev_ctl | mask); 781 "pcie_max_read_request_size %d ignored\n",
811 } 782 bfad->pci_name, pcie_max_read_reqsz);
812 } 783 }
813 } 784 }
814 785
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index 0eb35b9b3784..0eaec4748957 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -852,22 +852,6 @@ csio_hw_get_flash_params(struct csio_hw *hw)
852 return 0; 852 return 0;
853} 853}
854 854
855static void
856csio_set_pcie_completion_timeout(struct csio_hw *hw, u8 range)
857{
858 uint16_t val;
859 int pcie_cap;
860
861 if (!csio_pci_capability(hw->pdev, PCI_CAP_ID_EXP, &pcie_cap)) {
862 pci_read_config_word(hw->pdev,
863 pcie_cap + PCI_EXP_DEVCTL2, &val);
864 val &= 0xfff0;
865 val |= range ;
866 pci_write_config_word(hw->pdev,
867 pcie_cap + PCI_EXP_DEVCTL2, val);
868 }
869}
870
871/*****************************************************************************/ 855/*****************************************************************************/
872/* HW State machine assists */ 856/* HW State machine assists */
873/*****************************************************************************/ 857/*****************************************************************************/
@@ -2069,8 +2053,10 @@ csio_hw_configure(struct csio_hw *hw)
2069 goto out; 2053 goto out;
2070 } 2054 }
2071 2055
2072 /* Set pci completion timeout value to 4 seconds. */ 2056 /* Set PCIe completion timeout to 4 seconds */
2073 csio_set_pcie_completion_timeout(hw, 0xd); 2057 if (pci_is_pcie(hw->pdev))
2058 pcie_capability_clear_and_set_word(hw->pdev, PCI_EXP_DEVCTL2,
2059 PCI_EXP_DEVCTL2_COMP_TIMEOUT, 0xd);
2074 2060
2075 hw->chip_ops->chip_set_mem_win(hw, MEMWIN_CSIOSTOR); 2061 hw->chip_ops->chip_set_mem_win(hw, MEMWIN_CSIOSTOR);
2076 2062
diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index 62ee7131b204..30d20e74e48a 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -507,7 +507,7 @@ qlafx00_pci_config(scsi_qla_host_t *vha)
507 pci_write_config_word(ha->pdev, PCI_COMMAND, w); 507 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
508 508
509 /* PCIe -- adjust Maximum Read Request Size (2048). */ 509 /* PCIe -- adjust Maximum Read Request Size (2048). */
510 if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP)) 510 if (pci_is_pcie(ha->pdev))
511 pcie_set_readrq(ha->pdev, 2048); 511 pcie_set_readrq(ha->pdev, 2048);
512 512
513 ha->chip_revision = ha->pdev->revision; 513 ha->chip_revision = ha->pdev->revision;
@@ -660,10 +660,8 @@ char *
660qlafx00_pci_info_str(struct scsi_qla_host *vha, char *str) 660qlafx00_pci_info_str(struct scsi_qla_host *vha, char *str)
661{ 661{
662 struct qla_hw_data *ha = vha->hw; 662 struct qla_hw_data *ha = vha->hw;
663 int pcie_reg;
664 663
665 pcie_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP); 664 if (pci_is_pcie(ha->pdev)) {
666 if (pcie_reg) {
667 strcpy(str, "PCIe iSA"); 665 strcpy(str, "PCIe iSA");
668 return str; 666 return str;
669 } 667 }
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index baa7852468ef..1a38377a0032 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -558,7 +558,8 @@
558#define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */ 558#define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */
559#define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */ 559#define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */
560#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */ 560#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
561#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */ 561#define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */
562#define PCI_EXP_DEVCTL2_ARI 0x0020 /* Alternative Routing-ID */
562#define PCI_EXP_DEVCTL2_IDO_REQ_EN 0x0100 /* Allow IDO for requests */ 563#define PCI_EXP_DEVCTL2_IDO_REQ_EN 0x0100 /* Allow IDO for requests */
563#define PCI_EXP_DEVCTL2_IDO_CMP_EN 0x0200 /* Allow IDO for completions */ 564#define PCI_EXP_DEVCTL2_IDO_CMP_EN 0x0200 /* Allow IDO for completions */
564#define PCI_EXP_DEVCTL2_LTR_EN 0x0400 /* Enable LTR mechanism */ 565#define PCI_EXP_DEVCTL2_LTR_EN 0x0400 /* Enable LTR mechanism */