Skip to content

Commit 0430b1d

Browse files
committed
opp: Expose bandwidth information via debugfs
Expose the bandwidth information as well via debugfs. Signed-off-by: Viresh Kumar <[email protected]> Signed-off-by: Georgi Djakov <[email protected]>
1 parent 8b17f17 commit 0430b1d

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

drivers/interconnect/core.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,24 @@ void icc_set_tag(struct icc_path *path, u32 tag)
514514
}
515515
EXPORT_SYMBOL_GPL(icc_set_tag);
516516

517+
/**
518+
* icc_get_name() - Get name of the icc path
519+
* @path: reference to the path returned by icc_get()
520+
*
521+
* This function is used by an interconnect consumer to get the name of the icc
522+
* path.
523+
*
524+
* Returns a valid pointer on success, or NULL otherwise.
525+
*/
526+
const char *icc_get_name(struct icc_path *path)
527+
{
528+
if (!path)
529+
return NULL;
530+
531+
return path->name;
532+
}
533+
EXPORT_SYMBOL_GPL(icc_get_name);
534+
517535
/**
518536
* icc_set_bw() - set bandwidth constraints on an interconnect path
519537
* @path: reference to the path returned by icc_get()

drivers/opp/debugfs.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,47 @@ void opp_debug_remove_one(struct dev_pm_opp *opp)
3232
debugfs_remove_recursive(opp->dentry);
3333
}
3434

35+
static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
36+
size_t count, loff_t *ppos)
37+
{
38+
struct icc_path *path = fp->private_data;
39+
char buf[64];
40+
int i;
41+
42+
i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path));
43+
44+
return simple_read_from_buffer(userbuf, count, ppos, buf, i);
45+
}
46+
47+
static const struct file_operations bw_name_fops = {
48+
.open = simple_open,
49+
.read = bw_name_read,
50+
.llseek = default_llseek,
51+
};
52+
53+
static void opp_debug_create_bw(struct dev_pm_opp *opp,
54+
struct opp_table *opp_table,
55+
struct dentry *pdentry)
56+
{
57+
struct dentry *d;
58+
char name[11];
59+
int i;
60+
61+
for (i = 0; i < opp_table->path_count; i++) {
62+
snprintf(name, sizeof(name), "icc-path-%.1d", i);
63+
64+
/* Create per-path directory */
65+
d = debugfs_create_dir(name, pdentry);
66+
67+
debugfs_create_file("name", S_IRUGO, d, opp_table->paths[i],
68+
&bw_name_fops);
69+
debugfs_create_u32("peak_bw", S_IRUGO, d,
70+
&opp->bandwidth[i].peak);
71+
debugfs_create_u32("avg_bw", S_IRUGO, d,
72+
&opp->bandwidth[i].avg);
73+
}
74+
}
75+
3576
static void opp_debug_create_supplies(struct dev_pm_opp *opp,
3677
struct opp_table *opp_table,
3778
struct dentry *pdentry)
@@ -94,6 +135,7 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
94135
&opp->clock_latency_ns);
95136

96137
opp_debug_create_supplies(opp, opp_table, d);
138+
opp_debug_create_bw(opp, opp_table, d);
97139

98140
opp->dentry = d;
99141
}

include/linux/interconnect.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
3232
void icc_put(struct icc_path *path);
3333
int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
3434
void icc_set_tag(struct icc_path *path, u32 tag);
35+
const char *icc_get_name(struct icc_path *path);
3536

3637
#else
3738

@@ -65,6 +66,11 @@ static inline void icc_set_tag(struct icc_path *path, u32 tag)
6566
{
6667
}
6768

69+
static inline const char *icc_get_name(struct icc_path *path)
70+
{
71+
return NULL;
72+
}
73+
6874
#endif /* CONFIG_INTERCONNECT */
6975

7076
#endif /* __LINUX_INTERCONNECT_H */

0 commit comments

Comments
 (0)