summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-12-06 14:11:14 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-12-08 12:32:41 -0800
commit6f8f51012e924732a72780104f74431dc50950e3 (patch)
tree26a19edcb31d78440ca1ae1659c78b783f20cd9b
parentf62bec57927578aac304c386b070629e0690eb29 (diff)
downloadchrome-ec-6f8f51012e924732a72780104f74431dc50950e3.tar.gz
npcx: watchdog: Log PC on watchdog from exception context
If we watchdog while in exception context, our process PC is not very useful. Log the actual watchdog PC as our SW panic param, stored in R5. BUG=chrome-os-partner:60470 BRANCH=gru TEST=Add "while(1);" in ISR, wait for watchdog, check with 'panicinfo' that saved R5 is our watchdog PC. Change-Id: Idbdf1bc3507cc88e7a944c7bbe24ed87a6720eea Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/417061 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 2404a5e7bff4bed278b22260513132a985fa4004) Reviewed-on: https://chromium-review.googlesource.com/417113 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--chip/npcx/watchdog.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/chip/npcx/watchdog.c b/chip/npcx/watchdog.c
index 0b570df76a..d4f3f63134 100644
--- a/chip/npcx/watchdog.c
+++ b/chip/npcx/watchdog.c
@@ -59,6 +59,8 @@ static uint8_t watchdog_count(void)
void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp)
{
int wd_cnt;
+ uint32_t panic_info;
+
/* Clear timeout status for event */
SET_BIT(NPCX_ITCTS(ITIM_WDG_NO), NPCX_ITCTS_TO_STS);
@@ -76,14 +78,20 @@ void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp)
/* Print panic info */
watchdog_trace(excep_lr, excep_sp);
cflush();
-#ifdef CONFIG_SOFTWARE_PANIC
+
+ /*
+ * Log the panic PC if watchdog occurred in exception context
+ * or the watchdog task # otherwise.
+ */
+ panic_info = ((excep_lr & 0xf) == 1) ?
+ ((uint32_t *)excep_sp)[6] : task_get_current();
/*
* panic_reboot() will be called by software_panic(), so this
* typically will not return, and panic reason will appear
* as "soft".
*/
- software_panic(PANIC_SW_WATCHDOG, excep_lr);
-#endif
+ software_panic(PANIC_SW_WATCHDOG, panic_info);
+
/* Trigger watchdog immediately */
system_watchdog_reset();
}