linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: convert to generic irq_domain
@ 2011-12-17  5:18 Rob Herring
  2011-12-19 14:49 ` Sebastian Andrzej Siewior
  2012-01-15 16:35 ` Sebastian Andrzej Siewior
  0 siblings, 2 replies; 6+ messages in thread
From: Rob Herring @ 2011-12-17  5:18 UTC (permalink / raw)
  To: linux-kernel, devicetree-discuss
  Cc: Grant Likely, Rob Herring, x86, Thomas Gleixner,
	Sebastian Andrzej Siewior

From: Grant Likely <grant.likely@secretlab.ca>

This patch adds irq_domain infrastructure for translating from
hardware irq numbers to linux irqs.  This is particularly important
for architectures adding device tree support because the current
implementation (excluding PowerPC and SPARC) cannot handle
translation for more than a single interrupt controller.  irq_domain
supports device tree translation for any number of interrupt
controllers.

This is the x86 portion of irq_domain support originally posted by Grant
Likely with only a minor change removing irq_hw_number_t:

http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-July/006685.html

This is needed to avoid struct collisions with the generic irq_domain
support being added to kernel/irq/generic-chip.c.

Boot tested, but not on a DT enabled platform.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/x86/include/asm/irq_controller.h |   12 ----
 arch/x86/include/asm/prom.h           |   10 ---
 arch/x86/kernel/devicetree.c          |  101 +++++++++++----------------------
 3 files changed, 34 insertions(+), 89 deletions(-)
 delete mode 100644 arch/x86/include/asm/irq_controller.h

diff --git a/arch/x86/include/asm/irq_controller.h b/arch/x86/include/asm/irq_controller.h
deleted file mode 100644
index 423bbbd..0000000
--- a/arch/x86/include/asm/irq_controller.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __IRQ_CONTROLLER__
-#define __IRQ_CONTROLLER__
-
-struct irq_domain {
-	int (*xlate)(struct irq_domain *h, const u32 *intspec, u32 intsize,
-			u32 *out_hwirq, u32 *out_type);
-	void *priv;
-	struct device_node *controller;
-	struct list_head l;
-};
-
-#endif
diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index 644dd885..60bef66 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -21,7 +21,6 @@
 #include <asm/irq.h>
 #include <linux/atomic.h>
 #include <asm/setup.h>
-#include <asm/irq_controller.h>
 
 #ifdef CONFIG_OF
 extern int of_ioapic;
@@ -43,15 +42,6 @@ extern char cmd_line[COMMAND_LINE_SIZE];
 #define pci_address_to_pio pci_address_to_pio
 unsigned long pci_address_to_pio(phys_addr_t addr);
 
-/**
- * irq_dispose_mapping - Unmap an interrupt
- * @virq: linux virq number of the interrupt to unmap
- *
- * FIXME: We really should implement proper virq handling like power,
- * but that's going to be major surgery.
- */
-static inline void irq_dispose_mapping(unsigned int virq) { }
-
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
 #endif /* __ASSEMBLY__ */
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 5282179..5632e5b 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -17,64 +17,14 @@
 #include <linux/initrd.h>
 
 #include <asm/hpet.h>
-#include <asm/irq_controller.h>
 #include <asm/apic.h>
 #include <asm/pci_x86.h>
 
 __initdata u64 initial_dtb;
 char __initdata cmd_line[COMMAND_LINE_SIZE];
-static LIST_HEAD(irq_domains);
-static DEFINE_RAW_SPINLOCK(big_irq_lock);
 
 int __initdata of_ioapic;
 
-#ifdef CONFIG_X86_IO_APIC
-static void add_interrupt_host(struct irq_domain *ih)
-{
-	unsigned long flags;
-
-	raw_spin_lock_irqsave(&big_irq_lock, flags);
-	list_add(&ih->l, &irq_domains);
-	raw_spin_unlock_irqrestore(&big_irq_lock, flags);
-}
-#endif
-
-static struct irq_domain *get_ih_from_node(struct device_node *controller)
-{
-	struct irq_domain *ih, *found = NULL;
-	unsigned long flags;
-
-	raw_spin_lock_irqsave(&big_irq_lock, flags);
-	list_for_each_entry(ih, &irq_domains, l) {
-		if (ih->controller ==  controller) {
-			found = ih;
-			break;
-		}
-	}
-	raw_spin_unlock_irqrestore(&big_irq_lock, flags);
-	return found;
-}
-
-unsigned int irq_create_of_mapping(struct device_node *controller,
-				   const u32 *intspec, unsigned int intsize)
-{
-	struct irq_domain *ih;
-	u32 virq, type;
-	int ret;
-
-	ih = get_ih_from_node(controller);
-	if (!ih)
-		return 0;
-	ret = ih->xlate(ih, intspec, intsize, &virq, &type);
-	if (ret)
-		return 0;
-	if (type == IRQ_TYPE_NONE)
-		return virq;
-	irq_set_irq_type(virq, type);
-	return virq;
-}
-EXPORT_SYMBOL_GPL(irq_create_of_mapping);
-
 unsigned long pci_address_to_pio(phys_addr_t address)
 {
 	/*
@@ -354,36 +304,49 @@ static struct of_ioapic_type of_ioapic_type[] =
 	},
 };
 
-static int ioapic_xlate(struct irq_domain *id, const u32 *intspec, u32 intsize,
-			u32 *out_hwirq, u32 *out_type)
+static int ioapic_dt_translate(struct irq_domain *domain,
+				struct device_node *controller,
+				const u32 *intspec, u32 intsize,
+				unsigned long *out_hwirq, u32 *out_type)
 {
-	struct mp_ioapic_gsi *gsi_cfg;
 	struct io_apic_irq_attr attr;
 	struct of_ioapic_type *it;
 	u32 line, idx, type;
+	int rc;
 
-	if (intsize < 2)
+	if (controller != domain->of_node)
 		return -EINVAL;
 
-	line = *intspec;
-	idx = (u32) id->priv;
-	gsi_cfg = mp_ioapic_gsi_routing(idx);
-	*out_hwirq = line + gsi_cfg->gsi_base;
+	if (intsize < 2)
+		return -EINVAL;
 
-	intspec++;
-	type = *intspec;
+	line = intspec[0];
 
-	if (type >= ARRAY_SIZE(of_ioapic_type))
+	if (intspec[1] >= ARRAY_SIZE(of_ioapic_type))
 		return -EINVAL;
 
-	it = of_ioapic_type + type;
-	*out_type = it->out_type;
+	it = of_ioapic_type + intspec[1];
+	type = it->out_type;
 
+	idx = (u32) domain->priv;
 	set_io_apic_irq_attr(&attr, idx, line, it->trigger, it->polarity);
 
-	return io_apic_setup_irq_pin_once(*out_hwirq, cpu_to_node(0), &attr);
+	rc = io_apic_setup_irq_pin_once(irq_domain_to_irq(domain, line),
+					cpu_to_node(0), &attr);
+	if (rc)
+		return rc;
+
+	if (out_hwirq)
+		*out_hwirq = line;
+	if (out_type)
+		*out_type = type;
+	return 0;
 }
 
+const struct irq_domain_ops ioapic_irq_domain_ops = {
+	.dt_translate = ioapic_dt_translate,
+};
+
 static void __init ioapic_add_ofnode(struct device_node *np)
 {
 	struct resource r;
@@ -399,13 +362,17 @@ static void __init ioapic_add_ofnode(struct device_node *np)
 	for (i = 0; i < nr_ioapics; i++) {
 		if (r.start == mpc_ioapic_addr(i)) {
 			struct irq_domain *id;
+			struct mp_ioapic_gsi *gsi_cfg;
+
+			gsi_cfg = mp_ioapic_gsi_routing(i);
 
 			id = kzalloc(sizeof(*id), GFP_KERNEL);
 			BUG_ON(!id);
-			id->controller = np;
-			id->xlate = ioapic_xlate;
+			id->ops = &ioapic_irq_domain_ops;
+			id->irq_base = gsi_cfg->gsi_base;
+			id->of_node = np;
 			id->priv = (void *)i;
-			add_interrupt_host(id);
+			irq_domain_add(id);
 			return;
 		}
 	}
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: convert to generic irq_domain
  2011-12-17  5:18 [PATCH] x86: convert to generic irq_domain Rob Herring
@ 2011-12-19 14:49 ` Sebastian Andrzej Siewior
  2011-12-30 15:22   ` Rob Herring
  2012-01-15 16:35 ` Sebastian Andrzej Siewior
  1 sibling, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2011-12-19 14:49 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree-discuss, Grant Likely, Rob Herring, x86,
	Thomas Gleixner

* Rob Herring | 2011-12-16 23:18:49 [-0600]:

>This is needed to avoid struct collisions with the generic irq_domain
>support being added to kernel/irq/generic-chip.c.
>
>Boot tested, but not on a DT enabled platform.

I had a patch in my tree for this and it did not work. One bug was fixed
by eef24a ("irq: Fix check for already initialized irq_domain in
irq_domain_add"). Something else come up after that. I will grab a board
test it later and let you know :)

Sebastian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: convert to generic irq_domain
  2011-12-19 14:49 ` Sebastian Andrzej Siewior
@ 2011-12-30 15:22   ` Rob Herring
  2012-01-09  8:19     ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2011-12-30 15:22 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, devicetree-discuss, Grant Likely, Rob Herring, x86,
	Thomas Gleixner

Sebastian,

On 12/19/2011 08:49 AM, Sebastian Andrzej Siewior wrote:
> * Rob Herring | 2011-12-16 23:18:49 [-0600]:
> 
>> This is needed to avoid struct collisions with the generic irq_domain
>> support being added to kernel/irq/generic-chip.c.
>>
>> Boot tested, but not on a DT enabled platform.
> 
> I had a patch in my tree for this and it did not work. One bug was fixed
> by eef24a ("irq: Fix check for already initialized irq_domain in
> irq_domain_add"). Something else come up after that. I will grab a board
> test it later and let you know :)
> 

Any update on testing this?

Rob

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: convert to generic irq_domain
  2011-12-30 15:22   ` Rob Herring
@ 2012-01-09  8:19     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-01-09  8:19 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree-discuss, Grant Likely, Rob Herring, x86,
	Thomas Gleixner

* Rob Herring | 2011-12-30 09:22:40 [-0600]:

>Any update on testing this?

Just got back from vacation, will do this soon.

>
>Rob

Sebastian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: convert to generic irq_domain
  2011-12-17  5:18 [PATCH] x86: convert to generic irq_domain Rob Herring
  2011-12-19 14:49 ` Sebastian Andrzej Siewior
@ 2012-01-15 16:35 ` Sebastian Andrzej Siewior
  2012-01-16 16:16   ` Grant Likely
  1 sibling, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-01-15 16:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, devicetree-discuss, Grant Likely, Rob Herring, x86,
	Thomas Gleixner

* Rob Herring | 2011-12-16 23:18:49 [-0600]:

>From: Grant Likely <grant.likely@secretlab.ca>
>
>This is needed to avoid struct collisions with the generic irq_domain
>support being added to kernel/irq/generic-chip.c.
>
>Boot tested, but not on a DT enabled platform.

If you add this piece into your patch:

>From 34d9bb9b582136c8412e14ad870c8aaaa28c9e15 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sun, 15 Jan 2012 16:52:13 +0100
Subject: [PATCH] fixup of "x86: convert to generic irq_domain"

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/x86/Kconfig             |    1 +
 arch/x86/kernel/devicetree.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d6f1e91..0d74f88 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -397,6 +397,7 @@ config X86_INTEL_CE
 	select X86_REBOOTFIXUPS
 	select OF
 	select OF_EARLY_FLATTREE
+	select IRQ_DOMAIN
 	---help---
 	  Select for the Intel CE media processor (CE4100) SOC.
 	  This option compiles in support for the CE4100 SOC for settop
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 5632e5b..41eb2a7 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -4,6 +4,7 @@
 #include <linux/bootmem.h>
 #include <linux/export.h>
 #include <linux/io.h>
+#include <linux/irqdomain.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/of.h>
-- 

you add my acked-by to it.

Sebastian

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: convert to generic irq_domain
  2012-01-15 16:35 ` Sebastian Andrzej Siewior
@ 2012-01-16 16:16   ` Grant Likely
  0 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2012-01-16 16:16 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Rob Herring, linux-kernel, devicetree-discuss, Rob Herring, x86,
	Thomas Gleixner

On Sun, Jan 15, 2012 at 05:35:38PM +0100, Sebastian Andrzej Siewior wrote:
> * Rob Herring | 2011-12-16 23:18:49 [-0600]:
> 
> >From: Grant Likely <grant.likely@secretlab.ca>
> >
> >This is needed to avoid struct collisions with the generic irq_domain
> >support being added to kernel/irq/generic-chip.c.
> >
> >Boot tested, but not on a DT enabled platform.
> 
> If you add this piece into your patch:
> 
> From 34d9bb9b582136c8412e14ad870c8aaaa28c9e15 Mon Sep 17 00:00:00 2001
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Date: Sun, 15 Jan 2012 16:52:13 +0100
> Subject: [PATCH] fixup of "x86: convert to generic irq_domain"
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

It's a little late for 3.3, and I've got a major rework to irq_domain
almost ready which will get merged in 3.4.  I'll rework the patch on
top of that series and get you to retest.

g.

> ---
>  arch/x86/Kconfig             |    1 +
>  arch/x86/kernel/devicetree.c |    1 +
>  2 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index d6f1e91..0d74f88 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -397,6 +397,7 @@ config X86_INTEL_CE
>  	select X86_REBOOTFIXUPS
>  	select OF
>  	select OF_EARLY_FLATTREE
> +	select IRQ_DOMAIN
>  	---help---
>  	  Select for the Intel CE media processor (CE4100) SOC.
>  	  This option compiles in support for the CE4100 SOC for settop
> diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
> index 5632e5b..41eb2a7 100644
> --- a/arch/x86/kernel/devicetree.c
> +++ b/arch/x86/kernel/devicetree.c
> @@ -4,6 +4,7 @@
>  #include <linux/bootmem.h>
>  #include <linux/export.h>
>  #include <linux/io.h>
> +#include <linux/irqdomain.h>
>  #include <linux/interrupt.h>
>  #include <linux/list.h>
>  #include <linux/of.h>
> -- 
> 
> you add my acked-by to it.
> 
> Sebastian

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-16 16:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-17  5:18 [PATCH] x86: convert to generic irq_domain Rob Herring
2011-12-19 14:49 ` Sebastian Andrzej Siewior
2011-12-30 15:22   ` Rob Herring
2012-01-09  8:19     ` Sebastian Andrzej Siewior
2012-01-15 16:35 ` Sebastian Andrzej Siewior
2012-01-16 16:16   ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).