board_r: move initr_watchdog to be called after initr_serial
PATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
The initr_watchdog is currently placed before initr_serial. The initr_watchdog calls printf and printf finally calls ops->putc of a serial driver.
However, gd->cur_serial_dev points to a udevice allocated in board_f. The gd->cur_serial_dev->driver->ops->putc points the the code region before relocation.
Some serial drivers call WATCHDOG_RESET() in ops->putc. When DM is enabled for watchdog, watchdog_reset() is called. watchdog_reset() calls get_timer to get current timer.
On some platforms the timer driver is also a DM driver. initr_watchdog is placed right after initr_dm, which means the timer driver hasn't been initialized. So dm_timer_init() is called. To create a new udevice, calloc is called.
However start from ops->putc, u-boot execution flow is redirected into the memory region before relocation (board_f). In board_f, dlmalloc hasn't been initialized. The call to calloc will fail, and this will cause DM to print out an error message, and it will call printf again, causing recursive error outputs.
This patch places initr_watchdog after initr_serial to solve this issue.
---
Changes since v1: move initr_watchdog instead of initr_serial
--- common/board_r.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
common/board_r.c +3 -3
@@ -678,9 +678,6 @@ static init_fnc_t init_sequence_r[] = {#ifdef CONFIG_DM initr_dm,#endif -#if defined(CONFIG_WDT ) - initr_watchdog, -#endif #if defined(CONFIG_ARM ) || defined(CONFIG_NDS32 ) || defined(CONFIG_RISCV ) || \ defined(CONFIG_SANDBOX ) board_init, /* Setup chipselects */
@@ -700,6 +697,9 @@ static init_fnc_t init_sequence_r[] = { stdio_init_tables, initr_serial, initr_announce, +#if defined(CONFIG_WDT ) + initr_watchdog, +#endif INIT_FUNC_WATCHDOG_RESET#ifdef CONFIG_NEEDS_MANUAL_RELOC initr_manual_reloc_cmdtable,
Signature · 1 line
2.18.0
PATCH v2 1/3 board_r: move initr_watchdog to be called, after initr_serial
Hi,
May I know if this patch is still under review ?
I have converted OMAP3 watchdog driver into driver model for TI AM33XX based SOC and tested corresponding patches on BeagleBone Black board.
Build was successful but board goes into a loop when turned on/runtime, problem identified and is in sync with Weijie Gao's explanation and his patch for such behaviour (please follow this thread for explanation).
When initr_watchdog is moved/placed just after initr_serial, board is behaving normal. Tested on BeagleBone Black.
Please suggest if there are any workarounds for this problem.
Regards
Signature · 6 lines
Suniel Mahesh Embedded Linux, Kernel & U-Boot engineer https://github.com/sunielmahesh www.tuxtrons.com https://github.com/techveda Hyderabad, India
PATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
In reply to Weijie GaoCc'ing a few people
Quoted 49 lines · Weijie Gao
The
initr_watchdogis currently placed beforeinitr_serial. Theinitr_watchdogcalls printf and printf finally callsops->putcof a serial driver.However,
gd->cur_serial_devpoints to a udevice allocated inboard_f. Thegd->cur_serial_dev->driver->ops->putcpoints the the code region before relocation.Some serial drivers call
WATCHDOG_RESET()inops->putc. When DM is enabled for watchdog,watchdog_reset()is called.watchdog_reset()callsget_timerto get current timer.On some platforms the timer driver is also a DM driver.
initr_watchdogis placed right afterinitr_dm, which means the timer driver hasn't been initialized. Sodm_timer_init()is called. To create a new udevice, calloc is called.However start from
ops->putc, u-boot execution flow is redirected into the memory region before relocation (board_f). Inboard_f, dlmalloc hasn't been initialized. The call to calloc will fail, and this will cause DM to print out an error message, and it will call printf again, causing recursive error outputs.This patch places
initr_watchdogafterinitr_serialto solve this issue.Cc Stefan Roese <[email protected]>Reviewed-by Ryder Lee <[email protected]>Signed-off-by Weijie Gao <[email protected]>---
Changes since v1: moveinitr_watchdoginstead ofinitr_serial--- common/board_r.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)common/board_r.c +0
-3@@ -678,9 +678,6 @@ static init_fnc_t init_sequence_r[] = {#ifdef CONFIG_DM initr_dm,#endif -#if defined(CONFIG_WDT ) - initr_watchdog, -#endif #if defined(CONFIG_ARM ) || defined(CONFIG_NDS32 ) || defined(CONFIG_RISCV ) || \ defined(CONFIG_SANDBOX ) board_init, /* Setup chipselects */
common/board_r.c static init_fnc_t init_sequence_r[] = { · line 705
Quoted 9 lines
common/board_r.c +3
-0@@ -700,6 +697,9 @@ static init_fnc_t init_sequence_r[] = { stdio_init_tables, initr_serial, initr_announce, +#if defined(CONFIG_WDT ) + initr_watchdog, +#endif INIT_FUNC_WATCHDOG_RESET#ifdef CONFIG_NEEDS_MANUAL_RELOC initr_manual_reloc_cmdtable,
Frank, does this patch fix the watchdog issue on your board as well?
Tom, could you please apply this patch to the upcoming release?
Thanks,
Stefan
PATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
Hi Stefan/Tom
this Patch in combination with https://patchwork.ozlabs.org/patch/1113120/ seem to fix issues on bananapi-r2 /mt7623 (bootloop/hang on WDT servicing) if CONFIG_WATCHDOG is not set to "n" (else it will be set to y because of new "imply WATCHDOG" inside of "config WDT").
@tom can you please include this 2 Patches in master?
regards Frank
PATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
Hi Frank,
Quoted 3 lines · Frank Wunderlich
Hi Stefan/Tom
this Patch in combination with https://patchwork.ozlabs.org/patch/1113120/
This one already is applied in mainline:
https://gitlab.denx.de/u-boot/u-boot/commit/2bc1821e8662f9ed67cc6eeb680148bb5c148379
Even though the coding style is pretty messed up. We should clean this file up a bit.
Thanks,
Stefan
PATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
Hi
It looks this fix is not yet merged. Tom can you add it before release? Without it bpi-r2 and maybe other boards are broken.
Regards Frank
PATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
In reply to Stefan RoesePATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
Agreed with frank. My patches for watchdog DM conversion depends on this change set.
tested on AM335x based Beaglebone Black
Regards
Signature · 6 lines
Suniel Mahesh Embedded Linux, Kernel & U-Boot engineer https://github.com/sunielmahesh www.tuxtrons.com https://github.com/techveda Hyderabad, India
PATCH v2 1/3 board_r: move initr_watchdog to be called after initr_serial
In reply to Weijie GaoQuoted 23 lines · Weijie Gao
The
initr_watchdogis currently placed beforeinitr_serial. Theinitr_watchdogcalls printf and printf finally callsops->putcof a serial driver.However,
gd->cur_serial_devpoints to a udevice allocated inboard_f. Thegd->cur_serial_dev->driver->ops->putcpoints the the code region before relocation.Some serial drivers call
WATCHDOG_RESET()inops->putc. When DM is enabled for watchdog,watchdog_reset()is called.watchdog_reset()callsget_timerto get current timer.On some platforms the timer driver is also a DM driver.
initr_watchdogis placed right afterinitr_dm, which means the timer driver hasn't been initialized. Sodm_timer_init()is called. To create a new udevice, calloc is called.However start from
ops->putc, u-boot execution flow is redirected into the memory region before relocation (board_f). Inboard_f, dlmalloc hasn't been initialized. The call to calloc will fail, and this will cause DM to print out an error message, and it will call printf again, causing recursive error outputs.
Quoted 8 lines
This patch places
initr_watchdogafterinitr_serialto solve this issue.Cc Stefan Roese <[email protected]>Reviewed-by Ryder Lee <[email protected]>Signed-off-by Weijie Gao <[email protected]>Reviewed-by Stefan Roese <[email protected]>Tested-by Frank Wunderlich <[email protected]>Tested-by Suniel Mahesh <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190707/e9beaa2b/attachment.sig>