Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI/MSI: Allow an msi_controller to be associated to an irq domain

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_controller 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@arm.com>
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Link: http://lkml.kernel.org/r/1416048553-29289-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Marc Zyngier and committed by
Thomas Gleixner
020c3126 8e047ada

+17 -2
+14 -2
drivers/pci/msi.c
··· 37 37 return pci_msi_default_domain; 38 38 } 39 39 40 + static struct irq_domain *pci_msi_get_domain(struct pci_dev *dev) 41 + { 42 + struct irq_domain *domain = NULL; 43 + 44 + if (dev->bus->msi) 45 + domain = dev->bus->msi->domain; 46 + if (!domain) 47 + domain = arch_get_pci_msi_domain(dev); 48 + 49 + return domain; 50 + } 51 + 40 52 static int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) 41 53 { 42 54 struct irq_domain *domain; 43 55 44 - domain = arch_get_pci_msi_domain(dev); 56 + domain = pci_msi_get_domain(dev); 45 57 if (domain) 46 58 return pci_msi_domain_alloc_irqs(domain, dev, nvec, type); 47 59 ··· 64 52 { 65 53 struct irq_domain *domain; 66 54 67 - domain = arch_get_pci_msi_domain(dev); 55 + domain = pci_msi_get_domain(dev); 68 56 if (domain) 69 57 pci_msi_domain_free_irqs(domain, dev); 70 58 else
+3
include/linux/msi.h
··· 108 108 struct device *dev; 109 109 struct device_node *of_node; 110 110 struct list_head list; 111 + #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN 112 + struct irq_domain *domain; 113 + #endif 111 114 112 115 int (*setup_irq)(struct msi_controller *chip, struct pci_dev *dev, 113 116 struct msi_desc *desc);