Skip to content

Commit 31fd3be

Browse files
Lorenzo PieralisiMarc Zyngier
authored andcommitted
of/irq: Add of_msi_xlate() helper function
Add an of_msi_xlate() helper that maps a device ID and returns the device node of the MSI controller the device ID is mapped to. Required by core functions that need an MSI controller device node pointer at the same time as a mapped device ID, of_msi_map_id() is not sufficient for that purpose. Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Cc: Rob Herring <[email protected]> Cc: Marc Zyngier <[email protected]> Reviewed-by: Rob Herring (Arm) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 03a28dc commit 31fd3be

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

drivers/of/irq.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,20 @@ void __init of_irq_init(const struct of_device_id *matches)
670670
}
671671
}
672672

673-
static u32 __of_msi_map_id(struct device *dev, struct device_node **np,
674-
u32 id_in)
673+
/**
674+
* of_msi_xlate - map a MSI ID and find relevant MSI controller node
675+
* @dev: device for which the mapping is to be done.
676+
* @msi_np: Pointer to store the MSI controller node
677+
* @id_in: Device ID.
678+
*
679+
* Walk up the device hierarchy looking for devices with a "msi-map"
680+
* property. If found, apply the mapping to @id_in. @msi_np pointed
681+
* value must be NULL on entry, if an MSI controller is found @msi_np is
682+
* initialized to the MSI controller node with a reference held.
683+
*
684+
* Returns: The mapped MSI id.
685+
*/
686+
u32 of_msi_xlate(struct device *dev, struct device_node **msi_np, u32 id_in)
675687
{
676688
struct device *parent_dev;
677689
u32 id_out = id_in;
@@ -682,7 +694,7 @@ static u32 __of_msi_map_id(struct device *dev, struct device_node **np,
682694
*/
683695
for (parent_dev = dev; parent_dev; parent_dev = parent_dev->parent)
684696
if (!of_map_id(parent_dev->of_node, id_in, "msi-map",
685-
"msi-map-mask", np, &id_out))
697+
"msi-map-mask", msi_np, &id_out))
686698
break;
687699
return id_out;
688700
}
@@ -700,7 +712,7 @@ static u32 __of_msi_map_id(struct device *dev, struct device_node **np,
700712
*/
701713
u32 of_msi_map_id(struct device *dev, struct device_node *msi_np, u32 id_in)
702714
{
703-
return __of_msi_map_id(dev, &msi_np, id_in);
715+
return of_msi_xlate(dev, &msi_np, id_in);
704716
}
705717

706718
/**
@@ -719,7 +731,7 @@ struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 id,
719731
{
720732
struct device_node *np = NULL;
721733

722-
__of_msi_map_id(dev, &np, id);
734+
of_msi_xlate(dev, &np, id);
723735
return irq_find_matching_host(np, bus_token);
724736
}
725737

include/linux/of_irq.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
5454
u32 id,
5555
u32 bus_token);
5656
extern void of_msi_configure(struct device *dev, const struct device_node *np);
57+
extern u32 of_msi_xlate(struct device *dev, struct device_node **msi_np, u32 id_in);
5758
u32 of_msi_map_id(struct device *dev, struct device_node *msi_np, u32 id_in);
5859
#else
5960
static inline void of_irq_init(const struct of_device_id *matches)
@@ -100,6 +101,10 @@ static inline struct irq_domain *of_msi_map_get_device_domain(struct device *dev
100101
static inline void of_msi_configure(struct device *dev, struct device_node *np)
101102
{
102103
}
104+
static inline u32 of_msi_xlate(struct device *dev, struct device_node **msi_np, u32 id_in)
105+
{
106+
return id_in;
107+
}
103108
static inline u32 of_msi_map_id(struct device *dev,
104109
struct device_node *msi_np, u32 id_in)
105110
{

0 commit comments

Comments
 (0)