trace: select TIMER_EARLY to avoid infinite recursion
Subsystems (3)
PATCH v4 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.
---
Changes in v4:
- no change
Changes in v3:
- no change
Changes in v2:
- new patch
lib/Kconfig | 1 + 1 file changed, 1 insertion(+)
lib/Kconfig +1 -0
@@ -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
Signature · 1 line
2.17.1
PATCH v4 2/2 riscv: timer: Add support for an early timer
Added support for timer_early_get_count() and timer_early_get_rate() This is mostly useful in tracing.
---
Changes in v4:
- Rebase on master
Changes in v3:
- Add IS_ENABLED(CONFIG_TIMER_EARLY) for timer_early_get_rate() and timer_early_get_count() functions.
Changes in v2:
- make u-boot compile for qemu (include/configs/qemu-riscv.h)
drivers/timer/andes_plmt_timer.c | 21 ++++++++++++++++++++- drivers/timer/riscv_timer.c | 21 ++++++++++++++++++++- drivers/timer/sifive_clint_timer.c | 21 ++++++++++++++++++++- include/configs/ax25-ae350.h | 5 +++++ include/configs/qemu-riscv.h | 5 +++++ include/configs/sifive-fu540.h | 5 +++++ 6 files changed, 75 insertions(+), 3 deletions(-)
drivers/timer/andes_plmt_timer.c +20 -1
@@ -18,11 +18,30 @@/* mtime register */ #define MTIME_REG (base) ((ulong)(base)) -static u64 andes_plmt_get_count (struct udevice *dev) +static u64 notrace andes_plmt_get_count(struct udevice *dev) {return readq ((void __iomem *)MTIME_REG (dev_get_priv (dev))); } +#if CONFIG_IS_ENABLED (RISCV_MMODE ) &&IS_ENABLED (CONFIG_TIMER_EARLY ) +/** +* timer_early_get_rate() - Get the timer rate before driver model +*/ +unsigned long notrace timer_early_get_rate (void ) +{ +return RISCV_MMODE_TIMER_FREQ ; +} + +/** +* timer_early_get_count() - Get the timer count before driver model +* +*/ +u64 notrace timer_early_get_count(void) +{ +return readq ((void __iomem *)MTIME_REG (RISCV_MMODE_TIMERBASE )); +} +#endif +static const struct timer_ops andes_plmt_ops = { .get_count = andes_plmt_get_count, };
drivers/timer/riscv_timer.c +20 -1
@@ -16,7 +16,7 @@#include <timer.h> #include <asm/csr.h> -static u64 riscv_timer_get_count (struct udevice *dev) +static u64 notrace riscv_timer_get_count(struct udevice *dev) {__maybe_unused u32 hi, lo;
@@ -31,6 +31,25 @@ static u64 riscv_timer_get_count(struct udevice *dev)return ((u64 )hi <<32 ) | lo; } +#if CONFIG_IS_ENABLED (RISCV_SMODE ) &&IS_ENABLED (CONFIG_TIMER_EARLY ) +/** +* timer_early_get_rate() - Get the timer rate before driver model +*/ +unsigned long notrace timer_early_get_rate (void ) +{ +return RISCV_SMODE_TIMER_FREQ ; +} + +/** +* timer_early_get_count() - Get the timer count before driver model +* +*/ +u64 notrace timer_early_get_count(void) +{ +return riscv_timer_get_count (NULL ); +} +#endif +static int riscv_timer_probe (struct udevice *dev) {struct timer_dev_priv *uc_priv =dev_get_uclass_priv (dev);
drivers/timer/sifive_clint_timer.c +20 -1
@@ -15,11 +15,30 @@/* mtime register */ #define MTIME_REG (base) ((ulong)(base) + 0xbff8) -static u64 sifive_clint_get_count (struct udevice *dev) +static u64 notrace sifive_clint_get_count(struct udevice *dev) {return readq ((void __iomem *)MTIME_REG (dev_get_priv (dev))); } +#if CONFIG_IS_ENABLED (RISCV_MMODE ) &&IS_ENABLED (CONFIG_TIMER_EARLY ) +/** +* timer_early_get_rate() - Get the timer rate before driver model +*/ +unsigned long notrace timer_early_get_rate (void ) +{ +return RISCV_MMODE_TIMER_FREQ ; +} + +/** +* timer_early_get_count() - Get the timer count before driver model +* +*/ +u64 notrace timer_early_get_count(void) +{ +return readq ((void __iomem *)MTIME_REG (RISCV_MMODE_TIMERBASE )); +} +#endif +static const struct timer_ops sifive_clint_ops = { .get_count = sifive_clint_get_count, };
include/configs/ax25-ae350.h +5 -0
@@ -17,6 +17,11 @@#endif #endif +#define RISCV_MMODE_TIMERBASE 0xe6000000 +#define RISCV_MMODE_TIMER_FREQ 60000000 + +#define RISCV_SMODE_TIMER_FREQ 60000000 +/* * CPU and Board Configuration Options */
include/configs/qemu-riscv.h +5 -0
@@ -29,6 +29,11 @@#define CONFIG_STANDALONE_LOAD_ADDR 0x80200000 +#define RISCV_MMODE_TIMERBASE 0x2000000 +#define RISCV_MMODE_TIMER_FREQ 1000000 + +#define RISCV_SMODE_TIMER_FREQ 1000000 +/* Environment options */ #ifndef CONFIG_SPL_BUILD
include/configs/sifive-fu540.h +5 -0
@@ -36,6 +36,11 @@#define CONFIG_STANDALONE_LOAD_ADDR 0x80200000 +#define RISCV_MMODE_TIMERBASE 0x2000000 +#define RISCV_MMODE_TIMER_FREQ 1000000 + +#define RISCV_SMODE_TIMER_FREQ 1000000 +/* Environment options */ #ifndef CONFIG_SPL_BUILD
Signature · 1 line
2.17.1