All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE
@ 2017-04-06 12:48 Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 1/7] MIPS: Introduce irq_stack Amit Pundir
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:48 UTC (permalink / raw)
  To: gregkh; +Cc: stable, james.hogan

Hi Greg,

Picked up these patches from LEDE source tree,
for your consideration for stable 4.4.

Cherry-picked and build tested on v4.4.58 for
ARCH=mips + allmodconfig.

Felix Fietkau (1):
  MIPS: Lantiq: Fix cascaded IRQ setup

Matt Redfearn (6):
  MIPS: Introduce irq_stack
  MIPS: Stack unwinding while on IRQ stack
  MIPS: Only change $28 to thread_info if coming from user mode
  MIPS: Switch to the irq_stack in interrupts
  MIPS: Select HAVE_IRQ_EXIT_ON_IRQ_STACK
  MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch

 arch/mips/Kconfig                  |  1 +
 arch/mips/include/asm/irq.h        | 12 ++++++
 arch/mips/include/asm/stackframe.h |  7 ++++
 arch/mips/kernel/asm-offsets.c     |  1 +
 arch/mips/kernel/genex.S           | 81 +++++++++++++++++++++++++++++++++++---
 arch/mips/kernel/irq.c             | 11 ++++++
 arch/mips/kernel/process.c         | 15 ++++++-
 arch/mips/lantiq/irq.c             | 38 ++++++++----------
 8 files changed, 139 insertions(+), 27 deletions(-)

-- 
2.7.4

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

* [PATCH for-4.4 1/7] MIPS: Introduce irq_stack
  2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
@ 2017-04-06 12:48 ` Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 2/7] MIPS: Stack unwinding while on IRQ stack Amit Pundir
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:48 UTC (permalink / raw)
  To: gregkh
  Cc: stable, james.hogan, Matt Redfearn, Thomas Gleixner,
	Paolo Bonzini, Chris Metcalf, Petr Mladek, Paul Burton,
	Aaron Tomlin, Andrew Morton, linux-kernel, linux-mips,
	Ralf Baechle

From: Matt Redfearn <matt.redfearn@imgtec.com>

Allocate a per-cpu irq stack for use within interrupt handlers.

Also add a utility function on_irq_stack to determine if a given stack
pointer is within the irq stack for that cpu.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Acked-by: Jason A. Donenfeld <jason@zx2c4.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Aaron Tomlin <atomlin@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14740/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
(cherry picked from commit fe8bd18ffea5327344d4ec2bf11f47951212abd0)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/include/asm/irq.h    | 12 ++++++++++++
 arch/mips/kernel/asm-offsets.c |  1 +
 arch/mips/kernel/irq.c         | 11 +++++++++++
 3 files changed, 24 insertions(+)

diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h
index 15e0fec..ebb9efb 100644
--- a/arch/mips/include/asm/irq.h
+++ b/arch/mips/include/asm/irq.h
@@ -17,6 +17,18 @@
 
 #include <irq.h>
 
+#define IRQ_STACK_SIZE			THREAD_SIZE
+
+extern void *irq_stack[NR_CPUS];
+
+static inline bool on_irq_stack(int cpu, unsigned long sp)
+{
+	unsigned long low = (unsigned long)irq_stack[cpu];
+	unsigned long high = low + IRQ_STACK_SIZE;
+
+	return (low <= sp && sp <= high);
+}
+
 #ifdef CONFIG_I8259
 static inline int irq_canonicalize(int irq)
 {
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index 154e203..ec053ce 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -101,6 +101,7 @@ void output_thread_info_defines(void)
 	OFFSET(TI_REGS, thread_info, regs);
 	DEFINE(_THREAD_SIZE, THREAD_SIZE);
 	DEFINE(_THREAD_MASK, THREAD_MASK);
+	DEFINE(_IRQ_STACK_SIZE, IRQ_STACK_SIZE);
 	BLANK();
 }
 
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index 8eb5af8..dc1180a 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -25,6 +25,8 @@
 #include <linux/atomic.h>
 #include <asm/uaccess.h>
 
+void *irq_stack[NR_CPUS];
+
 /*
  * 'what should we do if we get a hw irq event on an illegal vector'.
  * each architecture has to answer this themselves.
@@ -55,6 +57,15 @@ void __init init_IRQ(void)
 		irq_set_noprobe(i);
 
 	arch_init_irq();
+
+	for_each_possible_cpu(i) {
+		int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE;
+		void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages);
+
+		irq_stack[i] = s;
+		pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i,
+			irq_stack[i], irq_stack[i] + IRQ_STACK_SIZE);
+	}
 }
 
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
-- 
2.7.4

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

* [PATCH for-4.4 2/7] MIPS: Stack unwinding while on IRQ stack
  2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 1/7] MIPS: Introduce irq_stack Amit Pundir
@ 2017-04-06 12:48 ` Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 3/7] MIPS: Only change $28 to thread_info if coming from user mode Amit Pundir
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:48 UTC (permalink / raw)
  To: gregkh
  Cc: stable, james.hogan, Matt Redfearn, Thomas Gleixner,
	Adam Buchbinder, Maciej W . Rozycki, Marcin Nowakowski,
	Chris Metcalf, Paul Burton, Jiri Slaby, Andrew Morton,
	linux-mips, linux-kernel, Ralf Baechle

From: Matt Redfearn <matt.redfearn@imgtec.com>

Within unwind stack, check if the stack pointer being unwound is within
the CPU's irq_stack and if so use that page rather than the task's stack
page.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Acked-by: Jason A. Donenfeld <jason@zx2c4.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Adam Buchbinder <adam.buchbinder@gmail.com>
Cc: Maciej W. Rozycki <macro@imgtec.com>
Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14741/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
(cherry picked from commit d42d8d106b0275b027c1e8992c42aecf933436ea)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/kernel/process.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index fc537d1..8c26eca 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -32,6 +32,7 @@
 #include <asm/cpu.h>
 #include <asm/dsp.h>
 #include <asm/fpu.h>
+#include <asm/irq.h>
 #include <asm/msa.h>
 #include <asm/pgtable.h>
 #include <asm/mipsregs.h>
@@ -552,7 +553,19 @@ EXPORT_SYMBOL(unwind_stack_by_address);
 unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
 			   unsigned long pc, unsigned long *ra)
 {
-	unsigned long stack_page = (unsigned long)task_stack_page(task);
+	unsigned long stack_page = 0;
+	int cpu;
+
+	for_each_possible_cpu(cpu) {
+		if (on_irq_stack(cpu, *sp)) {
+			stack_page = (unsigned long)irq_stack[cpu];
+			break;
+		}
+	}
+
+	if (!stack_page)
+		stack_page = (unsigned long)task_stack_page(task);
+
 	return unwind_stack_by_address(stack_page, sp, pc, ra);
 }
 #endif
-- 
2.7.4

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

* [PATCH for-4.4 3/7] MIPS: Only change $28 to thread_info if coming from user mode
  2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 1/7] MIPS: Introduce irq_stack Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 2/7] MIPS: Stack unwinding while on IRQ stack Amit Pundir
@ 2017-04-06 12:48 ` Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 4/7] MIPS: Switch to the irq_stack in interrupts Amit Pundir
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:48 UTC (permalink / raw)
  To: gregkh
  Cc: stable, james.hogan, Matt Redfearn, Thomas Gleixner, Paul Burton,
	linux-mips, linux-kernel, Ralf Baechle

From: Matt Redfearn <matt.redfearn@imgtec.com>

The SAVE_SOME macro is used to save the execution context on all
exceptions.
If an exception occurs while executing user code, the stack is switched
to the kernel's stack for the current task, and register $28 is switched
to point to the current_thread_info, which is at the bottom of the stack
region.
If the exception occurs while executing kernel code, the stack is left,
and this change ensures that register $28 is not updated. This is the
correct behaviour when the kernel can be executing on the separate irq
stack, because the thread_info will not be at the base of it.

With this change, register $28 is only switched to it's kernel
conventional usage of the currrent thread info pointer at the point at
which execution enters kernel space. Doing it on every exception was
redundant, but OK without an IRQ stack, but will be erroneous once that
is introduced.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Acked-by: Jason A. Donenfeld <jason@zx2c4.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14742/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
(cherry picked from commit 510d86362a27577f5ee23f46cfb354ad49731e61)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/include/asm/stackframe.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/mips/include/asm/stackframe.h b/arch/mips/include/asm/stackframe.h
index a71da57..5347f13 100644
--- a/arch/mips/include/asm/stackframe.h
+++ b/arch/mips/include/asm/stackframe.h
@@ -216,12 +216,19 @@
 		LONG_S	$25, PT_R25(sp)
 		LONG_S	$28, PT_R28(sp)
 		LONG_S	$31, PT_R31(sp)
+
+		/* Set thread_info if we're coming from user mode */
+		mfc0	k0, CP0_STATUS
+		sll	k0, 3		/* extract cu0 bit */
+		bltz	k0, 9f
+
 		ori	$28, sp, _THREAD_MASK
 		xori	$28, _THREAD_MASK
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
 		.set    mips64
 		pref    0, 0($28)       /* Prefetch the current pointer */
 #endif
+9:
 		.set	pop
 		.endm
 
-- 
2.7.4

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

* [PATCH for-4.4 4/7] MIPS: Switch to the irq_stack in interrupts
  2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
                   ` (2 preceding siblings ...)
  2017-04-06 12:48 ` [PATCH for-4.4 3/7] MIPS: Only change $28 to thread_info if coming from user mode Amit Pundir
@ 2017-04-06 12:48 ` Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 5/7] MIPS: Select HAVE_IRQ_EXIT_ON_IRQ_STACK Amit Pundir
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:48 UTC (permalink / raw)
  To: gregkh
  Cc: stable, james.hogan, Matt Redfearn, Thomas Gleixner, Paul Burton,
	linux-mips, linux-kernel, Ralf Baechle

From: Matt Redfearn <matt.redfearn@imgtec.com>

When enterring interrupt context via handle_int or except_vec_vi, switch
to the irq_stack of the current CPU if it is not already in use.

The current stack pointer is masked with the thread size and compared to
the base or the irq stack. If it does not match then the stack pointer
is set to the top of that stack, otherwise this is a nested irq being
handled on the irq stack so the stack pointer should be left as it was.

The in-use stack pointer is placed in the callee saved register s1. It
will be saved to the stack when plat_irq_dispatch is invoked and can be
restored once control returns here.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Acked-by: Jason A. Donenfeld <jason@zx2c4.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14743/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
(cherry picked from commit dda45f701c9d7ad4ac0bb446e3a96f6df9a468d9)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/kernel/genex.S | 81 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 76 insertions(+), 5 deletions(-)

diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index baa7b6f..2c7cd62 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -188,9 +188,44 @@ NESTED(handle_int, PT_SIZE, sp)
 
 	LONG_L	s0, TI_REGS($28)
 	LONG_S	sp, TI_REGS($28)
-	PTR_LA	ra, ret_from_irq
-	PTR_LA  v0, plat_irq_dispatch
-	jr	v0
+
+	/*
+	 * SAVE_ALL ensures we are using a valid kernel stack for the thread.
+	 * Check if we are already using the IRQ stack.
+	 */
+	move	s1, sp # Preserve the sp
+
+	/* Get IRQ stack for this CPU */
+	ASM_CPUID_MFC0	k0, ASM_SMP_CPUID_REG
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
+	lui	k1, %hi(irq_stack)
+#else
+	lui	k1, %highest(irq_stack)
+	daddiu	k1, %higher(irq_stack)
+	dsll	k1, 16
+	daddiu	k1, %hi(irq_stack)
+	dsll	k1, 16
+#endif
+	LONG_SRL	k0, SMP_CPUID_PTRSHIFT
+	LONG_ADDU	k1, k0
+	LONG_L	t0, %lo(irq_stack)(k1)
+
+	# Check if already on IRQ stack
+	PTR_LI	t1, ~(_THREAD_SIZE-1)
+	and	t1, t1, sp
+	beq	t0, t1, 2f
+
+	/* Switch to IRQ stack */
+	li	t1, _IRQ_STACK_SIZE
+	PTR_ADD sp, t0, t1
+
+2:
+	jal	plat_irq_dispatch
+
+	/* Restore sp */
+	move	sp, s1
+
+	j	ret_from_irq
 #ifdef CONFIG_CPU_MICROMIPS
 	nop
 #endif
@@ -263,8 +298,44 @@ NESTED(except_vec_vi_handler, 0, sp)
 
 	LONG_L	s0, TI_REGS($28)
 	LONG_S	sp, TI_REGS($28)
-	PTR_LA	ra, ret_from_irq
-	jr	v0
+
+	/*
+	 * SAVE_ALL ensures we are using a valid kernel stack for the thread.
+	 * Check if we are already using the IRQ stack.
+	 */
+	move	s1, sp # Preserve the sp
+
+	/* Get IRQ stack for this CPU */
+	ASM_CPUID_MFC0	k0, ASM_SMP_CPUID_REG
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
+	lui	k1, %hi(irq_stack)
+#else
+	lui	k1, %highest(irq_stack)
+	daddiu	k1, %higher(irq_stack)
+	dsll	k1, 16
+	daddiu	k1, %hi(irq_stack)
+	dsll	k1, 16
+#endif
+	LONG_SRL	k0, SMP_CPUID_PTRSHIFT
+	LONG_ADDU	k1, k0
+	LONG_L	t0, %lo(irq_stack)(k1)
+
+	# Check if already on IRQ stack
+	PTR_LI	t1, ~(_THREAD_SIZE-1)
+	and	t1, t1, sp
+	beq	t0, t1, 2f
+
+	/* Switch to IRQ stack */
+	li	t1, _IRQ_STACK_SIZE
+	PTR_ADD sp, t0, t1
+
+2:
+	jal	plat_irq_dispatch
+
+	/* Restore sp */
+	move	sp, s1
+
+	j	ret_from_irq
 	END(except_vec_vi_handler)
 
 /*
-- 
2.7.4

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

* [PATCH for-4.4 5/7] MIPS: Select HAVE_IRQ_EXIT_ON_IRQ_STACK
  2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
                   ` (3 preceding siblings ...)
  2017-04-06 12:48 ` [PATCH for-4.4 4/7] MIPS: Switch to the irq_stack in interrupts Amit Pundir
@ 2017-04-06 12:48 ` Amit Pundir
  2017-04-06 12:48 ` [PATCH for-4.4 6/7] MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch Amit Pundir
  2017-04-06 12:49 ` [PATCH for-4.4 7/7] MIPS: Lantiq: Fix cascaded IRQ setup Amit Pundir
  6 siblings, 0 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:48 UTC (permalink / raw)
  To: gregkh
  Cc: stable, james.hogan, Matt Redfearn, Thomas Gleixner, linux-mips,
	linux-kernel, Ralf Baechle

From: Matt Redfearn <matt.redfearn@imgtec.com>

Since do_IRQ is now invoked on a separate IRQ stack, we select
HAVE_IRQ_EXIT_ON_IRQ_STACK so that softirq's may be invoked directly
from irq_exit(), rather than requiring do_softirq_own_stack.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Acked-by: Jason A. Donenfeld <jason@zx2c4.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14744/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
(cherry picked from commit 3cc3434fd6307d06b53b98ce83e76bf9807689b9)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index db45961..49c276c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -9,6 +9,7 @@ config MIPS
 	select HAVE_CONTEXT_TRACKING
 	select HAVE_GENERIC_DMA_COHERENT
 	select HAVE_IDE
+	select HAVE_IRQ_EXIT_ON_IRQ_STACK
 	select HAVE_OPROFILE
 	select HAVE_PERF_EVENTS
 	select PERF_USE_VMALLOC
-- 
2.7.4

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

* [PATCH for-4.4 6/7] MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch
  2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
                   ` (4 preceding siblings ...)
  2017-04-06 12:48 ` [PATCH for-4.4 5/7] MIPS: Select HAVE_IRQ_EXIT_ON_IRQ_STACK Amit Pundir
@ 2017-04-06 12:48 ` Amit Pundir
  2017-04-06 12:49 ` [PATCH for-4.4 7/7] MIPS: Lantiq: Fix cascaded IRQ setup Amit Pundir
  6 siblings, 0 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:48 UTC (permalink / raw)
  To: gregkh
  Cc: stable, james.hogan, Matt Redfearn, Ralf Baechle, Paul Burton,
	linux-mips

From: Matt Redfearn <matt.redfearn@imgtec.com>

Commit dda45f701c9d ("MIPS: Switch to the irq_stack in interrupts")
changed both the normal and vectored interrupt handlers. Unfortunately
the vectored version, "except_vec_vi_handler", was incorrectly modified
to unconditionally jal to plat_irq_dispatch, rather than doing a jalr to
the vectored handler that has been set up. This is ok for many platforms
which set the vectored handler to plat_irq_dispatch anyway, but will
cause problems with platforms that use other handlers.

Fixes: dda45f701c9d ("MIPS: Switch to the irq_stack in interrupts")
Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/15110/
Signed-off-by: James Hogan <james.hogan@imgtec.com>
(cherry picked from commit c25f8064c1d5731a2ce5664def890140dcdd3e5c)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/kernel/genex.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index 2c7cd62..619e30e 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -330,7 +330,7 @@ NESTED(except_vec_vi_handler, 0, sp)
 	PTR_ADD sp, t0, t1
 
 2:
-	jal	plat_irq_dispatch
+	jalr	v0
 
 	/* Restore sp */
 	move	sp, s1
-- 
2.7.4

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

* [PATCH for-4.4 7/7] MIPS: Lantiq: Fix cascaded IRQ setup
  2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
                   ` (5 preceding siblings ...)
  2017-04-06 12:48 ` [PATCH for-4.4 6/7] MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch Amit Pundir
@ 2017-04-06 12:49 ` Amit Pundir
  2017-04-06 13:19     ` James Hogan
  6 siblings, 1 reply; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 12:49 UTC (permalink / raw)
  To: gregkh; +Cc: stable, james.hogan, Felix Fietkau, linux-mips

From: Felix Fietkau <nbd@nbd.name>

With the IRQ stack changes integrated, the XRX200 devices started
emitting a constant stream of kernel messages like this:

[  565.415310] Spurious IRQ: CAUSE=0x1100c300

This is caused by IP0 getting handled by plat_irq_dispatch() rather than
its vectored interrupt handler, which is fixed by commit de856416e714
("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").

Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
for all MIPS CPU interrupts.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Acked-by: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/15077/
[james.hogan@imgtec.com: tweaked commit message]
Signed-off-by: James Hogan <james.hogan@imgtec.com>

(cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
 arch/mips/lantiq/irq.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c
index 2e7f60c..51cdc46 100644
--- a/arch/mips/lantiq/irq.c
+++ b/arch/mips/lantiq/irq.c
@@ -269,6 +269,11 @@ static void ltq_hw5_irqdispatch(void)
 DEFINE_HWx_IRQDISPATCH(5)
 #endif
 
+static void ltq_hw_irq_handler(struct irq_desc *desc)
+{
+	ltq_hw_irqdispatch(irq_desc_get_irq(desc) - 2);
+}
+
 #ifdef CONFIG_MIPS_MT_SMP
 void __init arch_init_ipiirq(int irq, struct irqaction *action)
 {
@@ -313,23 +318,19 @@ static struct irqaction irq_call = {
 asmlinkage void plat_irq_dispatch(void)
 {
 	unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
-	unsigned int i;
-
-	if ((MIPS_CPU_TIMER_IRQ == 7) && (pending & CAUSEF_IP7)) {
-		do_IRQ(MIPS_CPU_TIMER_IRQ);
-		goto out;
-	} else {
-		for (i = 0; i < MAX_IM; i++) {
-			if (pending & (CAUSEF_IP2 << i)) {
-				ltq_hw_irqdispatch(i);
-				goto out;
-			}
-		}
+	int irq;
+
+	if (!pending) {
+		spurious_interrupt();
+		return;
 	}
-	pr_alert("Spurious IRQ: CAUSE=0x%08x\n", read_c0_status());
 
-out:
-	return;
+	pending >>= CAUSEB_IP;
+	while (pending) {
+		irq = fls(pending) - 1;
+		do_IRQ(MIPS_CPU_IRQ_BASE + irq);
+		pending &= ~BIT(irq);
+	}
 }
 
 static int icu_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
@@ -354,11 +355,6 @@ static const struct irq_domain_ops irq_domain_ops = {
 	.map = icu_map,
 };
 
-static struct irqaction cascade = {
-	.handler = no_action,
-	.name = "cascade",
-};
-
 int __init icu_of_init(struct device_node *node, struct device_node *parent)
 {
 	struct device_node *eiu_node;
@@ -390,7 +386,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
 	mips_cpu_irq_init();
 
 	for (i = 0; i < MAX_IM; i++)
-		setup_irq(i + 2, &cascade);
+		irq_set_chained_handler(i + 2, ltq_hw_irq_handler);
 
 	if (cpu_has_vint) {
 		pr_info("Setting up vectored interrupts\n");
-- 
2.7.4

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

* Re: [PATCH for-4.4 7/7] MIPS: Lantiq: Fix cascaded IRQ setup
@ 2017-04-06 13:19     ` James Hogan
  0 siblings, 0 replies; 11+ messages in thread
From: James Hogan @ 2017-04-06 13:19 UTC (permalink / raw)
  To: Amit Pundir; +Cc: gregkh, stable, Felix Fietkau, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]

Hi Amit,

On Thu, Apr 06, 2017 at 06:19:00PM +0530, Amit Pundir wrote:
> From: Felix Fietkau <nbd@nbd.name>
> 
> With the IRQ stack changes integrated, the XRX200 devices started
> emitting a constant stream of kernel messages like this:
> 
> [  565.415310] Spurious IRQ: CAUSE=0x1100c300
> 
> This is caused by IP0 getting handled by plat_irq_dispatch() rather than
> its vectored interrupt handler, which is fixed by commit de856416e714
> ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").
> 
> Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
> by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
> for all MIPS CPU interrupts.
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> Acked-by: John Crispin <john@phrozen.org>
> Cc: linux-mips@linux-mips.org
> Patchwork: https://patchwork.linux-mips.org/patch/15077/
> [james.hogan@imgtec.com: tweaked commit message]
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> 
> (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>

Weren't you going to drop this one?

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH for-4.4 7/7] MIPS: Lantiq: Fix cascaded IRQ setup
@ 2017-04-06 13:19     ` James Hogan
  0 siblings, 0 replies; 11+ messages in thread
From: James Hogan @ 2017-04-06 13:19 UTC (permalink / raw)
  To: Amit Pundir; +Cc: gregkh, stable, Felix Fietkau, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]

Hi Amit,

On Thu, Apr 06, 2017 at 06:19:00PM +0530, Amit Pundir wrote:
> From: Felix Fietkau <nbd@nbd.name>
> 
> With the IRQ stack changes integrated, the XRX200 devices started
> emitting a constant stream of kernel messages like this:
> 
> [  565.415310] Spurious IRQ: CAUSE=0x1100c300
> 
> This is caused by IP0 getting handled by plat_irq_dispatch() rather than
> its vectored interrupt handler, which is fixed by commit de856416e714
> ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").
> 
> Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
> by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
> for all MIPS CPU interrupts.
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> Acked-by: John Crispin <john@phrozen.org>
> Cc: linux-mips@linux-mips.org
> Patchwork: https://patchwork.linux-mips.org/patch/15077/
> [james.hogan@imgtec.com: tweaked commit message]
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> 
> (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>

Weren't you going to drop this one?

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH for-4.4 7/7] MIPS: Lantiq: Fix cascaded IRQ setup
  2017-04-06 13:19     ` James Hogan
  (?)
@ 2017-04-06 13:25     ` Amit Pundir
  -1 siblings, 0 replies; 11+ messages in thread
From: Amit Pundir @ 2017-04-06 13:25 UTC (permalink / raw)
  To: James Hogan; +Cc: Greg Kroah-Hartman, stable, Felix Fietkau, linux-mips

Hi,

On 6 April 2017 at 18:49, James Hogan <james.hogan@imgtec.com> wrote:
> Hi Amit,
>
> On Thu, Apr 06, 2017 at 06:19:00PM +0530, Amit Pundir wrote:
>> From: Felix Fietkau <nbd@nbd.name>
>>
>> With the IRQ stack changes integrated, the XRX200 devices started
>> emitting a constant stream of kernel messages like this:
>>
>> [  565.415310] Spurious IRQ: CAUSE=0x1100c300
>>
>> This is caused by IP0 getting handled by plat_irq_dispatch() rather than
>> its vectored interrupt handler, which is fixed by commit de856416e714
>> ("MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch").
>>
>> Fix plat_irq_dispatch() to handle non-vectored IPI interrupts correctly
>> by setting up IP2-6 as proper chained IRQ handlers and calling do_IRQ
>> for all MIPS CPU interrupts.
>>
>> Signed-off-by: Felix Fietkau <nbd@nbd.name>
>> Acked-by: John Crispin <john@phrozen.org>
>> Cc: linux-mips@linux-mips.org
>> Patchwork: https://patchwork.linux-mips.org/patch/15077/
>> [james.hogan@imgtec.com: tweaked commit message]
>> Signed-off-by: James Hogan <james.hogan@imgtec.com>
>>
>> (cherry picked from commit 6c356eda225e3ee134ed4176b9ae3a76f793f4dd)
>> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
>
> Weren't you going to drop this one?

I thought you wanted me to drop this one because the
dependent/relevant patches were not pushed to stable at that time. But
I re-read your email and I missed one important part that this
particular patch is valid for a separate bug introduced in IRQ stack
stuff in 4.11. I missed that important part. My apologies for that.
Again.

Greg please drop this one for both 4.4 and 4.9.

Regards,
Amit Pundir

>
> Cheers
> James

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

end of thread, other threads:[~2017-04-06 13:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06 12:48 [PATCH for-4.4 0/7] mips: IRQ stack patches from LEDE Amit Pundir
2017-04-06 12:48 ` [PATCH for-4.4 1/7] MIPS: Introduce irq_stack Amit Pundir
2017-04-06 12:48 ` [PATCH for-4.4 2/7] MIPS: Stack unwinding while on IRQ stack Amit Pundir
2017-04-06 12:48 ` [PATCH for-4.4 3/7] MIPS: Only change $28 to thread_info if coming from user mode Amit Pundir
2017-04-06 12:48 ` [PATCH for-4.4 4/7] MIPS: Switch to the irq_stack in interrupts Amit Pundir
2017-04-06 12:48 ` [PATCH for-4.4 5/7] MIPS: Select HAVE_IRQ_EXIT_ON_IRQ_STACK Amit Pundir
2017-04-06 12:48 ` [PATCH for-4.4 6/7] MIPS: IRQ Stack: Fix erroneous jal to plat_irq_dispatch Amit Pundir
2017-04-06 12:49 ` [PATCH for-4.4 7/7] MIPS: Lantiq: Fix cascaded IRQ setup Amit Pundir
2017-04-06 13:19   ` James Hogan
2017-04-06 13:19     ` James Hogan
2017-04-06 13:25     ` Amit Pundir

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.