[PATCH] PCI/MSI: Allow an msi_chip to be associated to an irq domain

From: Marc Zyngier
Date: Wed Nov 12 2014 - 05:32:46 EST


With the new stacked irq domains, it becomes pretty tempting
to allocate an MSI domain per PCI bus, which would remove
the requirement of either relying on arch-specific code, or
a default PCI MSI domain.

By allowing the msi_chip structure to carry a pointer to
an irq_domain, we can easily use this in pci_msi_setup_msi_irqs.
The existing code can still be used as a fallback if the MSI driver
does not populate the domain field.

Tested on arm64 with the GICv3 ITS driver.

Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
---
drivers/pci/msi.c | 9 +++++++--
include/linux/msi.h | 3 +++
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 9947fb4..1752537 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -86,9 +86,14 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)

static int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
- struct irq_domain *domain;
+ struct irq_domain *domain = NULL;

- domain = arch_get_pci_msi_domain(dev);
+#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
+ if (dev->bus->msi)
+ domain = dev->bus->msi->domain;
+#endif
+ if (!domain)
+ domain = arch_get_pci_msi_domain(dev);
if (domain)
return pci_msi_domain_alloc_irqs(domain, type, dev);

diff --git a/include/linux/msi.h b/include/linux/msi.h
index 9b2e73e..2325950 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -89,6 +89,9 @@ struct msi_chip {
struct device *dev;
struct device_node *of_node;
struct list_head list;
+#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
+ struct irq_domain *domain;
+#endif

int (*setup_irq)(struct msi_chip *chip, struct pci_dev *dev,
struct msi_desc *desc);
--
2.0.4

Thoughts?

Thanks,

M.
--
Jazz is not dead. It just smells funny...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/