RISC-V tracing support
Subsystems (2)
cover RISC-V tracing support
This series add a support of tracing for RISC-V arch.
This series is also available here [1] for testing. Series depends on [2].
[1] https://github.com/pragnesh26992/u-boot/tree/trace
[2] https://patchwork.ozlabs.org/project/uboot/cover/20200729095636.1077054-1-seanga2 at gmail.com/
How to test this patch:
1) Enable tracing in "configs/sifive_fu540_defconfig" CONFIG_TRACE=y CONFIG_TRACE_BUFFER_SIZE=0x01000000 CONFIG_TRACE_CALL_DEPTH_LIMIT=15 CONFIG_CMD_TRACE=y
2) make FTRACE=1 sifive_fu540_defconfig
3) make FTRACE=1
Following are the boot messages on FU540 five cores SMP platform:
U-Boot 2020.10-rc1-02837-g8613dc2e66 (Aug 24 2020 - 20:03:47 +0530)
CPU: rv64imac Model: SiFive HiFive Unleashed A00 DRAM: 8 GiB trace: enabled MMC: spi at 10050000:mmc at 0: 0 Loading Environment from SPIFlash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB OK In: serial at 10010000 Out: serial at 10010000 Err: serial at 10010000
Board serial number should not be 0 !!
Net:
Warning: ethernet at 10090000 (eth0) using random MAC address - 92:a1:a7:02:5a:14
eth0: ethernet at 10090000
Hit any key to stop autoboot: 0
=> trace stats
177,722 function sites
37,057,350 function calls
1 untracked function calls
1,279,612 traced function calls (36015585 dropped due to overflow)
19 maximum observed call depth
15 call depth limit
37,055,565 calls not traced due to depth
=>
Pragnesh Patel (3):
riscv: Add timer_get_us() for tracing
riscv: Mark riscv_timer_get_count() and sifive_clint_get_count() with
'notrace'
riscv: Mark andes_plmt_get_count() with 'notrace'
arch/riscv/lib/Makefile | 1 + arch/riscv/lib/andes_plmt.c | 2 +- arch/riscv/lib/sifive_clint.c | 2 +- arch/riscv/lib/timer.c | 50 +++++++++++++++++++++++++++++++++++ drivers/timer/riscv_timer.c | 2 +- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 arch/riscv/lib/timer.c
Signature · 1 line
2.17.1
PATCH 1/3 riscv: Add timer_get_us() for tracing
timer_get_us() will use timer_ops->get_count() function for timer counter. For S-mode U-Boot, CSR_TIMEH and CSR_TIME will provide a timer counter and For M-mode U-Boot, mtime register will provide the same.
--- arch/riscv/lib/Makefile | 1 + arch/riscv/lib/timer.c | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 arch/riscv/lib/timer.c
arch/riscv/lib/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-y += setjmp.o obj-$(CONFIG_$(SPL_)SMP) += smp.o obj-$(CONFIG_SPL_BUILD) += spl.o obj-y += fdt_fixup.o +obj-$(CONFIG_TIMER) += timer.o # For building EFI apps CFLAGS_$(EFI_CRT0) := $(CFLAGS_EFI)
arch/riscv/lib/timer.c new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 1/3 riscv: Add timer_get_us() for tracing
Hi Pragnesh,
Quoted 37 lines · Pragnesh Patel
timer_get_us()will usetimer_ops->get_count()function for timer counter. For S-mode U-Boot,CSR_TIMEHandCSR_TIMEwill provide a timer counter and For M-mode U-Boot, mtime register will provide the same.Signed-off-by Pragnesh Patel <[email protected]>--- arch/riscv/lib/Makefile | 1 + arch/riscv/lib/timer.c | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 arch/riscv/lib/timer.carch/riscv/lib/Makefile +1
-0@@ -26,6 +26,7 @@ obj-y += setjmp.o obj-$(CONFIG_$(SPL_)SMP) += smp.o obj-$(CONFIG_SPL_BUILD) += spl.o obj-y += fdt_fixup.o +obj-$(CONFIG_TIMER) += timer.o # For building EFI apps CFLAGS_$(EFI_CRT0) := $(CFLAGS_EFI)arch/riscv/lib/timer.c new file +7
-0@@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2020 SiFive, Inc +* +* Authors: +* Pragnesh Patel <[email protected]> +*/
arch/riscv/lib/timer.c line 17
Quoted 10 lines
arch/riscv/lib/timer.c new file +10
-0+ +#include <common.h> +#include <dm.h> +#include <timer.h> + +DECLARE_GLOBAL_DATA_PTR ; + +static struct udevice *timer; + +ulong notrace timer_get_us(void)
Does the weak one in lib/time.c not work on RISC-V?
Quoted 14 lines
arch/riscv/lib/timer.c new file +14
-0+{ +u64 count; +ulong rate; +int ret; + +/** +* gd->timer will become NULL in initr_dm(), so assign gd->timer +* to other static global timer, so that timer_get_us() can use it. +*/ +if (!timer && gd->timer) + timer = (struct udevice *)gd->timer; + +if (timer) { + ret =timer_get_count (timer, &count);
arch/riscv/lib/timer.c line 41
Quoted 10 lines
arch/riscv/lib/timer.c new file +10
-0+if (ret) +return ret; + + rate =timer_get_rate (timer); + } + +return (ulong )count / rate; +} + +int timer_init (void )
Why is this function necessary?
arch/riscv/lib/timer.c line 45
Quoted 4 lines
arch/riscv/lib/timer.c new file +4
-0+{ +int ret; + + ret =dm_timer_init ();
Does enabling CONFIG_TIMER_EARLY help?
arch/riscv/lib/timer.c line 50
Quoted 5 lines
arch/riscv/lib/timer.c new file +5
-0+if (ret) +return ret; + +return 0 ; +}
Regards,
Bin
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/3 riscv: Add timer_get_us() for tracing
Hi Pragnesh
Quoted 51 lines
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Friday, September 11, 2020 2:48 PM
To: Pragnesh Patel
Cc: U-Boot Mailing List; Atish Patra; Anup Patel; Sagar Kadam; Rick Jian-Zhi Chen(???); Paul Walmsley; Bin Meng; Lukas Auer; Sean Anderson
Subject: Re: [PATCH 1/3] riscv: Addtimer_get_us()for tracingHi Pragnesh,
Quoted 41 lines · Pragnesh Patel
timer_get_us()will usetimer_ops->get_count()function for timer counter. For S-mode U-Boot,CSR_TIMEHandCSR_TIMEwill provide a timer counter and For M-mode U-Boot, mtime register will provide the same.Signed-off-by Pragnesh Patel <[email protected]>--- arch/riscv/lib/Makefile | 1 + arch/riscv/lib/timer.c | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 arch/riscv/lib/timer.carch/riscv/lib/Makefile +1
-0@@ -26,6 +26,7 @@ obj-y += setjmp.o obj-$(CONFIG_$(SPL_)SMP) += smp.o obj-$(CONFIG_SPL_BUILD) += spl.o obj-y += fdt_fixup.o +obj-$(CONFIG_TIMER) += timer.o # For building EFI apps CFLAGS_$(EFI_CRT0) := $(CFLAGS_EFI)arch/riscv/lib/timer.c new file +11
-0@@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2020 SiFive, Inc +* +* Authors: +* Pragnesh Patel <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <timer.h>
Quoted 8 lines
arch/riscv/lib/timer.c line 17
Quoted 6 lines
arch/riscv/lib/timer.c new file +6
-0+ +DECLARE_GLOBAL_DATA_PTR ; + +static struct udevice *timer; + +ulong notrace timer_get_us(void)Does the weak one in
lib/time.cnot work on RISC-V?
Do you have any comments about Bin's reply ?
Thanks,
Rick
Quoted 43 lines
Quoted 15 lines
arch/riscv/lib/timer.c new file +14
-0+{ +u64 count; +ulong rate; +int ret; + +/** +* gd->timer will become NULL in initr_dm(), so assign gd->timer +* to other static global timer, so that timer_get_us() can use it. +*/ +if (!timer && gd->timer) + timer = (struct udevice *)gd->timer; + +if (timer) { + ret =timer_get_count (timer, &count);arch/riscv/lib/timer.c line 41
Quoted 10 lines
arch/riscv/lib/timer.c new file +10
-0+if (ret) +return ret; + + rate =timer_get_rate (timer); + } + +return (ulong )count / rate; +} + +int timer_init (void )Why is this function necessary?
arch/riscv/lib/timer.c line 45
Quoted 4 lines
arch/riscv/lib/timer.c new file +4
-0+{ +int ret; + + ret =dm_timer_init ();Does enabling
CONFIG_TIMER_EARLYhelp?arch/riscv/lib/timer.c line 50
Quoted 5 lines
arch/riscv/lib/timer.c new file +5
-0+if (ret) +return ret; + +return 0 ; +}Regards,
Bin
PATCH 1/3 riscv: Add timer_get_us() for tracing
Hi Bin,
Quoted 11 lines
-----Original Message-----
From: Rick Chen <[email protected]>
Sent: 21 October 2020 08:58
To: Pragnesh Patel <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; Atish Patra <[email protected]>; Anup Patel <[email protected]>; Sagar Kadam <[email protected]>; Bin Meng <[email protected]>; Lukas Auer <[email protected]>; Sean Anderson <[email protected]>; rick <[email protected]>; Alan Kao <[email protected]>
Subject: Re: [PATCH 1/3] riscv: Addtimer_get_us()for tracing
Quoted 65 lines
[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe
Hi Pragnesh
Quoted 60 lines
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Friday, September 11, 2020 2:48 PM
To: Pragnesh Patel
Cc: U-Boot Mailing List; Atish Patra; Anup Patel; Sagar Kadam; Rick Jian-Zhi Chen(???); Paul Walmsley; Bin Meng; Lukas Auer; Sean Anderson
Subject: Re: [PATCH 1/3] riscv: Addtimer_get_us()for tracingHi Pragnesh,
Quoted 37 lines · Pragnesh Patel
timer_get_us()will usetimer_ops->get_count()function for timer counter. For S-mode U-Boot,CSR_TIMEHandCSR_TIMEwill provide a timer counter and For M-mode U-Boot, mtime register will provide the same.Signed-off-by Pragnesh Patel <[email protected]>--- arch/riscv/lib/Makefile | 1 + arch/riscv/lib/timer.c | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 arch/riscv/lib/timer.carch/riscv/lib/Makefile index renamed from arch/riscv/lib/Makefile +0
-0
10ac5b06d3..fbb68e583b100644arch/riscv/lib/Makefile +1
-0@@ -26,6 +26,7 @@ obj-y += setjmp.o obj-$(CONFIG_$(SPL_)SMP) += smp.o obj-$(CONFIG_SPL_BUILD) += spl.o obj-y += fdt_fixup.o +obj-$(CONFIG_TIMER) += timer.o # For building EFI apps CFLAGS_$(EFI_CRT0) := $(CFLAGS_EFI) diff --git
a/arch/riscv/lib/timer.cb/arch/riscv/lib/timer.cnew file mode 100644 index 0000000000..3e423f2805arch/riscv/lib/timer.c new file +7
-0@@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2020 SiFive, Inc +* +* Authors: +* Pragnesh Patel <[email protected]> +*/ arch/riscv/lib/timer.c line 17
Quoted 10 lines
arch/riscv/lib/timer.c new file +10
-0+ +#include <common.h> +#include <dm.h> +#include <timer.h> + +DECLARE_GLOBAL_DATA_PTR ; + +static struct udevice *timer; + +ulong notrace timer_get_us(void)Does the weak one in
lib/time.cnot work on RISC-V?
No because if "gd->timer" is set early then also it will become NULL in initr_dm()
static int initr_dm(void) {
...
#ifdef CONFIG_TIMER
gd->timer = NULL;#endif
...
}
So timer_get_us() again try to call dm_timer_init() to initialize "gd->timer" and it got stuck in tracing.
Not all the functins are marked with notrace in dm_timer_init().
Quoted 40 lines
Do you have any comments about Bin's reply ?
Thanks,
RickQuoted 34 lines
Quoted 15 lines
arch/riscv/lib/timer.c new file +14
-0+{ +u64 count; +ulong rate; +int ret; + +/** +* gd->timer will become NULL in initr_dm(), so assign gd->timer +* to other static global timer, so that timer_get_us() can use it. +*/ +if (!timer && gd->timer) + timer = (struct udevice *)gd->timer; + +if (timer) { + ret =timer_get_count (timer, &count);arch/riscv/lib/timer.c line 41
Quoted 10 lines
arch/riscv/lib/timer.c new file +10
-0+if (ret) +return ret; + + rate =timer_get_rate (timer); + } + +return (ulong )count / rate; +} + +int timer_init (void )Why is this function necessary?
arch/riscv/lib/timer.c line 45
Quoted 4 lines
arch/riscv/lib/timer.c new file +4
-0+{ +int ret; + + ret =dm_timer_init ();Does enabling
CONFIG_TIMER_EARLYhelp?
I need to implement timer_early_get_count() and timer_early_get_rate() for that. Will look into this
Quoted 9 lines
Quoted 9 lines
arch/riscv/lib/timer.c line 50
Quoted 6 lines
arch/riscv/lib/timer.c new file +5
-0+if (ret) +return ret; + +return 0 ; +}Regards,
Bin
PATCH 2/3 riscv: Mark riscv_timer_get_count() and sifive_clint_get_count() with 'notrace'
In reply to Pragnesh PatelMark them as 'notrace' so that it doesn't cause infinite recursion.
--- arch/riscv/lib/sifive_clint.c | 2 +- drivers/timer/riscv_timer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/riscv/lib/sifive_clint.c +1 -1
@@ -62,7 +62,7 @@ int riscv_get_ipi(int hart, int *pending)return 0 ; } -static int sifive_clint_get_count (struct udevice *dev,u64 *count) +static int notrace sifive_clint_get_count(struct udevice *dev, u64 *count) { *count =readq ((void __iomem *)MTIME_REG (dev->priv));
drivers/timer/riscv_timer.c +1 -1
@@ -16,7 +16,7 @@#include <timer.h> #include <asm/csr.h> -static int riscv_timer_get_count (struct udevice *dev,u64 *count) +static int notrace riscv_timer_get_count(struct udevice *dev, u64 *count) {if (IS_ENABLED (CONFIG_64BIT )) { *count =csr_read (CSR_TIME );
Signature · 1 line
2.17.1
PATCH 3/3 riscv: Mark andes_plmt_get_count() with 'notrace'
In reply to Pragnesh PatelFor M-mode U-boot, andes_plmt_get_count() will provide timer counter. Mark it as 'notrace' so that it doesn't cause infinite recursion.
--- arch/riscv/lib/andes_plmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/lib/andes_plmt.c +1 -1
@@ -17,7 +17,7 @@/* mtime register */ #define MTIME_REG (base) ((ulong)(base)) -static int andes_plmt_get_count (struct udevice *dev,u64 *count) +static int notrace andes_plmt_get_count(struct udevice *dev, u64 *count) { *count =readq ((void __iomem *)MTIME_REG (dev->priv));
Signature · 1 line
2.17.1
cover RISC-V tracing support
In reply to Pragnesh PatelQuoted 54 lines · Pragnesh Patel
This series add a support of tracing for RISC-V arch.
This series is also available here [1] for testing. Series depends on [2].
[1] https://github.com/pragnesh26992/u-boot/tree/trace
[2] https://patchwork.ozlabs.org/project/uboot/cover/20200729095636.1077054-1-seanga2 at gmail.com/How to test this patch:
1) Enable tracing in "configs/sifive_fu540_defconfig"CONFIG_TRACE=yCONFIG_TRACE_BUFFER_SIZE=0x01000000CONFIG_TRACE_CALL_DEPTH_LIMIT=15CONFIG_CMD_TRACE=y2) make FTRACE=1
sifive_fu540_defconfig
3) make FTRACE=1Following are the boot messages on FU540 five cores SMP platform:
U-Boot 2020.10-rc1-02837-g8613dc2e66 (Aug 24 2020 - 20:03:47 +0530)
CPU: rv64imac Model: SiFive HiFive Unleashed A00 DRAM: 8 GiB trace: enabled MMC: spi at 10050000:mmc at 0: 0 Loading Environment from SPIFlash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB OK In: serial at 10010000 Out: serial at 10010000 Err: serial at 10010000Board serial number should not be 0 !!
Net:
Warning: ethernet at 10090000 (eth0) using random MAC address - 92:a1:a7:02:5a:14
eth0: ethernet at 10090000
Hit any key to stop autoboot: 0
=> trace stats
177,722 function sites
37,057,350 function calls
1 untracked function calls
1,279,612 traced function calls (36015585 dropped due to overflow)
19 maximum observed call depth
15 call depth limit
37,055,565 calls not traced due to depth
=>Pragnesh Patel (3):
riscv: Addtimer_get_us()for tracing
riscv: Markriscv_timer_get_count()andsifive_clint_get_count()with
'notrace'
riscv: Markandes_plmt_get_count()with 'notrace'
Quoted 8 lines
arch/riscv/lib/Makefile | 1 + arch/riscv/lib/andes_plmt.c | 2 +- arch/riscv/lib/sifive_clint.c | 2 +- arch/riscv/lib/timer.c | 50 +++++++++++++++++++++++++++++++++++ drivers/timer/riscv_timer.c | 2 +- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 arch/riscv/lib/timer.c
I tested this on a K210 and had to reduce CONFIG_TRACE_BUFFER_SIZE to 0x100000 (1M) because of its reduced ram. Here is some example output:
U-Boot 2020.10-rc1-00164-gbb14d962f5 (Sep 01 2020 - 16:17:43 -0400)
DRAM: 8 MiB trace: enabled In: serial at 38000000 Out: serial at 38000000 Err: serial at 38000000
=> trace stats
76,948 function sites
82,375,426 function calls
1 untracked function calls
36,075 traced function calls (164135507 dropped due to overflow)
17 maximum observed call depth
15 call depth limit
679,059 calls not traced due to depth
=>
--Sean
A message that is not in the archive (sent off-list or not yet received): [email protected]
cover RISC-V tracing support
Quoted 68 lines
From: Pragnesh Patel [mailto:pragnesh.patel at sifive.com]
Sent: Monday, August 24, 2020 10:44 PM
To: u-boot at lists.denx.de; atish.patra at wdc.com; bmeng.cn at gmail.com; anup.patel at wdc.com; sagar.kadam at sifive.com; Rick Jian-Zhi Chen(???)
Cc: paul.walmsley at sifive.com; Pragnesh Patel
Subject: [PATCH 0/3] RISC-V tracing supportThis series add a support of tracing for RISC-V arch.
This series is also available here [1] for testing. Series depends on [2].
[1] https://github.com/pragnesh26992/u-boot/tree/trace
[2] https://patchwork.ozlabs.org/project/uboot/cover/20200729095636.1077054-1-seanga2 at gmail.com/How to test this patch:
1) Enable tracing in "configs/sifive_fu540_defconfig"CONFIG_TRACE=yCONFIG_TRACE_BUFFER_SIZE=0x01000000CONFIG_TRACE_CALL_DEPTH_LIMIT=15CONFIG_CMD_TRACE=y2) make FTRACE=1
sifive_fu540_defconfig
3) make FTRACE=1Following are the boot messages on FU540 five cores SMP platform:
U-Boot 2020.10-rc1-02837-g8613dc2e66 (Aug 24 2020 - 20:03:47 +0530)
CPU: rv64imac Model: SiFive HiFive Unleashed A00 DRAM: 8 GiB trace: enabled MMC: spi at 10050000:mmc at 0: 0 Loading Environment from SPIFlash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB OK In: serial at 10010000 Out: serial at 10010000 Err: serial at 10010000Board serial number should not be 0 !!
Net:
Warning: ethernet at 10090000 (eth0) using random MAC address - 92:a1:a7:02:5a:14
eth0: ethernet at 10090000
Hit any key to stop autoboot: 0
=> trace stats
177,722 function sites
37,057,350 function calls
1 untracked function calls
1,279,612 traced function calls (36015585 dropped due to overflow)
19 maximum observed call depth
15 call depth limit
37,055,565 calls not traced due to depth
=>Pragnesh Patel (3):
riscv: Addtimer_get_us()for tracing
riscv: Markriscv_timer_get_count()andsifive_clint_get_count()with
'notrace'
riscv: Markandes_plmt_get_count()with 'notrace'arch/riscv/lib/Makefile | 1 + arch/riscv/lib/andes_plmt.c | 2 +- arch/riscv/lib/sifive_clint.c | 2 +- arch/riscv/lib/timer.c | 50 +++++++++++++++++++++++++++++++++++ drivers/timer/riscv_timer.c | 2 +- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 arch/riscv/lib/timer.c
Quoted 1 line
--
I have verified it in AE350 platfom as below:
U-Boot 2020.10-rc1-05918-g658fb7e-dirty (Sep 03 2020 - 08:08:28 +0800)
DRAM: 1 GiB trace: enabled Flash: 64 MiB MMC: mmc at f0e00000: 0 Loading Environment from SPIFlash... SF: Detected mx25u1635e with page size 256 Bytes, erase size 4 KiB, total 2 MiB OK In: serial at f0300000 Out: serial at f0300000 Err: serial at f0300000 Net: no alias for ethernet0
Warning: mac at e0100000 (eth0) using random MAC address - 2a:6c:3c:57:4b:30
eth0: mac at e0100000
Hit any key to stop autoboot: 0
RISC-V #
RISC-V # trace stats
166,074 function sites
1,071,417 function calls
1 untracked function calls
1,030,665 traced function calls
19 maximum observed call depth
15 call depth limit
1,145,728 calls not traced due to depth
RISC-V # trace stats
166,074 function sites
2,552,905 function calls
1 untracked function calls
1,287,378 traced function calls (958047 dropped due to overflow)
19 maximum observed call depth
15 call depth limit
2,900,311 calls not traced due to depth
RISC-V #
Thanks,
Rick