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 09/14] gtrace: Add RISC-V Trace ramsink driver
Date: Thu, 26 Nov 2026 10:13:18 +0000 [thread overview]
Message-ID: <sashiko-outbox-235255@kernel.org> (raw)
In-Reply-To: <4ea1823645f6841ddb551eb9a7bb81bd0879e57f.1795512532.git.mayuresh.chitale@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] gtrace: stale trace data copied on wrap in
rvtrace_ramsink_copyto_auxbuf()
--
commit ed8acf419ff33b6e8c0e35b30a76e41399f3be04
Author: Mayuresh Chitale <mayuresh.chitale@oss.qualcomm.com>
gtrace: Add RISC-V Trace ramsink driver
This commit adds the RISC-V E-Trace ramsink driver for the gtrace
framework, storing trace data into a system memory DMA buffer and copying
it to the perf AUX buffer.
> diff --git a/drivers/hwtracing/gtrace/rvtrace-ramsink.c b/drivers/hwtracing/gtrace/rvtrace-ramsink.c
> new file mode 100644
> index 0000000000000..24697e6096ec8
> --- /dev/null
> +++ b/drivers/hwtracing/gtrace/rvtrace-ramsink.c
[ ... ]
> +static size_t rvtrace_ramsink_copyto_auxbuf(struct gtrace_component *comp,
> + struct gtrace_perf_auxbuf *buf,
> + size_t size,
> + u64 *aux_flags)
> +{
> + struct rvtrace_ramsink_priv *priv = dev_get_drvdata(&comp->dev);
> + struct trace_buf src, dst;
> + size_t bytes = 0;
> + bool wrap;
> + u64 wp;
> +
> + dst.base = buf->base;
> + dst.len = buf->length;
> + dst.cur = buf->pos;
> + src.base = priv->va;
> + src.len = priv->size;
> + *aux_flags = 0;
> + wp = gtrace_read_pair(comp->pdata, RVTRACE_RAMSINK_WPLOW_OFF,
> + RVTRACE_RAMSINK_WPHIGH_OFF);
> + wrap = wp & RVTRACE_RAMSINK_WPLOW_WRAP;
> + wp &= ~RVTRACE_RAMSINK_WPLOW_WRAP;
> +
> + if (wp < priv->start || wp >= priv->end ||
> + (!wrap && wp < priv->prev_wp))
> + return 0;
> +
> + if (wrap) {
> + gtrace_write_pair(comp->pdata, priv->start, RVTRACE_RAMSINK_WPLOW_OFF,
> + RVTRACE_RAMSINK_WPHIGH_OFF);
> + src.cur = wp - priv->start;
> + priv->prev_wp = priv->start;
> + /*
> + * There is no way to tell if trRamWp wrapped around more than once. As a
> + * result priv->prev_wp can't be used and the entire buffer must be copied
> + * even though some data might be duplicated.
> + */
> + bytes = priv->size;
> + } else {
> + src.cur = priv->prev_wp - priv->start;
> + bytes = wp - priv->prev_wp;
> + priv->prev_wp = wp;
> + }
[Severity: High]
As reported by Leo Yu-Chi Liang on v6 [1], can the wrap path copy stale
trace data from earlier captures into the perf AUX buffer?
When a capture finishes without wrapping, the non-wrap branch advances
priv->prev_wp to wp without resetting trRamWP to priv->start, and
rvtrace_ramsink_start() does not reset trRamWP or priv->prev_wp either.
The next capture therefore resumes writing at priv->prev_wp. If it crosses
priv->end and stops at a wrapped wp < priv->prev_wp, the region
[wp, priv->prev_wp) was not written during that capture and still holds
data from previous captures or an earlier perf session, yet the wrap branch
copies the full priv->size bytes starting at wp.
Resetting trRamWP and priv->prev_wp to priv->start in
rvtrace_ramsink_start() (or after each copy in
rvtrace_ramsink_copyto_auxbuf()) would ensure each capture starts at the
beginning of the buffer.
[1] https://lore.kernel.org/r/20261126065537.705845-1-leo.liang@sifive.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795512532.git.mayuresh.chitale@oss.qualcomm.com?part=9
next prev parent reply other threads:[~2026-11-26 10:13 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
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 [this message]
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-235255@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