aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwtracing/coresight/coresight-etb10.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwtracing/coresight/coresight-etb10.c')
-rw-r--r--drivers/hwtracing/coresight/coresight-etb10.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 4ee4c80a4354..0764647b92bc 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -374,7 +374,30 @@ static void *etb_alloc_buffer(struct coresight_device *csdev,
int nr_pages, bool overwrite)
{
int node, cpu = event->cpu;
+ u32 capacity;
struct cs_buffers *buf;
+ struct etb_drvdata *drvdata;
+
+ /*
+ * In snapsot mode the size of the perf ring buffer needs to be equal
+ * to the size of the device's internal memory if we want to reuse the
+ * generic AUX buffer management mechanic.
+ *
+ * For example (assuming 4096 byte page size):
+ *
+ * # cat /sys/bus/coresight/devices/20010000.etb/mgmt/rdp
+ * 0x2000
+ * # perf record -e cs_etm/@20010000.etf/ -S -m,8 --per-thread $APP
+ *
+ */
+ drvdata = dev_get_drvdata(csdev->dev.parent);
+ capacity = drvdata->buffer_depth * ETB_FRAME_SIZE_WORDS;
+
+ if (overwrite &&
+ ((nr_pages << PAGE_SHIFT) != capacity)) {
+ dev_err(&csdev->dev, "Ring buffer not equal to device buffer");
+ return NULL;
+ }
if (cpu == -1)
cpu = smp_processor_id();