@@ -57,6 +57,8 @@ struct trbe_buf {
57
57
* trbe_limit sibling pointers.
58
58
*/
59
59
unsigned long trbe_base ;
60
+ /* The base programmed into the TRBE */
61
+ unsigned long trbe_hw_base ;
60
62
unsigned long trbe_limit ;
61
63
unsigned long trbe_write ;
62
64
int nr_pages ;
@@ -470,12 +472,13 @@ static void set_trbe_limit_pointer_enabled(unsigned long addr)
470
472
471
473
static void trbe_enable_hw (struct trbe_buf * buf )
472
474
{
473
- WARN_ON (buf -> trbe_write < buf -> trbe_base );
475
+ WARN_ON (buf -> trbe_hw_base < buf -> trbe_base );
476
+ WARN_ON (buf -> trbe_write < buf -> trbe_hw_base );
474
477
WARN_ON (buf -> trbe_write >= buf -> trbe_limit );
475
478
set_trbe_disabled ();
476
479
isb ();
477
480
clr_trbe_status ();
478
- set_trbe_base_pointer (buf -> trbe_base );
481
+ set_trbe_base_pointer (buf -> trbe_hw_base );
479
482
set_trbe_write_pointer (buf -> trbe_write );
480
483
481
484
/*
@@ -520,7 +523,12 @@ static unsigned long trbe_get_trace_size(struct perf_output_handle *handle,
520
523
else
521
524
write = get_trbe_write_pointer ();
522
525
523
- end_off = write - get_trbe_base_pointer ();
526
+ /*
527
+ * TRBE may use a different base address than the base
528
+ * of the ring buffer. Thus use the beginning of the ring
529
+ * buffer to compute the offsets.
530
+ */
531
+ end_off = write - buf -> trbe_base ;
524
532
start_off = PERF_IDX2OFF (handle -> head , buf );
525
533
526
534
if (WARN_ON_ONCE (end_off < start_off ))
@@ -678,6 +686,8 @@ static int __arm_trbe_enable(struct trbe_buf *buf,
678
686
trbe_stop_and_truncate_event (handle );
679
687
return - ENOSPC ;
680
688
}
689
+ /* Set the base of the TRBE to the buffer base */
690
+ buf -> trbe_hw_base = buf -> trbe_base ;
681
691
* this_cpu_ptr (buf -> cpudata -> drvdata -> handle ) = handle ;
682
692
trbe_enable_hw (buf );
683
693
return 0 ;
@@ -771,7 +781,7 @@ static bool is_perf_trbe(struct perf_output_handle *handle)
771
781
struct trbe_drvdata * drvdata = cpudata -> drvdata ;
772
782
int cpu = smp_processor_id ();
773
783
774
- WARN_ON (buf -> trbe_base != get_trbe_base_pointer ());
784
+ WARN_ON (buf -> trbe_hw_base != get_trbe_base_pointer ());
775
785
WARN_ON (buf -> trbe_limit != get_trbe_limit_pointer ());
776
786
777
787
if (cpudata -> mode != CS_MODE_PERF )
0 commit comments