mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leo Yu-Chi Liang <leo.liang@sifive.com>
To: Mayuresh Chitale <mchitale@gmail.com>,
	Anup Patel <anup@brainfault.org>,  Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Paul Walmsley <pjw@kernel.org>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	 Alexandre Ghiti <alex@ghiti.fr>,
	Samuel Holland <samuel.holland@sifive.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Leo Yu-Chi Liang <leo.liang@sifive.com>,
	 linmin@eswincomputing.com, vincent.chen@sifive.com,
	 luyulin@eswincomputing.com, pritesh.patel@einfochips.com,
	 ganboing@gmail.com, dongxuyang@eswincomputing.com,
	 pinkesh.vaghela@einfochips.com, nick.hu@sifive.com,
	eric.lin@sifive.com,  huangyifeng@eswincomputing.com,
	darshan.prajapati@einfochips.com
Subject: [PATCH 07/10] gtrace: rvtrace: Add pre-ratified trace funnel driver
Date: Thu, 26 Nov 2026 01:07:13 -0800	[thread overview]
Message-ID: <20261126-send-preratified-trace-v1-7-1e686fd75be7@sifive.com> (raw)
In-Reply-To: <20261126-send-preratified-trace-v1-0-1e686fd75be7@sifive.com>

From: Eric Lin <eric.lin@sifive.com>

Add the initial implementation to support the pre-ratified RISC-V
trace funnel. This implementation provides basic functionality to
enable the trace funnel, configure its next sink when tracing starts,
and disable the funnel when tracing stops.

Co-developed-by: Nick Hu <nick.hu@sifive.com>
Signed-off-by: Nick Hu <nick.hu@sifive.com>
Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Eric Lin <eric.lin@sifive.com>
Signed-off-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
---
 drivers/hwtracing/gtrace/Kconfig          | 13 ++++
 drivers/hwtracing/gtrace/Makefile         |  1 +
 drivers/hwtracing/gtrace/rvtrace-funnel.c | 98 +++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)

diff --git a/drivers/hwtracing/gtrace/Kconfig b/drivers/hwtracing/gtrace/Kconfig
index b1f9ca8f73cb..66fc2791d8f4 100644
--- a/drivers/hwtracing/gtrace/Kconfig
+++ b/drivers/hwtracing/gtrace/Kconfig
@@ -43,6 +43,19 @@ config RVTRACE_ENCODER
 	  To compile this driver as a module, choose M here: the module
 	  will be called rvtrace-encoder.
 
+config RVTRACE_FUNNEL
+	tristate "RISC-V Trace Funnel driver"
+	depends on RVTRACE_V0
+	default y
+	help
+	  This driver provides support for the RISC-V trace funnel component
+	  which combines the trace data from multiple upstream components
+	  into a single trace stream. Only pre-ratified trace funnels are
+	  supported for now.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called rvtrace-funnel.
+
 config RVTRACE_RAMSINK
 	tristate "RISC-V Trace Ramsink driver"
 	depends on RVTRACE
diff --git a/drivers/hwtracing/gtrace/Makefile b/drivers/hwtracing/gtrace/Makefile
index 0a2e2d1732c2..38dd96b3dc34 100644
--- a/drivers/hwtracing/gtrace/Makefile
+++ b/drivers/hwtracing/gtrace/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_RVTRACE) += rvtrace.o
 rvtrace-y := rvtrace-platform.o
 rvtrace-$(CONFIG_RVTRACE_V0) += rvtrace-v0.o
 obj-$(CONFIG_RVTRACE_ENCODER) += rvtrace-encoder.o
+obj-$(CONFIG_RVTRACE_FUNNEL) += rvtrace-funnel.o
 obj-$(CONFIG_RVTRACE_RAMSINK) += rvtrace-ramsink.o
diff --git a/drivers/hwtracing/gtrace/rvtrace-funnel.c b/drivers/hwtracing/gtrace/rvtrace-funnel.c
new file mode 100644
index 000000000000..2e0843d233ab
--- /dev/null
+++ b/drivers/hwtracing/gtrace/rvtrace-funnel.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2026 SiFive Inc.
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/gtrace.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include "rvtrace.h"
+#include "rvtrace-v0.h"
+
+static int rvtrace_funnel_start(struct gtrace_path_node *node)
+{
+	struct gtrace_component *comp = node->comp;
+	int ret;
+
+	/* Set pre-ratified comp's next sink */
+	ret = rvtrace_v0_sink_config(node);
+	if (ret) {
+		dev_err(&comp->dev, "failed to set next sink.\n");
+		return ret;
+	}
+
+	ret = gtrace_enable_component(comp);
+	if (ret)
+		dev_err(&comp->dev, "failed to enable funnel.\n");
+
+	return ret;
+}
+
+static int rvtrace_funnel_stop(struct gtrace_component *comp)
+{
+	int ret;
+
+	ret = gtrace_disable_component(comp);
+	if (ret) {
+		dev_err(&comp->dev, "failed to disable funnel.\n");
+		return ret;
+	}
+
+	return rvtrace_comp_poll_empty(comp);
+}
+
+static int rvtrace_funnel_probe(struct gtrace_component *comp)
+{
+	int ret;
+
+	ret = gtrace_enable_component(comp);
+	if (ret)
+		return dev_err_probe(&comp->dev, ret, "failed to enable funnel.\n");
+
+	return 0;
+}
+
+static void rvtrace_funnel_remove(struct gtrace_component *comp)
+{
+	int ret;
+
+	ret = gtrace_disable_component(comp);
+	if (ret)
+		dev_err(&comp->dev, "failed to disable funnel.\n");
+}
+
+static const struct gtrace_component_id rvtrace_funnel_ids[] = {
+	{ .type = GTRACE_RVTRACE_FUNNEL,
+	  .version = rvtrace_component_mkversion(0, 0), },
+	{},
+};
+
+static struct gtrace_driver rvtrace_funnel_driver = {
+	.id_table = rvtrace_funnel_ids,
+	.start = rvtrace_funnel_start,
+	.stop = rvtrace_funnel_stop,
+	.probe = rvtrace_funnel_probe,
+	.remove = rvtrace_funnel_remove,
+	.driver = {
+		.name = "rvtrace-funnel",
+	},
+};
+
+static int __init rvtrace_funnel_init(void)
+{
+	return gtrace_register_driver(&rvtrace_funnel_driver);
+}
+
+static void __exit rvtrace_funnel_exit(void)
+{
+	gtrace_unregister_driver(&rvtrace_funnel_driver);
+}
+
+module_init(rvtrace_funnel_init);
+module_exit(rvtrace_funnel_exit);
+
+/* Module information */
+MODULE_DESCRIPTION("RISC-V Trace Funnel Driver");
+MODULE_LICENSE("GPL");

-- 
2.43.7


  parent reply	other threads:[~2026-11-26  9:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Leo Yu-Chi Liang [this message]
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:07 ` [PATCH 10/10] gtrace: rvtrace: Add copyto_auxbuf callback for pre-ratified encoder and funnel Leo Yu-Chi Liang

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=20261126-send-preratified-trace-v1-7-1e686fd75be7@sifive.com \
    --to=leo.liang@sifive.com \
    --cc=alex@ghiti.fr \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=conor+dt@kernel.org \
    --cc=darshan.prajapati@einfochips.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dongxuyang@eswincomputing.com \
    --cc=eric.lin@sifive.com \
    --cc=ganboing@gmail.com \
    --cc=huangyifeng@eswincomputing.com \
    --cc=krzk+dt@kernel.org \
    --cc=linmin@eswincomputing.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=luyulin@eswincomputing.com \
    --cc=mchitale@gmail.com \
    --cc=nick.hu@sifive.com \
    --cc=palmer@dabbelt.com \
    --cc=pinkesh.vaghela@einfochips.com \
    --cc=pjw@kernel.org \
    --cc=pritesh.patel@einfochips.com \
    --cc=robh@kernel.org \
    --cc=samuel.holland@sifive.com \
    --cc=vincent.chen@sifive.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

all inboxes | Powered by JetHome®