[PATCH 11/19] coresight: trbe: Apply overwrite erratum for only wrap event

Leo Yan posted 19 patches 2 months, 1 week ago
[PATCH 11/19] coresight: trbe: Apply overwrite erratum for only wrap event
Posted by Leo Yan 2 months, 1 week ago
The overwrite erratum occurs only on wrap events, so apply the extra
wrap condition check in the workaround.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
index e579ea98523c24d23a0cd265dcdd0a46b52b52da..2600af12a8fb94bb8c74efda2a101aacd01b0b34 100644
--- a/drivers/hwtracing/coresight/coresight-trbe.c
+++ b/drivers/hwtracing/coresight/coresight-trbe.c
@@ -714,7 +714,7 @@ static unsigned long trbe_get_trace_size(struct perf_output_handle *handle,
 	 * 64bytes. Thus we ignore the potential triggering of the erratum
 	 * on WRAP and limit the data to LIMIT.
 	 */
-	if (wrap)
+	if (wrap && trbe_may_overwrite_in_fill_mode(buf->cpudata))
 		write = get_trbe_limit_pointer();
 	else
 		write = get_trbe_write_pointer();
@@ -736,7 +736,7 @@ static unsigned long trbe_get_trace_size(struct perf_output_handle *handle,
 	 * the space we skipped with IGNORE packets. And we are always
 	 * guaranteed to have at least a PAGE_SIZE space in the buffer.
 	 */
-	if (trbe_may_overwrite_in_fill_mode(buf->cpudata) &&
+	if (wrap && trbe_may_overwrite_in_fill_mode(buf->cpudata) &&
 	    !WARN_ON(size < overwrite_skip))
 		__trbe_pad_buf(buf, start_off, overwrite_skip);
 

-- 
2.34.1
Re: [PATCH 11/19] coresight: trbe: Apply overwrite erratum for only wrap event
Posted by Suzuki K Poulose 2 months, 1 week ago
On 01/12/2025 11:22, Leo Yan wrote:
> The overwrite erratum occurs only on wrap events, so apply the extra
> wrap condition check in the workaround.
> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
>   drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index e579ea98523c24d23a0cd265dcdd0a46b52b52da..2600af12a8fb94bb8c74efda2a101aacd01b0b34 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -714,7 +714,7 @@ static unsigned long trbe_get_trace_size(struct perf_output_handle *handle,
>   	 * 64bytes. Thus we ignore the potential triggering of the erratum
>   	 * on WRAP and limit the data to LIMIT.
>   	 */
> -	if (wrap)
> +	if (wrap && trbe_may_overwrite_in_fill_mode(buf->cpudata))
>   		write = get_trbe_limit_pointer();

This must be trbe_may_write_out_of_range() ?

Suzuki


>   	else
>   		write = get_trbe_write_pointer();
> @@ -736,7 +736,7 @@ static unsigned long trbe_get_trace_size(struct perf_output_handle *handle,
>   	 * the space we skipped with IGNORE packets. And we are always
>   	 * guaranteed to have at least a PAGE_SIZE space in the buffer.
>   	 */
> -	if (trbe_may_overwrite_in_fill_mode(buf->cpudata) &&
> +	if (wrap && trbe_may_overwrite_in_fill_mode(buf->cpudata) &&
>   	    !WARN_ON(size < overwrite_skip))
>   		__trbe_pad_buf(buf, start_off, overwrite_skip);
>   
>
Re: [PATCH 11/19] coresight: trbe: Apply overwrite erratum for only wrap event
Posted by Leo Yan 2 months, 1 week ago
On Tue, Dec 02, 2025 at 12:05:52PM +0000, Suzuki K Poulose wrote:
> On 01/12/2025 11:22, Leo Yan wrote:
> > The overwrite erratum occurs only on wrap events, so apply the extra
> > wrap condition check in the workaround.
> > 
> > Signed-off-by: Leo Yan <leo.yan@arm.com>
> > ---
> >   drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> > index e579ea98523c24d23a0cd265dcdd0a46b52b52da..2600af12a8fb94bb8c74efda2a101aacd01b0b34 100644
> > --- a/drivers/hwtracing/coresight/coresight-trbe.c
> > +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> > @@ -714,7 +714,7 @@ static unsigned long trbe_get_trace_size(struct perf_output_handle *handle,
> >   	 * 64bytes. Thus we ignore the potential triggering of the erratum
> >   	 * on WRAP and limit the data to LIMIT.
> >   	 */
> > -	if (wrap)
> > +	if (wrap && trbe_may_overwrite_in_fill_mode(buf->cpudata))
> >   		write = get_trbe_limit_pointer();
> 
> This must be trbe_may_write_out_of_range() ?

SDEN (e.g., [1]) is ambiguous about how the write pointer acts for the
out-of-range erratum.

However, SDEN explicitly states for overwrite erratum: "The current
write pointer also increments by the same number of cache line
locations.

If this is still concerned, I can add check
trbe_may_write_out_of_range() in next spin.

Thanks,
Leo

[1] https://documentation-service.arm.com/static/636a660b4e6cf12278ad89c4?token=
Re: [PATCH 11/19] coresight: trbe: Apply overwrite erratum for only wrap event
Posted by Leo Yan 2 months, 1 week ago
On Tue, Dec 02, 2025 at 04:56:47PM +0000, Coresight ML wrote:
> On Tue, Dec 02, 2025 at 12:05:52PM +0000, Suzuki K Poulose wrote:
> > On 01/12/2025 11:22, Leo Yan wrote:
> > > The overwrite erratum occurs only on wrap events, so apply the extra
> > > wrap condition check in the workaround.
> > > 
> > > Signed-off-by: Leo Yan <leo.yan@arm.com>
> > > ---
> > >   drivers/hwtracing/coresight/coresight-trbe.c | 4 ++--
> > >   1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> > > index e579ea98523c24d23a0cd265dcdd0a46b52b52da..2600af12a8fb94bb8c74efda2a101aacd01b0b34 100644
> > > --- a/drivers/hwtracing/coresight/coresight-trbe.c
> > > +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> > > @@ -714,7 +714,7 @@ static unsigned long trbe_get_trace_size(struct perf_output_handle *handle,
> > >   	 * 64bytes. Thus we ignore the potential triggering of the erratum
> > >   	 * on WRAP and limit the data to LIMIT.
> > >   	 */
> > > -	if (wrap)
> > > +	if (wrap && trbe_may_overwrite_in_fill_mode(buf->cpudata))
> > >   		write = get_trbe_limit_pointer();
> > 
> > This must be trbe_may_write_out_of_range() ?
> 
> SDEN (e.g., [1]) is ambiguous about how the write pointer acts for the
> out-of-range erratum.

Thought again, we should not worry about out-of-range case.

As the workaround always ensures sufficient space beyond the limit, the
write pointer remains valid within the allocated buffer even if it is
updated and crosses that limit.