Skip to content

Commit 1dc41e5

Browse files
committed
sh: Fixup 4K irq stacks.
There was a clobber issue with the register we were saving the stack in, so we switch to a register that we handle in the clobber list properly already. This also follows the x86 changes for allowing the softirq checks from hardirq context. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent db9b99d commit 1dc41e5

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

‎arch/sh/kernel/irq.c‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ union irq_ctx {
7878
u32 stack[THREAD_SIZE/sizeof(u32)];
7979
};
8080

81-
static union irq_ctx *hardirq_ctx[NR_CPUS];
82-
static union irq_ctx *softirq_ctx[NR_CPUS];
81+
static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly;
82+
static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly;
8383
#endif
8484

8585
asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
@@ -136,17 +136,24 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
136136
irqctx->tinfo.task = curctx->tinfo.task;
137137
irqctx->tinfo.previous_sp = current_stack_pointer;
138138

139+
/*
140+
* Copy the softirq bits in preempt_count so that the
141+
* softirq checks work in the hardirq context.
142+
*/
143+
irqctx->tinfo.preempt_count =
144+
(irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
145+
(curctx->tinfo.preempt_count & SOFTIRQ_MASK);
146+
139147
__asm__ __volatile__ (
140148
"mov %0, r4 \n"
141-
"mov r15, r9 \n"
149+
"mov r15, r8 \n"
142150
"jsr @%1 \n"
143151
/* swith to the irq stack */
144152
" mov %2, r15 \n"
145153
/* restore the stack (ring zero) */
146-
"mov r9, r15 \n"
154+
"mov r8, r15 \n"
147155
: /* no outputs */
148156
: "r" (irq), "r" (generic_handle_irq), "r" (isp)
149-
/* XXX: A somewhat excessive clobber list? -PFM */
150157
: "memory", "r0", "r1", "r2", "r3", "r4",
151158
"r5", "r6", "r7", "r8", "t", "pr"
152159
);
@@ -194,7 +201,7 @@ void irq_ctx_init(int cpu)
194201
irqctx->tinfo.task = NULL;
195202
irqctx->tinfo.exec_domain = NULL;
196203
irqctx->tinfo.cpu = cpu;
197-
irqctx->tinfo.preempt_count = SOFTIRQ_OFFSET;
204+
irqctx->tinfo.preempt_count = 0;
198205
irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
199206

200207
softirq_ctx[cpu] = irqctx;
@@ -240,10 +247,14 @@ asmlinkage void do_softirq(void)
240247
"mov r9, r15 \n"
241248
: /* no outputs */
242249
: "r" (__do_softirq), "r" (isp)
243-
/* XXX: A somewhat excessive clobber list? -PFM */
244250
: "memory", "r0", "r1", "r2", "r3", "r4",
245251
"r5", "r6", "r7", "r8", "r9", "r15", "t", "pr"
246252
);
253+
254+
/*
255+
* Shouldnt happen, we returned above if in_interrupt():
256+
*/
257+
WARN_ON_ONCE(softirq_count());
247258
}
248259

249260
local_irq_restore(flags);

0 commit comments

Comments
 (0)