aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/msi.c42
-rw-r--r--include/linux/pci.h2
2 files changed, 21 insertions, 23 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 00cc78c7aa04..99befbd99938 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -111,32 +111,26 @@ void default_restore_msi_irqs(struct pci_dev *dev, int irq)
111} 111}
112#endif 112#endif
113 113
114static void msi_set_enable(struct pci_dev *dev, int pos, int enable) 114static void msi_set_enable(struct pci_dev *dev, int enable)
115{ 115{
116 u16 control; 116 u16 control;
117 117
118 BUG_ON(!pos); 118 pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
119
120 pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control);
121 control &= ~PCI_MSI_FLAGS_ENABLE; 119 control &= ~PCI_MSI_FLAGS_ENABLE;
122 if (enable) 120 if (enable)
123 control |= PCI_MSI_FLAGS_ENABLE; 121 control |= PCI_MSI_FLAGS_ENABLE;
124 pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); 122 pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
125} 123}
126 124
127static void msix_set_enable(struct pci_dev *dev, int enable) 125static void msix_set_enable(struct pci_dev *dev, int enable)
128{ 126{
129 int pos;
130 u16 control; 127 u16 control;
131 128
132 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); 129 pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &control);
133 if (pos) { 130 control &= ~PCI_MSIX_FLAGS_ENABLE;
134 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control); 131 if (enable)
135 control &= ~PCI_MSIX_FLAGS_ENABLE; 132 control |= PCI_MSIX_FLAGS_ENABLE;
136 if (enable) 133 pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, control);
137 control |= PCI_MSIX_FLAGS_ENABLE;
138 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
139 }
140} 134}
141 135
142static inline __attribute_const__ u32 msi_mask(unsigned x) 136static inline __attribute_const__ u32 msi_mask(unsigned x)
@@ -402,7 +396,7 @@ static void __pci_restore_msi_state(struct pci_dev *dev)
402 pos = entry->msi_attrib.pos; 396 pos = entry->msi_attrib.pos;
403 397
404 pci_intx_for_msi(dev, 0); 398 pci_intx_for_msi(dev, 0);
405 msi_set_enable(dev, pos, 0); 399 msi_set_enable(dev, 0);
406 arch_restore_msi_irqs(dev, dev->irq); 400 arch_restore_msi_irqs(dev, dev->irq);
407 401
408 pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); 402 pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control);
@@ -557,7 +551,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
557 unsigned mask; 551 unsigned mask;
558 552
559 pos = pci_find_capability(dev, PCI_CAP_ID_MSI); 553 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
560 msi_set_enable(dev, pos, 0); /* Disable MSI during set up */ 554 msi_set_enable(dev, 0); /* Disable MSI during set up */
561 555
562 pci_read_config_word(dev, msi_control_reg(pos), &control); 556 pci_read_config_word(dev, msi_control_reg(pos), &control);
563 /* MSI Entry Initialization */ 557 /* MSI Entry Initialization */
@@ -598,7 +592,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
598 592
599 /* Set MSI enabled bits */ 593 /* Set MSI enabled bits */
600 pci_intx_for_msi(dev, 0); 594 pci_intx_for_msi(dev, 0);
601 msi_set_enable(dev, pos, 1); 595 msi_set_enable(dev, 1);
602 dev->msi_enabled = 1; 596 dev->msi_enabled = 1;
603 597
604 dev->irq = entry->irq; 598 dev->irq = entry->irq;
@@ -885,7 +879,7 @@ void pci_msi_shutdown(struct pci_dev *dev)
885 desc = list_first_entry(&dev->msi_list, struct msi_desc, list); 879 desc = list_first_entry(&dev->msi_list, struct msi_desc, list);
886 pos = desc->msi_attrib.pos; 880 pos = desc->msi_attrib.pos;
887 881
888 msi_set_enable(dev, pos, 0); 882 msi_set_enable(dev, 0);
889 pci_intx_for_msi(dev, 1); 883 pci_intx_for_msi(dev, 1);
890 dev->msi_enabled = 0; 884 dev->msi_enabled = 0;
891 885
@@ -1048,15 +1042,17 @@ EXPORT_SYMBOL(pci_msi_enabled);
1048 1042
1049void pci_msi_init_pci_dev(struct pci_dev *dev) 1043void pci_msi_init_pci_dev(struct pci_dev *dev)
1050{ 1044{
1051 int pos;
1052 INIT_LIST_HEAD(&dev->msi_list); 1045 INIT_LIST_HEAD(&dev->msi_list);
1053 1046
1054 /* Disable the msi hardware to avoid screaming interrupts 1047 /* Disable the msi hardware to avoid screaming interrupts
1055 * during boot. This is the power on reset default so 1048 * during boot. This is the power on reset default so
1056 * usually this should be a noop. 1049 * usually this should be a noop.
1057 */ 1050 */
1058 pos = pci_find_capability(dev, PCI_CAP_ID_MSI); 1051 dev->msi_cap = pci_find_capability(dev, PCI_CAP_ID_MSI);
1059 if (pos) 1052 if (dev->msi_cap)
1060 msi_set_enable(dev, pos, 0); 1053 msi_set_enable(dev, 0);
1061 msix_set_enable(dev, 0); 1054
1055 dev->msix_cap = pci_find_capability(dev, PCI_CAP_ID_MSIX);
1056 if (dev->msix_cap)
1057 msix_set_enable(dev, 0);
1062} 1058}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9587d4d19279..b73c2460ad57 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -232,6 +232,8 @@ struct pci_dev {
232 u8 revision; /* PCI revision, low byte of class word */ 232 u8 revision; /* PCI revision, low byte of class word */
233 u8 hdr_type; /* PCI header type (`multi' flag masked out) */ 233 u8 hdr_type; /* PCI header type (`multi' flag masked out) */
234 u8 pcie_cap; /* PCI-E capability offset */ 234 u8 pcie_cap; /* PCI-E capability offset */
235 u8 msi_cap; /* MSI capability offset */
236 u8 msix_cap; /* MSI-X capability offset */
235 u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */ 237 u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */
236 u8 rom_base_reg; /* which config register controls the ROM */ 238 u8 rom_base_reg; /* which config register controls the ROM */
237 u8 pin; /* which interrupt pin this device uses */ 239 u8 pin; /* which interrupt pin this device uses */