From: "Pali Rohár" <pali@kernel.org>
To: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Tom Rini <trini@konsulko.com>, Stefan Roese <sr@denx.de>,
u-boot@lists.denx.de
Subject: Re: Broken watchdog in u-boot master branch
Date: Tue, 11 Oct 2022 09:25:43 +0200 [thread overview]
Message-ID: <20221011072543.wp666tzuf7hdeny2@pali> (raw)
In-Reply-To: <cfc802e1-9f39-1fb1-ed31-daac9606ce36@prevas.dk>
On Tuesday 11 October 2022 09:18:56 Rasmus Villemoes wrote:
> On 10/10/2022 15.55, Tom Rini wrote:
> > On Sun, Oct 09, 2022 at 09:12:25PM +0200, Pali Rohár wrote:
> >
> >> Hello! Watchdog code seems to be broken in u-boot master branch.
> >> On Nokia N900 I'm getting following message in qemu:
> >>
> >> cyclic function rx51_watchdog took too long: 10000us vs 1000us max, disabling
> >>
> >> Seems that watchdog core code is not prepared for "slower" watchdogs
> >> which communicate over slower i2c bus, like it is the case for N900.
> >>
> >> Disabling slower watchdog is a bad idea as it would result in reboot
> >> loop instead of slower - but working code.
>
> So, a few thoughts.
>
> First, I assume that that board has a very coarse-grained tick, probably
> just 1000Hz.
IIRC i2c is running at 100kHz. But u-boot i2c driver contains more
udelay() calls and more busy loops. And I was told that there are also
some hw erratas. So at the end if some other driver calls u-boot dm
function for i2c transfer, it can spend more time than expected...
Also there is another issue is that udelay() itself calls watchdog reset
function. So if watchdog is on i2c which driver calls udelay() it means
that watchdog reset function may be called in infinite loop. For this
reason n900 watchdog driver has lock which prevents and eliminate this
loop (if somebody calls reset during active lock then reset does
nothing).
> Otherwise it would be pretty amazing for cpu_time to come
> out as 10ms exactly. That's not the board's fault, of course, just an
> observation, but it is something we need to bear in mind. If the
> resolution is merely 100Hz, so 10ms is simply the granularity, we cannot
> really meaningfully compare the cpu_time to anything less than that,
> because every once in a while it _will_ happen that we sample "now" just
> before the tick, run the function, then sample again just after, and it
> may only have taken 17us, yet the diff comes out as 10ms.
>
> Second, perhaps the threshold should not be a compile-time constant, but
> instead a fraction of the requested call frequency (say 1.5%, 1/64).
> I.e., if we've registered a function to be called every 10 seconds, we'd
> check if its runtime exceeded (10000000 >> 6) us. Preferably per above
> that bound is rounded up to a multiple of the timer's granularity (we
> can get that, right?)
>
> Third, perhaps we shouldn't disable it, but just print a (one-time)
> warning. Adding a "already-warned" field to struct cyclic_info is
> certainly simple enough.
>
> Rasmus
next prev parent reply other threads:[~2022-10-11 7:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-09 19:12 Broken watchdog in u-boot master branch Pali Rohár
2022-10-10 13:55 ` Tom Rini
2022-10-10 16:19 ` Pali Rohár
2022-10-11 7:18 ` Rasmus Villemoes
2022-10-11 7:25 ` Pali Rohár [this message]
2022-10-17 6:52 ` Stefan Roese
2022-10-10 16:28 ` Tom Rini
2022-10-10 17:22 ` Pali Rohár
2022-10-10 17:40 ` Tom Rini
2022-10-10 17:44 ` Pali Rohár
2022-10-10 17:56 ` Tom Rini
2022-10-10 18:01 ` Pali Rohár
2022-10-10 18:14 ` Tom Rini
2022-10-10 19:24 ` Tom Rini
2022-10-10 19:33 ` Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221011072543.wp666tzuf7hdeny2@pali \
--to=pali@kernel.org \
--cc=rasmus.villemoes@prevas.dk \
--cc=sr@denx.de \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox