Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f16fc87 authored by Nishanth Menon's avatar Nishanth Menon Committed by Jason Cooper
Browse files

irqchip: crossbar: Check for premapped crossbar before allocating



If irq_of_parse_and_map is executed twice, the same crossbar is mapped to two
different GIC interrupts. This is completely undesirable. Instead, check
if the requested crossbar event is pre-allocated and provide that GIC
mapping back to caller if already allocated.

Signed-off-by: default avatarNishanth Menon <nm@ti.com>
Signed-off-by: default avatarSricharan R <r.sricharan@ti.com>
Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
Link: https://lkml.kernel.org/r/1403766634-18543-3-git-send-email-r.sricharan@ti.com


Signed-off-by: default avatarJason Cooper <jason@lakedaemon.net>
parent 1d50d2ce
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -51,6 +51,17 @@ static inline void crossbar_writeb(int irq_no, int cb_no)
	writeb(cb_no, cb->crossbar_base + cb->register_offsets[irq_no]);
	writeb(cb_no, cb->crossbar_base + cb->register_offsets[irq_no]);
}
}


static inline int get_prev_map_irq(int cb_no)
{
	int i;

	for (i = 0; i < cb->int_max; i++)
		if (cb->irq_map[i] == cb_no)
			return i;

	return -ENODEV;
}

static inline int allocate_free_irq(int cb_no)
static inline int allocate_free_irq(int cb_no)
{
{
	int i;
	int i;
@@ -88,11 +99,16 @@ static int crossbar_domain_xlate(struct irq_domain *d,
{
{
	unsigned long ret;
	unsigned long ret;


	ret = get_prev_map_irq(intspec[1]);
	if (!IS_ERR_VALUE(ret))
		goto found;

	ret = allocate_free_irq(intspec[1]);
	ret = allocate_free_irq(intspec[1]);


	if (IS_ERR_VALUE(ret))
	if (IS_ERR_VALUE(ret))
		return ret;
		return ret;


found:
	*out_hwirq = ret + GIC_IRQ_START;
	*out_hwirq = ret + GIC_IRQ_START;
	return 0;
	return 0;
}
}