Skip to contentSkip to conversation

ARC IRQ setup changes

PATCH New Vineet Gupta 1 participant 6 messages Jan 29, 2016 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

cover ARC IRQ setup changes

Hi,

This series came out as a result of discussions during EZChip platform code review.

There is one real fix for irq domain lookup as pointed by Marc.

Please have alook.

Thx,
-Vineet

Vineet Gupta (5):
ARC: [intc-compact] Remove IPI setup from ARCompact port
ARC: [intc-compact] setup TIMER as percpu_dev
ARC: [intc] opencode arc_request_percpu_irq
ARC: [intc-*] Do a domain lookup in primary handler for hwirq -> linux
virq
ARC: [intc-*] switch to linear domain

 arch/arc/Kconfig               |  1 +
 arch/arc/include/asm/irq.h     |  8 +------
 arch/arc/kernel/intc-arcv2.c   | 13 ++++++-----
 arch/arc/kernel/intc-compact.c | 18 +++++++--------
 arch/arc/kernel/irq.c          | 50 ++----------------------------------------
 arch/arc/kernel/smp.c          | 11 +++++++++-
 6 files changed, 31 insertions(+), 70 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/5 ARC: [intc-compact] Remove IPI setup from ARCompact port

There is no real ARC700 based SMP SoC so remove IPI definition. EZChip's SMP ARC700 is going to use a different intc and IPI provider anyways.

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/include/asm/irq.h     | 5 +----
 arch/arc/kernel/intc-compact.c | 3 ---
 2 files changed, 1 insertion(+), 7 deletions(-)
arch/arc/include/asm/irq.h +1 -4
index 44b6ea85e8fb..c9b4d83c70f7 100644
@@ -12,10 +12,7 @@
 #define NR_CPU_IRQS	32  /* number of interrupt lines of ARC770 CPU */
 #define NR_IRQS		128 /* allow some CPU external IRQ handling */
 
-/* Platform Independent IRQs */
-#ifdef CONFIG_ISA_ARCOMPACT
-#define IPI_IRQ		(NR_CPU_IRQS-1) /* dummy to enable SMP build for up hardware */
-#else
+#ifdef CONFIG_ISA_ARCV2
 #define IPI_IRQ         19
 #endif
 
arch/arc/kernel/intc-compact.c +0 -3
index 5d390958d233..2955b39ea2b0 100644
@@ -83,9 +83,6 @@ static int arc_intc_domain_map(struct irq_domain *d, unsigned int irq,
 {
 	switch (irq) {
 	case TIMER0_IRQ:
-#ifdef CONFIG_SMP
-	case IPI_IRQ:
-#endif
 		irq_set_chip_and_handler(irq, &onchip_intc, handle_percpu_irq);
 		break;
 	default:
Signature · 1 line
2.5.0
#2 lore raw

PATCH 2/5 ARC: [intc-compact] setup TIMER as percpu_dev

In reply to Vineet Gupta

This removes the quirk from arc_request_percpu_irq() and paves way for future simplifications

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/kernel/intc-compact.c |  3 ++-
 arch/arc/kernel/irq.c          | 12 ------------
 2 files changed, 2 insertions(+), 13 deletions(-)
arch/arc/kernel/intc-compact.c +2 -1
index 2955b39ea2b0..d31bc647146d 100644
@@ -81,8 +81,9 @@ static struct irq_chip onchip_intc = {
 static int arc_intc_domain_map(struct irq_domain *d, unsigned int irq,
 			       irq_hw_number_t hw)
 {
-	switch (irq) {
+	switch (hw) {
 	case TIMER0_IRQ:
+		irq_set_percpu_devid(irq);
 		irq_set_chip_and_handler(irq, &onchip_intc, handle_percpu_irq);
 		break;
 	default:
arch/arc/kernel/irq.c +0 -12
index ba17f85285cf..88074b50456b 100644
@@ -72,18 +72,6 @@ void arc_request_percpu_irq(int irq, int cpu,
 	if (!cpu) {
 		int rc;
 
-#ifdef CONFIG_ISA_ARCOMPACT
-		/*
-		 * A subsequent request_percpu_irq() fails if percpu_devid is
-		 * not set. That in turns sets NOAUTOEN, meaning each core needs
-		 * to call enable_percpu_irq()
-		 *
-		 * For ARCv2, this is done in irq map function since we know
-		 * which irqs are strictly per cpu
-		 */
-		irq_set_percpu_devid(irq);
-#endif
-
 		rc = request_percpu_irq(irq, isr, irq_nm, percpu_dev);
 		if (rc)
 			panic("Percpu IRQ request failed for %d\n", irq);
Signature · 1 line
2.5.0
#3 lore raw

PATCH 3/5 ARC: [intc] opencode arc_request_percpu_irq

In reply to Vineet Gupta

- With only 1 caller, simply opencode it.

- The idea however is to remove the API usage since it has a subltle design flaw - relies on being called on cpu0 first. This is true for some early per cpu irqs such as TIMER/IPI, but not for late probed per cpu peripherals such a perf. And it's usage in perf has already bitten us once: see c6317bc7c5ab
("ARCv2: perf: Ensure perf intr gets enabled on all cores") where we ended up open coding it anyways

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/include/asm/irq.h |  3 ---
 arch/arc/kernel/irq.c      | 29 -----------------------------
 arch/arc/kernel/smp.c      | 11 ++++++++++-
 3 files changed, 10 insertions(+), 33 deletions(-)
arch/arc/include/asm/irq.h +0 -3
index c9b4d83c70f7..de33e83eb24d 100644
@@ -20,8 +20,5 @@
 #include <asm-generic/irq.h>
 
 extern void arc_init_IRQ(void);
-void arc_request_percpu_irq(int irq, int cpu,
-                            irqreturn_t (*isr)(int irq, void *dev),
-                            const char *irq_nm, void *percpu_dev);
 
 #endif
arch/arc/kernel/irq.c +0 -29
index 88074b50456b..fb6dede9d05f 100644
@@ -50,32 +50,3 @@ void arch_do_IRQ(unsigned int irq, struct pt_regs *regs)
 	irq_exit();
 	set_irq_regs(old_regs);
 }
-
-/*
- * API called for requesting percpu interrupts - called by each CPU
- *  - For boot CPU, actually request the IRQ with genirq core + enables
- *  - For subsequent callers only enable called locally
- *
- * Relies on being called by boot cpu first (i.e. request called ahead) of
- * any enable as expected by genirq. Hence Suitable only for TIMER, IPI
- * which are guaranteed to be setup on boot core first.
- * Late probed peripherals such as perf can't use this as there no guarantee
- * of being called on boot CPU first.
- */
-
-void arc_request_percpu_irq(int irq, int cpu,
-                            irqreturn_t (*isr)(int irq, void *dev),
-                            const char *irq_nm,
-                            void *percpu_dev)
-{
-	/* Boot cpu calls request, all call enable */
-	if (!cpu) {
-		int rc;
-
-		rc = request_percpu_irq(irq, isr, irq_nm, percpu_dev);
-		if (rc)
-			panic("Percpu IRQ request failed for %d\n", irq);
-	}
-
-	enable_percpu_irq(irq, 0);
-}
arch/arc/kernel/smp.c +10 -1
index ea790f1c1107..0e71ad0a43c0 100644
@@ -354,7 +354,16 @@ int smp_ipi_irq_setup(int cpu, int irq)
 {
 	int *dev = per_cpu_ptr(&ipi_dev, cpu);
 
-	arc_request_percpu_irq(irq, cpu, do_IPI, "IPI Interrupt", dev);
+	/* Boot cpu calls request, all call enable */
+	if (!cpu) {
+		int rc;
+
+		rc = request_percpu_irq(irq, do_IPI, "IPI Interrupt", dev);
+		if (rc)
+			panic("Percpu IRQ request failed for %d\n", irq);
+	}
+
+	enable_percpu_irq(irq, 0);
 
 	return 0;
 }
Signature · 1 line
2.5.0
#4 lore raw

PATCH 4/5 ARC: [intc-*] Do a domain lookup in primary handler for hwirq -> linux virq

In reply to Vineet Gupta

The primary interrupt handler arch_do_IRQ() was passing hwirq as linux virq to core code. This was fragile and worked so far as we only had legacy/linear domains.

This came out of a rant by Marc Zyngier.
http://lists.infradead.org/pipermail/linux-snps-arc/2015-December/000298.html

Cc Marc Zyngier <marc.zyngier at arm.com>
Cc Thomas Gleixner <tglx at linutronix.de>
Cc Noam Camus <noamc at ezchip.com>
Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/Kconfig               |  1 +
 arch/arc/kernel/intc-arcv2.c   |  9 ++++++---
 arch/arc/kernel/intc-compact.c | 10 ++++++----
 arch/arc/kernel/irq.c          |  9 ++-------
 4 files changed, 15 insertions(+), 14 deletions(-)
arch/arc/Kconfig +1 -0
index 0faf954c860c..73b5b41ceb6f 100644
@@ -32,6 +32,7 @@ config ARC
 	select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND
 	select HAVE_OPROFILE
 	select HAVE_PERF_EVENTS
+	select HANDLE_DOMAIN_IRQ
 	select IRQ_DOMAIN
 	select MODULES_USE_ELF_RELA
 	select NO_BOOTMEM
arch/arc/kernel/intc-arcv2.c +6 -3
index 0394f9f61b46..cede73b50d31 100644
@@ -130,21 +130,24 @@ static const struct irq_domain_ops arcv2_irq_ops = {
 	.map = arcv2_irq_map,
 };
 
-static struct irq_domain *root_domain;
 
 static int __init
 init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
 {
+	struct irq_domain *root_domain;
+
 	if (parent)
 		panic("DeviceTree incore intc not a root irq controller\n");
 
 	root_domain = irq_domain_add_legacy(intc, NR_CPU_IRQS, 0, 0,
 					    &arcv2_irq_ops, NULL);
-
 	if (!root_domain)
 		panic("root irq domain not avail\n");
 
-	/* with this we don't need to export root_domain */
+	/*
+	 * Needed for primary domain lookup to succeed
+	 * This is a primary irqchip, and can never have a parent
+	 */
 	irq_set_default_host(root_domain);
 
 	return 0;
arch/arc/kernel/intc-compact.c +6 -4
index d31bc647146d..48a8b24de23e 100644
@@ -97,21 +97,23 @@ static const struct irq_domain_ops arc_intc_domain_ops = {
 	.map = arc_intc_domain_map,
 };
 
-static struct irq_domain *root_domain;
-
 static int __init
 init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
 {
+	struct irq_domain *root_domain;
+
 	if (parent)
 		panic("DeviceTree incore intc not a root irq controller\n");
 
 	root_domain = irq_domain_add_legacy(intc, NR_CPU_IRQS, 0, 0,
 					    &arc_intc_domain_ops, NULL);
-
 	if (!root_domain)
 		panic("root irq domain not avail\n");
 
-	/* with this we don't need to export root_domain */
+	/*
+	 * Needed for primary domain lookup to succeed
+	 * This is a primary irqchip, and can never have a parent
+	 */
 	irq_set_default_host(root_domain);
 
 	return 0;
arch/arc/kernel/irq.c +2 -7
index fb6dede9d05f..538b36afe89e 100644
@@ -41,12 +41,7 @@ void __init init_IRQ(void)
  * "C" Entry point for any ARC ISR, called from low level vector handler
  * @irq is the vector number read from ICAUSE reg of on-chip intc
  */
-void arch_do_IRQ(unsigned int irq, struct pt_regs *regs)
+void arch_do_IRQ(unsigned int hwirq, struct pt_regs *regs)
 {
-	struct pt_regs *old_regs = set_irq_regs(regs);
-
-	irq_enter();
-	generic_handle_irq(irq);
-	irq_exit();
-	set_irq_regs(old_regs);
+	handle_domain_irq(NULL, hwirq, regs);
 }
Signature · 1 line
2.5.0
#5 lore raw

PATCH 5/5 ARC: [intc-*] switch to linear domain

In reply to Vineet Gupta

Now that we have Timers probed from DT, don't need legacy domain

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/kernel/intc-arcv2.c   | 4 ++--
 arch/arc/kernel/intc-compact.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arc/kernel/intc-arcv2.c +2 -2
index cede73b50d31..c92de8148104 100644
@@ -139,8 +139,7 @@ init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
 	if (parent)
 		panic("DeviceTree incore intc not a root irq controller\n");
 
-	root_domain = irq_domain_add_legacy(intc, NR_CPU_IRQS, 0, 0,
-					    &arcv2_irq_ops, NULL);
+	root_domain = irq_domain_add_linear(intc, NR_CPU_IRQS, &arcv2_irq_ops, NULL);
 	if (!root_domain)
 		panic("root irq domain not avail\n");
 
@@ -150,6 +149,7 @@ init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
 	 */
 	irq_set_default_host(root_domain);
 
+	irq_create_mapping(root_domain, IPI_IRQ);
 	return 0;
 }
 
arch/arc/kernel/intc-compact.c +1 -1
index 48a8b24de23e..c5cceca36118 100644
@@ -105,7 +105,7 @@ init_onchip_IRQ(struct device_node *intc, struct device_node *parent)
 	if (parent)
 		panic("DeviceTree incore intc not a root irq controller\n");
 
-	root_domain = irq_domain_add_legacy(intc, NR_CPU_IRQS, 0, 0,
+	root_domain = irq_domain_add_linear(intc, NR_CPU_IRQS,
 					    &arc_intc_domain_ops, NULL);
 	if (!root_domain)
 		panic("root irq domain not avail\n");
Signature · 1 line
2.5.0