Skip to content

Commit 942bbee

Browse files
Linu CherianSuzuki K Poulose
authored andcommitted
coresight: tmc: Stop trace capture on FlIn
Configure TMC ETR and ETF to flush and stop trace capture on FlIn event based on sysfs attribute, /sys/bus/coresight/devices/tmc_etXn/stop_on_flush. Signed-off-by: Linu Cherian <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d58a70b commit 942bbee

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,40 @@ static ssize_t buffer_size_store(struct device *dev,
532532

533533
static DEVICE_ATTR_RW(buffer_size);
534534

535+
static ssize_t stop_on_flush_show(struct device *dev,
536+
struct device_attribute *attr, char *buf)
537+
{
538+
struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
539+
540+
return sprintf(buf, "%#x\n", drvdata->stop_on_flush);
541+
}
542+
543+
static ssize_t stop_on_flush_store(struct device *dev,
544+
struct device_attribute *attr,
545+
const char *buf, size_t size)
546+
{
547+
int ret;
548+
u8 val;
549+
struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
550+
551+
ret = kstrtou8(buf, 0, &val);
552+
if (ret)
553+
return ret;
554+
if (val)
555+
drvdata->stop_on_flush = true;
556+
else
557+
drvdata->stop_on_flush = false;
558+
559+
return size;
560+
}
561+
562+
static DEVICE_ATTR_RW(stop_on_flush);
563+
564+
535565
static struct attribute *coresight_tmc_attrs[] = {
536566
&dev_attr_trigger_cntr.attr,
537567
&dev_attr_buffer_size.attr,
568+
&dev_attr_stop_on_flush.attr,
538569
NULL,
539570
};
540571

drivers/hwtracing/coresight/coresight-tmc-etf.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static int tmc_set_etf_buffer(struct coresight_device *csdev,
1919
static int __tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
2020
{
2121
int rc = 0;
22+
u32 ffcr;
2223

2324
CS_UNLOCK(drvdata->base);
2425

@@ -32,10 +33,12 @@ static int __tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
3233
}
3334

3435
writel_relaxed(TMC_MODE_CIRCULAR_BUFFER, drvdata->base + TMC_MODE);
35-
writel_relaxed(TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI |
36-
TMC_FFCR_FON_FLIN | TMC_FFCR_FON_TRIG_EVT |
37-
TMC_FFCR_TRIGON_TRIGIN,
38-
drvdata->base + TMC_FFCR);
36+
37+
ffcr = TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI | TMC_FFCR_FON_FLIN |
38+
TMC_FFCR_FON_TRIG_EVT | TMC_FFCR_TRIGON_TRIGIN;
39+
if (drvdata->stop_on_flush)
40+
ffcr |= TMC_FFCR_STOP_ON_FLUSH;
41+
writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
3942

4043
writel_relaxed(drvdata->trigger_cntr, drvdata->base + TMC_TRG);
4144
tmc_enable_hw(drvdata);
@@ -225,7 +228,6 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev)
225228
used = true;
226229
drvdata->buf = buf;
227230
}
228-
229231
ret = tmc_etb_enable_hw(drvdata);
230232
if (!ret) {
231233
coresight_set_mode(csdev, CS_MODE_SYSFS);

drivers/hwtracing/coresight/coresight-tmc-etr.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ static void tmc_sync_etr_buf(struct tmc_drvdata *drvdata)
10601060

10611061
static int __tmc_etr_enable_hw(struct tmc_drvdata *drvdata)
10621062
{
1063-
u32 axictl, sts;
1063+
u32 axictl, sts, ffcr;
10641064
struct etr_buf *etr_buf = drvdata->etr_buf;
10651065
int rc = 0;
10661066

@@ -1106,10 +1106,12 @@ static int __tmc_etr_enable_hw(struct tmc_drvdata *drvdata)
11061106
writel_relaxed(sts, drvdata->base + TMC_STS);
11071107
}
11081108

1109-
writel_relaxed(TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI |
1110-
TMC_FFCR_FON_FLIN | TMC_FFCR_FON_TRIG_EVT |
1111-
TMC_FFCR_TRIGON_TRIGIN,
1112-
drvdata->base + TMC_FFCR);
1109+
ffcr = TMC_FFCR_EN_FMT | TMC_FFCR_EN_TI | TMC_FFCR_FON_FLIN |
1110+
TMC_FFCR_FON_TRIG_EVT | TMC_FFCR_TRIGON_TRIGIN;
1111+
if (drvdata->stop_on_flush)
1112+
ffcr |= TMC_FFCR_STOP_ON_FLUSH;
1113+
writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
1114+
11131115
writel_relaxed(drvdata->trigger_cntr, drvdata->base + TMC_TRG);
11141116
tmc_enable_hw(drvdata);
11151117

drivers/hwtracing/coresight/coresight-tmc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ struct tmc_resrv_buf {
220220
* @pid: Process ID of the process that owns the session that is using
221221
* this component. For example this would be the pid of the Perf
222222
* process.
223+
* @stop_on_flush: Stop on flush trigger user configuration.
223224
* @buf: Snapshot of the trace data for ETF/ETB.
224225
* @etr_buf: details of buffer used in TMC-ETR
225226
* @len: size of the available trace for ETF/ETB.
@@ -251,6 +252,7 @@ struct tmc_drvdata {
251252
spinlock_t spinlock;
252253
pid_t pid;
253254
bool reading;
255+
bool stop_on_flush;
254256
union {
255257
char *buf; /* TMC ETB */
256258
struct etr_buf *etr_buf; /* TMC ETR */

0 commit comments

Comments
 (0)