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>
This commit is contained in:
Mathieu Poirier 2016-04-29 13:22:59 -06:00
parent e5fd3d6e84
commit 376daf04d5
3 changed files with 29 additions and 16 deletions

View file

@ -184,7 +184,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
* list of devices from source to sink that can be * list of devices from source to sink that can be
* referenced later when the path is actually needed. * referenced later when the path is actually needed.
*/ */
event_data->path[cpu] = coresight_build_path(csdev); event_data->path[cpu] = coresight_build_path(csdev, NULL);
if (!event_data->path[cpu]) if (!event_data->path[cpu])
goto err; goto err;
} }

View file

@ -94,7 +94,8 @@ static inline void CS_UNLOCK(void __iomem *addr)
void coresight_disable_path(struct list_head *path); void coresight_disable_path(struct list_head *path);
int coresight_enable_path(struct list_head *path, u32 mode); int coresight_enable_path(struct list_head *path, u32 mode);
struct coresight_device *coresight_get_sink(struct list_head *path); struct coresight_device *coresight_get_sink(struct list_head *path);
struct list_head *coresight_build_path(struct coresight_device *csdev); struct list_head *coresight_build_path(struct coresight_device *csdev,
const char *sink);
void coresight_release_path(struct list_head *path); void coresight_release_path(struct list_head *path);
#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X

View file

@ -371,31 +371,42 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
/** /**
* _coresight_build_path - recursively build a path from a @csdev to a sink. * _coresight_build_path - recursively build a path from a @csdev to a sink.
* @csdev: The device to start from. * @csdev: The device to start from.
* @sink: The name of the sink this path should connect with.
* @path: The list to add devices to. * @path: The list to add devices to.
* *
* The tree of Coresight device is traversed until an activated sink is * The tree of Coresight device is traversed until an activated sink or
* found. From there the sink is added to the list along with all the * the one specified by @sink is found.
* devices that led to that point - the end result is a list from source * From there the sink is added to the list along with all the devices that
* to sink. In that list the source is the first device and the sink the * led to that point - the end result is a list from source to sink. In that
* last one. * list the source is the first device and the sink the last one.
*/ */
static int _coresight_build_path(struct coresight_device *csdev, static int _coresight_build_path(struct coresight_device *csdev,
struct list_head *path) const char *sink, struct list_head *path)
{ {
int i; int i;
bool found = false; bool found = false;
struct coresight_node *node; struct coresight_node *node;
/* An activated sink has been found. Enqueue the element */ /*
if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || * First see if we are dealing with a sink. If we have one check if
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && csdev->activated) * it was selected via sysFS or the perf cmd line.
*/
if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
/* Activated via perf cmd line */
if (sink && !strcmp(dev_name(&csdev->dev), sink))
goto out; goto out;
/* Activatred via sysFS */
if (csdev->activated)
goto out;
}
/* Not a sink - recursively explore each port found on this element */ /* Not a sink - recursively explore each port found on this element */
for (i = 0; i < csdev->nr_outport; i++) { for (i = 0; i < csdev->nr_outport; i++) {
struct coresight_device *child_dev = csdev->conns[i].child_dev; struct coresight_device *child_dev = csdev->conns[i].child_dev;
if (child_dev && _coresight_build_path(child_dev, path) == 0) { if (child_dev &&
_coresight_build_path(child_dev, sink, path) == 0) {
found = true; found = true;
break; break;
} }
@ -422,7 +433,8 @@ out:
return 0; return 0;
} }
struct list_head *coresight_build_path(struct coresight_device *csdev) struct list_head *coresight_build_path(struct coresight_device *csdev,
const char *sink)
{ {
struct list_head *path; struct list_head *path;
int rc; int rc;
@ -433,7 +445,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev)
INIT_LIST_HEAD(path); INIT_LIST_HEAD(path);
rc = _coresight_build_path(csdev, path); rc = _coresight_build_path(csdev, sink, path);
if (rc) { if (rc) {
kfree(path); kfree(path);
return ERR_PTR(rc); return ERR_PTR(rc);
@ -508,7 +520,7 @@ int coresight_enable(struct coresight_device *csdev)
if (csdev->enable) if (csdev->enable)
goto out; goto out;
path = coresight_build_path(csdev); path = coresight_build_path(csdev, NULL);
if (IS_ERR(path)) { if (IS_ERR(path)) {
pr_err("building path(s) failed\n"); pr_err("building path(s) failed\n");
ret = PTR_ERR(path); ret = PTR_ERR(path);