Skip to content

Commit 0814151

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: etm4x: Hook pause and resume callbacks
Add callbacks for pausing and resuming the tracer. A "paused" flag in the driver data indicates whether the tracer is paused. If the flag is set, the driver will skip starting the hardware trace. The flag is always set to false for the sysfs mode, meaning the tracer will never be paused in the case. 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 5fa96c8 commit 0814151

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

drivers/hwtracing/coresight/coresight-etm4x-core.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
577577
etm4x_relaxed_write32(csa, trcpdcr | TRCPDCR_PU, TRCPDCR);
578578
}
579579

580-
rc = etm4_enable_trace_unit(drvdata);
580+
if (!drvdata->paused)
581+
rc = etm4_enable_trace_unit(drvdata);
581582
done:
582583
etm4_cs_lock(drvdata, csa);
583584

@@ -820,6 +821,9 @@ static int etm4_enable_perf(struct coresight_device *csdev,
820821

821822
drvdata->trcid = path->trace_id;
822823

824+
/* Populate pause state */
825+
drvdata->paused = !!READ_ONCE(event->hw.aux_paused);
826+
823827
/* And enable it */
824828
ret = etm4_enable_hw(drvdata);
825829

@@ -846,6 +850,9 @@ static int etm4_enable_sysfs(struct coresight_device *csdev, struct coresight_pa
846850

847851
drvdata->trcid = path->trace_id;
848852

853+
/* Tracer will never be paused in sysfs mode */
854+
drvdata->paused = false;
855+
849856
/*
850857
* Executing etm4_enable_hw on the cpu whose ETM is being enabled
851858
* ensures that register writes occur when cpu is powered.
@@ -1080,10 +1087,43 @@ static void etm4_disable(struct coresight_device *csdev,
10801087
coresight_set_mode(csdev, CS_MODE_DISABLED);
10811088
}
10821089

1090+
static int etm4_resume_perf(struct coresight_device *csdev)
1091+
{
1092+
struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1093+
struct csdev_access *csa = &csdev->access;
1094+
1095+
if (coresight_get_mode(csdev) != CS_MODE_PERF)
1096+
return -EINVAL;
1097+
1098+
etm4_cs_unlock(drvdata, csa);
1099+
etm4_enable_trace_unit(drvdata);
1100+
etm4_cs_lock(drvdata, csa);
1101+
1102+
drvdata->paused = false;
1103+
return 0;
1104+
}
1105+
1106+
static void etm4_pause_perf(struct coresight_device *csdev)
1107+
{
1108+
struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
1109+
struct csdev_access *csa = &csdev->access;
1110+
1111+
if (coresight_get_mode(csdev) != CS_MODE_PERF)
1112+
return;
1113+
1114+
etm4_cs_unlock(drvdata, csa);
1115+
etm4_disable_trace_unit(drvdata);
1116+
etm4_cs_lock(drvdata, csa);
1117+
1118+
drvdata->paused = true;
1119+
}
1120+
10831121
static const struct coresight_ops_source etm4_source_ops = {
10841122
.cpu_id = etm4_cpu_id,
10851123
.enable = etm4_enable,
10861124
.disable = etm4_disable,
1125+
.resume_perf = etm4_resume_perf,
1126+
.pause_perf = etm4_pause_perf,
10871127
};
10881128

10891129
static const struct coresight_ops etm4_cs_ops = {

drivers/hwtracing/coresight/coresight-etm4x.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ struct etmv4_save_state {
983983
* @state_needs_restore: True when there is context to restore after PM exit
984984
* @skip_power_up: Indicates if an implementation can skip powering up
985985
* the trace unit.
986+
* @paused: Indicates if the trace unit is paused.
986987
* @arch_features: Bitmap of arch features of etmv4 devices.
987988
*/
988989
struct etmv4_drvdata {
@@ -1036,6 +1037,7 @@ struct etmv4_drvdata {
10361037
struct etmv4_save_state *save_state;
10371038
bool state_needs_restore;
10381039
bool skip_power_up;
1040+
bool paused;
10391041
DECLARE_BITMAP(arch_features, ETM4_IMPDEF_FEATURE_MAX);
10401042
};
10411043

0 commit comments

Comments
 (0)