Skip to contentSkip to conversation

watchdog: Fix watchdog enablement in SPL and TPL

PATCH In review Marek Vasut 3 participants 6 messages Aug 30, 2021 – Sep 2, 2021 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: Fix watchdog enablement in SPL and TPL

Commit 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog") completely broke WDT operation in both SPL and TPL, in either case those WDTs are never enabled. Fix it by filling in the missing Kconfig options for SPL and TPL.

Fixes 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog")
Cc Pali Rohar <[email protected]>
Cc Stefan Roese <[email protected]>
---
 drivers/watchdog/Kconfig | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/watchdog/Kconfig +20 -0
index f0ff2612a6b..65d974c4dd5 100644
@@ -273,4 +273,24 @@ config SPL_WDT
 	  Enable driver model for watchdog timer in SPL.
 	  This is similar to CONFIG_WDT in U-Boot.
 
+config SPL_WATCHDOG_AUTOSTART
+	bool "Automatically start watchdog timer in SPL"
+	depends on SPL && WDT
+	default y
+	help
+	  Automatically start watchdog timer and start servicing it during
+	  SPL phase. Enabled by default. Disable this option if you want
+	  to compile U-Boot with CONFIG_WDT support but do not want to
+	  activate watchdog, like when CONFIG_WDT option is disabled.
+
+config TPL_WATCHDOG_AUTOSTART
+	bool "Automatically start watchdog timer in TPL"
+	depends on TPL && WDT
+	default y
+	help
+	  Automatically start watchdog timer and start servicing it during
+	  TPL phase. Enabled by default. Disable this option if you want
+	  to compile U-Boot with CONFIG_WDT support but do not want to
+	  activate watchdog, like when CONFIG_WDT option is disabled.
+
 endmenu
Signature · 1 line
2.33.0
#1 lore raw

Hi Marek

Quoted 41 lines · Marek Vasut

Commit 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog") completely broke WDT operation in both SPL and TPL, in either case those WDTs are never enabled. Fix it by filling in the missing Kconfig options for SPL and TPL.

Fixes 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog")
Cc Pali Rohar <[email protected]>
Cc Stefan Roese <[email protected]>

---
 drivers/watchdog/Kconfig | 20 ++++++++++++++++++++

 1 file changed, 20 insertions(+)
drivers/watchdog/Kconfig +0 -0
index f0ff2612a6b..65d974c4dd5 100644
@@ -273,4 +273,24 @@ config SPL_WDT

          Enable driver model for watchdog timer in SPL. This is similar to CONFIG_WDT in U-Boot.

drivers/watchdog/Kconfig +20 -0
+config SPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in SPL"
+       depends on SPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
+         SPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to
+         activate watchdog, like when CONFIG_WDT option is disabled.
+
+config TPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in TPL"
+       depends on TPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
+         TPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to
+         activate watchdog, like when CONFIG_WDT option is disabled.
+
Quoted 1 line

 endmenu

Those Kconfig entries look fine. However, I am wondering where exactly they get used. Am I missing anything?

Cheers

Marcel

#2 lore raw
Quoted 39 lines · Marcel Ziswiler

Hi Marek

Quoted 36 lines · Marek Vasut

Commit 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog") completely broke WDT operation in both SPL and TPL, in either case those WDTs are never enabled. Fix it by filling in the missing Kconfig options for SPL and TPL.

Fixes 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog")
Cc Pali Rohar <[email protected]>
Cc Stefan Roese <[email protected]>
---
  drivers/watchdog/Kconfig | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/watchdog/Kconfig +15 -0
index f0ff2612a6b..65d974c4dd5 100644
@@ -273,4 +273,24 @@ config SPL_WDT
           Enable driver model for watchdog timer in SPL.
           This is similar to CONFIG_WDT in U-Boot.
 
+config SPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in SPL"
+       depends on SPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
+         SPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to
+         activate watchdog, like when CONFIG_WDT option is disabled.
+
+config TPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in TPL"
+       depends on TPL && WDT
+       default y
+       help
Quoted 8 lines

drivers/watchdog/Kconfig config SPL_WDT · line 296

Quoted 6 lines
drivers/watchdog/Kconfig +5 -0
+         Automatically start watchdog timer and start servicing it during
+         TPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to
+         activate watchdog, like when CONFIG_WDT option is disabled.
+
  endmenu

Those Kconfig entries look fine. However, I am wondering where exactly they get used. Am I missing anything?

Have a look at the patch this Fixes:, if those Kconfig entries are not present, the WDT is disabled in SPL and TPL unconditionally.

It could be that if you're using some non-free or proprietary preloader instead of SPL, you won't run into this problem.

#3 lore raw
Quoted 50 lines · Marek Vasut
Quoted 40 lines · Marcel Ziswiler

Hi Marek

Quoted 37 lines · Marek Vasut

Commit 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog") completely broke WDT operation in both SPL and TPL, in either case those WDTs are never enabled. Fix it by filling in the missing Kconfig options for SPL and TPL.

Fixes 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog")
Cc Pali Rohar <[email protected]>
Cc Stefan Roese <[email protected]>

---
  drivers/watchdog/Kconfig | 20 ++++++++++++++++++++

  1 file changed, 20 insertions(+)
drivers/watchdog/Kconfig +0 -0
index f0ff2612a6b..65d974c4dd5 100644
@@ -273,4 +273,24 @@ config SPL_WDT

           Enable driver model for watchdog timer in SPL. This is similar to CONFIG_WDT in U-Boot.

drivers/watchdog/Kconfig +16 -0
+config SPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in SPL"
+       depends on SPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
+         SPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to
+         activate watchdog, like when CONFIG_WDT option is disabled.
+
+config TPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in TPL"
+       depends on TPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
Quoted 8 lines
Quoted 5 lines

+         TPL phase. Enabled by default. Disable this option if you want +         to compile U-Boot with CONFIG_WDT support but do not want to +         activate watchdog, like when CONFIG_WDT option is disabled. +
  endmenu

Those Kconfig entries look fine. However, I am wondering where exactly they get used. Am I missing anything?

Quoted 2 lines

Have a look at the patch this Fixes:, if those Kconfig entries are not present, the WDT is disabled in SPL and TPL unconditionally.

Yes, I did. But I guess I was not aware of how exactly that CONFIG_IS_ENABLED(WATCHDOG_AUTOSTART) behaves. While I have not really found this documented or the implementation thereof I assume it pre-fixes config stuff with SPL_ resp. TPL_ when building those flavors, correct?

I am wondering how many others are unaware of this (just like the author of the patch this fixes). Maybe we should at least document this properly somewhere, not?

Quoted 2 lines

It could be that if you're using some non-free or proprietary preloader instead of SPL, you won't run into this problem.

No, don't worry. I am not running anything evil (;-p).

Reviewed-by
#4 lore raw
Quoted 51 lines · Marcel Ziswiler
Quoted 50 lines · Marek Vasut
Quoted 48 lines · Marcel Ziswiler

Hi Marek

Quoted 32 lines · Marek Vasut

Commit 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog") completely broke WDT operation in both SPL and TPL, in either case those WDTs are never enabled. Fix it by filling in the missing Kconfig options for SPL and TPL.

Fixes 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog")
Cc Pali Rohar <[email protected]>
Cc Stefan Roese <[email protected]>
---
   drivers/watchdog/Kconfig | 20 ++++++++++++++++++++
   1 file changed, 20 insertions(+)
drivers/watchdog/Kconfig +11 -0
index f0ff2612a6b..65d974c4dd5 100644
@@ -273,4 +273,24 @@ config SPL_WDT
            Enable driver model for watchdog timer in SPL.
            This is similar to CONFIG_WDT in U-Boot.
 
+config SPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in SPL"
+       depends on SPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
+         SPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to
+         activate watchdog, like when CONFIG_WDT option is disabled.
+
+config TPL_WATCHDOG_AUTOSTART

drivers/watchdog/Kconfig config SPL_WDT · line 296

Quoted 10 lines
drivers/watchdog/Kconfig +9 -0
+       bool "Automatically start watchdog timer in TPL"
+       depends on TPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
+         TPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to
+         activate watchdog, like when CONFIG_WDT option is disabled.
+
   endmenu

Those Kconfig entries look fine. However, I am wondering where exactly they get used. Am I missing anything?

Quoted 8 lines
Quoted 2 lines

Have a look at the patch this Fixes:, if those Kconfig entries are not present, the WDT is disabled in SPL and TPL unconditionally.

Yes, I did. But I guess I was not aware of how exactly that CONFIG_IS_ENABLED(WATCHDOG_AUTOSTART) behaves.
While I have not really found this documented or the implementation thereof I assume it pre-fixes config stuff
with SPL_ resp. TPL_ when building those flavors, correct?

Yes.

Quoted 3 lines

I am wondering how many others are unaware of this (just like the author of the patch this fixes). Maybe we
should at least document this properly somewhere, not?

If this is not the case (I did not check this), then yes. A documentation for these CONFIG_IS_ENABLED() and IS_ENABLED() helpers would be very good.

Quoted 4 lines
Quoted 2 lines

It could be that if you're using some non-free or proprietary preloader instead of SPL, you won't run into this problem.

No, don't worry. I am not running anything evil (;-p).

You won't run into any issues with this problem, as it is fixed in a different way in master already, as Rasmus already pointed out:

https://lore.kernel.org/u-boot/[email protected]/

$ git describe --contains 5fc094351381c4254098a25404d8712324b6918e
v2021.10-rc1~19^2

commit 5fc094351381c4254098a25404d8712324b6918e

Author: Teresa Remmet <[email protected]>
Date:   Thu Jul 15 13:26:32 2021 +0200

drivers: watchdog: wdt-uclass: Use IS_ENABLED for WATCHDOG_AUTOSTART

There is no separate SPL/TPL config for WATCHDOG_AUTOSTART. So use IS_ENABLED instead of CONFIG_IS_ENABLED to make watchdog working in SPL again.

Fixes 830d29ac3721 ("watchdog: Allow to use CONFIG_WDT without

starting watchdog")

drivers/watchdog/wdt-uclass.c +1 -1
index a0c2429e5a43..17334dbda6c9 100644
@@ -53,7 +53,7 @@ int initr_watchdog(void)
                                                    4 * reset_period) / 4;
        }
 
-       if (!CONFIG_IS_ENABLED(WATCHDOG_AUTOSTART)) {
+       if (!IS_ENABLED(CONFIG_WATCHDOG_AUTOSTART)) {
                printf("WDT:   Not starting\n");
                return 0;
        }
#5 lore raw
Quoted 66 lines · Stefan Roese
Quoted 54 lines · Marcel Ziswiler
Quoted 53 lines · Marek Vasut
Quoted 51 lines · Marcel Ziswiler

Hi Marek

Quoted 38 lines · Marek Vasut

Commit 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog") completely broke WDT operation in both SPL and TPL, in either case those WDTs are never enabled. Fix it by filling in the missing Kconfig options for SPL and TPL.

Fixes 830d29ac372 ("watchdog: Allow to use CONFIG_WDT without starting watchdog")
Cc Pali Rohar <[email protected]>
Cc Stefan Roese <[email protected]>

---
   drivers/watchdog/Kconfig | 20 ++++++++++++++++++++

   1 file changed, 20 insertions(+)
drivers/watchdog/Kconfig +0 -0
index f0ff2612a6b..65d974c4dd5 100644
@@ -273,4 +273,24 @@ config SPL_WDT

            Enable driver model for watchdog timer in SPL. This is similar to CONFIG_WDT in U-Boot. +config SPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in SPL"
+       depends on SPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it during
+         SPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to +         activate watchdog, like when CONFIG_WDT option is disabled.

drivers/watchdog/Kconfig +7 -0
+
+config TPL_WATCHDOG_AUTOSTART
+       bool "Automatically start watchdog timer in TPL"
+       depends on TPL && WDT
+       default y
+       help
+         Automatically start watchdog timer and start servicing it 
Quoted 7 lines

during
+         TPL phase. Enabled by default. Disable this option if you want
+         to compile U-Boot with CONFIG_WDT support but do not want to +         activate watchdog, like when CONFIG_WDT option is disabled. +
   endmenu

Those Kconfig entries look fine. However, I am wondering where exactly they get used. Am I missing anything?

Quoted 8 lines
Quoted 2 lines

Have a look at the patch this Fixes:, if those Kconfig entries are not present, the WDT is disabled in SPL and TPL unconditionally.

Yes, I did. But I guess I was not aware of how exactly that CONFIG_IS_ENABLED(WATCHDOG_AUTOSTART) behaves.
While I have not really found this documented or the implementation thereof I assume it pre-fixes config stuff
with SPL_ resp. TPL_ when building those flavors, correct?

Yes.

Quoted 7 lines
Quoted 3 lines

I am wondering how many others are unaware of this (just like the author of the patch this fixes). Maybe we
should at least document this properly somewhere, not?

If this is not the case (I did not check this), then yes. A documentation for these CONFIG_IS_ENABLED() and IS_ENABLED() helpers would be very good.

You can possibly even auto-lint for CONFIG_IS_ENABLED(...)/IS_ENABLED(...) usage that is missing the Kconfig entries and warn about that, to prevent patches that break SPL/TPL .

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

It could be that if you're using some non-free or proprietary preloader instead of SPL, you won't run into this problem.

No, don't worry. I am not running anything evil (;-p).

You won't run into any issues with this problem, as it is fixed in a different way in master already, as Rasmus already pointed out:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 6 lines
$ git describe --contains 5fc094351381c4254098a25404d8712324b6918e
v2021.10-rc1~19^2

commit 5fc094351381c4254098a25404d8712324b6918e
Author: Teresa Remmet <[email protected]>
Date:   Thu Jul 15 13:26:32 2021 +0200

Yes.