Re: [PATCH v6 03/14] gtrace: Add RISC-V platform driver for the gtrace framework

From: Leo Liang

Date: Tue Oct 27 2026 - 00:54:23 EST


On Thu, Oct 01, 2026 at 10:52:14AM +0530, Mayuresh Chitale wrote:
> From: Anup Patel <anup.patel@xxxxxxxxxxxxxxxx>
>
> The RISC-V trace components defined by the RISC-V Trace Control Interface
> Specification are memory mapped devices which are organized in a
> graph-like topology and described in the device tree.
>
> Add the RISC-V platform driver for the gtrace framework. The driver
> parses the RISC-V component topology from the device tree, discovers the
> type and version of each component from its IMPL register, provides the
> RISC-V register level control ops and registers each component with the
> gtrace core.
>
> Signed-off-by: Anup Patel <anup.patel@xxxxxxxxxxxxxxxx>
> Co-developed-by: Mayuresh Chitale <mayuresh.chitale@xxxxxxxxxxxxxxxx>
> Signed-off-by: Mayuresh Chitale <mayuresh.chitale@xxxxxxxxxxxxxxxx>
> ---
> drivers/hwtracing/gtrace/Kconfig | 15 ++
> drivers/hwtracing/gtrace/Makefile | 3 +
> drivers/hwtracing/gtrace/gtrace-of.c | 126 +++++++++++++
> drivers/hwtracing/gtrace/rvtrace-platform.c | 186 ++++++++++++++++++++
> drivers/hwtracing/gtrace/rvtrace.h | 121 +++++++++++++
> include/linux/gtrace.h | 3 +
> 6 files changed, 454 insertions(+)
> create mode 100644 drivers/hwtracing/gtrace/gtrace-of.c
> create mode 100644 drivers/hwtracing/gtrace/rvtrace-platform.c
> create mode 100644 drivers/hwtracing/gtrace/rvtrace.h
>
>
> ...
>
> +
> +/*
> + * Parse the "out-ports" graph of the component's device tree node and allocate

typo: "in-ports"

> + * pdata->inconns.
> + *
> + * Return: 0 on success or when there are no input ports, -ENOMEM otherwise.
> + */
> +int gtrace_of_parse_inconns(struct gtrace_platform_data *pdata)
> +{
> + struct device_node *parent;
> + int ret = 0;
> +
> + parent = of_get_child_by_name(dev_of_node(pdata->dev), "in-ports");
> + if (!parent)
> + return 0;
> +
> + pdata->nr_inconns = of_graph_get_endpoint_count(parent);
> + pdata->inconns = devm_kcalloc(pdata->dev, pdata->nr_inconns,
> + sizeof(*pdata->inconns), GFP_KERNEL);
> + if (!pdata->inconns)
> + ret = -ENOMEM;
> +
> + of_node_put(parent);
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(gtrace_of_parse_inconns);