Skip to content

Commit 490a421

Browse files
committed
PM / devfreq: Add debugfs support with devfreq_summary file
Add debugfs interface to provide debugging information of devfreq device. It contains 'devfreq_summary' entry to show the summary of registered devfreq devices as following and the additional debugfs file will be added. - /sys/kernel/debug/devfreq/devfreq_summary [Detailed description of each field of 'devfreq_summary' debugfs file] - dev_name : Device name of h/w - dev : Device name made by devfreq core - parent_dev : If devfreq device uses the passive governor, show parent devfreq device name. Otherwise, show 'null'. - governor : Devfreq governor name - polling_ms : If devfreq device uses the simple_ondemand governor, polling_ms is necessary for the period. (unit: millisecond) - cur_freq_Hz : Current frequency (unit: Hz) - min_freq_Hz : Minimum frequency (unit: Hz) - max_freq_Hz : Maximum frequency (unit: Hz) [For example on Exynos5422-based Odroid-XU3 board] $ cat /sys/kernel/debug/devfreq/devfreq_summary dev_name dev parent_dev governor polling_ms cur_freq_Hz min_freq_Hz max_freq_Hz ------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------ 10c20000.memory-controller devfreq0 null simple_ondemand 0 165000000 165000000 825000000 soc:bus_wcore devfreq1 null simple_ondemand 50 532000000 88700000 532000000 soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000 soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000 soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000 soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000 soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000 soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000 soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000 soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 83250000 333000000 soc:bus_g2d_acp devfreq10 devfreq1 passive 0 266000000 66500000 266000000 soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000 soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 166500000 83250000 166500000 soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000 soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000 soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000 soc:bus_mscl devfreq16 devfreq1 passive 0 666000000 84000000 666000000 [lkp: Reported the build error] Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent 91d7f3f commit 490a421

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

‎drivers/devfreq/devfreq.c‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/kernel.h>
1111
#include <linux/kmod.h>
1212
#include <linux/sched.h>
13+
#include <linux/debugfs.h>
1314
#include <linux/errno.h>
1415
#include <linux/err.h>
1516
#include <linux/init.h>
@@ -33,6 +34,7 @@
3334
#define HZ_PER_KHZ 1000
3435

3536
static struct class *devfreq_class;
37+
static struct dentry *devfreq_debugfs;
3638

3739
/*
3840
* devfreq core provides delayed work based load monitoring helper
@@ -1643,6 +1645,81 @@ static struct attribute *devfreq_attrs[] = {
16431645
};
16441646
ATTRIBUTE_GROUPS(devfreq);
16451647

1648+
/**
1649+
* devfreq_summary_show() - Show the summary of the devfreq devices
1650+
* @s: seq_file instance to show the summary of devfreq devices
1651+
* @data: not used
1652+
*
1653+
* Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
1654+
* It helps that user can know the detailed information of the devfreq devices.
1655+
*
1656+
* Return 0 always because it shows the information without any data change.
1657+
*/
1658+
static int devfreq_summary_show(struct seq_file *s, void *data)
1659+
{
1660+
struct devfreq *devfreq;
1661+
struct devfreq *p_devfreq = NULL;
1662+
unsigned long cur_freq, min_freq, max_freq;
1663+
unsigned int polling_ms;
1664+
1665+
seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
1666+
"dev_name",
1667+
"dev",
1668+
"parent_dev",
1669+
"governor",
1670+
"polling_ms",
1671+
"cur_freq_Hz",
1672+
"min_freq_Hz",
1673+
"max_freq_Hz");
1674+
seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
1675+
"------------------------------",
1676+
"----------",
1677+
"----------",
1678+
"---------------",
1679+
"----------",
1680+
"------------",
1681+
"------------",
1682+
"------------");
1683+
1684+
mutex_lock(&devfreq_list_lock);
1685+
1686+
list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
1687+
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
1688+
if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
1689+
DEVFREQ_NAME_LEN)) {
1690+
struct devfreq_passive_data *data = devfreq->data;
1691+
1692+
if (data)
1693+
p_devfreq = data->parent;
1694+
} else {
1695+
p_devfreq = NULL;
1696+
}
1697+
#endif
1698+
1699+
mutex_lock(&devfreq->lock);
1700+
cur_freq = devfreq->previous_freq,
1701+
get_freq_range(devfreq, &min_freq, &max_freq);
1702+
polling_ms = devfreq->profile->polling_ms,
1703+
mutex_unlock(&devfreq->lock);
1704+
1705+
seq_printf(s,
1706+
"%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
1707+
dev_name(devfreq->dev.parent),
1708+
dev_name(&devfreq->dev),
1709+
p_devfreq ? dev_name(&p_devfreq->dev) : "null",
1710+
devfreq->governor_name,
1711+
polling_ms,
1712+
cur_freq,
1713+
min_freq,
1714+
max_freq);
1715+
}
1716+
1717+
mutex_unlock(&devfreq_list_lock);
1718+
1719+
return 0;
1720+
}
1721+
DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
1722+
16461723
static int __init devfreq_init(void)
16471724
{
16481725
devfreq_class = class_create(THIS_MODULE, "devfreq");
@@ -1659,6 +1736,11 @@ static int __init devfreq_init(void)
16591736
}
16601737
devfreq_class->dev_groups = devfreq_groups;
16611738

1739+
devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
1740+
debugfs_create_file("devfreq_summary", 0444,
1741+
devfreq_debugfs, NULL,
1742+
&devfreq_summary_fops);
1743+
16621744
return 0;
16631745
}
16641746
subsys_initcall(devfreq_init);

0 commit comments

Comments
 (0)