[PATCH v6 02/14] hwtracing: gtrace: Initial implementation of gtrace framework

Leo Yu-Chi Liang leo.liang at sifive.com
Mon Nov 9 19:08:07 PST 2026


Hi Mayuresh,

On 10/1/2026 1:22 PM, Mayuresh Chitale wrote:
> +const struct gtrace_component_id *gtrace_match_id(struct gtrace_component *comp,
> +						  const struct gtrace_component_id *ids)
> +{
> +	const struct gtrace_component_id *id;
> +
> +	for (id = ids; id->version; id++) {
> +		if (comp->id.type != id->type)
> +			continue;
> +
> +		return id;
> +	}

Following up on sashiko's comment: we are adding support for SiFive
pre-ratified trace components on top of this series, and they are
registered with major version 0. Using version 0 as the table terminator
means a driver cannot list a { type, version 0 } entry, which the
eswin/EIC7700 SoC ships.

For now this works because only the type is compared and the
mkversion(1, 0) entry matches any version. But a later version check
would silently drop version 0 components.

Since GTRACE_RVTRACE_ENCODER is 0, the type cannot be the terminator
either. How about reserving type 0:

	enum gtrace_component_type {
		GTRACE_COMPONENT_TYPE_NONE,	/* id table terminator */
		GTRACE_RVTRACE_ENCODER,
		...
	};

	for (id = ids; ids && id->type != GTRACE_COMPONENT_TYPE_NONE; id++) {

The NULL ids check would also cover the missing id_table case that
sashiko raised.

Thanks,
Leo



More information about the linux-riscv mailing list