[PATCH v6 08/19] coresight: Introduce coresight_enable_source() helper
Suzuki K Poulose
suzuki.poulose at arm.com
Fri Mar 13 04:31:19 PDT 2026
On 05/03/2026 10:17, Leo Yan wrote:
> Introduce the coresight_enable_source() helper for enabling source
> device, refine the comment for the imbalance between enable and disable
> pair functions.
>
> Reviewed-by: James Clark <james.clark at linaro.org>
> Tested-by: James Clark <james.clark at linaro.org>
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
> drivers/hwtracing/coresight/coresight-core.c | 15 ++++++++++++---
> drivers/hwtracing/coresight/coresight-etm-perf.c | 2 +-
> drivers/hwtracing/coresight/coresight-priv.h | 3 +++
> drivers/hwtracing/coresight/coresight-sysfs.c | 2 +-
> 4 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index 6956429ca507d850c8b8c62c65de4b6fe1a1740c..8e22f0993631fa3749437175ecc984ccb1cffc13 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -437,15 +437,24 @@ static void coresight_disable_helpers(struct coresight_device *csdev,
> }
>
> /*
> - * Helper function to call source_ops(csdev)->disable and also disable the
> - * helpers.
> + * coresight_enable_source() only enables the source but does nothing for the
> + * associated helpers. In contrast, coresight_disable_source() calls
> + * source_ops(csdev)->disable() and also disables the helpers.
> *
> * There is an imbalance between coresight_enable_path() and
> * coresight_disable_path(). Enabling also enables the source's helpers as part
> * of the path, but disabling always skips the first item in the path (which is
> * the source), so sources and their helpers don't get disabled as part of that
> - * function and we need the extra step here.
> + * function and we need the extra step in coresight_disable_source().
> */
> +int coresight_enable_source(struct coresight_device *csdev,
> + struct perf_event *event, enum cs_mode mode,
> + struct coresight_path *path)
> +{
> + return source_ops(csdev)->enable(csdev, event, mode, path);
Please could we double check to see if the csdev is source and then make
the call to future proof this ?
Rest looks fine to me.
Suzuki
> +}
> +EXPORT_SYMBOL_GPL(coresight_enable_source);
> +
> void coresight_disable_source(struct coresight_device *csdev, void *data)
> {
> source_ops(csdev)->disable(csdev, data);
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index f85dedf89a3f9e85d568ca4c320fa6fa6d9059ff..11c529fd4f3df973e5be9de2a7686163c1abceca 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -533,7 +533,7 @@ static void etm_event_start(struct perf_event *event, int flags)
> goto fail_end_stop;
>
> /* Finally enable the tracer */
> - if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF, path))
> + if (coresight_enable_source(csdev, event, CS_MODE_PERF, path))
> goto fail_disable_path;
>
> /*
> diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
> index 1ea882dffd703b2873e41b4ce0c2564d2ce9bbad..22fb6c5bffbf714bdbe2f4dcbfe66e453c2d1f4f 100644
> --- a/drivers/hwtracing/coresight/coresight-priv.h
> +++ b/drivers/hwtracing/coresight/coresight-priv.h
> @@ -248,6 +248,9 @@ void coresight_add_helper(struct coresight_device *csdev,
>
> void coresight_set_percpu_sink(int cpu, struct coresight_device *csdev);
> struct coresight_device *coresight_get_percpu_sink(int cpu);
> +int coresight_enable_source(struct coresight_device *csdev,
> + struct perf_event *event, enum cs_mode mode,
> + struct coresight_path *path);
> void coresight_disable_source(struct coresight_device *csdev, void *data);
> void coresight_pause_source(struct coresight_device *csdev);
> int coresight_resume_source(struct coresight_device *csdev);
> diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c
> index 7c7d3a3cb9f18a9dfa78eb5c19dda43fa6656271..cb1d4f90a9c245b2c2f6e818c0f4d905b86477db 100644
> --- a/drivers/hwtracing/coresight/coresight-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-sysfs.c
> @@ -66,7 +66,7 @@ static int coresight_enable_source_sysfs(struct coresight_device *csdev,
> */
> lockdep_assert_held(&coresight_mutex);
> if (coresight_get_mode(csdev) != CS_MODE_SYSFS) {
> - ret = source_ops(csdev)->enable(csdev, NULL, mode, path);
> + ret = coresight_enable_source(csdev, NULL, mode, path);
> if (ret)
> return ret;
> }
>
More information about the linux-arm-kernel
mailing list