diff mbox series

[v2,1/2] trace: select TIMER_EARLY to avoid infinite recursion

Message ID 20201222062236.27372-1-pragnesh.patel@sifive.com
State Superseded
Delegated to: Andes
Headers show
Series [v2,1/2] trace: select TIMER_EARLY to avoid infinite recursion | expand

Commit Message

Pragnesh Patel Dec. 22, 2020, 6:22 a.m. UTC
When tracing functions is enabled this adds calls to
__cyg_profile_func_enter() and __cyg_profile_func_exit() to the traced
functions.

__cyg_profile_func_enter() and __cyg_profile_func_exit() invoke
timer_get_us() to record the entry and exit time.

initr_dm() will make gd->dm_root = NULL and gd->timer = NULL, so
timer_get_us() -> get_ticks() -> dm_timer_init() will lead to an
indefinite recursion.

So select TIMER_EARLY when tracing got enabled.

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
---

Changes in v2:
- new patch

 lib/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Comments

Simon Glass Dec. 29, 2020, 3:31 a.m. UTC | #1
On Mon, 21 Dec 2020 at 23:23, Pragnesh Patel <pragnesh.patel@sifive.com> wrote:
>
> When tracing functions is enabled this adds calls to
> __cyg_profile_func_enter() and __cyg_profile_func_exit() to the traced
> functions.
>
> __cyg_profile_func_enter() and __cyg_profile_func_exit() invoke
> timer_get_us() to record the entry and exit time.
>
> initr_dm() will make gd->dm_root = NULL and gd->timer = NULL, so
> timer_get_us() -> get_ticks() -> dm_timer_init() will lead to an
> indefinite recursion.
>
> So select TIMER_EARLY when tracing got enabled.
>
> Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
> ---
>
> Changes in v2:
> - new patch
>
>  lib/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Rick Chen Dec. 30, 2020, 6:38 a.m. UTC | #2
> From: Pragnesh Patel [mailto:pragnesh.patel@sifive.com]
> Sent: Tuesday, December 22, 2020 2:23 PM
> To: u-boot@lists.denx.de
> Cc: atish.patra@wdc.com; palmerdabbelt@google.com; bmeng.cn@gmail.com; paul.walmsley@sifive.com; anup.patel@wdc.com; sagar.kadam@sifive.com; Rick Jian-Zhi Chen(陳建志); pragnesh.patel@openfive.com; Pragnesh Patel; Simon Glass; Stefan Roese; Joao Marcos Costa; Reuben Dowle; Weijie Gao; Marcin Juszkiewicz; Michael Walle; Marek Szyprowski; Keerthy
> Subject: [PATCH v2 1/2] trace: select TIMER_EARLY to avoid infinite recursion
>
> When tracing functions is enabled this adds calls to
> __cyg_profile_func_enter() and __cyg_profile_func_exit() to the traced
> functions.
>
> __cyg_profile_func_enter() and __cyg_profile_func_exit() invoke
> timer_get_us() to record the entry and exit time.
>
> initr_dm() will make gd->dm_root = NULL and gd->timer = NULL, so
> timer_get_us() -> get_ticks() -> dm_timer_init() will lead to an
> indefinite recursion.
>
> So select TIMER_EARLY when tracing got enabled.
>
> Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
> ---
>
> Changes in v2:
> - new patch
>
>  lib/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Rick Chen <rick@andestech.com>
diff mbox series

Patch

diff --git a/lib/Kconfig b/lib/Kconfig
index 7673d2e4e0..671386963a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -210,6 +210,7 @@  config BITREVERSE
 config TRACE
 	bool "Support for tracing of function calls and timing"
 	imply CMD_TRACE
+	select TIMER_EARLY
 	help
 	  Enables function tracing within U-Boot. This allows recording of call
 	  traces including timing information. The command can write data to