[PATCH RFC 04/12] rvtrace: Pass struct rvtrace_path_node to start callback

Eric Lin eric.lin at sifive.com
Tue Jun 30 02:46:27 PDT 2026


Routing trace data from a source to an output component requires
configuring the connections between components. The mechanism for this
configuration varies between hardware implementations:

  - Standard (ratified) RISC-V trace configures routing at the
    receiving end. For example, a funnel uses the trFunnelDisInput
    register to control which source input is accepted.
  - Pre-ratified hardware (e.g., SiFive) configures routing at the
    sending end, selecting the output destination by setting a bitfield
    directly within the current component's control MMIO register.

To seamlessly support both ratified and pre-ratified data flows,
component drivers require full path topology information (i.e., the
component and its connections) when starting, rather than just the
component itself.

Update the rvtrace_driver->start() callback to accept a
'struct rvtrace_path_node' instead of a 'struct rvtrace_component'
so that component drivers can access the node and connection
details required to program their specific routing registers.

Co-developed-by: Nick Hu <nick.hu at sifive.com>
Signed-off-by: Nick Hu <nick.hu at sifive.com>
Co-developed-by: Vincent Chen <vincent.chen at sifive.com>
Signed-off-by: Vincent Chen <vincent.chen at sifive.com>
Signed-off-by: Eric Lin <eric.lin at sifive.com>
---
 drivers/hwtracing/rvtrace/rvtrace-core.c    | 12 ++----------
 drivers/hwtracing/rvtrace/rvtrace-encoder.c |  3 ++-
 drivers/hwtracing/rvtrace/rvtrace-ramsink.c |  3 ++-
 include/linux/rvtrace.h                     | 14 +++++++++++++-
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/hwtracing/rvtrace/rvtrace-core.c b/drivers/hwtracing/rvtrace/rvtrace-core.c
index 51546cbcc6ad..12ffc6917c70 100644
--- a/drivers/hwtracing/rvtrace/rvtrace-core.c
+++ b/drivers/hwtracing/rvtrace/rvtrace-core.c
@@ -501,12 +501,6 @@ void rvtrace_unregister_component(struct rvtrace_component *comp)
 }
 EXPORT_SYMBOL_GPL(rvtrace_unregister_component);
 
-struct rvtrace_path_node {
-	struct list_head		head;
-	struct rvtrace_component	*comp;
-	struct rvtrace_connection	*conn;
-};
-
 struct rvtrace_component *rvtrace_path_source(struct rvtrace_path *path)
 {
 	struct rvtrace_path_node *node;
@@ -625,17 +619,15 @@ static void rvtrace_release_path_nodes(struct rvtrace_path *path)
 int rvtrace_path_start(struct rvtrace_path *path)
 {
 	const struct rvtrace_driver *rtdrv;
-	struct rvtrace_component *comp;
 	struct rvtrace_path_node *node;
 	int ret;
 
 	list_for_each_entry_reverse(node, &path->comp_list, head) {
-		comp = node->comp;
-		rtdrv = to_rvtrace_driver(comp->dev.driver);
+		rtdrv = to_rvtrace_driver(node->comp->dev.driver);
 		if (!rtdrv->start)
 			continue;
 
-		ret = rtdrv->start(comp);
+		ret = rtdrv->start(node);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/hwtracing/rvtrace/rvtrace-encoder.c b/drivers/hwtracing/rvtrace/rvtrace-encoder.c
index d189819aecf7..f0a4ac46b6a9 100644
--- a/drivers/hwtracing/rvtrace/rvtrace-encoder.c
+++ b/drivers/hwtracing/rvtrace/rvtrace-encoder.c
@@ -11,8 +11,9 @@
 #define RVTRACE_COMPONENT_CTRL_INSTMODE_SHIFT	4
 #define RVTRACE_COMPONENT_CTRL_INSTMODE_OPIT	0x6
 
-static int rvtrace_encoder_start(struct rvtrace_component *comp)
+static int rvtrace_encoder_start(struct rvtrace_path_node *node)
 {
+	struct rvtrace_component *comp = node->comp;
 	int ret;
 	u32 val;
 
diff --git a/drivers/hwtracing/rvtrace/rvtrace-ramsink.c b/drivers/hwtracing/rvtrace/rvtrace-ramsink.c
index e4b6f0547245..7aa525ac0f75 100644
--- a/drivers/hwtracing/rvtrace/rvtrace-ramsink.c
+++ b/drivers/hwtracing/rvtrace/rvtrace-ramsink.c
@@ -43,8 +43,9 @@ struct trace_buf {
 	size_t len;
 };
 
-static int rvtrace_ramsink_start(struct rvtrace_component *comp)
+static int rvtrace_ramsink_start(struct rvtrace_path_node *node)
 {
+	struct rvtrace_component *comp = node->comp;
 	int ret;
 	u32 val;
 
diff --git a/include/linux/rvtrace.h b/include/linux/rvtrace.h
index 9f1afcfd83e6..079fe16807d3 100644
--- a/include/linux/rvtrace.h
+++ b/include/linux/rvtrace.h
@@ -281,6 +281,18 @@ struct rvtrace_path {
 #define RVTRACE_INVALID_TRACE_ID	0
 };
 
+/**
+ * struct rvtrace_path_node - Representation of a node in the trace path
+ * @head: List head for linking nodes in the path
+ * @comp: Pointer to the trace component at this node
+ * @conn: Pointer to the connection leading to the next node (NULL for sink)
+ */
+struct rvtrace_path_node {
+	struct list_head		head;
+	struct rvtrace_component	*comp;
+	struct rvtrace_connection	*conn;
+};
+
 struct rvtrace_component *rvtrace_path_source(struct rvtrace_path *path);
 struct rvtrace_component *rvtrace_path_sink(struct rvtrace_path *path);
 struct rvtrace_path *rvtrace_create_path(struct rvtrace_component *source,
@@ -324,7 +336,7 @@ struct rvtrace_driver {
 	const struct rvtrace_component_id *id_table;
 	size_t			(*copyto_auxbuf)(struct rvtrace_component *comp,
 						 struct rvtrace_perf_auxbuf *buf);
-	int			(*start)(struct rvtrace_component *comp);
+	int			(*start)(struct rvtrace_path_node *node);
 	int			(*stop)(struct rvtrace_component *comp);
 	int			(*probe)(struct rvtrace_component *comp);
 	void			(*remove)(struct rvtrace_component *comp);

-- 
2.34.1




More information about the linux-riscv mailing list