Skip to content

Commit cd0ec59

Browse files
Lorenzo PieralisiMarc Zyngier
authored andcommitted
PCI/MSI: Add pci_msi_map_rid_ctlr_node() helper function
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 <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 31fd3be commit cd0ec59

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

drivers/pci/msi/irqdomain.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,26 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
427427
return rid;
428428
}
429429

430+
/**
431+
* pci_msi_map_rid_ctlr_node - Get the MSI controller node and MSI requester id (RID)
432+
* @pdev: The PCI device
433+
* @node: Pointer to store the MSI controller device node
434+
*
435+
* Use the firmware data to find the MSI controller node for @pdev.
436+
* If found map the RID and initialize @node with it. @node value must
437+
* be set to NULL on entry.
438+
*
439+
* Returns: The RID.
440+
*/
441+
u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node)
442+
{
443+
u32 rid = pci_dev_id(pdev);
444+
445+
pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
446+
447+
return of_msi_xlate(&pdev->dev, node, rid);
448+
}
449+
430450
/**
431451
* pci_msi_get_device_domain - Get the MSI domain for a given PCI device
432452
* @pdev: The PCI device

include/linux/msi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,
705705
struct msi_domain_info *info,
706706
struct irq_domain *parent);
707707
u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev);
708+
u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node);
708709
struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev);
709710
#else /* CONFIG_PCI_MSI */
710711
static inline struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev)

0 commit comments

Comments
 (0)