Skip to contentSkip to conversation

Marvell EBU irqchip improvements

PATCH New Thomas Petazzoni 3 participants 13 messages Apr 9, 2013 – May 13, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Marvell EBU irqchip improvements

Hello,

Here is a set of 5 patches that move the Marvell EBU IRQ controller driver to drivers/irqchip/ and do a few minor related cleanup or improvements.

Those commits were originally part of the series introducing PCIe MSI support for Marvell EBU platform, but the MSI support is not ready for merging. However, I'd like those preparation patches to be considered for 3.10.

Thanks,

Thomas

Thomas Petazzoni (5):
ARM: mvebu: move L2 cache initialization in init_early()
irqchip: move IRQ driver for Armada 370/XP
irqchip: armada-370-xp: move IRQ handler to avoid forward declaration
irqchip: armada-370-xp: slightly cleanup irq controller driver
ARM: mvebu: do not duplicate the mpic alias

 arch/arm/boot/dts/armada-370.dtsi                  |    2 +-
 arch/arm/boot/dts/armada-xp.dtsi                   |    2 +-
 arch/arm/mach-mvebu/Makefile                       |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |    9 +-
 drivers/irqchip/Makefile                           |    1 +
 .../irqchip}/irq-armada-370-xp.c                   |  106 ++++++++++----------
 6 files changed, 62 insertions(+), 60 deletions(-)
 rename {arch/arm/mach-mvebu => drivers/irqchip}/irq-armada-370-xp.c (91%)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/5 ARM: mvebu: move L2 cache initialization in init_early()

In preparation for moving the IRQ controller driver to drivers/irqchip/, we don't want the IRQ controller driver to be responsible for initializing the L2 cache. Instead, let's initialize the L2 cache at the init_early() level, like mach-exynos/common.c is doing.

---
 arch/arm/mach-mvebu/armada-370-xp.c     |    5 +++++
 arch/arm/mach-mvebu/irq-armada-370-xp.c |    4 ----
 2 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-mvebu/armada-370-xp.c +5 -0
index a5ea616d..c1bbfa7 100644
@@ -19,6 +19,7 @@
 #include <linux/time-armada-370-xp.h>
 #include <linux/clk/mvebu.h>
 #include <linux/dma-mapping.h>
+#include <asm/hardware/cache-l2x0.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
@@ -54,6 +55,10 @@ void __init armada_370_xp_init_early(void)
 	 * to make sure such the allocations won't fail.
 	 */
 	init_dma_coherent_pool_size(SZ_1M);
+
+#ifdef CONFIG_CACHE_L2X0
+	l2x0_of_init(0, ~0UL);
+#endif
 }
 
 static void __init armada_370_xp_dt_init(void)
arch/arm/mach-mvebu/irq-armada-370-xp.c +0 -4
index 6a9195e..f6699f3 100644
@@ -25,7 +25,6 @@
 #include <asm/mach/arch.h>
 #include <asm/exception.h>
 #include <asm/smp_plat.h>
-#include <asm/hardware/cache-l2x0.h>
 
 /* Interrupt Controller Registers Map */
 #define ARMADA_370_XP_INT_SET_MASK_OFFS		(0x48)
@@ -292,7 +291,4 @@ static const struct of_device_id mpic_of_match[] __initconst = {
 void __init armada_370_xp_init_irq(void)
 {
 	of_irq_init(mpic_of_match);
-#ifdef CONFIG_CACHE_L2X0
-	l2x0_of_init(0, ~0UL);
-#endif
 }
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/5 irqchip: move IRQ driver for Armada 370/XP

In reply to Thomas Petazzoni

When the Marvell Armada 370/XP support was included in the kernel, the drivers/irqchip/ directory didn't exist and the minimal infrastructure in it also didn't exist. Now that we have those things in place, we move the Armada 370/XP IRQ controller driver from arch/arm/mach-mvebu/irq-armada-370-xp.c to drivers/irqchip/irq-armada-370-xp.c.

Note in order to reduce code movement and therefore ease the review of this patch, we intentionally introduce a forward declaration of armada_370_xp_handle_irq(). It is in fact not needed because this handler can now simply be implemented before armada_370_xp_mpic_of_init(). That will be done in the next commit.

---
 arch/arm/mach-mvebu/Makefile                       |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |    4 ++--
 drivers/irqchip/Makefile                           |    1 +
 .../irqchip}/irq-armada-370-xp.c                   |   22 ++++++++++----------
 4 files changed, 15 insertions(+), 14 deletions(-)
 rename {arch/arm/mach-mvebu => drivers/irqchip}/irq-armada-370-xp.c (95%)
arch/arm/mach-mvebu/Makefile +1 -1
index da93bcb..c3be068 100644
@@ -5,6 +5,6 @@ AFLAGS_coherency_ll.o		:= -Wa,-march=armv7-a
 
 obj-y				 += system-controller.o
 obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o
-obj-$(CONFIG_ARCH_MVEBU)	 += addr-map.o coherency.o coherency_ll.o pmsu.o irq-armada-370-xp.o 
+obj-$(CONFIG_ARCH_MVEBU)	 += addr-map.o coherency.o coherency_ll.o pmsu.o
 obj-$(CONFIG_SMP)                += platsmp.o headsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)        += hotplug.o
arch/arm/mach-mvebu/armada-370-xp.c +2 -2
index c1bbfa7..433e8c5 100644
@@ -19,6 +19,7 @@
 #include <linux/time-armada-370-xp.h>
 #include <linux/clk/mvebu.h>
 #include <linux/dma-mapping.h>
+#include <linux/irqchip.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -77,8 +78,7 @@ DT_MACHINE_START(ARMADA_XP_DT, "Marvell Armada 370/XP (Device Tree)")
 	.init_machine	= armada_370_xp_dt_init,
 	.map_io		= armada_370_xp_map_io,
 	.init_early	= armada_370_xp_init_early,
-	.init_irq	= armada_370_xp_init_irq,
-	.handle_irq     = armada_370_xp_handle_irq,
+	.init_irq	= irqchip_init,
 	.init_time	= armada_370_xp_timer_and_clk_init,
 	.restart	= mvebu_restart,
 	.dt_compat	= armada_370_xp_dt_compat,
drivers/irqchip/Makefile +1 -0
index 98e3b87..dae27a7 100644
@@ -2,6 +2,7 @@ obj-$(CONFIG_IRQCHIP)			+= irqchip.o
 
 obj-$(CONFIG_ARCH_BCM2835)		+= irq-bcm2835.o
 obj-$(CONFIG_ARCH_EXYNOS)		+= exynos-combiner.o
+obj-$(CONFIG_ARCH_MVEBU)		+= irq-armada-370-xp.o
 obj-$(CONFIG_METAG)			+= irq-metag-ext.o
 obj-$(CONFIG_METAG_PERFCOUNTER_IRQS)	+= irq-metag.o
 obj-$(CONFIG_ARCH_SUNXI)		+= irq-sunxi.o
drivers/irqchip/irq-armada-370-xp.c renamed from arch/arm/mach-mvebu/irq-armada-370-xp.c +11 -11
similarity index 95%
rename from arch/arm/mach-mvebu/irq-armada-370-xp.c
rename to drivers/irqchip/irq-armada-370-xp.c
index f6699f3..d20a832 100644
@@ -25,6 +25,9 @@
 #include <asm/mach/arch.h>
 #include <asm/exception.h>
 #include <asm/smp_plat.h>
+#include <asm/mach/irq.h>
+
+#include "irqchip.h"
 
 /* Interrupt Controller Registers Map */
 #define ARMADA_370_XP_INT_SET_MASK_OFFS		(0x48)
@@ -202,6 +205,9 @@ static struct irq_domain_ops armada_370_xp_mpic_irq_ops = {
 	.xlate = irq_domain_xlate_onecell,
 };
 
+static asmlinkage void __exception_irq_entry
+armada_370_xp_handle_irq(struct pt_regs *regs);
+
 static int __init armada_370_xp_mpic_of_init(struct device_node *node,
 					     struct device_node *parent)
 {
@@ -237,11 +243,13 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
 
 #endif
 
+	set_handle_irq(armada_370_xp_handle_irq);
+
 	return 0;
 }
 
-asmlinkage void __exception_irq_entry armada_370_xp_handle_irq(struct pt_regs
-							       *regs)
+static asmlinkage void __exception_irq_entry
+armada_370_xp_handle_irq(struct pt_regs *regs)
 {
 	u32 irqstat, irqnr;
 
@@ -283,12 +291,4 @@ asmlinkage void __exception_irq_entry armada_370_xp_handle_irq(struct pt_regs
 	} while (1);
 }
 
-static const struct of_device_id mpic_of_match[] __initconst = {
-	{.compatible = "marvell,mpic", .data = armada_370_xp_mpic_of_init},
-	{},
-};
-
-void __init armada_370_xp_init_irq(void)
-{
-	of_irq_init(mpic_of_match);
-}
+IRQCHIP_DECLARE(armada_370_xp_mpic, "marvell,mpic", armada_370_xp_mpic_of_init);
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/5 irqchip: armada-370-xp: move IRQ handler to avoid forward declaration

In reply to Thomas Petazzoni

If we move the IRQ handler function above the initialization function, we avoid a forward declaration. This wasn't done as part of the previous commit, in order to increase the readibility of the previous commit, who was also moving the IRQ controller driver from arch/arm to drivers/irqchip.

---
 drivers/irqchip/irq-armada-370-xp.c |   83 +++++++++++++++++------------------
 1 file changed, 40 insertions(+), 43 deletions(-)
drivers/irqchip/irq-armada-370-xp.c +40 -43
index d20a832..1115bf8 100644
@@ -206,49 +206,6 @@ static struct irq_domain_ops armada_370_xp_mpic_irq_ops = {
 };
 
 static asmlinkage void __exception_irq_entry
-armada_370_xp_handle_irq(struct pt_regs *regs);
-
-static int __init armada_370_xp_mpic_of_init(struct device_node *node,
-					     struct device_node *parent)
-{
-	u32 control;
-
-	main_int_base = of_iomap(node, 0);
-	per_cpu_int_base = of_iomap(node, 1);
-
-	BUG_ON(!main_int_base);
-	BUG_ON(!per_cpu_int_base);
-
-	control = readl(main_int_base + ARMADA_370_XP_INT_CONTROL);
-
-	armada_370_xp_mpic_domain =
-		irq_domain_add_linear(node, (control >> 2) & 0x3ff,
-				&armada_370_xp_mpic_irq_ops, NULL);
-
-	if (!armada_370_xp_mpic_domain)
-		panic("Unable to add Armada_370_Xp MPIC irq domain (DT)\n");
-
-	irq_set_default_host(armada_370_xp_mpic_domain);
-
-#ifdef CONFIG_SMP
-	armada_xp_mpic_smp_cpu_init();
-
-	/*
-	 * Set the default affinity from all CPUs to the boot cpu.
-	 * This is required since the MPIC doesn't limit several CPUs
-	 * from acknowledging the same interrupt.
-	 */
-	cpumask_clear(irq_default_affinity);
-	cpumask_set_cpu(smp_processor_id(), irq_default_affinity);
-
-#endif
-
-	set_handle_irq(armada_370_xp_handle_irq);
-
-	return 0;
-}
-
-static asmlinkage void __exception_irq_entry
 armada_370_xp_handle_irq(struct pt_regs *regs)
 {
 	u32 irqstat, irqnr;
@@ -291,4 +248,44 @@ armada_370_xp_handle_irq(struct pt_regs *regs)
 	} while (1);
 }
 
+static int __init armada_370_xp_mpic_of_init(struct device_node *node,
+					     struct device_node *parent)
+{
+	u32 control;
+
+	main_int_base = of_iomap(node, 0);
+	per_cpu_int_base = of_iomap(node, 1);
+
+	BUG_ON(!main_int_base);
+	BUG_ON(!per_cpu_int_base);
+
+	control = readl(main_int_base + ARMADA_370_XP_INT_CONTROL);
+
+	armada_370_xp_mpic_domain =
+		irq_domain_add_linear(node, (control >> 2) & 0x3ff,
+				&armada_370_xp_mpic_irq_ops, NULL);
+
+	if (!armada_370_xp_mpic_domain)
+		panic("Unable to add Armada_370_Xp MPIC irq domain (DT)\n");
+
+	irq_set_default_host(armada_370_xp_mpic_domain);
+
+#ifdef CONFIG_SMP
+	armada_xp_mpic_smp_cpu_init();
+
+	/*
+	 * Set the default affinity from all CPUs to the boot cpu.
+	 * This is required since the MPIC doesn't limit several CPUs
+	 * from acknowledging the same interrupt.
+	 */
+	cpumask_clear(irq_default_affinity);
+	cpumask_set_cpu(smp_processor_id(), irq_default_affinity);
+
+#endif
+
+	set_handle_irq(armada_370_xp_handle_irq);
+
+	return 0;
+}
+
 IRQCHIP_DECLARE(armada_370_xp_mpic, "marvell,mpic", armada_370_xp_mpic_of_init);
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/5 irqchip: armada-370-xp: slightly cleanup irq controller driver

In reply to Thomas Petazzoni

In preparation for the introduction of MSI support in the IRQ controller driver, we clarify the implementation of IPI using additional defines for the manipulation of doorbells. Just like IPIs are implemented using doorbells, MSIs will also use doorbells, so it makes sense to do this preparatory cleanup first.

---
 drivers/irqchip/irq-armada-370-xp.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/irqchip/irq-armada-370-xp.c +8 -5
index 1115bf8..ad1e642 100644
@@ -48,7 +48,9 @@
 
 #define ARMADA_370_XP_TIMER0_PER_CPU_IRQ	(5)
 
-#define ACTIVE_DOORBELLS			(8)
+#define IPI_DOORBELL_START                      (0)
+#define IPI_DOORBELL_END                        (8)
+#define IPI_DOORBELL_MASK                       0xFF
 
 static DEFINE_RAW_SPINLOCK(irq_controller_lock);
 
@@ -192,7 +194,7 @@ void armada_xp_mpic_smp_cpu_init(void)
 	writel(0, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS);
 
 	/* Enable first 8 IPIs */
-	writel((1 << ACTIVE_DOORBELLS) - 1, per_cpu_int_base +
+	writel(IPI_DOORBELL_MASK, per_cpu_int_base +
 		ARMADA_370_XP_IN_DRBEL_MSK_OFFS);
 
 	/* Unmask IPI interrupt */
@@ -231,13 +233,14 @@ armada_370_xp_handle_irq(struct pt_regs *regs)
 
 			ipimask = readl_relaxed(per_cpu_int_base +
 						ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS)
-				& 0xFF;
+				& IPI_DOORBELL_MASK;
 
-			writel(0x0, per_cpu_int_base +
+			writel(~IPI_DOORBELL_MASK, per_cpu_int_base +
 				ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS);
 
 			/* Handle all pending doorbells */
-			for (ipinr = 0; ipinr < ACTIVE_DOORBELLS; ipinr++) {
+			for (ipinr = IPI_DOORBELL_START;
+			     ipinr < IPI_DOORBELL_END; ipinr++) {
 				if (ipimask & (0x1 << ipinr))
 					handle_IPI(ipinr, regs);
 			}
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 5/5 ARM: mvebu: do not duplicate the mpic alias

In reply to Thomas Petazzoni

The mpic alias is already defined in the common armada-370-xp.dtsi, so there's no need to repeat it at the armada-xp.dtsi and armada-370.dtsi level.

---
 arch/arm/boot/dts/armada-370.dtsi |    2 +-
 arch/arm/boot/dts/armada-xp.dtsi  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/armada-370.dtsi +1 -1
index a195deb..cede6a4 100644
@@ -33,7 +33,7 @@
 		gpio2 = &gpio2;
 	};
 
-	mpic: interrupt-controller at d0020000 {
+	interrupt-controller at d0020000 {
 	      reg = <0xd0020a00 0x1d0>,
 		    <0xd0021870 0x58>;
 	};
arch/arm/boot/dts/armada-xp.dtsi +1 -1
index ca00d83..2fed73b 100644
@@ -29,7 +29,7 @@
 		wt-override;
 	};
 
-	mpic: interrupt-controller at d0020000 {
+	interrupt-controller at d0020000 {
 	      reg = <0xd0020a00 0x2d0>,
 		    <0xd0021070 0x58>;
 	};
Signature · 1 line
1.7.9.5
#6 lore raw

cover Marvell EBU irqchip improvements

In reply to Thomas Petazzoni

Hi Thomas,

Quoted 11 lines · Thomas Petazzoni

Hello,

Here is a set of 5 patches that move the Marvell EBU IRQ controller driver to drivers/irqchip/ and do a few minor related cleanup or improvements.

Those commits were originally part of the series introducing PCIe MSI support for Marvell EBU platform, but the MSI support is not ready for merging. However, I'd like those preparation patches to be considered for 3.10.

I'm trying to test this patchset, assuming you've based it on top of v3.9-rc5.

However, patch 4/5 doesn't apply and I'm not really sure which other patches may be depending on this.

Any hints?

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
#7 lore raw

cover Marvell EBU irqchip improvements

Dear Ezequiel Garcia,

Quoted 7 lines · Ezequiel Garcia

I'm trying to test this patchset, assuming you've based it on top of v3.9-rc5.

However, patch 4/5 doesn't apply and I'm not really sure which other patches may be depending on this.

Any hints?

The patch set is based on 3.9-rc6, with no other dependencies. However, since a patch has been applied on the mvebu IRQ controller driver between 3.9-rc5 and 3.9-rc6, it probably explains the fact that the patch set doesn't apply as is on 3.9-rc5.

Best regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#8 lore raw

cover Marvell EBU irqchip improvements

Quoted 10 lines · Thomas Petazzoni

Dear Ezequiel Garcia,

Quoted 6 lines · Ezequiel Garcia

I'm trying to test this patchset, assuming you've based it on top of v3.9-rc5.

However, patch 4/5 doesn't apply and I'm not really sure which other patches may be depending on this.

Quoted 7 lines
Quoted 1 line

Any hints?

The patch set is based on 3.9-rc6, with no other dependencies. However, since a patch has been applied on the mvebu IRQ controller driver between 3.9-rc5 and 3.9-rc6, it probably explains the fact that the patch set doesn't apply as is on 3.9-rc5.

Indeed it applies cleanly on v3.9-rc6, thank you. On my AXP and A370 boards:

Also, FWIW, I've applied recent Greg's fix for GPIO IRQ:
"arm: mvebu: Fix the irq map function in SMP mode"

which applies cleanly on top of your patches!
(git can be really magical)

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
#9 lore raw

cover Marvell EBU irqchip improvements

Hello,

Quoted 4 lines · Ezequiel Garcia

Indeed it applies cleanly on v3.9-rc6, thank you. On my AXP and A370 boards:

Thanks for your testing!

Thomas (tglx), are you ok with the drivers/irqchip/ changes?

Thanks!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#10 lore raw

cover Marvell EBU irqchip improvements

Thomas (both),

Quoted 10 lines · Thomas Petazzoni
Quoted 4 lines · Ezequiel Garcia

Indeed it applies cleanly on v3.9-rc6, thank you. On my AXP and A370 boards:

Thanks for your testing!

Thomas (tglx), are you ok with the drivers/irqchip/ changes?

Would it be alright if we took this series through arm-soc with your Ack? Unfortunately, I see no way to reorder it or split it up to prevent cross tree dependencies. Conflicts on your side should be trivial.

thx,

Jason.

#11 lore raw

cover Marvell EBU irqchip improvements

In reply to Thomas Petazzoni
Quoted 13 lines · Thomas Petazzoni

Hello,

Here is a set of 5 patches that move the Marvell EBU IRQ controller driver to drivers/irqchip/ and do a few minor related cleanup or improvements.

Those commits were originally part of the series introducing PCIe MSI support for Marvell EBU platform, but the MSI support is not ready for merging. However, I'd like those preparation patches to be considered for 3.10.

Thanks,

Quoted 7 lines

Thomas

Thomas Petazzoni (5):
ARM: mvebu: move L2 cache initialization in init_early()
irqchip: move IRQ driver for Armada 370/XP
irqchip: armada-370-xp: move IRQ handler to avoid forward declaration
irqchip: armada-370-xp: slightly cleanup irq controller driver

I applied the above 4 patches to mvebu/irqchip in case tglx objects, it can be dropped without impacting other work.

Quoted 1 line

ARM: mvebu: do not duplicate the mpic alias

I already sent the PR for LPAE, which will conflict with this. I'll add this to mvebu/fixes once v3.9 drops.

Quoted 8 lines
 arch/arm/boot/dts/armada-370.dtsi                  |    2 +-
 arch/arm/boot/dts/armada-xp.dtsi                   |    2 +-
 arch/arm/mach-mvebu/Makefile                       |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |    9 +-
 drivers/irqchip/Makefile                           |    1 +
 .../irqchip}/irq-armada-370-xp.c                   |  106 ++++++++++----------
 6 files changed, 62 insertions(+), 60 deletions(-)
 rename {arch/arm/mach-mvebu => drivers/irqchip}/irq-armada-370-xp.c (91%)

thx,

Jason.

#12 lore raw

cover Marvell EBU irqchip improvements

Quoted 1 line · Jason Cooper

On Tue, Apr 09, 2013 at 11:26:13PM +0200, Thomas Petazzoni wrote:

...

Quoted 1 line
Quoted 1 line

Thomas Petazzoni (5):

...

Quoted 4 lines
Quoted 1 line

ARM: mvebu: do not duplicate the mpic alias

I already sent the PR for LPAE, which will conflict with this. I'll add this to mvebu/fixes once v3.9 drops.

Obviously, I meant v3.10-rc1. mvebu-next/fixes is now mvebu/fixes, rebased onto v3.10-rc1. This patch is included.

thx,

Jason.