Skip to content

Commit abffe22

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: perf: Support AUX trace pause and resume
This commit supports AUX trace pause and resume in a perf session for Arm CoreSight. First, we need to decide which flag can indicate the CoreSight PMU event has started. The 'event->hw.state' cannot be used for this purpose because its initial value and the value after hardware trace enabling are both 0. On the other hand, the context value 'ctxt->event_data' stores the ETM private info. This pointer is valid only when the PMU event has been enabled. It is safe to permit AUX trace pause and resume operations only when it is not a NULL pointer. To achieve fine-grained control of the pause and resume, only the tracer is disabled and enabled. This avoids the unnecessary complexity and latency caused by manipulating the entire link path. Signed-off-by: Leo Yan <[email protected]> Reviewed-by: Mike Leach <[email protected]> Reviewed-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0814151 commit abffe22

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

drivers/hwtracing/coresight/coresight-etm-perf.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
365365
continue;
366366
}
367367

368+
/*
369+
* If AUX pause feature is enabled but the ETM driver does not
370+
* support the operations, clear this CPU from the mask and
371+
* continue to next one.
372+
*/
373+
if (event->attr.aux_start_paused &&
374+
(!source_ops(csdev)->pause_perf || !source_ops(csdev)->resume_perf)) {
375+
dev_err_once(&csdev->dev, "AUX pause is not supported.\n");
376+
cpumask_clear_cpu(cpu, mask);
377+
continue;
378+
}
379+
368380
/*
369381
* No sink provided - look for a default sink for all the ETMs,
370382
* where this event can be scheduled.
@@ -450,6 +462,15 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
450462
goto out;
451463
}
452464

465+
static int etm_event_resume(struct coresight_device *csdev,
466+
struct etm_ctxt *ctxt)
467+
{
468+
if (!ctxt->event_data)
469+
return 0;
470+
471+
return coresight_resume_source(csdev);
472+
}
473+
453474
static void etm_event_start(struct perf_event *event, int flags)
454475
{
455476
int cpu = smp_processor_id();
@@ -463,6 +484,14 @@ static void etm_event_start(struct perf_event *event, int flags)
463484
if (!csdev)
464485
goto fail;
465486

487+
if (flags & PERF_EF_RESUME) {
488+
if (etm_event_resume(csdev, ctxt) < 0) {
489+
dev_err(&csdev->dev, "Failed to resume ETM event.\n");
490+
goto fail;
491+
}
492+
return;
493+
}
494+
466495
/* Have we messed up our tracking ? */
467496
if (WARN_ON(ctxt->event_data))
468497
goto fail;
@@ -545,6 +574,16 @@ static void etm_event_start(struct perf_event *event, int flags)
545574
return;
546575
}
547576

577+
static void etm_event_pause(struct coresight_device *csdev,
578+
struct etm_ctxt *ctxt)
579+
{
580+
if (!ctxt->event_data)
581+
return;
582+
583+
/* Stop tracer */
584+
coresight_pause_source(csdev);
585+
}
586+
548587
static void etm_event_stop(struct perf_event *event, int mode)
549588
{
550589
int cpu = smp_processor_id();
@@ -555,6 +594,9 @@ static void etm_event_stop(struct perf_event *event, int mode)
555594
struct etm_event_data *event_data;
556595
struct coresight_path *path;
557596

597+
if (mode & PERF_EF_PAUSE)
598+
return etm_event_pause(csdev, ctxt);
599+
558600
/*
559601
* If we still have access to the event_data via handle,
560602
* confirm that we haven't messed up the tracking.
@@ -899,7 +941,8 @@ int __init etm_perf_init(void)
899941
int ret;
900942

901943
etm_pmu.capabilities = (PERF_PMU_CAP_EXCLUSIVE |
902-
PERF_PMU_CAP_ITRACE);
944+
PERF_PMU_CAP_ITRACE |
945+
PERF_PMU_CAP_AUX_PAUSE);
903946

904947
etm_pmu.attr_groups = etm_pmu_attr_groups;
905948
etm_pmu.task_ctx_nr = perf_sw_context;

0 commit comments

Comments
 (0)