All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] ARC IRQ setup changes
@ 2016-01-29  7:36 Vineet Gupta
  2016-01-29  7:36 ` [PATCH 1/5] ARC: [intc-compact] Remove IPI setup from ARCompact port Vineet Gupta
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Vineet Gupta @ 2016-01-29  7:36 UTC (permalink / raw)
  To: linux-snps-arc

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(-)

-- 
2.5.0

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

* [PATCH 1/5] ARC: [intc-compact] Remove IPI setup from ARCompact port
  2016-01-29  7:36 [PATCH 0/5] ARC IRQ setup changes Vineet Gupta
@ 2016-01-29  7:36 ` Vineet Gupta
  2016-01-29  7:36 ` [PATCH 2/5] ARC: [intc-compact] setup TIMER as percpu_dev Vineet Gupta
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Vineet Gupta @ 2016-01-29  7:36 UTC (permalink / raw)
  To: linux-snps-arc

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(-)

diff --git a/arch/arc/include/asm/irq.h b/arch/arc/include/asm/irq.h
index 44b6ea85e8fb..c9b4d83c70f7 100644
--- a/arch/arc/include/asm/irq.h
+++ b/arch/arc/include/asm/irq.h
@@ -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
 
diff --git a/arch/arc/kernel/intc-compact.c b/arch/arc/kernel/intc-compact.c
index 5d390958d233..2955b39ea2b0 100644
--- a/arch/arc/kernel/intc-compact.c
+++ b/arch/arc/kernel/intc-compact.c
@@ -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:
-- 
2.5.0

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

* [PATCH 2/5] ARC: [intc-compact] setup TIMER as percpu_dev
  2016-01-29  7:36 [PATCH 0/5] ARC IRQ setup changes Vineet Gupta
  2016-01-29  7:36 ` [PATCH 1/5] ARC: [intc-compact] Remove IPI setup from ARCompact port Vineet Gupta
@ 2016-01-29  7:36 ` Vineet Gupta
  2016-01-29  7:36 ` [PATCH 3/5] ARC: [intc] opencode arc_request_percpu_irq Vineet Gupta
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Vineet Gupta @ 2016-01-29  7:36 UTC (permalink / raw)
  To: linux-snps-arc

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(-)

diff --git a/arch/arc/kernel/intc-compact.c b/arch/arc/kernel/intc-compact.c
index 2955b39ea2b0..d31bc647146d 100644
--- a/arch/arc/kernel/intc-compact.c
+++ b/arch/arc/kernel/intc-compact.c
@@ -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:
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
index ba17f85285cf..88074b50456b 100644
--- a/arch/arc/kernel/irq.c
+++ b/arch/arc/kernel/irq.c
@@ -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);
-- 
2.5.0

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

* [PATCH 3/5] ARC: [intc] opencode arc_request_percpu_irq
  2016-01-29  7:36 [PATCH 0/5] ARC IRQ setup changes Vineet Gupta
  2016-01-29  7:36 ` [PATCH 1/5] ARC: [intc-compact] Remove IPI setup from ARCompact port Vineet Gupta
  2016-01-29  7:36 ` [PATCH 2/5] ARC: [intc-compact] setup TIMER as percpu_dev Vineet Gupta
@ 2016-01-29  7:36 ` Vineet Gupta
  2016-01-29  7:36 ` [PATCH 4/5] ARC: [intc-*] Do a domain lookup in primary handler for hwirq -> linux virq Vineet Gupta
  2016-01-29  7:36 ` [PATCH 5/5] ARC: [intc-*] switch to linear domain Vineet Gupta
  4 siblings, 0 replies; 6+ messages in thread
From: Vineet Gupta @ 2016-01-29  7:36 UTC (permalink / raw)
  To: linux-snps-arc

- 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(-)

diff --git a/arch/arc/include/asm/irq.h b/arch/arc/include/asm/irq.h
index c9b4d83c70f7..de33e83eb24d 100644
--- a/arch/arc/include/asm/irq.h
+++ b/arch/arc/include/asm/irq.h
@@ -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
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
index 88074b50456b..fb6dede9d05f 100644
--- a/arch/arc/kernel/irq.c
+++ b/arch/arc/kernel/irq.c
@@ -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);
-}
diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
index ea790f1c1107..0e71ad0a43c0 100644
--- a/arch/arc/kernel/smp.c
+++ b/arch/arc/kernel/smp.c
@@ -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;
 }
-- 
2.5.0

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

* [PATCH 4/5] ARC: [intc-*] Do a domain lookup in primary handler for hwirq -> linux virq
  2016-01-29  7:36 [PATCH 0/5] ARC IRQ setup changes Vineet Gupta
                   ` (2 preceding siblings ...)
  2016-01-29  7:36 ` [PATCH 3/5] ARC: [intc] opencode arc_request_percpu_irq Vineet Gupta
@ 2016-01-29  7:36 ` Vineet Gupta
  2016-01-29  7:36 ` [PATCH 5/5] ARC: [intc-*] switch to linear domain Vineet Gupta
  4 siblings, 0 replies; 6+ messages in thread
From: Vineet Gupta @ 2016-01-29  7:36 UTC (permalink / raw)
  To: linux-snps-arc

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(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 0faf954c860c..73b5b41ceb6f 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -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
diff --git a/arch/arc/kernel/intc-arcv2.c b/arch/arc/kernel/intc-arcv2.c
index 0394f9f61b46..cede73b50d31 100644
--- a/arch/arc/kernel/intc-arcv2.c
+++ b/arch/arc/kernel/intc-arcv2.c
@@ -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;
diff --git a/arch/arc/kernel/intc-compact.c b/arch/arc/kernel/intc-compact.c
index d31bc647146d..48a8b24de23e 100644
--- a/arch/arc/kernel/intc-compact.c
+++ b/arch/arc/kernel/intc-compact.c
@@ -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;
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
index fb6dede9d05f..538b36afe89e 100644
--- a/arch/arc/kernel/irq.c
+++ b/arch/arc/kernel/irq.c
@@ -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);
 }
-- 
2.5.0

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

* [PATCH 5/5] ARC: [intc-*] switch to linear domain
  2016-01-29  7:36 [PATCH 0/5] ARC IRQ setup changes Vineet Gupta
                   ` (3 preceding siblings ...)
  2016-01-29  7:36 ` [PATCH 4/5] ARC: [intc-*] Do a domain lookup in primary handler for hwirq -> linux virq Vineet Gupta
@ 2016-01-29  7:36 ` Vineet Gupta
  4 siblings, 0 replies; 6+ messages in thread
From: Vineet Gupta @ 2016-01-29  7:36 UTC (permalink / raw)
  To: linux-snps-arc

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(-)

diff --git a/arch/arc/kernel/intc-arcv2.c b/arch/arc/kernel/intc-arcv2.c
index cede73b50d31..c92de8148104 100644
--- a/arch/arc/kernel/intc-arcv2.c
+++ b/arch/arc/kernel/intc-arcv2.c
@@ -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;
 }
 
diff --git a/arch/arc/kernel/intc-compact.c b/arch/arc/kernel/intc-compact.c
index 48a8b24de23e..c5cceca36118 100644
--- a/arch/arc/kernel/intc-compact.c
+++ b/arch/arc/kernel/intc-compact.c
@@ -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");
-- 
2.5.0

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

end of thread, other threads:[~2016-01-29  7:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-29  7:36 [PATCH 0/5] ARC IRQ setup changes Vineet Gupta
2016-01-29  7:36 ` [PATCH 1/5] ARC: [intc-compact] Remove IPI setup from ARCompact port Vineet Gupta
2016-01-29  7:36 ` [PATCH 2/5] ARC: [intc-compact] setup TIMER as percpu_dev Vineet Gupta
2016-01-29  7:36 ` [PATCH 3/5] ARC: [intc] opencode arc_request_percpu_irq Vineet Gupta
2016-01-29  7:36 ` [PATCH 4/5] ARC: [intc-*] Do a domain lookup in primary handler for hwirq -> linux virq Vineet Gupta
2016-01-29  7:36 ` [PATCH 5/5] ARC: [intc-*] switch to linear domain Vineet Gupta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.