[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ9a7ViMWpdVVt3veAbrr0HM5DyYcDechiJbub_S4uWKCfMfkw@mail.gmail.com>
Date: Thu, 14 Apr 2022 15:20:12 +0100
From: Mike Leach <mike.leach@...aro.org>
To: Mao Jinlong <quic_jinlmao@...cinc.com>
Cc: Mathieu Poirier <mathieu.poirier@...aro.org>,
Suzuki K Poulose <suzuki.poulose@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Leo Yan <leo.yan@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Tingwei Zhang <quic_tingweiz@...cinc.com>,
Yuanfang Zhang <quic_yuanfang@...cinc.com>,
Tao Zhang <quic_taozha@...cinc.com>,
Trilok Soni <quic_tsoni@...cinc.com>,
Hao Zhang <quic_hazha@...cinc.com>,
linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH v5 01/10] coresight: core: Use IDR for non-cpu bound
sources' paths.
On Tue, 12 Apr 2022 at 13:51, Mao Jinlong <quic_jinlmao@...cinc.com> wrote:
>
> Except stm, there could be other sources which are not associated
> with cpus. Use IDR to store and search these sources' paths.
>
> Signed-off-by: Mao Jinlong <quic_jinlmao@...cinc.com>
> ---
> drivers/hwtracing/coresight/coresight-core.c | 37 ++++++++++++++------
> 1 file changed, 26 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index bbf415c252f9..23ab16dd9b5d 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -8,6 +8,7 @@
> #include <linux/types.h>
> #include <linux/device.h>
> #include <linux/io.h>
> +#include <linux/idr.h>
> #include <linux/err.h>
> #include <linux/export.h>
> #include <linux/slab.h>
> @@ -27,6 +28,13 @@
> static DEFINE_MUTEX(coresight_mutex);
> static DEFINE_PER_CPU(struct coresight_device *, csdev_sink);
>
> +/*
> + * Use IDR to map the hash of the source's device name
> + * to the pointer of path for the source. The idr is for
> + * the sources which aren't associated with CPU.
> + */
> +static DEFINE_IDR(path_idr);
> +
> /**
> * struct coresight_node - elements of a path, from source to sink
> * @csdev: Address of an element.
> @@ -43,14 +51,6 @@ struct coresight_node {
> */
> static DEFINE_PER_CPU(struct list_head *, tracer_path);
>
> -/*
> - * As of this writing only a single STM can be found in CS topologies. Since
> - * there is no way to know if we'll ever see more and what kind of
> - * configuration they will enact, for the time being only define a single path
> - * for STM.
> - */
> -static struct list_head *stm_path;
> -
> /*
> * Set up a global trace ID map.
> * We may need a per sink ID map in future for larger / multi sink systems.
> @@ -1061,6 +1061,7 @@ int coresight_enable(struct coresight_device *csdev)
> struct coresight_device *sink;
> struct list_head *path;
> enum coresight_dev_subtype_source subtype;
> + u32 hash;
>
> subtype = csdev->subtype.source_subtype;
>
> @@ -1115,7 +1116,14 @@ int coresight_enable(struct coresight_device *csdev)
> per_cpu(tracer_path, cpu) = path;
> break;
> case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
> - stm_path = path;
> + /*
> + * Use the hash of source's device name as ID
> + * and map the ID to the pointer of the path.
> + */
> + hash = hashlen_hash(hashlen_string(NULL, dev_name(&csdev->dev)));
> + ret = idr_alloc_u32(&path_idr, path, &hash, hash, GFP_KERNEL);
> + if (ret)
> + goto err_source;
> break;
> default:
> /* We can't be here */
> @@ -1139,6 +1147,7 @@ void coresight_disable(struct coresight_device *csdev)
> {
> int cpu, ret;
> struct list_head *path = NULL;
> + u32 hash;
>
> mutex_lock(&coresight_mutex);
>
> @@ -1156,14 +1165,20 @@ void coresight_disable(struct coresight_device *csdev)
> per_cpu(tracer_path, cpu) = NULL;
> break;
> case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
> - path = stm_path;
> - stm_path = NULL;
> + hash = hashlen_hash(hashlen_string(NULL, dev_name(&csdev->dev)));
> + /* Find the path by the hash. */
> + path = idr_find(&path_idr, hash);
> + if (path == NULL) {
> + pr_err("Path is not found for %s\n", dev_name(&csdev->dev));
> + goto out;
> + }
> break;
> default:
> /* We can't be here */
> break;
> }
>
> + idr_remove(&path_idr, hash);
> coresight_disable_path(path);
> coresight_release_path(path);
>
> --
> 2.17.1
>
Reviewed by: Mike Leach <mike.leach@...aro.org>
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Powered by blists - more mailing lists