Skip to content

Commit 3c03c49

Browse files
Jie GanSuzuki K Poulose
authored andcommitted
Coresight: Introduce a new struct coresight_path
Introduce a new strcuture, 'struct coresight_path', to store the data that utilized by the devices in the path. The coresight_path will be built/released by coresight_build_path/coresight_release_path functions. Signed-off-by: Jie Gan <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 182e8c7 commit 3c03c49

File tree

6 files changed

+44
-32
lines changed

6 files changed

+44
-32
lines changed

drivers/hwtracing/coresight/coresight-core.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ static void coresight_drop_device(struct coresight_device *csdev)
670670
static int _coresight_build_path(struct coresight_device *csdev,
671671
struct coresight_device *source,
672672
struct coresight_device *sink,
673-
struct list_head *path)
673+
struct coresight_path *path)
674674
{
675675
int i, ret;
676676
bool found = false;
@@ -723,25 +723,25 @@ static int _coresight_build_path(struct coresight_device *csdev,
723723
return -ENOMEM;
724724

725725
node->csdev = csdev;
726-
list_add(&node->link, path);
726+
list_add(&node->link, &path->path_list);
727727

728728
return 0;
729729
}
730730

731-
struct list_head *coresight_build_path(struct coresight_device *source,
731+
struct coresight_path *coresight_build_path(struct coresight_device *source,
732732
struct coresight_device *sink)
733733
{
734-
struct list_head *path;
734+
struct coresight_path *path;
735735
int rc;
736736

737737
if (!sink)
738738
return ERR_PTR(-EINVAL);
739739

740-
path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
740+
path = kzalloc(sizeof(struct coresight_path), GFP_KERNEL);
741741
if (!path)
742742
return ERR_PTR(-ENOMEM);
743743

744-
INIT_LIST_HEAD(path);
744+
INIT_LIST_HEAD(&path->path_list);
745745

746746
rc = _coresight_build_path(source, source, sink, path);
747747
if (rc) {
@@ -759,12 +759,12 @@ struct list_head *coresight_build_path(struct coresight_device *source,
759759
* Go through all the elements of a path and 1) removed it from the list and
760760
* 2) free the memory allocated for each node.
761761
*/
762-
void coresight_release_path(struct list_head *path)
762+
void coresight_release_path(struct coresight_path *path)
763763
{
764764
struct coresight_device *csdev;
765765
struct coresight_node *nd, *next;
766766

767-
list_for_each_entry_safe(nd, next, path, link) {
767+
list_for_each_entry_safe(nd, next, &path->path_list, link) {
768768
csdev = nd->csdev;
769769

770770
coresight_drop_device(csdev);

drivers/hwtracing/coresight/coresight-etm-perf.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ static const struct attribute_group *etm_pmu_attr_groups[] = {
136136
NULL,
137137
};
138138

139-
static inline struct list_head **
139+
static inline struct coresight_path **
140140
etm_event_cpu_path_ptr(struct etm_event_data *data, int cpu)
141141
{
142142
return per_cpu_ptr(data->path, cpu);
143143
}
144144

145-
static inline struct list_head *
145+
static inline struct coresight_path *
146146
etm_event_cpu_path(struct etm_event_data *data, int cpu)
147147
{
148148
return *etm_event_cpu_path_ptr(data, cpu);
@@ -197,6 +197,7 @@ static void free_sink_buffer(struct etm_event_data *event_data)
197197
int cpu;
198198
cpumask_t *mask = &event_data->mask;
199199
struct coresight_device *sink;
200+
struct coresight_path *path;
200201

201202
if (!event_data->snk_config)
202203
return;
@@ -205,7 +206,8 @@ static void free_sink_buffer(struct etm_event_data *event_data)
205206
return;
206207

207208
cpu = cpumask_first(mask);
208-
sink = coresight_get_sink(etm_event_cpu_path(event_data, cpu));
209+
path = etm_event_cpu_path(event_data, cpu);
210+
sink = coresight_get_sink(&path->path_list);
209211
sink_ops(sink)->free_buffer(event_data->snk_config);
210212
}
211213

@@ -226,11 +228,11 @@ static void free_event_data(struct work_struct *work)
226228
cscfg_deactivate_config(event_data->cfg_hash);
227229

228230
for_each_cpu(cpu, mask) {
229-
struct list_head **ppath;
231+
struct coresight_path **ppath;
230232

231233
ppath = etm_event_cpu_path_ptr(event_data, cpu);
232234
if (!(IS_ERR_OR_NULL(*ppath))) {
233-
struct coresight_device *sink = coresight_get_sink(*ppath);
235+
struct coresight_device *sink = coresight_get_sink(&((*ppath)->path_list));
234236

235237
/*
236238
* Mark perf event as done for trace id allocator, but don't call
@@ -276,7 +278,7 @@ static void *alloc_event_data(int cpu)
276278
* unused memory when dealing with single CPU trace scenarios is small
277279
* compared to the cost of searching through an optimized array.
278280
*/
279-
event_data->path = alloc_percpu(struct list_head *);
281+
event_data->path = alloc_percpu(struct coresight_path *);
280282

281283
if (!event_data->path) {
282284
kfree(event_data);
@@ -352,7 +354,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
352354
* CPUs, we can handle it and fail the session.
353355
*/
354356
for_each_cpu(cpu, mask) {
355-
struct list_head *path;
357+
struct coresight_path *path;
356358
struct coresight_device *csdev;
357359

358360
csdev = per_cpu(csdev_src, cpu);
@@ -458,7 +460,7 @@ static void etm_event_start(struct perf_event *event, int flags)
458460
struct etm_ctxt *ctxt = this_cpu_ptr(&etm_ctxt);
459461
struct perf_output_handle *handle = &ctxt->handle;
460462
struct coresight_device *sink, *csdev = per_cpu(csdev_src, cpu);
461-
struct list_head *path;
463+
struct coresight_path *path;
462464
u64 hw_id;
463465
u8 trace_id;
464466

@@ -494,12 +496,12 @@ static void etm_event_start(struct perf_event *event, int flags)
494496

495497
path = etm_event_cpu_path(event_data, cpu);
496498
/* We need a sink, no need to continue without one */
497-
sink = coresight_get_sink(path);
499+
sink = coresight_get_sink(&path->path_list);
498500
if (WARN_ON_ONCE(!sink))
499501
goto fail_end_stop;
500502

501503
/* Nothing will happen without a path */
502-
if (coresight_enable_path(path, CS_MODE_PERF, handle))
504+
if (coresight_enable_path(&path->path_list, CS_MODE_PERF, handle))
503505
goto fail_end_stop;
504506

505507
/* Finally enable the tracer */
@@ -534,7 +536,7 @@ static void etm_event_start(struct perf_event *event, int flags)
534536
return;
535537

536538
fail_disable_path:
537-
coresight_disable_path(path);
539+
coresight_disable_path(&path->path_list);
538540
fail_end_stop:
539541
/*
540542
* Check if the handle is still associated with the event,
@@ -558,7 +560,7 @@ static void etm_event_stop(struct perf_event *event, int mode)
558560
struct etm_ctxt *ctxt = this_cpu_ptr(&etm_ctxt);
559561
struct perf_output_handle *handle = &ctxt->handle;
560562
struct etm_event_data *event_data;
561-
struct list_head *path;
563+
struct coresight_path *path;
562564

563565
/*
564566
* If we still have access to the event_data via handle,
@@ -599,7 +601,7 @@ static void etm_event_stop(struct perf_event *event, int mode)
599601
if (!path)
600602
return;
601603

602-
sink = coresight_get_sink(path);
604+
sink = coresight_get_sink(&path->path_list);
603605
if (!sink)
604606
return;
605607

@@ -643,7 +645,7 @@ static void etm_event_stop(struct perf_event *event, int mode)
643645
}
644646

645647
/* Disabling the path make its elements available to other sessions */
646-
coresight_disable_path(path);
648+
coresight_disable_path(&path->path_list);
647649
}
648650

649651
static int etm_event_add(struct perf_event *event, int mode)

drivers/hwtracing/coresight/coresight-etm-perf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct etm_event_data {
5959
cpumask_t aux_hwid_done;
6060
void *snk_config;
6161
u32 cfg_hash;
62-
struct list_head * __percpu *path;
62+
struct coresight_path * __percpu *path;
6363
};
6464

6565
int etm_perf_symlink(struct coresight_device *csdev, bool link);

drivers/hwtracing/coresight/coresight-priv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ struct coresight_device *coresight_get_sink(struct list_head *path);
139139
struct coresight_device *coresight_get_sink_by_id(u32 id);
140140
struct coresight_device *
141141
coresight_find_default_sink(struct coresight_device *csdev);
142-
struct list_head *coresight_build_path(struct coresight_device *csdev,
143-
struct coresight_device *sink);
144-
void coresight_release_path(struct list_head *path);
142+
struct coresight_path *coresight_build_path(struct coresight_device *csdev,
143+
struct coresight_device *sink);
144+
void coresight_release_path(struct coresight_path *path);
145145
int coresight_add_sysfs_link(struct coresight_sysfs_link *info);
146146
void coresight_remove_sysfs_link(struct coresight_sysfs_link *info);
147147
int coresight_create_conns_sysfs_group(struct coresight_device *csdev);

drivers/hwtracing/coresight/coresight-sysfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static DEFINE_IDR(path_idr);
2222
* When operating Coresight drivers from the sysFS interface, only a single
2323
* path can exist from a tracer (associated to a CPU) to a sink.
2424
*/
25-
static DEFINE_PER_CPU(struct list_head *, tracer_path);
25+
static DEFINE_PER_CPU(struct coresight_path *, tracer_path);
2626

2727
ssize_t coresight_simple_show_pair(struct device *_dev,
2828
struct device_attribute *attr, char *buf)
@@ -167,7 +167,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
167167
{
168168
int cpu, ret = 0;
169169
struct coresight_device *sink;
170-
struct list_head *path;
170+
struct coresight_path *path;
171171
enum coresight_dev_subtype_source subtype;
172172
u32 hash;
173173

@@ -209,7 +209,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
209209
goto out;
210210
}
211211

212-
ret = coresight_enable_path(path, CS_MODE_SYSFS, NULL);
212+
ret = coresight_enable_path(&path->path_list, CS_MODE_SYSFS, NULL);
213213
if (ret)
214214
goto err_path;
215215

@@ -251,7 +251,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
251251
return ret;
252252

253253
err_source:
254-
coresight_disable_path(path);
254+
coresight_disable_path(&path->path_list);
255255

256256
err_path:
257257
coresight_release_path(path);
@@ -262,7 +262,7 @@ EXPORT_SYMBOL_GPL(coresight_enable_sysfs);
262262
void coresight_disable_sysfs(struct coresight_device *csdev)
263263
{
264264
int cpu, ret;
265-
struct list_head *path = NULL;
265+
struct coresight_path *path = NULL;
266266
u32 hash;
267267

268268
mutex_lock(&coresight_mutex);
@@ -297,7 +297,7 @@ void coresight_disable_sysfs(struct coresight_device *csdev)
297297
break;
298298
}
299299

300-
coresight_disable_path(path);
300+
coresight_disable_path(&path->path_list);
301301
coresight_release_path(path);
302302

303303
out:

include/linux/coresight.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,16 @@ static struct coresight_dev_list (var) = { \
329329

330330
#define to_coresight_device(d) container_of(d, struct coresight_device, dev)
331331

332+
/**
333+
* struct coresight_path - data needed by enable/disable path
334+
* @path_list: path from source to sink.
335+
* @trace_id: trace_id of the whole path.
336+
*/
337+
struct coresight_path {
338+
struct list_head path_list;
339+
u8 trace_id;
340+
};
341+
332342
enum cs_mode {
333343
CS_MODE_DISABLED,
334344
CS_MODE_SYSFS,

0 commit comments

Comments
 (0)