aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/msi.c
diff options
context:
space:
mode:
authorYijing Wang <wangyijing@huawei.com>2014-06-19 04:30:30 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-07-03 18:55:07 -0400
commit31ea5d4dfe21fb50276dcd70ce268e58d57eccb4 (patch)
treee8831d2a1ea82d5b70f19044ade5f56746d92580 /drivers/pci/msi.c
parent199596ef9184ab2bc0eb43d1af9e0b723ce07840 (diff)
PCI/MSI: Cache Multiple Message Capable in struct msi_desc
The Multiple Message Capable field in the MSI Message Control register indicates how many vectors the device supports. This field is read-only, so cache it in msi_desc to avoid reading it repeatedly. Since we cache the extracted field (not the entire Message Control register), we can use msi_mask() instead of msi_capable_mask(), which is then unused, so remove it. [bhelgaas: fix whitespace, changelog] Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r--drivers/pci/msi.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 9c6995043fff..50a7e4e96da7 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -167,11 +167,6 @@ static inline __attribute_const__ u32 msi_mask(unsigned x)
167 return (1 << (1 << x)) - 1; 167 return (1 << (1 << x)) - 1;
168} 168}
169 169
170static inline __attribute_const__ u32 msi_capable_mask(u16 control)
171{
172 return msi_mask((control >> 1) & 7);
173}
174
175/* 170/*
176 * PCI 2.3 does not specify mask bits for each MSI interrupt. Attempting to 171 * PCI 2.3 does not specify mask bits for each MSI interrupt. Attempting to
177 * mask all MSI interrupts by clearing the MSI enable bit does not work 172 * mask all MSI interrupts by clearing the MSI enable bit does not work
@@ -454,7 +449,8 @@ static void __pci_restore_msi_state(struct pci_dev *dev)
454 arch_restore_msi_irqs(dev); 449 arch_restore_msi_irqs(dev);
455 450
456 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control); 451 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
457 msi_mask_irq(entry, msi_capable_mask(control), entry->masked); 452 msi_mask_irq(entry, msi_mask(entry->msi_attrib.multi_cap),
453 entry->masked);
458 control &= ~PCI_MSI_FLAGS_QSIZE; 454 control &= ~PCI_MSI_FLAGS_QSIZE;
459 control |= (entry->msi_attrib.multiple << 4) | PCI_MSI_FLAGS_ENABLE; 455 control |= (entry->msi_attrib.multiple << 4) | PCI_MSI_FLAGS_ENABLE;
460 pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control); 456 pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
@@ -617,6 +613,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
617 entry->msi_attrib.maskbit = !!(control & PCI_MSI_FLAGS_MASKBIT); 613 entry->msi_attrib.maskbit = !!(control & PCI_MSI_FLAGS_MASKBIT);
618 entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ 614 entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */
619 entry->msi_attrib.pos = dev->msi_cap; 615 entry->msi_attrib.pos = dev->msi_cap;
616 entry->msi_attrib.multi_cap = (control & PCI_MSI_FLAGS_QMASK) >> 1;
620 617
621 if (control & PCI_MSI_FLAGS_64BIT) 618 if (control & PCI_MSI_FLAGS_64BIT)
622 entry->mask_pos = dev->msi_cap + PCI_MSI_MASK_64; 619 entry->mask_pos = dev->msi_cap + PCI_MSI_MASK_64;
@@ -625,7 +622,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
625 /* All MSIs are unmasked by default, Mask them all */ 622 /* All MSIs are unmasked by default, Mask them all */
626 if (entry->msi_attrib.maskbit) 623 if (entry->msi_attrib.maskbit)
627 pci_read_config_dword(dev, entry->mask_pos, &entry->masked); 624 pci_read_config_dword(dev, entry->mask_pos, &entry->masked);
628 mask = msi_capable_mask(control); 625 mask = msi_mask(entry->msi_attrib.multi_cap);
629 msi_mask_irq(entry, mask, mask); 626 msi_mask_irq(entry, mask, mask);
630 627
631 list_add_tail(&entry->list, &dev->msi_list); 628 list_add_tail(&entry->list, &dev->msi_list);
@@ -870,7 +867,6 @@ void pci_msi_shutdown(struct pci_dev *dev)
870{ 867{
871 struct msi_desc *desc; 868 struct msi_desc *desc;
872 u32 mask; 869 u32 mask;
873 u16 ctrl;
874 870
875 if (!pci_msi_enable || !dev || !dev->msi_enabled) 871 if (!pci_msi_enable || !dev || !dev->msi_enabled)
876 return; 872 return;
@@ -883,8 +879,7 @@ void pci_msi_shutdown(struct pci_dev *dev)
883 dev->msi_enabled = 0; 879 dev->msi_enabled = 0;
884 880
885 /* Return the device with MSI unmasked as initial states */ 881 /* Return the device with MSI unmasked as initial states */
886 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &ctrl); 882 mask = msi_mask(desc->msi_attrib.multi_cap);
887 mask = msi_capable_mask(ctrl);
888 /* Keep cached state to be restored */ 883 /* Keep cached state to be restored */
889 arch_msi_mask_irq(desc, mask, ~mask); 884 arch_msi_mask_irq(desc, mask, ~mask);
890 885