Skip to content

Commit 080ee83

Browse files
Jie GanSuzuki K Poulose
authored andcommitted
Coresight: Change functions to accept the coresight_path
Modify following functions to accept the coresight_path. Devices in the path can read data from coresight_path if needed. - coresight_enable_path - coresight_disable_path - coresight_get_source - coresight_get_sink - coresight_enable_helpers - coresight_disable_helpers 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 7b365f0 commit 080ee83

File tree

4 files changed

+32
-33
lines changed

4 files changed

+32
-33
lines changed

drivers/hwtracing/coresight/coresight-core.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ struct coresight_device *coresight_get_percpu_sink(int cpu)
7777
}
7878
EXPORT_SYMBOL_GPL(coresight_get_percpu_sink);
7979

80-
static struct coresight_device *coresight_get_source(struct list_head *path)
80+
static struct coresight_device *coresight_get_source(struct coresight_path *path)
8181
{
8282
struct coresight_device *csdev;
8383

8484
if (!path)
8585
return NULL;
8686

87-
csdev = list_first_entry(path, struct coresight_node, link)->csdev;
87+
csdev = list_first_entry(&path->path_list, struct coresight_node, link)->csdev;
8888
if (!coresight_is_device_source(csdev))
8989
return NULL;
9090

@@ -333,20 +333,20 @@ static int coresight_enable_helper(struct coresight_device *csdev,
333333
return helper_ops(csdev)->enable(csdev, mode, data);
334334
}
335335

336-
static void coresight_disable_helper(struct coresight_device *csdev)
336+
static void coresight_disable_helper(struct coresight_device *csdev, void *data)
337337
{
338-
helper_ops(csdev)->disable(csdev, NULL);
338+
helper_ops(csdev)->disable(csdev, data);
339339
}
340340

341-
static void coresight_disable_helpers(struct coresight_device *csdev)
341+
static void coresight_disable_helpers(struct coresight_device *csdev, void *data)
342342
{
343343
int i;
344344
struct coresight_device *helper;
345345

346346
for (i = 0; i < csdev->pdata->nr_outconns; ++i) {
347347
helper = csdev->pdata->out_conns[i]->dest_dev;
348348
if (helper && coresight_is_helper(helper))
349-
coresight_disable_helper(helper);
349+
coresight_disable_helper(helper, data);
350350
}
351351
}
352352

@@ -363,7 +363,7 @@ static void coresight_disable_helpers(struct coresight_device *csdev)
363363
void coresight_disable_source(struct coresight_device *csdev, void *data)
364364
{
365365
source_ops(csdev)->disable(csdev, data);
366-
coresight_disable_helpers(csdev);
366+
coresight_disable_helpers(csdev, NULL);
367367
}
368368
EXPORT_SYMBOL_GPL(coresight_disable_source);
369369

@@ -372,16 +372,16 @@ EXPORT_SYMBOL_GPL(coresight_disable_source);
372372
* @nd in the list. If @nd is NULL, all the components, except the SOURCE are
373373
* disabled.
374374
*/
375-
static void coresight_disable_path_from(struct list_head *path,
375+
static void coresight_disable_path_from(struct coresight_path *path,
376376
struct coresight_node *nd)
377377
{
378378
u32 type;
379379
struct coresight_device *csdev, *parent, *child;
380380

381381
if (!nd)
382-
nd = list_first_entry(path, struct coresight_node, link);
382+
nd = list_first_entry(&path->path_list, struct coresight_node, link);
383383

384-
list_for_each_entry_continue(nd, path, link) {
384+
list_for_each_entry_continue(nd, &path->path_list, link) {
385385
csdev = nd->csdev;
386386
type = csdev->type;
387387

@@ -419,11 +419,11 @@ static void coresight_disable_path_from(struct list_head *path,
419419
}
420420

421421
/* Disable all helpers adjacent along the path last */
422-
coresight_disable_helpers(csdev);
422+
coresight_disable_helpers(csdev, path);
423423
}
424424
}
425425

426-
void coresight_disable_path(struct list_head *path)
426+
void coresight_disable_path(struct coresight_path *path)
427427
{
428428
coresight_disable_path_from(path, NULL);
429429
}
@@ -448,7 +448,7 @@ static int coresight_enable_helpers(struct coresight_device *csdev,
448448
return 0;
449449
}
450450

451-
int coresight_enable_path(struct list_head *path, enum cs_mode mode,
451+
int coresight_enable_path(struct coresight_path *path, enum cs_mode mode,
452452
void *sink_data)
453453
{
454454
int ret = 0;
@@ -458,12 +458,12 @@ int coresight_enable_path(struct list_head *path, enum cs_mode mode,
458458
struct coresight_device *source;
459459

460460
source = coresight_get_source(path);
461-
list_for_each_entry_reverse(nd, path, link) {
461+
list_for_each_entry_reverse(nd, &path->path_list, link) {
462462
csdev = nd->csdev;
463463
type = csdev->type;
464464

465465
/* Enable all helpers adjacent to the path first */
466-
ret = coresight_enable_helpers(csdev, mode, sink_data);
466+
ret = coresight_enable_helpers(csdev, mode, path);
467467
if (ret)
468468
goto err;
469469
/*
@@ -511,20 +511,21 @@ int coresight_enable_path(struct list_head *path, enum cs_mode mode,
511511
goto out;
512512
}
513513

514-
struct coresight_device *coresight_get_sink(struct list_head *path)
514+
struct coresight_device *coresight_get_sink(struct coresight_path *path)
515515
{
516516
struct coresight_device *csdev;
517517

518518
if (!path)
519519
return NULL;
520520

521-
csdev = list_last_entry(path, struct coresight_node, link)->csdev;
521+
csdev = list_last_entry(&path->path_list, struct coresight_node, link)->csdev;
522522
if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
523523
csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
524524
return NULL;
525525

526526
return csdev;
527527
}
528+
EXPORT_SYMBOL_GPL(coresight_get_sink);
528529

529530
u32 coresight_get_sink_id(struct coresight_device *csdev)
530531
{
@@ -680,7 +681,7 @@ static int coresight_get_trace_id(struct coresight_device *csdev,
680681
void coresight_path_assign_trace_id(struct coresight_path *path,
681682
enum cs_mode mode)
682683
{
683-
struct coresight_device *sink = coresight_get_sink(&path->path_list);
684+
struct coresight_device *sink = coresight_get_sink(path);
684685
struct coresight_node *nd;
685686
int trace_id;
686687

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ 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;
201200

202201
if (!event_data->snk_config)
203202
return;
@@ -206,8 +205,7 @@ static void free_sink_buffer(struct etm_event_data *event_data)
206205
return;
207206

208207
cpu = cpumask_first(mask);
209-
path = etm_event_cpu_path(event_data, cpu);
210-
sink = coresight_get_sink(&path->path_list);
208+
sink = coresight_get_sink(etm_event_cpu_path(event_data, cpu));
211209
sink_ops(sink)->free_buffer(event_data->snk_config);
212210
}
213211

@@ -232,7 +230,7 @@ static void free_event_data(struct work_struct *work)
232230

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

237235
/*
238236
* Mark perf event as done for trace id allocator, but don't call
@@ -494,12 +492,12 @@ static void etm_event_start(struct perf_event *event, int flags)
494492

495493
path = etm_event_cpu_path(event_data, cpu);
496494
/* We need a sink, no need to continue without one */
497-
sink = coresight_get_sink(&path->path_list);
495+
sink = coresight_get_sink(path);
498496
if (WARN_ON_ONCE(!sink))
499497
goto fail_end_stop;
500498

501499
/* Nothing will happen without a path */
502-
if (coresight_enable_path(&path->path_list, CS_MODE_PERF, handle))
500+
if (coresight_enable_path(path, CS_MODE_PERF, handle))
503501
goto fail_end_stop;
504502

505503
/* Finally enable the tracer */
@@ -531,7 +529,7 @@ static void etm_event_start(struct perf_event *event, int flags)
531529
return;
532530

533531
fail_disable_path:
534-
coresight_disable_path(&path->path_list);
532+
coresight_disable_path(path);
535533
fail_end_stop:
536534
/*
537535
* Check if the handle is still associated with the event,
@@ -596,7 +594,7 @@ static void etm_event_stop(struct perf_event *event, int mode)
596594
if (!path)
597595
return;
598596

599-
sink = coresight_get_sink(&path->path_list);
597+
sink = coresight_get_sink(path);
600598
if (!sink)
601599
return;
602600

@@ -640,7 +638,7 @@ static void etm_event_stop(struct perf_event *event, int mode)
640638
}
641639

642640
/* Disabling the path make its elements available to other sessions */
643-
coresight_disable_path(&path->path_list);
641+
coresight_disable_path(path);
644642
}
645643

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

drivers/hwtracing/coresight/coresight-priv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ static inline void CS_UNLOCK(void __iomem *addr)
132132
} while (0);
133133
}
134134

135-
void coresight_disable_path(struct list_head *path);
136-
int coresight_enable_path(struct list_head *path, enum cs_mode mode,
135+
void coresight_disable_path(struct coresight_path *path);
136+
int coresight_enable_path(struct coresight_path *path, enum cs_mode mode,
137137
void *sink_data);
138-
struct coresight_device *coresight_get_sink(struct list_head *path);
138+
struct coresight_device *coresight_get_sink(struct coresight_path *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);

drivers/hwtracing/coresight/coresight-sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
214214
if (!IS_VALID_CS_TRACE_ID(path->trace_id))
215215
goto err_path;
216216

217-
ret = coresight_enable_path(&path->path_list, CS_MODE_SYSFS, NULL);
217+
ret = coresight_enable_path(path, CS_MODE_SYSFS, NULL);
218218
if (ret)
219219
goto err_path;
220220

@@ -256,7 +256,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
256256
return ret;
257257

258258
err_source:
259-
coresight_disable_path(&path->path_list);
259+
coresight_disable_path(path);
260260

261261
err_path:
262262
coresight_release_path(path);
@@ -302,7 +302,7 @@ void coresight_disable_sysfs(struct coresight_device *csdev)
302302
break;
303303
}
304304

305-
coresight_disable_path(&path->path_list);
305+
coresight_disable_path(path);
306306
coresight_release_path(path);
307307

308308
out:

0 commit comments

Comments
 (0)