Re: [RFC 12/14] irq_domain: Add support for base irq and hwirq in legacy mappings

From
Rob Herring <hidden>
Date
2012-01-13 00:37:31
Also in
lkml
Reply to
Grant Likely, 2012-01-11
On 01/11/2012 02:22 PM, Grant Likely wrote:
Add support for a legacy mapping where irq = (hwirq - first_hwirq + first_irq)
so that a controller driver can allocate a fixed range of irq_descs and use
a simple calculation to translate back and forth between linux and hw irq
numbers.  This is needed to use an irq_domain with many of the ARM interrupt
controller drivers that manage their own irq_desc allocations.  Ultimately
the goal is to migrate those drivers to use the linear revmap, but doing it
this way allows each driver to be converted separately which makes the
migration path easier.

This patch generalizes the IRQ_DOMAIN_MAP_LEGACY method to use
(first_irq-first_hwirq) as the offset between hwirq and linux irq number,
and adds checks to make sure that the hwirq number does not exceed range
assigned to the controller.

Signed-off-by: Grant Likely <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/include/asm/irq.h   |    3 -
 arch/powerpc/sysdev/i8259.c      |    2 +-
 arch/powerpc/sysdev/tsi108_pci.c |    2 +-
 include/linux/irqdomain.h        |   20 +++++++++-
 kernel/irq/irqdomain.c           |   78 +++++++++++++++++++++++++-------------
 5 files changed, 73 insertions(+), 32 deletions(-)
snip...
quoted hunk ↗ jump to hunk
@@ -454,8 +477,11 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
 		return 0;
 
 	/* legacy -> bail early */
-	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY)
-		return hwirq;
+	if (domain->revmap_type == IRQ_DOMAIN_MAP_LEGACY) {
+		if (hwirq > domain->revmap_data.legacy.size)
+			return 0;
+		return domain->revmap_data.legacy.first_irq + hwirq;
This needs a "- domain->revmap_data.legacy.first_hwirq"

Rob
quoted hunk ↗ jump to hunk
+	}
 
 	/* Slow path does a linear search of the map */
 	if (hint < NUM_ISA_INTERRUPTS)
Thread (36 messages) 36 messages, 6 authors, last reply 2013-08-23
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help