]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI/MSI: Add pci_msi_map_rid_ctlr_node() helper function
authorLorenzo Pieralisi <lpieralisi@kernel.org>
Thu, 3 Jul 2025 10:25:15 +0000 (12:25 +0200)
committerMarc Zyngier <maz@kernel.org>
Tue, 8 Jul 2025 17:35:52 +0000 (18:35 +0100)
IRQchip drivers need a PCI/MSI function to map a RID to a MSI
controller deviceID namespace and at the same time retrieve the
struct device_node pointer of the MSI controller the RID is mapped
to.

Add pci_msi_map_rid_ctlr_node() to achieve this purpose.

Cc  Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20250703-gicv5-host-v7-25-12e71f1b3528@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
drivers/pci/msi/irqdomain.c
include/linux/msi.h

index c05152733993b8e3bc9551a10e2e31132e46b198..8a6e80d3963a47272bf87480f127002c7c784f63 100644 (file)
@@ -427,6 +427,26 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
        return rid;
 }
 
+/**
+ * pci_msi_map_rid_ctlr_node - Get the MSI controller node and MSI requester id (RID)
+ * @pdev:      The PCI device
+ * @node:      Pointer to store the MSI controller device node
+ *
+ * Use the firmware data to find the MSI controller node for @pdev.
+ * If found map the RID and initialize @node with it. @node value must
+ * be set to NULL on entry.
+ *
+ * Returns: The RID.
+ */
+u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node)
+{
+       u32 rid = pci_dev_id(pdev);
+
+       pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
+
+       return of_msi_xlate(&pdev->dev, node, rid);
+}
+
 /**
  * pci_msi_get_device_domain - Get the MSI domain for a given PCI device
  * @pdev:      The PCI device
index 6863540f4b71778fe505f65fb6eca5680d035c3b..a418e2695b0527ca1ab102a1abc1f22fa6f92fea 100644 (file)
@@ -705,6 +705,7 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,
                                             struct msi_domain_info *info,
                                             struct irq_domain *parent);
 u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev);
+u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node);
 struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev);
 #else /* CONFIG_PCI_MSI */
 static inline struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev)