coresight: etm-perf: Update to activate selected configuration
authorMike Leach <mike.leach@linaro.org>
Wed, 18 Aug 2021 19:40:17 +0000 (13:40 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Aug 2021 20:33:28 +0000 (22:33 +0200)
Add calls to activate the selected configuration as perf starts
and stops the tracing session.

Link: https://lore.kernel.org/r/20210723165444.1048-7-mike.leach@linaro.org
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20210818194022.379573-7-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-etm-perf.c
drivers/hwtracing/coresight/coresight-etm-perf.h

index e42ab919ddc33e3cf1e4a273ec380ebb24b46348..8ebd728d3a80066680f215008f1d210bbbc34256 100644 (file)
@@ -215,6 +215,10 @@ static void free_event_data(struct work_struct *work)
        /* Free the sink buffers, if there are any */
        free_sink_buffer(event_data);
 
+       /* clear any configuration we were using */
+       if (event_data->cfg_hash)
+               cscfg_deactivate_config(event_data->cfg_hash);
+
        for_each_cpu(cpu, mask) {
                struct list_head **ppath;
 
@@ -292,7 +296,7 @@ static bool sinks_compatible(struct coresight_device *a,
 static void *etm_setup_aux(struct perf_event *event, void **pages,
                           int nr_pages, bool overwrite)
 {
-       u32 id;
+       u32 id, cfg_hash;
        int cpu = event->cpu;
        cpumask_t *mask;
        struct coresight_device *sink = NULL;
@@ -310,6 +314,14 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
                sink = user_sink = coresight_get_sink_by_id(id);
        }
 
+       /* check if user wants a coresight configuration selected */
+       cfg_hash = (u32)((event->attr.config2 & GENMASK_ULL(63, 32)) >> 32);
+       if (cfg_hash) {
+               if (cscfg_activate_config(cfg_hash))
+                       goto err;
+               event_data->cfg_hash = cfg_hash;
+       }
+
        mask = &event_data->mask;
 
        /*
index ba617fe2217ee73e5806f16d1534d5dabccc87a7..468f7799ab4fb13303aadc1652e2396082acf564 100644 (file)
@@ -49,12 +49,14 @@ struct etm_filters {
  * @work:              Handle to free allocated memory outside IRQ context.
  * @mask:              Hold the CPU(s) this event was set for.
  * @snk_config:                The sink configuration.
+ * @cfg_hash:          The hash id of any coresight config selected.
  * @path:              An array of path, each slot for one CPU.
  */
 struct etm_event_data {
        struct work_struct work;
        cpumask_t mask;
        void *snk_config;
+       u32 cfg_hash;
        struct list_head * __percpu *path;
 };