* [PATCH] powerpc: allow opting out of WATCHDOG_RESET() from timer interrupt
@ 2020-03-16 21:15 Rasmus Villemoes
2020-03-18 15:16 ` [PATCH v2] " Rasmus Villemoes
0 siblings, 1 reply; 3+ messages in thread
From: Rasmus Villemoes @ 2020-03-16 21:15 UTC (permalink / raw)
To: u-boot
When using CONFIG_(SPL_)WDT, the watchdog_reset function is a lot more
complicated than just poking a few SOC-specific registers - it
involves accessing all kinds of global data, and if the interrupt
happens at the wrong time (say, in the middle of an WATCHDOG_RESET()
call from ordinary code), that can end up corrupting said global data.
Also, having WATCHDOG_RESET() called automatically from the timer
interrupt runs counter to the idea of a watchdog device - if the board
runs into an infinite loops with interrupts still enabled, the
watchdog will never fire.
Allow the board to opt out of this behaviour by setting
CONFIG_SYS_WATCHDOG_FREQ to 0 - as that setting is currently
nonsensical, it cannot affect any existing boards.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
arch/powerpc/lib/interrupts.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c
index 64ee0cc210..23ac5bca1e 100644
--- a/arch/powerpc/lib/interrupts.c
+++ b/arch/powerpc/lib/interrupts.c
@@ -79,7 +79,7 @@ void timer_interrupt(struct pt_regs *regs)
timestamp++;
#if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
- if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
+ if (CONFIG_SYS_WATCHDOG_FREQ && (timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
WATCHDOG_RESET ();
#endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] powerpc: allow opting out of WATCHDOG_RESET() from timer interrupt
2020-03-16 21:15 [PATCH] powerpc: allow opting out of WATCHDOG_RESET() from timer interrupt Rasmus Villemoes
@ 2020-03-18 15:16 ` Rasmus Villemoes
2020-03-19 9:10 ` Wolfgang Denk
0 siblings, 1 reply; 3+ messages in thread
From: Rasmus Villemoes @ 2020-03-18 15:16 UTC (permalink / raw)
To: u-boot
When using CONFIG_(SPL_)WDT, the watchdog_reset function is a lot more
complicated than just poking a few SOC-specific registers - it
involves accessing all kinds of global data, and if the interrupt
happens at the wrong time (say, in the middle of an WATCHDOG_RESET()
call from ordinary code), that can end up corrupting said global data.
Also, having WATCHDOG_RESET() called automatically from the timer
interrupt runs counter to the idea of a watchdog device - if the board
runs into an infinite loops with interrupts still enabled, the
watchdog will never fire.
Allow the board to opt out of this behaviour by setting
CONFIG_SYS_WATCHDOG_FREQ to 0 - as that setting is currently
nonsensical, it cannot affect any existing boards.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
v2: add comment explaining the semantics of setting CONFIG_SYS_WATCHDOG_FREQ to 0.
arch/powerpc/lib/interrupts.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c
index 64ee0cc210..b213e40578 100644
--- a/arch/powerpc/lib/interrupts.c
+++ b/arch/powerpc/lib/interrupts.c
@@ -79,7 +79,12 @@ void timer_interrupt(struct pt_regs *regs)
timestamp++;
#if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG)
- if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
+ /*
+ * Setting CONFIG_SYS_WATCHDOG_FREQ to 0 can be used to
+ * disable calling WATCHDOG_RESET() from the timer interrupt
+ * function.
+ */
+ if (CONFIG_SYS_WATCHDOG_FREQ && (timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
WATCHDOG_RESET ();
#endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] powerpc: allow opting out of WATCHDOG_RESET() from timer interrupt
2020-03-18 15:16 ` [PATCH v2] " Rasmus Villemoes
@ 2020-03-19 9:10 ` Wolfgang Denk
0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2020-03-19 9:10 UTC (permalink / raw)
To: u-boot
Dear Rasmus Villemoes,
In message <20200318151651.2510-1-rasmus.villemoes@prevas.dk> you wrote:
> When using CONFIG_(SPL_)WDT, the watchdog_reset function is a lot more
> complicated than just poking a few SOC-specific registers - it
> involves accessing all kinds of global data, and if the interrupt
> happens at the wrong time (say, in the middle of an WATCHDOG_RESET()
> call from ordinary code), that can end up corrupting said global data.
>
> Also, having WATCHDOG_RESET() called automatically from the timer
> interrupt runs counter to the idea of a watchdog device - if the board
> runs into an infinite loops with interrupts still enabled, the
> watchdog will never fire.
>
> Allow the board to opt out of this behaviour by setting
> CONFIG_SYS_WATCHDOG_FREQ to 0 - as that setting is currently
> nonsensical, it cannot affect any existing boards.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
If such a change gets implemented, it should at least be made
consistently, i. e. not only in arch/powerpc/lib/interrupts.c but
also in the timer_interrupt() handler in drivers/timer/mpc83xx_timer.c
and in dtimer_interrupt() in arch/m68k/lib/time.c and wherever else
similar code may exist.
Only changing one plase is not a good idea.
And please add some documentation also to the README.
Thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Our OS who art in CPU, UNIX be thy name.
Thy programs run, thy syscalls done,
In kernel as it is in user!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-19 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16 21:15 [PATCH] powerpc: allow opting out of WATCHDOG_RESET() from timer interrupt Rasmus Villemoes
2020-03-18 15:16 ` [PATCH v2] " Rasmus Villemoes
2020-03-19 9:10 ` Wolfgang Denk
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.