[PATCH v3 13/31] coresight: Set per CPU source pointer

Mike Leach mike.leach at linaro.org
Thu Oct 2 05:46:47 PDT 2025


On Mon, 15 Sept 2025 at 11:34, Leo Yan <leo.yan at arm.com> wrote:
>
> Introduce coresight_set_percpu_source() for setting CPU source device. The
> sources are maintained in a per CPU structure 'csdev_source'.
>
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
>  drivers/hwtracing/coresight/coresight-core.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index db325dff884d21cc8d93f32bfe3be5c0491ffc8d..25a530cde8938b366bbb144fdcc107271ebae276 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -34,6 +34,7 @@
>   */
>  DEFINE_MUTEX(coresight_mutex);
>  static DEFINE_PER_CPU(struct coresight_device *, csdev_sink);
> +static DEFINE_PER_CPU(struct coresight_device *, csdev_source);
>
>  /**
>   * struct coresight_node - elements of a path, from source to sink
> @@ -79,6 +80,11 @@ struct coresight_device *coresight_get_percpu_sink(int cpu)
>  }
>  EXPORT_SYMBOL_GPL(coresight_get_percpu_sink);
>
> +static void coresight_set_percpu_source(int cpu, struct coresight_device *csdev)
> +{
> +       per_cpu(csdev_source, cpu) = csdev;
> +}
> +
>  static struct coresight_device *coresight_get_source(struct coresight_path *path)
>  {
>         struct coresight_device *csdev;
> @@ -1393,6 +1399,10 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
>                         goto out_unlock;
>                 }
>         }
> +
> +       if (coresight_is_percpu_source(csdev))
> +               coresight_set_percpu_source(csdev->cpu, csdev);
> +
>         /* Device is now registered */
>         registered = true;
>
> @@ -1424,6 +1434,8 @@ EXPORT_SYMBOL_GPL(coresight_register);
>
>  void coresight_unregister(struct coresight_device *csdev)
>  {
> +       if (coresight_is_percpu_source(csdev))
> +               coresight_set_percpu_source(csdev->cpu, NULL);
>         etm_perf_del_symlink_sink(csdev);
>         /* Remove references of that device in the topology */
>         if (cti_assoc_ops && cti_assoc_ops->remove)
>
> --
> 2.34.1
>

Reviewed-by: Mike Leach <mike.leach at linaro.org>
-- 
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK



More information about the linux-arm-kernel mailing list