All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: u-boot leaves watchdog enabled by default
Date: Tue, 22 Sep 2020 02:52:36 +0200	[thread overview]
Message-ID: <8b920b94-6a27-4191-9f68-c6c486fb06fc@gmx.de> (raw)
In-Reply-To: <40c5d7ba798c9cf51a32cf5cb3882fea@walle.cc>

On 9/21/20 10:56 PM, Michael Walle wrote:
> Hi,
>
> Am 2020-09-21 20:50, schrieb Tom Rini:
>> On Mon, Sep 21, 2020 at 08:29:00PM +0200, Heinrich Schuchardt wrote:
>>> On 9/21/20 7:30 PM, Tom Rini wrote:
>>> > On Mon, Sep 21, 2020 at 11:01:37AM +0200, Stefan Roese wrote:
>>> >> Hi Michael,
>>> >> Hi Chris,
>>> >>
>>> >> On 15.09.20 12:44, Chris Packham wrote:
>>> >>>
>>> >>>
>>> >>> On Tue, 15 Sep 2020, 7:54 PM Michael Walle, <michael@walle.cc>
>>> wrote:
>>> >>>
>>> >>>???? Am 2020-09-15 09:44, schrieb Rayagonda Kokatanur:
>>> >>>????? > On Tue, Sep 15, 2020 at 12:56 PM Michael Walle
>>> <michael@walle.cc>
>>> >>>????? > wrote:
>>> >>>????? >>
>>> >>>????? >> Hi Stefan,
>>> >>>????? >>
>>> >>>????? >> it appears that since commit 06985289d45 ("watchdog:
>>> Implement
>>> >>>???? generic
>>> >>>????? >> watchdog_reset() version") - by default - the first
>>> watchdog is
>>> >>>????? >> started
>>> >>>????? >> unconditionally if CONFIG_WDT is set but never stopped
>>> before
>>> >>>???? booting
>>> >>>????? >> the operating system.
>>> >>>????? >>
>>> >>>????? >> Shouldn't it also be stopped uncondionally? What's worse
>>> is that on
>>> >>>????? >> one
>>> >>>????? >> board/arch the watchdog is stopped in arch_preboot_os()
>>> which is
>>> >>>???? never
>>>
>>> Which board are you referring to?
>
> See the commit above. It is board/alliedtelesis/x530/x530.c. It might
> not use
> EFI, but I tried to use it as a blueprint to disable the watchdog by
> default
> and then noticed it won't work in the bootefi case (and I guess the 'go'
> case).
>
>>>
>>> >>>????? >> called in the bootefi case. So even if I'd do a
>>> workaround and
>>> >>>???? stop it
>>> >>>????? >> manually in my board code, I couldn't do that
>>> consistently for
>>> >>>????? >> bootm/bootefi.
>>> >>>????? >>
>>> >>>????? >> Or am I missing something here?
>>> >>>????? >
>>> >>>????? > Define CONFIG_WATCHDOG.
>>> >>>????? > This takes care of resetting wdt.
>>> >>>
>>> >>>???? Yes as along as you're inside the bootloader, but when u-boot
>>> hands
>>> >>>???? control over the OS the watchdog is not serviced anymore;
>>> which wouldn't
>>> >>>???? be a problem per se, but it is enabled unconditionally by
>>> u-boot.
>>> >>>
>>> >>>
>>> >>> Just to add some data. At $dayjob we use this behaviour as a
>>> failsafe to
>>> >>> make sure our userspace gets to a point where it is servicing the
>>> >>> watchdog.
>>> >>
>>> >> Yes, this is exactly how this is supposed to work AFAIK.
>>> >>
>>> >> Michael, are you sure that the watchdog was disabled in U-Boot when
>>> >> booting into the OS before this patch?
>>> >>
>>> >>> That said having a leave-wdt-running environment variable would
>>> work for
>>> >>> our use case.
>>> >>
>>> >> I would rather use it the other way around. Something like "wdt-stop-
>>> >> pre-os" to optionally stop the WDT before booting into the OS.
>>> >>
>>> >> Remark:
>>> >> IMHO, if you don't use the WDT in the OS, it does not make much sense
>>> >> to enable the WDT in U-Boot.
>>> >
>>> > Yes, we need to be very careful about making it so that a watchdog is
>>> > disabled and not re-enabled before moving on for a whole bunch of
>>> > reasons.? And the best option would be to just disable the watchdog if
>>> > it won't be used while the device is running the OS.
>>> >
>>>
>>> The requirement of the UEFI specification is that if booting fails a
>>> system should reset after five minutes by default. We ensure this in the
>>> UEFI sub-system before ExitBootServices() using an EFI timer event.
>>>
>>> In the UEFI sub-system we currently call in ExitBootServices():
>>>
>>> ??????? efi_set_watchdog(0); /* this disables the EFI timer */
>>> ??????? WATCHDOG_RESET();
>>>
>>> Is there any requirement to do more?
>>
>> For EFI or ?? What I'm saying is that the watchdog must be left running
>> and not stopped, if we either:
>> - Came in to the world with the watchdog running AND were not
>> ? specifically told to disable the watching.
>> - Came in to the world and were told to enable a watchdog.
>
> My reason to start this thread was the fact that a watchdog is started
> by default in a generic way (i.e. initr_watchdog()) but there is _no_
> way to disable it. I'm having a minimal board configuration and I want
> to be able to boot the debian-installer via EFI -> grub-efi -> d-i.
> The debian installer is not aware of any watchdog. Thus if u-boot
> leave it running, it might bite at very inconvenient times like
> half through the installation.
>
> I'm fine with having a unified way to disable the watchdog per board,
> let it be a CONFIG_WDT_NO_START or a #define ENV "wdt-stop-pre-os", but
> it should work with bootm/booti/go/bootefi.
>
>> It's that first case with the AND I'm concerned with in general and this
>> thread.
>>
>> For the EFI case, I assume right now we aren't strictly adhering to the
>> 5 minute rule, but I also assume there's some way for UEFI to tell us to
>> call WATCHDOG_RESET() as needed.
>
> EFI timers seems to be unrelated to the watchdog, right?

The UEFI spec requires a watchdog with 5 min default time that can be be
manipulated via the UEFI API. To be independent of what the hardware
offers I implemented it only relying on timer ticks and not actually
using a hardware watchdog. Hence the current implementation does not
interfere with hardware watchdogs.

Best regards

Heinrich

  parent reply	other threads:[~2020-09-22  0:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15  7:26 u-boot leaves watchdog enabled by default Michael Walle
2020-09-15  7:44 ` Rayagonda Kokatanur
2020-09-15  7:54   ` Michael Walle
2020-09-15 10:44     ` Chris Packham
2020-09-21  9:01       ` Stefan Roese
2020-09-21 17:30         ` Tom Rini
2020-09-21 18:29           ` Heinrich Schuchardt
2020-09-21 18:50             ` Tom Rini
2020-09-21 20:56               ` Michael Walle
2020-09-21 21:10                 ` Chris Packham
2020-09-22  0:52                 ` Heinrich Schuchardt [this message]
2020-09-22  1:18                 ` Tom Rini
2020-09-22  6:59                   ` Michael Walle
2020-09-22 12:36                     ` Tom Rini
2020-09-22 13:18                       ` Michael Walle
2020-09-22 14:41                         ` Tom Rini
2020-09-22 15:41                           ` Michael Walle
2020-09-22 15:55                             ` Tom Rini
2020-09-21 20:41         ` Michael Walle

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=8b920b94-6a27-4191-9f68-c6c486fb06fc@gmx.de \
    --to=xypron.glpk@gmx.de \
    --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 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.