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 03/10] gtrace: rvtrace: Add pre-ratified private data callback
Date: Thu, 26 Nov 2026 01:07:09 -0800 [thread overview]
Message-ID: <20261126-send-preratified-trace-v1-3-1e686fd75be7@sifive.com> (raw)
In-Reply-To: <20261126-send-preratified-trace-v1-0-1e686fd75be7@sifive.com>
From: Eric Lin <eric.lin@sifive.com>
For pre-ratified trace hardware, a trace component might support
different trace sinks, and its trace sink availability information
is embedded within the implementation register.
Introduce a get_data() callback function in 'struct rvtrace_match_data'
to retrieve the component's supported trace sink features and store
this information in the gtrace component ID data (comp->id.data). This
allows the driver to access the pre-ratified hardware capabilities
during setup.
While at it, zero-initialize the on-stack gtrace_component_id so that
id.data is never left uninitialized for ratified components.
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/rvtrace-platform.c | 10 ++++++++++
drivers/hwtracing/gtrace/rvtrace-v0.c | 22 ++++++++++++++++++++++
drivers/hwtracing/gtrace/rvtrace-v0.h | 22 ++++++++++++++++++++++
drivers/hwtracing/gtrace/rvtrace.h | 4 ++++
4 files changed, 58 insertions(+)
diff --git a/drivers/hwtracing/gtrace/rvtrace-platform.c b/drivers/hwtracing/gtrace/rvtrace-platform.c
index 8c1503bd8d98..b9b256d469e2 100644
--- a/drivers/hwtracing/gtrace/rvtrace-platform.c
+++ b/drivers/hwtracing/gtrace/rvtrace-platform.c
@@ -71,6 +71,7 @@ static int rvtrace_platform_probe(struct platform_device *pdev)
u32 impl, type, major, minor;
struct device_node *node;
struct resource *res;
+ void *data = NULL;
int gtype;
int ret;
@@ -126,6 +127,12 @@ static int rvtrace_platform_probe(struct platform_device *pdev)
else
impl = gtrace_read32(pdata, RVTRACE_COMPONENT_IMPL_OFFSET);
+ if (match_data->get_data) {
+ data = match_data->get_data(pdata);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+ }
+
type = (impl >> RVTRACE_COMPONENT_IMPL_TYPE_SHIFT) &
RVTRACE_COMPONENT_IMPL_TYPE_MASK;
major = (impl >> RVTRACE_COMPONENT_IMPL_VERMAJOR_SHIFT) &
@@ -139,6 +146,7 @@ static int rvtrace_platform_probe(struct platform_device *pdev)
id.type = gtype;
id.version = rvtrace_component_mkversion(major, minor);
+ id.data = data;
comp = gtrace_register_component(&id, rvtrace_type_name(gtype), pdata);
if (IS_ERR(comp))
@@ -172,11 +180,13 @@ static const struct rvtrace_match_data rvtrace_std_data = {
static const struct rvtrace_match_data rvtrace_v0_encoder_data = {
.format = GTRACE_FORMAT_NTRACE,
.get_impl = rvtrace_v0_get_encoder_impl,
+ .get_data = rvtrace_v0_get_comp_data,
};
static const struct rvtrace_match_data rvtrace_v0_funnel_data = {
.format = GTRACE_FORMAT_NTRACE,
.get_impl = rvtrace_v0_get_funnel_impl,
+ .get_data = rvtrace_v0_get_comp_data,
};
#endif
diff --git a/drivers/hwtracing/gtrace/rvtrace-v0.c b/drivers/hwtracing/gtrace/rvtrace-v0.c
index a5ca9001bc08..01e62642c245 100644
--- a/drivers/hwtracing/gtrace/rvtrace-v0.c
+++ b/drivers/hwtracing/gtrace/rvtrace-v0.c
@@ -3,10 +3,32 @@
* Copyright (c) 2026 SiFive Inc.
*/
+#include <linux/device.h>
+#include <linux/err.h>
#include <linux/gtrace.h>
#include "rvtrace.h"
#include "rvtrace-v0.h"
+void *rvtrace_v0_get_comp_data(struct gtrace_platform_data *pdata)
+{
+ struct rvtrace_v0_comp_features *data;
+ u32 impl;
+
+ data = devm_kzalloc(pdata->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return ERR_PTR(-ENOMEM);
+
+ impl = gtrace_read32(pdata, RVTRACE_COMPONENT_IMPL_OFFSET);
+
+ data->has_sram_sink = impl & RVTRACE_V0_IMPL_HAS_SRAM_SINK_MASK;
+ data->has_atb_sink = impl & RVTRACE_V0_IMPL_HAS_ATB_SINK_MASK;
+ data->has_pib_sink = impl & RVTRACE_V0_IMPL_HAS_PIB_SINK_MASK;
+ data->has_sba_sink = impl & RVTRACE_V0_IMPL_HAS_SBA_SINK_MASK;
+ data->has_funnel_sink = impl & RVTRACE_V0_IMPL_HAS_FUNNEL_SINK_MASK;
+
+ return data;
+}
+
static u32 rvtrace_v0_get_impl(struct gtrace_platform_data *pdata,
enum rvtrace_component_type type)
{
diff --git a/drivers/hwtracing/gtrace/rvtrace-v0.h b/drivers/hwtracing/gtrace/rvtrace-v0.h
index 2d83c87936b9..0681405fa414 100644
--- a/drivers/hwtracing/gtrace/rvtrace-v0.h
+++ b/drivers/hwtracing/gtrace/rvtrace-v0.h
@@ -9,9 +9,31 @@
#define __RVTRACE_V0_H__
#include <linux/gtrace.h>
+#include <linux/bits.h>
#include <linux/types.h>
+#define RVTRACE_V0_IMPL_HAS_SRAM_SINK_BIT 4
+#define RVTRACE_V0_IMPL_HAS_ATB_SINK_BIT 5
+#define RVTRACE_V0_IMPL_HAS_PIB_SINK_BIT 6
+#define RVTRACE_V0_IMPL_HAS_SBA_SINK_BIT 7
+#define RVTRACE_V0_IMPL_HAS_FUNNEL_SINK_BIT 8
+
+#define RVTRACE_V0_IMPL_HAS_SRAM_SINK_MASK BIT(RVTRACE_V0_IMPL_HAS_SRAM_SINK_BIT)
+#define RVTRACE_V0_IMPL_HAS_ATB_SINK_MASK BIT(RVTRACE_V0_IMPL_HAS_ATB_SINK_BIT)
+#define RVTRACE_V0_IMPL_HAS_PIB_SINK_MASK BIT(RVTRACE_V0_IMPL_HAS_PIB_SINK_BIT)
+#define RVTRACE_V0_IMPL_HAS_SBA_SINK_MASK BIT(RVTRACE_V0_IMPL_HAS_SBA_SINK_BIT)
+#define RVTRACE_V0_IMPL_HAS_FUNNEL_SINK_MASK BIT(RVTRACE_V0_IMPL_HAS_FUNNEL_SINK_BIT)
+
+struct rvtrace_v0_comp_features {
+ bool has_sram_sink;
+ bool has_atb_sink;
+ bool has_pib_sink;
+ bool has_sba_sink;
+ bool has_funnel_sink;
+};
+
u32 rvtrace_v0_get_encoder_impl(struct gtrace_platform_data *pdata);
u32 rvtrace_v0_get_funnel_impl(struct gtrace_platform_data *pdata);
+void *rvtrace_v0_get_comp_data(struct gtrace_platform_data *pdata);
#endif /* __RVTRACE_V0_H__ */
diff --git a/drivers/hwtracing/gtrace/rvtrace.h b/drivers/hwtracing/gtrace/rvtrace.h
index 7f9e88d99b8f..b0cf2e1d875f 100644
--- a/drivers/hwtracing/gtrace/rvtrace.h
+++ b/drivers/hwtracing/gtrace/rvtrace.h
@@ -115,10 +115,14 @@ static inline const char *rvtrace_type_name(enum gtrace_component_type type)
* @get_impl: Optional callback to retrieve the implementation register value
* encoded in the standard RISC-V trace IMPL register format. Used
* by pre-ratified components whose IMPL register layout differs.
+ * @get_data: Optional callback to retrieve component specific private data
+ * which is stored in gtrace_component_id.data. Returns an ERR_PTR()
+ * on failure.
*/
struct rvtrace_match_data {
enum gtrace_format format;
u32 (*get_impl)(struct gtrace_platform_data *pdata);
+ void *(*get_data)(struct gtrace_platform_data *pdata);
};
static inline int rvtrace_comp_poll_empty(struct gtrace_component *comp)
--
2.43.7
next prev 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 ` Leo Yu-Chi Liang [this message]
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: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-3-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®