[PATCH RFC 05/12] rvtrace: encoder: Add pre-ratified support

From: Eric Lin

Date: Tue Jun 30 2026 - 05:53:26 EST


Add pre-ratified version support to the encoder driver and a
pre-ratified match rule in rvtrace_match_id(). This allows
pre-ratified trace hardware to leverage the rvtrace driver
framework.

Co-developed-by: Nick Hu <nick.hu@xxxxxxxxxx>
Signed-off-by: Nick Hu <nick.hu@xxxxxxxxxx>
Co-developed-by: Vincent Chen <vincent.chen@xxxxxxxxxx>
Signed-off-by: Vincent Chen <vincent.chen@xxxxxxxxxx>
Signed-off-by: Eric Lin <eric.lin@xxxxxxxxxx>
---
drivers/hwtracing/rvtrace/rvtrace-core.c | 24 ++++++++++++++++--------
drivers/hwtracing/rvtrace/rvtrace-encoder.c | 2 ++
2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/hwtracing/rvtrace/rvtrace-core.c b/drivers/hwtracing/rvtrace/rvtrace-core.c
index 12ffc6917c70..153cf3ebffff 100644
--- a/drivers/hwtracing/rvtrace/rvtrace-core.c
+++ b/drivers/hwtracing/rvtrace/rvtrace-core.c
@@ -70,7 +70,7 @@ const struct rvtrace_component_id *rvtrace_match_id(struct rvtrace_component *co
u32 comp_maj, comp_min, id_maj, id_min;
const struct rvtrace_component_id *id;

- for (id = ids; id->version && id->type; id++) {
+ for (id = ids; id->type; id++) {
if (comp->id.type != id->type)
return NULL;

@@ -81,13 +81,21 @@ const struct rvtrace_component_id *rvtrace_match_id(struct rvtrace_component *co
if (comp_maj > id_maj)
continue;

- /* Refer to Ch. 5 'Versioning of components of the Trace Control spec. */
- if (comp_maj < id_maj)
- dev_warn(&comp->dev, "Older component with major version %d\n", comp_maj);
- if (comp_min == 15)
- dev_warn(&comp->dev, "Experimental component\n");
- else if (comp_min > id_min)
- dev_warn(&comp->dev, "Newer component with minor version %d\n", comp_min);
+ if (comp_maj == 0) {
+ if (id_maj > 0)
+ continue;
+ } else {
+ /* Refer to Ch. 5 'Versioning of components of the Trace Control spec. */
+ if (comp_maj < id_maj)
+ dev_warn(&comp->dev, "Older component with major version %d\n",
+ comp_maj);
+ if (comp_min == 15)
+ dev_warn(&comp->dev, "Experimental component\n");
+ else if (comp_min > id_min)
+ dev_warn(&comp->dev, "Newer component with minor version %d\n",
+ comp_min);
+ }
+

return id;
}
diff --git a/drivers/hwtracing/rvtrace/rvtrace-encoder.c b/drivers/hwtracing/rvtrace/rvtrace-encoder.c
index f0a4ac46b6a9..f3be47e448cf 100644
--- a/drivers/hwtracing/rvtrace/rvtrace-encoder.c
+++ b/drivers/hwtracing/rvtrace/rvtrace-encoder.c
@@ -98,6 +98,8 @@ static void rvtrace_encoder_remove(struct rvtrace_component *comp)
static struct rvtrace_component_id rvtrace_encoder_ids[] = {
{ .type = RVTRACE_COMPONENT_TYPE_ENCODER,
.version = rvtrace_component_mkversion(1, 0), },
+ { .type = RVTRACE_COMPONENT_TYPE_ENCODER,
+ .version = rvtrace_component_mkversion(0, 0), },
{},
};


--
2.34.1