aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Shan <shangw@linux.vnet.ibm.com>2013-04-04 12:54:32 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-04-23 11:50:30 -0400
commitf465136d7287538cabdcdbf8deb24f99a9f855e4 (patch)
tree42cf963af111d5cdbf25b0840a8b83ecb946cb22
parentcdf1fd4d906bc8c06510fd3e1d6a073441792792 (diff)
PCI: Use cached MSI cap while enabling MSI interrupts
The patch uses the cached MSI capability offset in pci_dev instead of reading it from config space when enabling MSI interrupts. [bhelgaas: removed unrelated msi_control_reg() changes] Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/msi.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 60a4b10fa99c..0138550dc806 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -546,14 +546,13 @@ out_unroll:
546static int msi_capability_init(struct pci_dev *dev, int nvec) 546static int msi_capability_init(struct pci_dev *dev, int nvec)
547{ 547{
548 struct msi_desc *entry; 548 struct msi_desc *entry;
549 int pos, ret; 549 int ret;
550 u16 control; 550 u16 control;
551 unsigned mask; 551 unsigned mask;
552 552
553 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
554 msi_set_enable(dev, 0); /* Disable MSI during set up */ 553 msi_set_enable(dev, 0); /* Disable MSI during set up */
555 554
556 pci_read_config_word(dev, msi_control_reg(pos), &control); 555 pci_read_config_word(dev, msi_control_reg(dev->msi_cap), &control);
557 /* MSI Entry Initialization */ 556 /* MSI Entry Initialization */
558 entry = alloc_msi_entry(dev); 557 entry = alloc_msi_entry(dev);
559 if (!entry) 558 if (!entry)
@@ -564,9 +563,9 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
564 entry->msi_attrib.entry_nr = 0; 563 entry->msi_attrib.entry_nr = 0;
565 entry->msi_attrib.maskbit = is_mask_bit_support(control); 564 entry->msi_attrib.maskbit = is_mask_bit_support(control);
566 entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ 565 entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */
567 entry->msi_attrib.pos = pos; 566 entry->msi_attrib.pos = dev->msi_cap;
568 567
569 entry->mask_pos = msi_mask_reg(pos, entry->msi_attrib.is_64); 568 entry->mask_pos = msi_mask_reg(dev->msi_cap, entry->msi_attrib.is_64);
570 /* All MSIs are unmasked by default, Mask them all */ 569 /* All MSIs are unmasked by default, Mask them all */
571 if (entry->msi_attrib.maskbit) 570 if (entry->msi_attrib.maskbit)
572 pci_read_config_dword(dev, entry->mask_pos, &entry->masked); 571 pci_read_config_dword(dev, entry->mask_pos, &entry->masked);
@@ -807,13 +806,13 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type)
807 */ 806 */
808int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec) 807int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
809{ 808{
810 int status, pos, maxvec; 809 int status, maxvec;
811 u16 msgctl; 810 u16 msgctl;
812 811
813 pos = pci_find_capability(dev, PCI_CAP_ID_MSI); 812 if (!dev->msi_cap)
814 if (!pos)
815 return -EINVAL; 813 return -EINVAL;
816 pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &msgctl); 814
815 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &msgctl);
817 maxvec = 1 << ((msgctl & PCI_MSI_FLAGS_QMASK) >> 1); 816 maxvec = 1 << ((msgctl & PCI_MSI_FLAGS_QMASK) >> 1);
818 if (nvec > maxvec) 817 if (nvec > maxvec)
819 return maxvec; 818 return maxvec;
@@ -838,14 +837,13 @@ EXPORT_SYMBOL(pci_enable_msi_block);
838 837
839int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec) 838int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec)
840{ 839{
841 int ret, pos, nvec; 840 int ret, nvec;
842 u16 msgctl; 841 u16 msgctl;
843 842
844 pos = pci_find_capability(dev, PCI_CAP_ID_MSI); 843 if (!dev->msi_cap)
845 if (!pos)
846 return -EINVAL; 844 return -EINVAL;
847 845
848 pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &msgctl); 846 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &msgctl);
849 ret = 1 << ((msgctl & PCI_MSI_FLAGS_QMASK) >> 1); 847 ret = 1 << ((msgctl & PCI_MSI_FLAGS_QMASK) >> 1);
850 848
851 if (maxvec) 849 if (maxvec)