* [PATCH v6 1/4] coresight: etm4x: Fix event count decoding
2026-11-20 18:54 [PATCH v6 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
@ 2026-11-20 18:54 ` Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 2/4] coresight: etm4x: Skip features requiring unavailable events Amir Ayupov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Amir Ayupov @ 2026-11-20 18:54 UTC (permalink / raw)
To: James Clark, Leo Yan, Suzuki K Poulose, Mike Leach, Alexander Shishkin
Cc: Will Deacon, Mark Rutland, Greg Kroah-Hartman, Jonathan Corbet,
Mathieu Poirier, Randy Dunlap, Shuah Khan, Daniel Pereira,
coresight, linux-arm-kernel, linux-perf-users, linux-doc,
linux-kernel
From: Leo Yan <leo.yan@arm.com>
TRCIDR0.NUMEVENT normally encodes the number of events minus one.
From ETMv4.3 onwards, including ETE, a zero TRCIDR4.NUMRSPAIR instead
means that no events are implemented and NUMEVENT is zero. The sysfs
event controls currently interpret this combination as one event and
allow writes to unsupported event fields.
Decode NUMEVENT after NUMRSPAIR and store the actual number of events
in nr_event. Use the decoded resource count so that older ETM versions,
where a zero NUMRSPAIR represents one resource pair, still report at
least one event. Update both sysfs event controls to use the actual
count and clear their event fields when no events are implemented.
Also correct the instruction event enable mask for the single-event
case to use INSTEN[0]. The existing mask uses INSTEN[1], preventing
event 0 from being enabled.
This change depends on the recent driver refactoring. With no reported
failures, it is not intended for stable backporting.
Signed-off-by: Leo Yan <leo.yan@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Tested-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
.../coresight/coresight-etm4x-core.c | 13 +++++++--
.../coresight/coresight-etm4x-sysfs.c | 29 ++++++++++---------
2 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index e21be6468e9544..af017bd8a54773 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -1451,8 +1451,6 @@ static void etm4_init_arch_data(void *info)
caps->trccci = !!(etmidr0 & TRCIDR0_TRCCCI);
/* RETSTACK, bit[9] Return stack bit */
caps->retstack = !!(etmidr0 & TRCIDR0_RETSTACK);
- /* NUMEVENT, bits[11:10] Number of events field */
- caps->nr_event = FIELD_GET(TRCIDR0_NUMEVENT_MASK, etmidr0);
/* QSUPP, bits[16:15] Q element support field */
caps->q_support = FIELD_GET(TRCIDR0_QSUPP_MASK, etmidr0);
if (caps->q_support)
@@ -1519,6 +1517,17 @@ static void etm4_init_arch_data(void *info)
caps->nr_resource = FIELD_GET(TRCIDR4_NUMRSPAIR_MASK, etmidr4);
if ((drvdata->arch < ETM_ARCH_V4_3) || (caps->nr_resource > 0))
caps->nr_resource += 1;
+
+ /*
+ * NUMEVENT encodes the number of events minus one. From ETMv4.3,
+ * including ETE, NUMRSPAIR == 0 means no events are implemented.
+ * nr_resource already accounts for the pre-ETMv4.3 encoding.
+ */
+ if (caps->nr_resource)
+ caps->nr_event = FIELD_GET(TRCIDR0_NUMEVENT_MASK, etmidr0) + 1;
+ else
+ caps->nr_event = 0;
+
/*
* NUMSSCC, bits[23:20] the number of single-shot
* comparator control for tracing. Read any status regs as these
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
index db9e603f97ba82..fb38f0102290a5 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
@@ -513,19 +513,22 @@ static ssize_t event_store(struct device *dev,
raw_spin_lock(&drvdata->spinlock);
switch (caps->nr_event) {
- case 0x0:
+ case 0:
+ sysfs_config->eventctrl0 = 0;
+ break;
+ case 1:
/* EVENT0, bits[7:0] */
sysfs_config->eventctrl0 = val & 0xFF;
break;
- case 0x1:
- /* EVENT1, bits[15:8] */
+ case 2:
+ /* EVENT1, bits[15:8] */
sysfs_config->eventctrl0 = val & 0xFFFF;
break;
- case 0x2:
+ case 3:
/* EVENT2, bits[23:16] */
sysfs_config->eventctrl0 = val & 0xFFFFFF;
break;
- case 0x3:
+ case 4:
/* EVENT3, bits[31:24] */
sysfs_config->eventctrl0 = val;
break;
@@ -565,22 +568,22 @@ static ssize_t event_instren_store(struct device *dev,
/* start by clearing all instruction event enable bits */
sysfs_config->eventctrl1 &= ~TRCEVENTCTL1R_INSTEN_MASK;
switch (caps->nr_event) {
- case 0x0:
- /* generate Event element for event 1 */
- sysfs_config->eventctrl1 |= val & TRCEVENTCTL1R_INSTEN_1;
+ case 1:
+ /* generate Event element for event 0 */
+ sysfs_config->eventctrl1 |= val & TRCEVENTCTL1R_INSTEN_0;
break;
- case 0x1:
- /* generate Event element for event 1 and 2 */
+ case 2:
+ /* generate Event element for events 0 and 1 */
sysfs_config->eventctrl1 |= val & (TRCEVENTCTL1R_INSTEN_0 |
TRCEVENTCTL1R_INSTEN_1);
break;
- case 0x2:
- /* generate Event element for event 1, 2 and 3 */
+ case 3:
+ /* generate Event element for events 0, 1 and 2 */
sysfs_config->eventctrl1 |= val & (TRCEVENTCTL1R_INSTEN_0 |
TRCEVENTCTL1R_INSTEN_1 |
TRCEVENTCTL1R_INSTEN_2);
break;
- case 0x3:
+ case 4:
/* generate Event element for all 4 events */
sysfs_config->eventctrl1 |= val & (TRCEVENTCTL1R_INSTEN_0 |
TRCEVENTCTL1R_INSTEN_1 |
--
2.52.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v6 2/4] coresight: etm4x: Skip features requiring unavailable events
2026-11-20 18:54 [PATCH v6 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 1/4] coresight: etm4x: Fix event count decoding Amir Ayupov
@ 2026-11-20 18:54 ` Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 3/4] coresight: perf: Filter sources lacking the selected configuration Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 4/4] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
3 siblings, 0 replies; 5+ messages in thread
From: Amir Ayupov @ 2026-11-20 18:54 UTC (permalink / raw)
To: James Clark, Leo Yan, Suzuki K Poulose, Mike Leach, Alexander Shishkin
Cc: Will Deacon, Mark Rutland, Greg Kroah-Hartman, Jonathan Corbet,
Mathieu Poirier, Randy Dunlap, Shuah Khan, Daniel Pereira,
coresight, linux-arm-kernel, linux-perf-users, linux-doc,
linux-kernel
Feature register mappings accept TRCEVENTCTL0R without checking which
event fields the trace unit implements. A feature that drives EVENT1 can
therefore load on a trace unit with only EVENT0 and silently produce no
pulses.
Validate the descriptors before checking their requested EVENT fields
against the decoded event count. Parameterized writes are checked against
every writable field because parameter values may change after loading.
Let the configuration manager treat -EOPNOTSUPP as a per-device skip and
release the unlinked feature instance, while malformed descriptions and
other errors still abort loading.
Suggested-by: Mike Leach <mike.leach@arm.com>
Assisted-by: Devmate:GPT-6.1-Sol
Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
.../hwtracing/coresight/coresight-config.h | 3 ++
.../hwtracing/coresight/coresight-etm4x-cfg.c | 47 +++++++++++++++++--
.../hwtracing/coresight/coresight-syscfg.c | 7 +++
3 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-config.h b/drivers/hwtracing/coresight/coresight-config.h
index ae6295e3081319..8f3c37b0421e24 100644
--- a/drivers/hwtracing/coresight/coresight-config.h
+++ b/drivers/hwtracing/coresight/coresight-config.h
@@ -245,6 +245,9 @@ struct cscfg_config_csdev {
*
* @load_feat: Pass a feature descriptor into the device and create the
* loaded feature instance (struct cscfg_feature_csdev).
+ * Return -EOPNOTSUPP if the device lacks required resources; the
+ * manager skips that device. Other errors abort loading. An
+ * unsupported feature must leave device state unchanged.
*/
struct cscfg_csdev_feat_ops {
int (*load_feat)(struct coresight_device *csdev,
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-cfg.c b/drivers/hwtracing/coresight/coresight-etm4x-cfg.c
index 52cb036bb04b96..278329075f380d 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-cfg.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-cfg.c
@@ -127,6 +127,28 @@ static int etm4_cfg_map_reg_offset(struct etmv4_drvdata *drvdata,
return err;
}
+static int etm4_cfg_check_eventctl0_support(const struct cscfg_regval_desc *reg_desc,
+ unsigned int nr_event)
+{
+ u32 requested;
+
+ if (reg_desc->offset != TRCEVENTCTL0R)
+ return 0;
+
+ /* Parameters can change after loading, so check all writable fields. */
+ if (reg_desc->type & CS_CFG_REG_TYPE_VAL_PARAM)
+ requested = reg_desc->type & CS_CFG_REG_TYPE_VAL_MASK ?
+ reg_desc->mask32 : U32_MAX;
+ else
+ requested = reg_desc->type & CS_CFG_REG_TYPE_VAL_MASK ?
+ reg_desc->val32 & reg_desc->mask32 : reg_desc->val32;
+
+ /* Four events use the full register: do not shift a u32 by 32. */
+ if (nr_event < 4 && (requested >> (8 * nr_event)))
+ return -EOPNOTSUPP;
+ return 0;
+}
+
/**
* etm4_cfg_load_feature - load a feature into a device instance.
*
@@ -149,6 +171,7 @@ static int etm4_cfg_load_feature(struct coresight_device *csdev,
struct device *dev = csdev->dev.parent;
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
const struct cscfg_feature_desc *feat_desc = feat_csdev->feat_desc;
+ const struct cscfg_regval_desc *reg_desc;
u32 offset;
int i = 0, err = 0;
@@ -162,12 +185,28 @@ static int etm4_cfg_load_feature(struct coresight_device *csdev,
*/
feat_csdev->drv_spinlock = NULL;
- /* process the register descriptions */
- for (i = 0; i < feat_csdev->nr_regs && !err; i++) {
- offset = feat_desc->regs_desc[i].offset;
+ /* Validate every description before deciding whether to skip a device. */
+ for (i = 0; i < feat_csdev->nr_regs; i++) {
+ reg_desc = &feat_desc->regs_desc[i];
+ offset = reg_desc->offset;
+ if ((reg_desc->type & CS_CFG_REG_TYPE_VAL_PARAM) &&
+ reg_desc->param_idx >= (u32)feat_csdev->nr_params)
+ return -EINVAL;
+ if (offset == TRCEVENTCTL0R &&
+ (reg_desc->type & CS_CFG_REG_TYPE_VAL_64BIT))
+ return -EINVAL;
err = etm4_cfg_map_reg_offset(drvdata, &feat_csdev->regs_csdev[i], offset);
+ if (err)
+ return err;
}
- return err;
+
+ for (i = 0; i < feat_csdev->nr_regs; i++) {
+ err = etm4_cfg_check_eventctl0_support(&feat_desc->regs_desc[i],
+ drvdata->caps.nr_event);
+ if (err)
+ return err;
+ }
+ return 0;
}
/* match information when loading configurations */
diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
index 2bfdd7b45e49c8..11946e5718fc5e 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg.c
+++ b/drivers/hwtracing/coresight/coresight-syscfg.c
@@ -176,6 +176,7 @@ static int cscfg_load_feat_csdev(struct coresight_device *csdev,
struct cscfg_feature_desc *feat_desc,
struct cscfg_csdev_feat_ops *ops)
{
+ struct device *dev = csdev->dev.parent;
struct cscfg_feature_csdev *feat_csdev;
unsigned long flags;
int err;
@@ -189,6 +190,12 @@ static int cscfg_load_feat_csdev(struct coresight_device *csdev,
/* load the feature into the device */
err = ops->load_feat(csdev, feat_csdev);
+ if (err == -EOPNOTSUPP) {
+ devm_kfree(dev, feat_csdev->regs_csdev);
+ devm_kfree(dev, feat_csdev->params_csdev);
+ devm_kfree(dev, feat_csdev);
+ return 0;
+ }
if (err)
return err;
--
2.52.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v6 3/4] coresight: perf: Filter sources lacking the selected configuration
2026-11-20 18:54 [PATCH v6 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 1/4] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 2/4] coresight: etm4x: Skip features requiring unavailable events Amir Ayupov
@ 2026-11-20 18:54 ` Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 4/4] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
3 siblings, 0 replies; 5+ messages in thread
From: Amir Ayupov @ 2026-11-20 18:54 UTC (permalink / raw)
To: James Clark, Leo Yan, Suzuki K Poulose, Mike Leach, Alexander Shishkin
Cc: Will Deacon, Mark Rutland, Greg Kroah-Hartman, Jonathan Corbet,
Mathieu Poirier, Randy Dunlap, Shuah Khan, Daniel Pereira,
coresight, linux-arm-kernel, linux-perf-users, linux-doc,
linux-kernel
A system configuration may deliberately omit some CoreSight devices.
Keep generic configuration enablement as a successful no-op for
nonparticipants, but exclude ETM sources without the selected
configuration before allocating an AUX session.
Add a setup-only query while the configuration is globally activated,
checking device registration and per-device availability under the
manager mutex. Use the existing path-building failure handling to remove
unsupported CPUs and fail setup if no usable source remains.
Suggested-by: Mike Leach <mike.leach@arm.com>
Assisted-by: Devmate:GPT-6.1-Sol
Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
.../hwtracing/coresight/coresight-etm-perf.c | 4 +++
.../hwtracing/coresight/coresight-syscfg.c | 32 +++++++++++++++++++
.../hwtracing/coresight/coresight-syscfg.h | 2 ++
3 files changed, 38 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 09b21a711a8764..2d64c3314c0bad 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -350,6 +350,7 @@ etm_event_build_path(struct perf_event *event, int cpu,
{
struct coresight_path *path = NULL;
struct coresight_device *source, *sink;
+ u32 cfg_hash = ATTR_CFG_GET_FLD(&event->attr, configid);
int ret;
source = coresight_get_percpu_source_ref(cpu);
@@ -361,6 +362,9 @@ etm_event_build_path(struct perf_event *event, int cpu,
if (!source)
return NULL;
+ if (cfg_hash && !cscfg_csdev_can_activate_config(source, cfg_hash))
+ goto out;
+
/*
* If AUX pause feature is enabled but the ETM driver does not
* support the operations, skip for this source.
diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
index 11946e5718fc5e..f4e122f66e98c8 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg.c
+++ b/drivers/hwtracing/coresight/coresight-syscfg.c
@@ -1050,6 +1050,38 @@ void cscfg_deactivate_config(unsigned long cfg_hash)
}
EXPORT_SYMBOL_GPL(cscfg_deactivate_config);
+/**
+ * cscfg_csdev_can_activate_config - Check whether a configuration is loaded on a device.
+ * @csdev: CoreSight device to check.
+ * @cfg_hash: Selector for the configuration.
+ *
+ * Does not activate or program the configuration. May sleep. The caller must
+ * keep the configuration activated while using the result to prevent unloading.
+ */
+bool cscfg_csdev_can_activate_config(struct coresight_device *csdev,
+ unsigned long cfg_hash)
+{
+ struct cscfg_registered_csdev *csdev_item;
+ struct cscfg_config_csdev *config_csdev;
+
+ guard(mutex)(&cscfg_mutex);
+ if (!cscfg_mgr)
+ return false;
+
+ /* Unregistered devices do not have initialized configuration lists. */
+ list_for_each_entry(csdev_item, &cscfg_mgr->csdev_desc_list, item) {
+ if (csdev_item->csdev != csdev)
+ continue;
+ list_for_each_entry(config_csdev, &csdev->config_csdev_list, node) {
+ if ((unsigned long)config_csdev->config_desc->event_ea->var == cfg_hash)
+ return config_csdev->config_desc->available;
+ }
+ break;
+ }
+ return false;
+}
+EXPORT_SYMBOL_GPL(cscfg_csdev_can_activate_config);
+
/**
* cscfg_csdev_enable_active_config - Enable matching active configuration for device.
*
diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h
index 658e93c3705f1c..05289060a277e5 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg.h
+++ b/drivers/hwtracing/coresight/coresight-syscfg.h
@@ -120,6 +120,8 @@ int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags,
void cscfg_unregister_csdev(struct coresight_device *csdev);
int cscfg_activate_config(unsigned long cfg_hash);
void cscfg_deactivate_config(unsigned long cfg_hash);
+bool cscfg_csdev_can_activate_config(struct coresight_device *csdev,
+ unsigned long cfg_hash);
void cscfg_csdev_reset_feats(struct coresight_device *csdev);
int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
unsigned long cfg_hash, int preset);
--
2.52.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v6 4/4] coresight: Add pmu_pulse/extout_pulse
2026-11-20 18:54 [PATCH v6 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
` (2 preceding siblings ...)
2026-11-20 18:54 ` [PATCH v6 3/4] coresight: perf: Filter sources lacking the selected configuration Amir Ayupov
@ 2026-11-20 18:54 ` Amir Ayupov
3 siblings, 0 replies; 5+ messages in thread
From: Amir Ayupov @ 2026-11-20 18:54 UTC (permalink / raw)
To: James Clark, Leo Yan, Suzuki K Poulose, Mike Leach, Alexander Shishkin
Cc: Will Deacon, Mark Rutland, Greg Kroah-Hartman, Jonathan Corbet,
Mathieu Poirier, Randy Dunlap, Shuah Khan, Daniel Pereira,
coresight, linux-arm-kernel, linux-perf-users, linux-doc,
linux-kernel
Drive external output 1 from the always-true trace resource for an
external consumer to count. Change only EVENT1 so other event fields
remain intact, and avoid output 0 because it is the trace trigger and
can stop TRBE capture.
Producer resource validation loads the feature only on trace units
implementing EVENT1. PMU counting support and implementation-defined
output routing remain independent consumer responsibilities. Include
the preload declarations in the defining translation unit and document
setup-time source filtering and the separately selected trcextout1 event.
Assisted-by: Devmate:GPT-6.1-Sol
Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
.../trace/coresight/coresight-config.rst | 6 +++
.../trace/coresight/coresight-perf.rst | 15 +++++++
drivers/hwtracing/coresight/Makefile | 3 +-
.../coresight/coresight-cfg-pmu-pulse.c | 39 +++++++++++++++++++
.../coresight/coresight-cfg-preload.c | 2 +
.../coresight/coresight-cfg-preload.h | 2 +
6 files changed, 66 insertions(+), 1 deletion(-)
create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
diff --git a/Documentation/trace/coresight/coresight-config.rst b/Documentation/trace/coresight/coresight-config.rst
index 6d5ffa6f73471b..1c194fd5f55816 100644
--- a/Documentation/trace/coresight/coresight-config.rst
+++ b/Documentation/trace/coresight/coresight-config.rst
@@ -42,6 +42,12 @@ accesses in the driver - the resource usage and parameter descriptions
translated into appropriate register accesses. This interpretation makes it easy
and efficient for the feature to be programmed onto the device when required.
+The device driver checks requested event fields when loading a feature. For
+example, ``extout_pulse`` is loaded only where EVENT1 is implemented, based on
+the trace unit's decoded event count. A valid feature requiring unavailable
+resources is skipped for that device. This does not check whether a PMU can
+count the output.
+
The feature will not be active on the device until the feature is enabled, and
the device itself is enabled. When the device is enabled then enabled features
will be programmed into the device hardware.
diff --git a/Documentation/trace/coresight/coresight-perf.rst b/Documentation/trace/coresight/coresight-perf.rst
index 0a77741a431ef9..dbae2acd3634a9 100644
--- a/Documentation/trace/coresight/coresight-perf.rst
+++ b/Documentation/trace/coresight/coresight-perf.rst
@@ -109,6 +109,21 @@ Example for triggering AUX pause and resume with PMU event::
-e cycles/aux-action=pause,period=10000000/ \
-e cycles/aux-action=resume,period=1050000/ -- sleep 1
+Using external-output pulses
+----------------------------
+
+The ``pmu_pulse`` configuration drives fixed external output 1. Separately
+select the matching PMU event, ``trcextout1``, to count it. The hardware must
+support and connect this output to that PMU; this is not checked automatically.
+
+Perf skips CPUs whose trace units do not support this configuration and fails
+setup if none remain. Use the PMU instance that counts output 1 on your system::
+
+ perf record -a -e '{cs_etm/pmu_pulse,aux-action=start-paused/u,cycles/aux-action=resume,period=10000000/u,armv8_pmuv3_0/trcextout1,aux-action=pause,period=5000/u}' -- sleep 1
+
+Tracing starts paused. The cycles event resumes it every 10000000 cycles;
+``trcextout1`` pauses it after 5000 counted pulses.
+
Perf test - Verify kernel and userspace perf CoreSight work
-----------------------------------------------------------
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile
index ab16d06783a572..e2768c79d08616 100644
--- a/drivers/hwtracing/coresight/Makefile
+++ b/drivers/hwtracing/coresight/Makefile
@@ -28,7 +28,8 @@ obj-$(CONFIG_CORESIGHT) += coresight.o
coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \
coresight-sysfs.o coresight-syscfg.o coresight-config.o \
coresight-cfg-preload.o coresight-cfg-afdo.o coresight-cfg-pstop.o \
- coresight-syscfg-configfs.o coresight-trace-id.o
+ coresight-syscfg-configfs.o coresight-trace-id.o \
+ coresight-cfg-pmu-pulse.o
obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o
coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \
coresight-tmc-etr.o
diff --git a/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c b/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
new file mode 100644
index 00000000000000..139596d54d5883
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Pulse trace-unit external output 1 with the always-true resource. */
+
+#include "coresight-config.h"
+
+#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
+#include "coresight-etm4x-cfg.h"
+#include "coresight-cfg-preload.h"
+
+/* Output 0 is the trace trigger and can stop TRBE capture. */
+static struct cscfg_regval_desc extout_pulse_regs[] = {
+ {
+ .type = CS_CFG_REG_TYPE_STD | CS_CFG_REG_TYPE_VAL_MASK,
+ .offset = TRCEVENTCTL0R,
+ .val32 = ETM4_RES_SEL_TRUE << 8,
+ .mask32 = GENMASK_U32(15, 8),
+ },
+};
+
+struct cscfg_feature_desc extout_pulse_etm4x = {
+ .name = "extout_pulse",
+ .description = "Pulse external output 1 with the always-true resource.\n",
+ .match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4,
+ .nr_regs = ARRAY_SIZE(extout_pulse_regs),
+ .regs_desc = extout_pulse_regs,
+};
+
+static const char *pmu_pulse_ref_names[] = {
+ "extout_pulse",
+};
+
+struct cscfg_config_desc pmu_pulse_etm4x = {
+ .name = "pmu_pulse",
+ .description = "Pulse external output 1 for an external consumer.\n",
+ .nr_feat_refs = ARRAY_SIZE(pmu_pulse_ref_names),
+ .feat_ref_names = pmu_pulse_ref_names,
+};
+
+#endif
diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.c b/drivers/hwtracing/coresight/coresight-cfg-preload.c
index 4980e68483c5b9..a9a60a1c408455 100644
--- a/drivers/hwtracing/coresight/coresight-cfg-preload.c
+++ b/drivers/hwtracing/coresight/coresight-cfg-preload.c
@@ -14,6 +14,7 @@ static struct cscfg_feature_desc *preload_feats[] = {
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
&strobe_etm4x,
&gen_etrig_etm4x,
+ &extout_pulse_etm4x,
#endif
NULL
};
@@ -22,6 +23,7 @@ static struct cscfg_config_desc *preload_cfgs[] = {
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
&afdo_etm4x,
&pstop_etm4x,
+ &pmu_pulse_etm4x,
#endif
NULL
};
diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.h b/drivers/hwtracing/coresight/coresight-cfg-preload.h
index 291ba530a6a520..0058627f65ae5b 100644
--- a/drivers/hwtracing/coresight/coresight-cfg-preload.h
+++ b/drivers/hwtracing/coresight/coresight-cfg-preload.h
@@ -12,4 +12,6 @@ extern struct cscfg_feature_desc strobe_etm4x;
extern struct cscfg_config_desc afdo_etm4x;
extern struct cscfg_feature_desc gen_etrig_etm4x;
extern struct cscfg_config_desc pstop_etm4x;
+extern struct cscfg_feature_desc extout_pulse_etm4x;
+extern struct cscfg_config_desc pmu_pulse_etm4x;
#endif
--
2.52.1
^ permalink raw reply [flat|nested] 5+ messages in thread