Skip to content

Commit 0530983

Browse files
author
Georgi Djakov
committed
interconnect: Add a name to struct icc_path
When debugging interconnect things, it turned out that saving the path name and including it in the traces is quite useful, especially for devices with multiple paths. For the path name we use the one specified in DT, or if we use platform data, the name is based on the source and destination node names. Suggested-by: Bjorn Andersson <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Georgi Djakov <[email protected]>
1 parent dd018a9 commit 0530983

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

drivers/interconnect/core.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,17 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
356356

357357
mutex_lock(&icc_lock);
358358
path = path_find(dev, src_node, dst_node);
359-
if (IS_ERR(path))
360-
dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path));
361359
mutex_unlock(&icc_lock);
360+
if (IS_ERR(path)) {
361+
dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path));
362+
return path;
363+
}
364+
365+
if (name)
366+
path->name = kstrdup_const(name, GFP_KERNEL);
367+
else
368+
path->name = kasprintf(GFP_KERNEL, "%s-%s",
369+
src_node->name, dst_node->name);
362370

363371
return path;
364372
}
@@ -481,9 +489,12 @@ struct icc_path *icc_get(struct device *dev, const int src_id, const int dst_id)
481489
goto out;
482490

483491
path = path_find(dev, src, dst);
484-
if (IS_ERR(path))
492+
if (IS_ERR(path)) {
485493
dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path));
494+
goto out;
495+
}
486496

497+
path->name = kasprintf(GFP_KERNEL, "%s-%s", src->name, dst->name);
487498
out:
488499
mutex_unlock(&icc_lock);
489500
return path;
@@ -519,6 +530,7 @@ void icc_put(struct icc_path *path)
519530
}
520531
mutex_unlock(&icc_lock);
521532

533+
kfree_const(path->name);
522534
kfree(path);
523535
}
524536
EXPORT_SYMBOL_GPL(icc_put);

drivers/interconnect/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ struct icc_req {
2929

3030
/**
3131
* struct icc_path - interconnect path structure
32+
* @name: a string name of the path (useful for ftrace)
3233
* @num_nodes: number of hops (nodes)
3334
* @reqs: array of the requests applicable to this path of nodes
3435
*/
3536
struct icc_path {
37+
const char *name;
3638
size_t num_nodes;
3739
struct icc_req reqs[];
3840
};

0 commit comments

Comments
 (0)