diff options
author | David Daney <david.daney@cavium.com> | 2015-10-08 15:10:49 -0700 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2015-10-16 13:07:12 +0100 |
commit | b6eec9b717d4dcb39ef024b8a3b619a32468b01e (patch) | |
tree | 938c3d37100f02ef76c4d197abc5cc662d3fa923 /drivers/pci | |
parent | 8db02d8b4089fa8098a170738e8ae7939aa8ae7a (diff) | |
download | op-kernel-dev-b6eec9b717d4dcb39ef024b8a3b619a32468b01e.zip op-kernel-dev-b6eec9b717d4dcb39ef024b8a3b619a32468b01e.tar.gz |
PCI/MSI: Add helper function pci_msi_domain_get_msi_rid().
Add pci_msi_domain_get_msi_rid() to return the MSI requester id (RID).
Initially needed by gic-v3 based systems. It will be used by follow on
patch to drivers/irqchip/irq-gic-v3-its-pci-msi.c
Initially supports mapping the RID via OF device tree. In the future,
this could be extended to use ACPI _IORT tables as well.
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/msi.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index ddd59fe..5ab5c4f 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -20,6 +20,7 @@ #include <linux/io.h> #include <linux/slab.h> #include <linux/irqdomain.h> +#include <linux/of_irq.h> #include "pci.h" @@ -1327,4 +1328,35 @@ struct irq_domain *pci_msi_create_default_irq_domain(struct fwnode_handle *fwnod return domain; } + +static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) +{ + u32 *pa = data; + + *pa = alias; + return 0; +} +/** + * pci_msi_domain_get_msi_rid - Get the MSI requester id (RID) + * @domain: The interrupt domain + * @pdev: The PCI device. + * + * The RID for a device is formed from the alias, with a firmware + * supplied mapping applied + * + * Returns: The RID. + */ +u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) +{ + struct device_node *of_node; + u32 rid = 0; + + pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); + + of_node = irq_domain_get_of_node(domain); + if (of_node) + rid = of_msi_map_rid(&pdev->dev, of_node, rid); + + return rid; +} #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */ |