From: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <pjw@kernel.org>,
Greg KH <gregkh@linuxfoundation.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ian Rogers <irogers@google.com>
Cc: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Mayuresh Chitale <mchitale@gmail.com>,
Anup Patel <anup@brainfault.org>,
Atish Patra <atish.patra@linux.dev>,
Andrew Jones <andrew.jones@oss.qualcomm.com>,
Sunil V L <sunilvl@oss.qualcomm.com>,
linux-riscv@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Zane Leung <liangzhen@linux.spacemit.com>
Subject: [PATCH v7 00/14] Linux RISC-V trace framework and drivers
Date: Thu, 26 Nov 2026 15:25:21 +0530 [thread overview]
Message-ID: <cover.1795512532.git.mayuresh.chitale@oss.qualcomm.com> (raw)
This series adds 'gtrace' which is an architecture-neutral hardware trace
framework with RISC-V E-trace as its first backend. The 'gtrace' core framework
has the minimal shared plumbing (component registration, path create/destroy,
path start/stop, etc) and the RISC-V trace drivers are its first consumer.
It should be possible for the required ARM components to be adapted to the same
framework in a future.
This series also adds initial support for RISC-V trace component drivers.
The RISC-V trace v1.0 specification is already ratified and can be found at:
https://github.com/riscv-non-isa/e-trace-encap/releases/tag/v1.0.0-ratified
https://github.com/riscv-non-isa/tg-nexus-trace/releases/tag/1.0_Ratified
The drivers use the common trace control interface. E-Trace remains the
preferred format for the generic RISC-V compatible string; the encoder now
reads back the accepted hardware format and updates the component's format.
In the future, there will be subsequent series adding:
1) Sysfs support
2) ACPI support
3) More trace drivers (such as funnel, ATB, etc)
4) Support for upcoming self-hosted trace specification
5) Arm component support under the gtrace framework
6) ... and more ...
These patches can also be found in the riscv_trace_support_v7 branch at:
https://github.com/mdchitale/linux.git
To test the patches, we need QEMU virt machine with RISC-V trace support
which can be found in rv-etrace_v4 branch at:
https://gitlab.com/danielhb/qemu.git
To capture gtrace data using perf on QEMU virt machine do the following:
1) Launch QEMU virt machine
$ qemu-system-riscv64 -nographic -M virt -smp 2 -bios fw_dynamic.bin \
-kernel Image -append "root=/dev/vda rw console=ttyS0 earlycon=sbi" \
-drive file=rootfs.img,id=disk1,if=none,format=raw \
-device virtio-blk-device,drive=disk1
2) Run perf record to capture gtrace data
$ perf record --all-cpus -e gtrace/event=0x1/ <command>
3) The step2 would create a perf.data file which has the gtrace data.
Now run perf report -D and look for PERF_RECORD_AUXTRACE event
section(s) which point(s) to the actual gtrace data offset.
Changes since v6:
- Rebased on latest upstream
- Add a gtrace component type of NONE version-zero components can match
- Hold gtrace component references for firmware-node and CPU-source lookups,
- Detach incoming/outgoing connection pointers before removing components
- Balance temporary OF node references and outgoing references on parser
and platform-probe failures; fix the CPU-node diagnostic lifetime and
the OF module device table declaration.
- Use a spinlock to guard trace-ID and component ready callbacks
- Probe SRCBITS using all possible allowed widths and select the final
allowed width
- Read back the trace format (e-trace/n-trace) supported by hardware and update
platform driver state accordingly
- Make ramsink register-pair helper functions generic to gtrace
- Copy AUX data from the actual path sink and not the first component that implemented
the aux copy callback.
- Pass the available AUX byte limit to the core and sink callbacks
whereas sink driver returns the actual byte count and AUX flags.
- Release AUX mappings data directly in free_aux() instead of deferring it via workqueue
- Set the AUX_OUTPUT_HW_ID to the encoder's hardware source ID
- Other fixes for issues reported by Sashiko bot
Changes since v5:
- Moved the DT connection parsing into the gtrace core as gtrace-of.c.
- Added start_count and a lock to the core's private component data
to serialize start/stop/copyto_auxbuf operations. Dropped
perf_buf_lock.
- Added handling of partially enabled path by disabling all enabled
components
- Added cycle detection when walking the trace component graph
- Added trace source ID configuration in the encoder driver
- Added trace format (E-Trace/N-Trace) selection via the platform driver
compatible string. It is used by encoder and perf drivers to set it
into hardware and perf data header respectively
- Modified the ramsink buffer setup to read back the trRamStart and
trRamLimit registers, and program the sync frequency, memory format
and stop-on-wrap settings at start time
- Improved error handling and added path owner in the perf driver
- Fixed several issues reported by sashiko-bot but some of its findings
are deferred to a later version.
Changes since v4:
- Introduced a new architecture-neutral 'gtrace' (Generic Trace) framework
and moved the RISC-V trace drivers on top of it instead of a RISC-V-only
'rvtrace' core.
- Added new PATCH3 "gtrace: Add RISC-V platform driver for the gtrace
framework" to split out the RISC-V platform/DT code from the core
framework patch.
- Moved all rvtrace driver sources from drivers/hwtracing/rvtrace/ to
drivers/hwtracing/gtrace/, with single Kconfig, Makefile using
- Made the perf driver (previously rvtrace-perf.c) architecture-neutral
and moved it into the gtrace framework as gtrace-perf.c; PMU name
changed from "rvtrace" to "gtrace"
- Added new PATCH8 "perf: Add gtrace AUX buffer trace format type" to
define PERF_AUX_FLAG_GTRACE_FORMAT_ETRACE which is used in later patches.
- copyto_auxbuf() and gtrace_path_copyto_auxbuf() now take an output
parameter so the AUX data format can be reported by the sink
driver by setting PERF_AUX_FLAG_GTRACE_FORMAT_ETRACE.
- Renamed the generic side of the perf tools support from rvtrace* to
gtrace*. perf.data ABI is unchanged.
- Fixed gtrace ramsink start/stop to call gtrace_enable_component()/
gtrace_disable_component() to remove duplication with code in
gtrace-core.c
- Updated the MAINTAINERS patch to refer to gtrace framework instead of
rvtrace
Changes since v3:
- Rebased on Linux-7.1-rc1
- Use kzalloc_obj() in-place of kzalloc() in PATCH2, PATCH3 and PATCH9
- Improved PATCH7 to save the previous WP value
Changes since v2:
- Rebased on Linux-7.0-rc1
- Addressed Rob's comments on DT bindings in PATCH1
- Addressed ref-count related issues in rvtrace_of_parse_outconns()
of PATCH2
- Made RVtrace framework more generic by avoiding implicit access
to component registers in PATCH2
- More improvements in trRamStart/Limit/WP programming and other
improvments in PATCH7
- Removed RVTRACE_BUF_LEN from PATCH9
- Removed redundant page_size from PATCH10
- Renamed found_etm in PATCH10
- Removed rvtrace_recording_init() declaration from header in PATCH11
Changes since v1:
- Rebased on Linux-6.18-rc3
- Addressed Rob's comments in dt-bindings added by PATCH1
- Get reference of conn->dest_fwnode and add missing break in
rvtrace_of_parse_outconns() of rvtrace-platform drivers added
by PATCH2
- Added new inline function rvtrace_comp_is_empty() in PATCH2
and used it in rvtrace_encoder_stop() added by PATCH5
- Fixed trRamWPLow usage in PATCH7
- Determine RAM sink buffer size based on component implementation
ID and reduce default RAM sink buffer size to 1MB
- Add new PATCH8 to enable DMA_RESTRICTED_POOL in RISC-V defconfig
so that implementations with RAM sink address restrictions can
be handled.
Anup Patel (7):
dt-bindings: Add RISC-V trace component bindings
hwtracing: gtrace: Initial implementation of gtrace framework
gtrace: Add RISC-V platform driver for the gtrace framework
gtrace: Add functions to create/destroy a trace component path
gtrace: Add function to copy into perf AUX buffer
riscv: Enable DMA_RESTRICTED_POOL in defconfig
MAINTAINERS: Add entry for RISC-V trace framework
Mayuresh Chitale (7):
gtrace: Add functions to start/stop tracing on a component path
gtrace: Add RISC-V Trace encoder driver
perf: Add gtrace AUX buffer trace format type
gtrace: Add RISC-V Trace ramsink driver
gtrace: Add perf driver for tracing using perf tool
perf tools: Add RISC-V trace PMU record capabilities
perf tools: Initial support for gtrace decoder
.../bindings/riscv/riscv,trace-component.yaml | 120 +++
MAINTAINERS | 11 +
arch/riscv/configs/defconfig | 1 +
drivers/Makefile | 1 +
drivers/hwtracing/Kconfig | 2 +
drivers/hwtracing/gtrace/Kconfig | 59 ++
drivers/hwtracing/gtrace/Makefile | 9 +
drivers/hwtracing/gtrace/gtrace-core.c | 962 ++++++++++++++++++
drivers/hwtracing/gtrace/gtrace-of.c | 133 +++
drivers/hwtracing/gtrace/gtrace-perf.c | 368 +++++++
drivers/hwtracing/gtrace/rvtrace-encoder.c | 274 +++++
drivers/hwtracing/gtrace/rvtrace-platform.c | 194 ++++
drivers/hwtracing/gtrace/rvtrace-ramsink.c | 366 +++++++
drivers/hwtracing/gtrace/rvtrace.h | 121 +++
include/linux/gtrace.h | 382 +++++++
include/uapi/linux/perf_event.h | 5 +
tools/include/uapi/linux/perf_event.h | 5 +
tools/perf/arch/riscv/util/Build | 1 +
tools/perf/arch/riscv/util/auxtrace.c | 220 ++++
tools/perf/util/Build | 1 +
tools/perf/util/auxtrace.c | 4 +
tools/perf/util/auxtrace.h | 1 +
tools/perf/util/gtrace-decoder.c | 99 ++
tools/perf/util/gtrace.h | 17 +
24 files changed, 3356 insertions(+)
create mode 100644 Documentation/devicetree/bindings/riscv/riscv,trace-component.yaml
create mode 100644 drivers/hwtracing/gtrace/Kconfig
create mode 100644 drivers/hwtracing/gtrace/Makefile
create mode 100644 drivers/hwtracing/gtrace/gtrace-core.c
create mode 100644 drivers/hwtracing/gtrace/gtrace-of.c
create mode 100644 drivers/hwtracing/gtrace/gtrace-perf.c
create mode 100644 drivers/hwtracing/gtrace/rvtrace-encoder.c
create mode 100644 drivers/hwtracing/gtrace/rvtrace-platform.c
create mode 100644 drivers/hwtracing/gtrace/rvtrace-ramsink.c
create mode 100644 drivers/hwtracing/gtrace/rvtrace.h
create mode 100644 include/linux/gtrace.h
create mode 100644 tools/perf/arch/riscv/util/auxtrace.c
create mode 100644 tools/perf/util/gtrace-decoder.c
create mode 100644 tools/perf/util/gtrace.h
base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
--
2.43.0
next reply other threads:[~2026-11-26 9:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 9:55 Mayuresh Chitale [this message]
2026-11-26 9:55 ` [PATCH v7 01/14] dt-bindings: Add RISC-V trace component bindings Mayuresh Chitale
2026-11-26 10:07 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 02/14] hwtracing: gtrace: Initial implementation of gtrace framework Mayuresh Chitale
2026-11-26 10:15 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 03/14] gtrace: Add RISC-V platform driver for the " Mayuresh Chitale
2026-11-26 10:12 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 04/14] gtrace: Add functions to create/destroy a trace component path Mayuresh Chitale
2026-11-26 10:07 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 05/14] gtrace: Add functions to start/stop tracing on a " Mayuresh Chitale
2026-11-26 10:05 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 06/14] gtrace: Add RISC-V Trace encoder driver Mayuresh Chitale
2026-11-26 10:09 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 07/14] gtrace: Add function to copy into perf AUX buffer Mayuresh Chitale
2026-11-26 10:05 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 08/14] perf: Add gtrace AUX buffer trace format type Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 09/14] gtrace: Add RISC-V Trace ramsink driver Mayuresh Chitale
2026-11-26 10:13 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 10/14] riscv: Enable DMA_RESTRICTED_POOL in defconfig Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 11/14] gtrace: Add perf driver for tracing using perf tool Mayuresh Chitale
2026-11-26 10:23 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 12/14] perf tools: Add RISC-V trace PMU record capabilities Mayuresh Chitale
2026-11-26 10:19 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 13/14] perf tools: Initial support for gtrace decoder Mayuresh Chitale
2026-11-26 10:17 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 14/14] MAINTAINERS: Add entry for RISC-V trace framework Mayuresh Chitale
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1795512532.git.mayuresh.chitale@oss.qualcomm.com \
--to=mayuresh.chitale@oss.qualcomm.com \
--cc=adrian.hunter@intel.com \
--cc=alex@ghiti.fr \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrew.jones@oss.qualcomm.com \
--cc=anup@brainfault.org \
--cc=atish.patra@linux.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=liangzhen@linux.spacemit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mchitale@gmail.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=robh@kernel.org \
--cc=sunilvl@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox