Skip to content

Commit 376daf0

Browse files
coresight: adding sink parameter to function coresight_build_path()
Up to now function coresight_build_path() was counting on a sink to have been selected (from sysFS) prior to being called. This patch adds a string argument so that a sink matching the argument can be selected. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent e5fd3d6 commit 376daf0

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
184184
* list of devices from source to sink that can be
185185
* referenced later when the path is actually needed.
186186
*/
187-
event_data->path[cpu] = coresight_build_path(csdev);
187+
event_data->path[cpu] = coresight_build_path(csdev, NULL);
188188
if (!event_data->path[cpu])
189189
goto err;
190190
}

drivers/hwtracing/coresight/coresight-priv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ static inline void CS_UNLOCK(void __iomem *addr)
9494
void coresight_disable_path(struct list_head *path);
9595
int coresight_enable_path(struct list_head *path, u32 mode);
9696
struct coresight_device *coresight_get_sink(struct list_head *path);
97-
struct list_head *coresight_build_path(struct coresight_device *csdev);
97+
struct list_head *coresight_build_path(struct coresight_device *csdev,
98+
const char *sink);
9899
void coresight_release_path(struct list_head *path);
99100

100101
#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X

drivers/hwtracing/coresight/coresight.c

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -371,31 +371,42 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
371371
/**
372372
* _coresight_build_path - recursively build a path from a @csdev to a sink.
373373
* @csdev: The device to start from.
374+
* @sink: The name of the sink this path should connect with.
374375
* @path: The list to add devices to.
375376
*
376-
* The tree of Coresight device is traversed until an activated sink is
377-
* found. From there the sink is added to the list along with all the
378-
* devices that led to that point - the end result is a list from source
379-
* to sink. In that list the source is the first device and the sink the
380-
* last one.
377+
* The tree of Coresight device is traversed until an activated sink or
378+
* the one specified by @sink is found.
379+
* From there the sink is added to the list along with all the devices that
380+
* led to that point - the end result is a list from source to sink. In that
381+
* list the source is the first device and the sink the last one.
381382
*/
382383
static int _coresight_build_path(struct coresight_device *csdev,
383-
struct list_head *path)
384+
const char *sink, struct list_head *path)
384385
{
385386
int i;
386387
bool found = false;
387388
struct coresight_node *node;
388389

389-
/* An activated sink has been found. Enqueue the element */
390-
if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
391-
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && csdev->activated)
392-
goto out;
390+
/*
391+
* First see if we are dealing with a sink. If we have one check if
392+
* it was selected via sysFS or the perf cmd line.
393+
*/
394+
if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
395+
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
396+
/* Activated via perf cmd line */
397+
if (sink && !strcmp(dev_name(&csdev->dev), sink))
398+
goto out;
399+
/* Activatred via sysFS */
400+
if (csdev->activated)
401+
goto out;
402+
}
393403

394404
/* Not a sink - recursively explore each port found on this element */
395405
for (i = 0; i < csdev->nr_outport; i++) {
396406
struct coresight_device *child_dev = csdev->conns[i].child_dev;
397407

398-
if (child_dev && _coresight_build_path(child_dev, path) == 0) {
408+
if (child_dev &&
409+
_coresight_build_path(child_dev, sink, path) == 0) {
399410
found = true;
400411
break;
401412
}
@@ -422,7 +433,8 @@ static int _coresight_build_path(struct coresight_device *csdev,
422433
return 0;
423434
}
424435

425-
struct list_head *coresight_build_path(struct coresight_device *csdev)
436+
struct list_head *coresight_build_path(struct coresight_device *csdev,
437+
const char *sink)
426438
{
427439
struct list_head *path;
428440
int rc;
@@ -433,7 +445,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev)
433445

434446
INIT_LIST_HEAD(path);
435447

436-
rc = _coresight_build_path(csdev, path);
448+
rc = _coresight_build_path(csdev, sink, path);
437449
if (rc) {
438450
kfree(path);
439451
return ERR_PTR(rc);
@@ -508,7 +520,7 @@ int coresight_enable(struct coresight_device *csdev)
508520
if (csdev->enable)
509521
goto out;
510522

511-
path = coresight_build_path(csdev);
523+
path = coresight_build_path(csdev, NULL);
512524
if (IS_ERR(path)) {
513525
pr_err("building path(s) failed\n");
514526
ret = PTR_ERR(path);

0 commit comments

Comments
 (0)