Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

opp: Expose bandwidth information via debugfs

Expose the bandwidth information as well via debugfs.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

+66
+18
drivers/interconnect/core.c
··· 515 515 EXPORT_SYMBOL_GPL(icc_set_tag); 516 516 517 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 + 535 + /** 518 536 * icc_set_bw() - set bandwidth constraints on an interconnect path 519 537 * @path: reference to the path returned by icc_get() 520 538 * @avg_bw: average bandwidth in kilobytes per second
+42
drivers/opp/debugfs.c
··· 32 32 debugfs_remove_recursive(opp->dentry); 33 33 } 34 34 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 + 35 76 static void opp_debug_create_supplies(struct dev_pm_opp *opp, 36 77 struct opp_table *opp_table, 37 78 struct dentry *pdentry) ··· 135 94 &opp->clock_latency_ns); 136 95 137 96 opp_debug_create_supplies(opp, opp_table, d); 97 + opp_debug_create_bw(opp, opp_table, d); 138 98 139 99 opp->dentry = d; 140 100 }
+6
include/linux/interconnect.h
··· 32 32 void icc_put(struct icc_path *path); 33 33 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); 34 34 void icc_set_tag(struct icc_path *path, u32 tag); 35 + const char *icc_get_name(struct icc_path *path); 35 36 36 37 #else 37 38 ··· 64 63 65 64 static inline void icc_set_tag(struct icc_path *path, u32 tag) 66 65 { 66 + } 67 + 68 + static inline const char *icc_get_name(struct icc_path *path) 69 + { 70 + return NULL; 67 71 } 68 72 69 73 #endif /* CONFIG_INTERCONNECT */