From 11c2c9223688c9d8d5833ab1d0d9dd7dfdca635d Mon Sep 17 00:00:00 2001 From: Dino Li Date: Wed, 16 Dec 2015 18:31:07 +0800 Subject: nds32: start_irq_handler() use system stack [symptom] The 'vboot_hash_start()' always return busy error and variable 'in_progress' got a strange value(should be 0 or 1). 'start_irq_handler()' causes scratchpad overflow in first context switch. It must be called after SP switch to system stack in ISR. NOTE: The scratchpad is still also need more size even if 'start_irq_handler()' is using system stack. following is detail: 1. uint32_t scratchpad[19] 0x81d34 ~ 0x81d7f [__task_start:] 2. /* put the dummy stack pointer at the top of the stack in scratchpad */ addi $sp, $r3, 4 * 18 -> SP 0x81d7c 3. syscall push return address (-4) -> SP 0x81d78 [ISR:] 4. push r15, fp, lp, and sp (-0x10) -> SP 0x81d68 5. push r0 ~ r5 (-0x18) -> SP 0x81d50 [__switch_task:] 6. /* save ipsw, ipc, r6, r7, r8, r9, r10 on the current process stack */ (-0x1C) -> SP 0x81d34 Signed-off-by: Dino Li BRANCH=none BUG=none TEST=1. hash done. 2. console command 'taskinfo'. 3. the scratchpad does not overflow after first context switch. Change-Id: If5d89ff5c945a777010492fcfb54bf41f434ed69 Reviewed-on: https://chromium-review.googlesource.com/317468 Commit-Ready: Dino Li Tested-by: Dino Li Reviewed-by: Randall Spangler --- core/nds32/init.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/nds32/init.S') diff --git a/core/nds32/init.S b/core/nds32/init.S index 1f0b5c28e6..1f9c71b3c6 100644 --- a/core/nds32/init.S +++ b/core/nds32/init.S @@ -20,13 +20,13 @@ __entry_\()\name: smw.adm $r15, [$sp], $r15, 0xb /* r0-r5 are caller saved */ smw.adm $r0, [$sp], $r5, 0 - /* isr entry */ - jal start_irq_handler /* switch to system stack if we are called from process stack */ la $r3, stack_end mov55 $fp, $sp slt45 $r3, $sp /* if sp > end of system stack, then r15 = 1 and */ cmovn $sp, $r3, $r15 /* point sp to the top of the system stack */ + /* isr entry */ + jal start_irq_handler /* C routine handler */ jal \name\()_handler /* check whether we need to change the scheduled task */ -- cgit v1.2.1