From: sashiko-bot@kernel.org
To: "Mayuresh Chitale" <mayuresh.chitale@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v7 06/14] gtrace: Add RISC-V Trace encoder driver
Date: Thu, 26 Nov 2026 10:09:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-235248@kernel.org> (raw)
In-Reply-To: <7c08bb0d199c3a8cf0ec0b875d5a42165ec164eb.1795512532.git.mayuresh.chitale@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] gtrace: broken source ID bit-width probing in
rvtrace_encoder_probe()
- [Medium] gtrace: missing trTeEmpty flush poll in
rvtrace_encoder_stop()
--
commit 23f7809d52c4ad4dc2d6c2111a3f04ab70095757
Author: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
gtrace: Add RISC-V Trace encoder driver
This commit adds the initial driver for the RISC-V E-Trace encoder
component defined by the RISC-V Trace Control Interface specification.
> diff --git a/drivers/hwtracing/gtrace/rvtrace-encoder.c b/drivers/hwtracing/gtrace/rvtrace-encoder.c
> new file mode 100644
> index 0000000000000..f528a6af42e14
> --- /dev/null
> +++ b/drivers/hwtracing/gtrace/rvtrace-encoder.c
[ ... ]
> +static int rvtrace_encoder_probe(struct gtrace_component *comp)
> +{
> + struct gtrace_platform_data *pdata = comp->pdata;
> + struct rvtrace_encoder_priv *priv;
> + u32 val, hw_srcbits, srcbits;
> + int ret;
[ ... ]
> + /* Check if trTeInhibitSrc is hardwired to 1 */
> + val = gtrace_read32(pdata, RVTRACE_COMPONENT_CTRL_OFFSET);
> + val &= ~BIT(RVTRACE_COMPONENT_CTRL_INHIBITSRC_SHIFT);
> + gtrace_write32(pdata, val, RVTRACE_COMPONENT_CTRL_OFFSET);
> + val = gtrace_read32(pdata, RVTRACE_COMPONENT_CTRL_OFFSET);
> + if (!(val & BIT(RVTRACE_COMPONENT_CTRL_INHIBITSRC_SHIFT))) {
> + /* Probe how many bits can trTeSrcID span in the emitted Trace messages */
> + val = gtrace_read32(pdata, RVTRACE_ENCODER_INSTFEAT_OFFSET);
> + hw_srcbits = RVTRACE_ENCODER_INSTFEAT_SRCBITS_MAX;
> + do {
> + val &= ~RVTRACE_ENCODER_INSTFEAT_SRCBITS_MASK;
> + val |= FIELD_PREP(RVTRACE_ENCODER_INSTFEAT_SRCBITS_MASK, hw_srcbits);
> + gtrace_write32(pdata, val, RVTRACE_ENCODER_INSTFEAT_OFFSET);
> + val = gtrace_read32(pdata, RVTRACE_ENCODER_INSTFEAT_OFFSET);
> + if (FIELD_GET(RVTRACE_ENCODER_INSTFEAT_SRCBITS_MASK, val) == hw_srcbits)
> + break;
> + } while (--hw_srcbits);
> + /* Determine if there are sufficient bits to hold max cpus */
> + srcbits = min_t(u32, hw_srcbits, order_base_2(nr_cpu_ids));
> + if (srcbits && pdata->bound_cpu < BIT(srcbits)) {
> + rvtrace_encoder_set_srcid(pdata, srcbits);
> + val = gtrace_read32(pdata, RVTRACE_ENCODER_INSTFEAT_OFFSET);
> + if (FIELD_GET(RVTRACE_ENCODER_INSTFEAT_SRCBITS_MASK, val) == srcbits)
> + priv->srcbits = srcbits;
> + }
> + }
[Severity: High]
Does clamping srcbits with order_base_2(nr_cpu_ids) leave priv->srcbits
unset on single-CPU systems or hardware with a fixed trTeSrcBits width?
When nr_cpu_ids is 1, order_base_2(1) evaluates to 0, so srcbits is 0 and
no source ID is configured. In addition, trTeSrcBits in trTeInstFeatures
is a WARL field often fixed to a synthesis-time width (e.g. 4 bits); when
order_base_2(nr_cpu_ids) is smaller than that fixed width, reading back
RVTRACE_ENCODER_INSTFEAT_SRCBITS_MASK returns hw_srcbits rather than
srcbits, causing the equality check to fail and disabling source IDs even
though hw_srcbits can hold pdata->bound_cpu.
[ ... ]
> +static int rvtrace_encoder_stop(struct gtrace_component *comp)
> +{
> + struct gtrace_platform_data *pdata = comp->pdata;
> + int ret, err;
> + u32 val;
> +
> + val = gtrace_read32(pdata, RVTRACE_COMPONENT_CTRL_OFFSET);
> + val &= ~BIT(RVTRACE_COMPONENT_CTRL_ITRACE_SHIFT);
> + gtrace_write32(pdata, val, RVTRACE_COMPONENT_CTRL_OFFSET);
> + ret = gtrace_poll_bit(pdata, RVTRACE_COMPONENT_CTRL_OFFSET,
> + RVTRACE_COMPONENT_CTRL_ITRACE_SHIFT, 0,
> + pdata->control_poll_timeout_usecs);
> + if (ret)
> + dev_err(&comp->dev, "failed to stop tracing.\n");
> +
> + err = gtrace_disable_component(comp);
> + if (err)
> + dev_err(&comp->dev, "failed to disable encoder.\n");
> +
> + return ret ?: err;
> +}
[Severity: Medium]
Should rvtrace_encoder_stop() call rvtrace_comp_poll_empty(comp) before
disabling the encoder?
Per the RISC-V Trace Control Interface specification, clearing
trTeInstTracing causes the encoder to flush remaining queued trace
packets and assert trTeEmpty when drained. Disabling the component
before trTeEmpty asserts can discard buffered trace data at the end of a
session.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795512532.git.mayuresh.chitale@oss.qualcomm.com?part=6
next prev parent reply other threads:[~2026-11-26 10:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 9:55 [PATCH v7 00/14] Linux RISC-V trace framework and drivers Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 01/14] dt-bindings: Add RISC-V trace component bindings Mayuresh Chitale
2026-11-26 10:07 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 02/14] hwtracing: gtrace: Initial implementation of gtrace framework Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 03/14] gtrace: Add RISC-V platform driver for the " Mayuresh Chitale
2026-11-26 10:12 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 04/14] gtrace: Add functions to create/destroy a trace component path Mayuresh Chitale
2026-11-26 10:07 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 05/14] gtrace: Add functions to start/stop tracing on a " Mayuresh Chitale
2026-11-26 10:05 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 06/14] gtrace: Add RISC-V Trace encoder driver Mayuresh Chitale
2026-11-26 10:09 ` sashiko-bot [this message]
2026-11-26 9:55 ` [PATCH v7 07/14] gtrace: Add function to copy into perf AUX buffer Mayuresh Chitale
2026-11-26 10:05 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 08/14] perf: Add gtrace AUX buffer trace format type Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 09/14] gtrace: Add RISC-V Trace ramsink driver Mayuresh Chitale
2026-11-26 10:13 ` sashiko-bot
2026-11-26 9:55 ` [PATCH v7 10/14] riscv: Enable DMA_RESTRICTED_POOL in defconfig Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 11/14] gtrace: Add perf driver for tracing using perf tool Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 12/14] perf tools: Add RISC-V trace PMU record capabilities Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 13/14] perf tools: Initial support for gtrace decoder Mayuresh Chitale
2026-11-26 9:55 ` [PATCH v7 14/14] MAINTAINERS: Add entry for RISC-V trace framework Mayuresh Chitale
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=sashiko-outbox-235248@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=mayuresh.chitale@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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