MSI: arch must connect the irq and the msi_desc
set_irq_msi() currently connects an irq_desc to an msi_desc. The archs call
it at some point in their setup routine, and then the generic code sets up the
reverse mapping from the msi_desc back to the irq.
set_irq_msi() should do both connections, making it the one and only call
required to connect an irq with it's MSI desc and vice versa.
The arch code MUST call set_irq_msi(), and it must do so only once it's sure
it's not going to fail the irq allocation.
Given that there's no need for the arch to return the irq anymore, the return
value from the arch setup routine just becomes 0 for success and anything else
for failure.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 7a44ba4..88362f1 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -297,7 +297,7 @@
static int msi_capability_init(struct pci_dev *dev)
{
struct msi_desc *entry;
- int pos, irq;
+ int pos, ret;
u16 control;
msi_set_enable(dev, 0); /* Ensure msi is disabled as I set it up */
@@ -335,21 +335,19 @@
maskbits);
}
/* Configure MSI capability structure */
- irq = arch_setup_msi_irq(dev, entry);
- if (irq < 0) {
+ ret = arch_setup_msi_irq(dev, entry);
+ if (ret) {
kfree(entry);
- return irq;
+ return ret;
}
- entry->irq = irq;
list_add(&entry->list, &dev->msi_list);
- set_irq_msi(irq, entry);
/* Set MSI enabled bits */
pci_intx(dev, 0); /* disable intx */
msi_set_enable(dev, 1);
dev->msi_enabled = 1;
- dev->irq = irq;
+ dev->irq = entry->irq;
return 0;
}
@@ -367,7 +365,7 @@
struct msix_entry *entries, int nvec)
{
struct msi_desc *entry;
- int irq, pos, i, j, nr_entries;
+ int irq, pos, i, j, nr_entries, ret;
unsigned long phys_addr;
u32 table_offset;
u16 control;
@@ -407,16 +405,13 @@
entry->mask_base = base;
/* Configure MSI-X capability structure */
- irq = arch_setup_msi_irq(dev, entry);
- if (irq < 0) {
+ ret = arch_setup_msi_irq(dev, entry);
+ if (ret) {
kfree(entry);
break;
}
- entry->irq = irq;
- entries[i].vector = irq;
+ entries[i].vector = entry->irq;
list_add(&entry->list, &dev->msi_list);
-
- set_irq_msi(irq, entry);
}
if (i != nvec) {
int avail = i - 1;