Devicetree
 help / color / mirror / Atom feed
* [PATCH 00/10] gtrace: Add support for SiFive pre-ratified RISC-V trace components
@ 2026-11-26  9:07 Leo Yu-Chi Liang
  2026-11-26  9:07 ` [PATCH 01/10] dt-bindings: riscv: Add SiFive pre-ratified " Leo Yu-Chi Liang
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Leo Yu-Chi Liang @ 2026-11-26  9:07 UTC (permalink / raw)
  To: Mayuresh Chitale, Anup Patel, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Samuel Holland, Alexander Shishkin
  Cc: linux-riscv, devicetree, linux-kernel, Leo Yu-Chi Liang, linmin,
	vincent.chen, luyulin, pritesh.patel, ganboing, dongxuyang,
	pinkesh.vaghela, nick.hu, eric.lin, huangyifeng,
	darshan.prajapati

This series adds support for pre-ratified (version 0.x) RISC-V trace
hardware, such as the SiFive trace encoder and trace funnel as integrated
in the ESWIN EIC7700 (HiFive Premier P550), on top of the gtrace framework
posted by Mayuresh Chitale and Anup Patel [1].

The gtrace framework and the rvtrace drivers in [1] target the ratified
RISC-V Trace Control Interface. Hardware that predates the ratified
specification is functionally the same (encoder -> funnel -> sink), but
differs in how it is discovered, routed and where the sink lives. The
specification of the pre-ratified trace hardware, is described in the
EIC7700X SoC Technical Reference Manual [3].
This series makes the existing framework drivers handle both flavours
instead of adding a second, parallel driver stack.

Background: how pre-ratified hardware differs
---------------------------------------------

 1. Discovery. The IMPL register layout differs and does not encode the
    component type. The sink availability is also reported there. Specific
    compatible strings are therefore needed: "sifive,trace-encoder0" and
    "sifive,trace-funnel0".

 2. Source ID. The number of SRC bits is preset by hardware (teImpl.nSrcBits)
    and offset 0x8 is the read-only teImplExtra register, not
    trTeInstFeatures. The trTeInstMode encoding also differs.

 3. Routing. Ratified hardware routes at the receiving end (e.g. a funnel
    masks inputs with trFunnelDisInput). Pre-ratified hardware routes at the
    sending end: the destination sink is chosen by a bitfield in the sending
    component's own control register.

 4. Sink. A ratified RAM sink is an independent component with its own MMIO
    block. A pre-ratified RAM sink is embedded in the encoder or funnel
    register block, with a different register map.

 5. Buffer placement. The sink limit and write-pointer registers share their
    upper 32 bits with the sink base register, so the trace buffer must not
    cross a 4 GiB boundary.

These touch the gtrace framework from [1], so I would like feedback on them
in particular. Do you think supporting pre-ratified spec by the following
modification is the way to go?

Architectural changes
---------------------

 * Per-compatible match data (struct rvtrace_match_data) carries two optional
   callbacks. get_impl() translates the pre-ratified IMPL register into the
   standard IMPL layout, so the common probe code needs no special case.
   get_data() returns component private data (the available sinks), stored in
   gtrace_component_id.data.

 * Version 0 is handled inside the existing drivers. Components are
   identified by major version 0 (rvtrace_comp_is_v0()), and the
   pre-ratified specifics are isolated in a new rvtrace-v0.{c,h}, selected
   by CONFIG_RVTRACE_V0. Ratified-only configurations are not affected.

 * Routing is configured at start() time from the path topology
   (rvtrace_v0_sink_config()). This needs the next hop of the path, which the
   old start() callback could not see; see the API changes below.

 * The embedded RAM sink reuses the ratified RAM sink setup and copy
   functions. The register offsets are abstracted into struct
   rvtrace_ramsink_regs, and the standard and v0 layouts each provide one.
   An encoder or funnel only sets up its sink when it supports the SBA sink
   and has no output connection, i.e. when it is the end of a path.

 * Because an encoder or funnel can now be in the middle of a path and also
   implement copyto_auxbuf(), gtrace_path_copyto_auxbuf() now only calls the
   callback of the path's sink. Previously it called the first component in
   the path that implemented it.

Function signature and API changes
----------------------------------

 * struct gtrace_driver::start()
     int (*start)(struct gtrace_component *comp);
   becomes
     int (*start)(struct gtrace_path_node *node);
   Pre-ratified hardware needs the information of the next component to pick
   the sink at the sending end. The node gives access to both the component
   (node->comp) and the connection (node->conn).

 * gtrace_match_id()
   Now ends id_table iteration on GTRACE_COMPONENT_TYPE_NONE instead of a
   zero version. A non-zero version as the end-of-table marker cannot work
   with version 0 entries such as rvtrace_component_mkversion(0, 0).

 * rvtrace_ramsink_read_pair() / rvtrace_ramsink_write_pair()
     (pdata, low_off)           ->  (pdata, low_off, high_off)
     (pdata, val, low_off)      ->  (pdata, val, low_off, high_off)
   Zane also suggested this and Mayuresh said to fix this in v7.

 * rvtrace_ramsink copyto_auxbuf()
   Split into __rvtrace_ramsink_copyto_auxbuf(comp, priv, buf, format), which
   takes the private data explicitly, and a thin wrapper that keeps the
   existing callback signature. The v0 encoder and funnel call the helper
   through the new rvtrace_v0_ramsink_copyto_auxbuf().

Testing
-------

 * Boot tested on a HiFive Premier P550 (ESWIN EIC7700, four P550 cores).
   Tracing was verified to work on this board:

     perf record -e gtrace/event=0x1/ ls

   and the decoded trace content was checked.

 * Firmware: U-Boot from [2] (branch eic7x-dt-fix-hfp) and OpenSBI v1.9.

 * For this testing I reverted commit a7b9ce39fbe4 ("serial: 8250_dw: Ensure
   BUSY is deasserted") locally, because without it the P550 hits an init
   hang. This also happens on v7.4-rc4. See the note at the end.
   The revert is not part of this series.

Dependencies
------------

This series applies on top of [1] (v6, 14 patches), rebased onto v7.4-rc4.
Zane has a patchset implementing RISC-V Linux trace support [4], which add
RISC-V trace funnel support. I will try to review and merge the pre-ratified
funnel accordingly.

[1] https://lore.kernel.org/all/20261001052243.3042627-1-mayuresh.chitale@oss.qualcomm.com/
[2] https://github.com/ganboing/u-boot-eic7x/tree/eic7x-dt-fix-hfp
[3] https://github.com/eswincomputing/EIC7700X-SoC-Technical-Reference-Manual/releases
[4] https://lore.kernel.org/all/20261023031505.2020925-1-liangzhen@linux.spacemit.com/

Side note: UART init hang on EIC7700 (question for the ESWIN folks)
--------------------------------------------------------------------

I added the people working on upstreaming EIC7700 / P550 support to Cc for
this one, as it is unrelated to the trace series.

On the HiFive Premier P550, booting v7.0 or later to a built-in initramfs
(busybox) hangs at init. I bisected it between v6.19 and v7.0 to

  a7b9ce39fbe4 serial: 8250_dw: Ensure BUSY is deasserted

and the hang is still there on v7.4-rc4. Reverting that commit makes the
board boot, and so does adding "snps,uart-16550-compatible" to the DW UART
nodes (the latter I only tried on v7.0).
The commit adds a BUSY workaround. I have not found the root cause.

Do you see the same hang with an initramfs on your boards?

Signed-off-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
---
Eric Lin (9):
      dt-bindings: riscv: Add SiFive pre-ratified trace components
      gtrace: rvtrace: Add pre-ratified implementation callback
      gtrace: rvtrace: Add pre-ratified private data callback
      gtrace: rvtrace: Add pre-ratified encoder support
      gtrace: rvtrace: Add pre-ratified trace sink config
      gtrace: rvtrace: Add pre-ratified trace funnel driver
      gtrace: rvtrace: Introduce struct rvtrace_ramsink_regs to abstract register offsets
      gtrace: rvtrace: Add pre-ratified ramsink setup
      gtrace: rvtrace: Add copyto_auxbuf callback for pre-ratified encoder and funnel

Leo Yu-Chi Liang (1):
      gtrace: Terminate id_table iteration on GTRACE_COMPONENT_TYPE_NONE

 .../bindings/riscv/riscv,trace-component.yaml      |  96 +++++++++-
 drivers/hwtracing/gtrace/Kconfig                   |  25 +++
 drivers/hwtracing/gtrace/Makefile                  |   5 +-
 drivers/hwtracing/gtrace/gtrace-core.c             |  34 ++--
 drivers/hwtracing/gtrace/rvtrace-encoder.c         |  79 +++++++-
 drivers/hwtracing/gtrace/rvtrace-funnel.c          | 132 +++++++++++++
 drivers/hwtracing/gtrace/rvtrace-platform.c        |  46 ++++-
 drivers/hwtracing/gtrace/rvtrace-ramsink.c         | 211 +++++++++++++++++++--
 drivers/hwtracing/gtrace/rvtrace-ramsink.h         |  43 +++++
 drivers/hwtracing/gtrace/rvtrace-v0.c              |  99 ++++++++++
 drivers/hwtracing/gtrace/rvtrace-v0.h              |  80 ++++++++
 drivers/hwtracing/gtrace/rvtrace.h                 |  22 +++
 include/linux/gtrace.h                             |  20 +-
 13 files changed, 833 insertions(+), 59 deletions(-)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261124-send-preratified-trace-e32dc2b34a0a
prerequisite-message-id: 20261001052243.3042627-1-mayuresh.chitale@oss.qualcomm.com
prerequisite-patch-id: 1d7b783884bfe7e1d91063e0f8a232b86cdf4c31
prerequisite-patch-id: 8f59df8d7a27f0b3d3f34a0abb35e6c893c0858b
prerequisite-patch-id: ef326ac6eba908afdd7a49a264094367ed03a1c0
prerequisite-patch-id: dae8df7640ac89ff801741dba7e6d8e66432d54b
prerequisite-patch-id: 56b583656f75c0bf3eec5dac4113782110bbcf0a
prerequisite-patch-id: eacbdac5b4875ee7c84d9878f5a3cccfb79f7476
prerequisite-patch-id: 81535ef70fc7c3823810f14dcd1a069a05e6e2ac
prerequisite-patch-id: 65f827c9235a732612499b9ef95355872dc12a9f
prerequisite-patch-id: 53d04850a79d6b6fa1d88b6b0d2cebc4348a41d7
prerequisite-patch-id: 7a9c5eaccb41e1e63169edc3605f2dde7c373da4
prerequisite-patch-id: 6e0bd370e542f4cd0db70ff88b6634be6a446aec
prerequisite-patch-id: 509f41312fbcaa6a2bd0d9255cfd2116dc241adb
prerequisite-patch-id: 0ede4337d462b0cec2b67c10533768c7de762408
prerequisite-patch-id: 6b8939aa81ca09a16895a9ecf4de71e377a04ea6

Best regards,
--  
Leo Yu-Chi Liang <leo.liang@sifive.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-11-26  9:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  9:07 [PATCH 00/10] gtrace: Add support for SiFive pre-ratified RISC-V trace components Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 01/10] dt-bindings: riscv: Add SiFive pre-ratified " Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 02/10] gtrace: rvtrace: Add pre-ratified implementation callback Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 03/10] gtrace: rvtrace: Add pre-ratified private data callback Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 04/10] gtrace: rvtrace: Add pre-ratified encoder support Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 05/10] gtrace: Terminate id_table iteration on GTRACE_COMPONENT_TYPE_NONE Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 06/10] gtrace: rvtrace: Add pre-ratified trace sink config Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 07/10] gtrace: rvtrace: Add pre-ratified trace funnel driver Leo Yu-Chi Liang
2026-11-26  9:19   ` sashiko-bot
2026-11-26  9:07 ` [PATCH 08/10] gtrace: rvtrace: Introduce struct rvtrace_ramsink_regs to abstract register offsets Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 09/10] gtrace: rvtrace: Add pre-ratified ramsink setup Leo Yu-Chi Liang
2026-11-26  9:19   ` sashiko-bot
2026-11-26  9:07 ` [PATCH 10/10] gtrace: rvtrace: Add copyto_auxbuf callback for pre-ratified encoder and funnel Leo Yu-Chi Liang
2026-11-26  9:32   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox