Skip to contentSkip to conversation

ARM: reset: Move SYSRESET condition from Makefile into source file

RFC PATCH New Claudius Heine 3 participants 11 messages Nov 27, 2019 – Nov 28, 2019 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +2 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif
Signature · 1 line
2.21.0
#1 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 50 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +1 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 4 lines
arch/arm/lib/reset.c +1 -0
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

#2 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

regards

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch at denx.de

           PGP key: 6FF2 E59F 00C6 BC28 31D8 64C1 1173 CB19 9808 B153
                             Keyserver: hkp://pool.sks-keyservers.net
#3 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 64 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Quoted 7 lines

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

#4 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 69 lines · Marek Vasut
Quoted 68 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

Quoted 5 lines
Quoted 3 lines

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

Not sure what you mean... sysreset implements do_reset:

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.c#L112

But the SPL does not have sysreset in this case, so it needs something different.

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch at denx.de

           PGP key: 6FF2 E59F 00C6 BC28 31D8 64C1 1173 CB19 9808 B153
                             Keyserver: hkp://pool.sks-keyservers.net
#5 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 74 lines · Claudius Heine
Quoted 73 lines · Marek Vasut
Quoted 71 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

Quoted 8 lines
Quoted 1 line

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

Not sure what you mean... sysreset implements do_reset:

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.c#L112

But the SPL does not have sysreset in this case, so it needs something different.

Oh, so you need CONFIG_$(SPL_TPL_)SYSRESET then ?

#6 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 77 lines · Marek Vasut
Quoted 76 lines · Claudius Heine
Quoted 74 lines · Marek Vasut
Quoted 64 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Quoted 7 lines

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

Quoted 8 lines
Quoted 6 lines

Not sure what you mean... sysreset implements do_reset:

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.c#L112

But the SPL does not have sysreset in this case, so it needs something different.

Oh, so you need CONFIG_$(SPL_TPL_)SYSRESET then ?

Well that would probably not enough. I would also need settings for the watchdog, because the SPL does not have DM support, so while u-boot uses CONFIG_WATCHDOG the SPL uses CONFIG_HW_WATCHDOG.

Easier that changing all this is something like this in the board header file (as I described in the commit description):

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

In case of imx6, that way the SPL uses the hw_watchdog_reset from the imx watchdog driver instead of the 'watchdog_reset'.

'watchdog_reset' is not available since that is implemented in wdt-uclass.c and CONFIG_SPL_WDT depends on SPL_DM.

#7 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 94 lines · Claudius Heine
Quoted 77 lines · Marek Vasut
Quoted 76 lines · Claudius Heine
Quoted 74 lines · Marek Vasut
Quoted 64 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Quoted 7 lines

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

Quoted 8 lines
Quoted 6 lines

Not sure what you mean... sysreset implements do_reset:

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.c#L112

But the SPL does not have sysreset in this case, so it needs something different.

Oh, so you need CONFIG_$(SPL_TPL_)SYSRESET then ?

Well that would probably not enough. I would also need settings for the watchdog, because the SPL does not have DM support, so while u-boot uses CONFIG_WATCHDOG the SPL uses CONFIG_HW_WATCHDOG.

Easier that changing all this is something like this in the board header file (as I described in the commit description):

Quoted 6 lines
    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

Can't we add DM watchdog to SPL instead ?

Quoted 5 lines

In case of imx6, that way the SPL uses the hw_watchdog_reset from the imx watchdog driver instead of the 'watchdog_reset'.

'watchdog_reset' is not available since that is implemented in wdt-uclass.c and CONFIG_SPL_WDT depends on SPL_DM.

#8 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 95 lines · Marek Vasut
Quoted 94 lines · Claudius Heine
Quoted 77 lines · Marek Vasut
Quoted 76 lines · Claudius Heine
Quoted 74 lines · Marek Vasut
Quoted 64 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Quoted 7 lines

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

Quoted 8 lines
Quoted 6 lines

Not sure what you mean... sysreset implements do_reset:

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.c#L112

But the SPL does not have sysreset in this case, so it needs something different.

Oh, so you need CONFIG_$(SPL_TPL_)SYSRESET then ?

Well that would probably not enough. I would also need settings for the watchdog, because the SPL does not have DM support, so while u-boot uses CONFIG_WATCHDOG the SPL uses CONFIG_HW_WATCHDOG.

Easier that changing all this is something like this in the board header file (as I described in the commit description):

Quoted 8 lines
Quoted 6 lines
    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

Can't we add DM watchdog to SPL instead ?

Do you mean implementing SPL_DM support for this board so that we can use the DM watchdog and sysreset?

Well you know more about this than me. But it probably comes down to technical limitations like size of the SPL.

Lukasz has done something similar with the display5 board [1], but that uses PANIC_HANG to avoid this issue.

[1]
https://gitlab.denx.de/u-boot/u-boot/blob/4b19b89ca4a866b7baa642533e6dbd67cd832d27/include/configs/display5.h#L343

Quoted 6 lines
Quoted 6 lines

In case of imx6, that way the SPL uses the hw_watchdog_reset from the imx watchdog driver instead of the 'watchdog_reset'.

'watchdog_reset' is not available since that is implemented in wdt-uclass.c and CONFIG_SPL_WDT depends on SPL_DM

#9 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

Quoted 103 lines · Claudius Heine
Quoted 102 lines · Marek Vasut
Quoted 100 lines · Claudius Heine
Quoted 77 lines · Marek Vasut
Quoted 76 lines · Claudius Heine
Quoted 74 lines · Marek Vasut
Quoted 64 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y	+= interrupts_64.o
 else
 obj-y	+= interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y	+= reset.o
-endif
 
 obj-y	+= cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)	+= cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/*NOTREACHED*/
 	return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Quoted 7 lines

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

Quoted 8 lines
Quoted 6 lines

Not sure what you mean... sysreset implements do_reset:

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.c#L112

But the SPL does not have sysreset in this case, so it needs something different.

Oh, so you need CONFIG_$(SPL_TPL_)SYSRESET then ?

Well that would probably not enough. I would also need settings for the watchdog, because the SPL does not have DM support, so while u-boot uses CONFIG_WATCHDOG the SPL uses CONFIG_HW_WATCHDOG.

Easier that changing all this is something like this in the board header file (as I described in the commit description):

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif
Quoted 4 lines
Quoted 1 line

Can't we add DM watchdog to SPL instead ?

Do you mean implementing SPL_DM support for this board so that we can use the DM watchdog and sysreset?

Isn't SPL DM already implemented ?

[...]

#10 lore raw

RFC PATCH 1/1 ARM: reset: Move SYSRESET condition from Makefile into source file

In reply to Claudius Heine
Quoted 102 lines · Claudius Heine
Quoted 77 lines · Marek Vasut
Quoted 76 lines · Claudius Heine
Quoted 74 lines · Marek Vasut
Quoted 64 lines · Claudius Heine

Hi Marek,

Quoted 46 lines · Marek Vasut
Quoted 45 lines · Claudius Heine

In case CONFIG_SYSRESET is set, do_reset from reset.c will not be available anywere, even if SYSRESET is disabled for SPL in the board specific header file like this:

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif

'do_reset' is called from SPL for instance from the panic handler in case SPL_USB_SDP is enabled and PANIC_HANG is not set.

Setting PANIC_HANG would solve this issue, but it also changes the behavior in case a panic occurs.

---
 arch/arm/lib/Makefile | 2 --
 arch/arm/lib/reset.c  | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/Makefile +0 -2
index 9de9a9acee..763eb4498f 100644
@@ -56,9 +56,7 @@ obj-y  += interrupts_64.o
 else
 obj-y   += interrupts.o
 endif
-ifndef CONFIG_SYSRESET
 obj-y   += reset.o
-endif
 
 obj-y   += cache.o
 obj-$(CONFIG_SYS_ARM_CACHE_CP15)        += cache-cp15.o
arch/arm/lib/reset.c +0 -0
index f3ea116e87..11e680be1d 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 
Quoted 12 lines

arch/arm/lib/reset.c int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 44

Quoted 9 lines
arch/arm/lib/reset.c +2 -0
+#if !defined(CONFIG_SYSRESET)
 __weak void reset_misc(void)
 {
 }
@@ -40,3 +41,4 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
         /*NOTREACHED*/
         return 0;
 }
+#endif

Does this mean there's now one huge ifdef around the entire source file? That's odd.

Right. Other suggestions?

Quoted 7 lines

Maybe having 'do_reset' here as a weak instead, so that sysreset can overwrite it? But then the other definitions in arch/*/lib/reset.c should probably be the same for consistency sake?

I tried with this patch not to change anything in case SYSRESET is enabled too much and since the file isn't too large I thought that would be ok for now.

What if sysreset implemented do_reset ? Wouldn't that solve the issue ?

Quoted 8 lines
Quoted 6 lines

Not sure what you mean... sysreset implements do_reset:

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.c#L112

But the SPL does not have sysreset in this case, so it needs something different.

Oh, so you need CONFIG_$(SPL_TPL_)SYSRESET then ?

Well that would probably not enough. I would also need settings for the watchdog, because the SPL does not have DM support, so while u-boot uses CONFIG_WATCHDOG the SPL uses CONFIG_HW_WATCHDOG.

Easier that changing all this is something like this in the board header file (as I described in the commit description):

    #if defined(CONFIG_SPL_BUILD)
    #undef CONFIG_WDT
    #undef CONFIG_WATCHDOG
    #undef CONFIG_SYSRESET
    #define CONFIG_HW_WATCHDOG
    #endif
Quoted 5 lines

In case of imx6, that way the SPL uses the hw_watchdog_reset from the imx watchdog driver instead of the 'watchdog_reset'.

'watchdog_reset' is not available since that is implemented in wdt-uclass.c and CONFIG_SPL_WDT depends on SPL_DM.

That seems totally unrelated to this patch.

I think this patch should change the Makefile to use CONFIG_$(SPL_TPL_)SYSRESET and you need to solve your watchdog issue in a separate patch.

Regards,
Simon