All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: cw00.choi@samsung.com, chanwoo@kernel.org,
	myungjoo.ham@samsung.com, kyungmin.park@samsung.com
Subject: [PATCH] PM / devfreq: Add debugfs support with devfreq_summary file
Date: Thu, 26 Dec 2019 15:07:49 +0900	[thread overview]
Message-ID: <20191226060749.13881-1-cw00.choi@samsung.com> (raw)
In-Reply-To: CGME20191226060101epcas1p11a225c00bb7ab2f6b7895b4cb00b9871@epcas1p1.samsung.com

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

[For example on Exynos5422-based Odroid-XU3 board]
- In order to show the multiple governors on devfreq_summay result,
change the governor of devfreq0 from simple_ondemand to userspace.

$ cat /sys/kernel/debug/devfreq/devfreq_summary
dev name                       dev        parent dev governor        cur_freq     min_freq     max_freq
------------------------------ ---------- ---------- --------------- ------------ ------------ ------------
10c20000.memory-controller     devfreq0              userspace       165000000    165000000    825000000
soc:bus_wcore                  devfreq1              simple_ondemand 400000000    84000000     400000000
soc:bus_noc                    devfreq2   devfreq1   passive         100000000    67000000     100000000
soc:bus_fsys_apb               devfreq3   devfreq1   passive         200000000    100000000    200000000
soc:bus_fsys                   devfreq4   devfreq1   passive         200000000    100000000    200000000
soc:bus_fsys2                  devfreq5   devfreq1   passive         150000000    75000000     150000000
soc:bus_mfc                    devfreq6   devfreq1   passive         333000000    96000000     333000000
soc:bus_gen                    devfreq7   devfreq1   passive         267000000    89000000     267000000
soc:bus_peri                   devfreq8   devfreq1   passive         67000000     67000000     67000000
soc:bus_g2d                    devfreq9   devfreq1   passive         333000000    84000000     333000000
soc:bus_g2d_acp                devfreq10  devfreq1   passive         267000000    67000000     267000000
soc:bus_jpeg                   devfreq11  devfreq1   passive         300000000    75000000     300000000
soc:bus_jpeg_apb               devfreq12  devfreq1   passive         167000000    84000000     167000000
soc:bus_disp1_fimd             devfreq13  devfreq1   passive         200000000    120000000    200000000
soc:bus_disp1                  devfreq14  devfreq1   passive         300000000    120000000    300000000
soc:bus_gscl_scaler            devfreq15  devfreq1   passive         300000000    150000000    300000000
soc:bus_mscl                   devfreq16  devfreq1   passive         400000000    84000000     400000000

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/devfreq/devfreq.c | 65 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index acd21345a070..d7177cc0a914 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/kmod.h>
 #include <linux/sched.h>
+#include <linux/debugfs.h>
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/init.h>
@@ -33,6 +34,7 @@
 #define HZ_PER_KHZ	1000
 
 static struct class *devfreq_class;
+static struct dentry *devfreq_debugfs;
 
 /*
  * devfreq core provides delayed work based load monitoring helper
@@ -1670,6 +1672,62 @@ static struct attribute *devfreq_attrs[] = {
 };
 ATTRIBUTE_GROUPS(devfreq);
 
+static int devfreq_summary_show(struct seq_file *s, void *data)
+{
+	struct devfreq *devfreq;
+	struct devfreq *parent_devfreq;
+	unsigned long cur_freq, min_freq, max_freq;
+
+	seq_printf(s, "%-30s %-10s %-10s %-15s %-12s %-12s %-12s\n",
+			"dev name",
+			"dev",
+			"parent dev",
+			"governor",
+			"cur_freq",
+			"min_freq",
+			"max_freq");
+	seq_printf(s, "%-30s %-10s %-10s %-15s %-12s %-12s %-12s\n",
+			"------------------------------",
+			"----------",
+			"----------",
+			"---------------",
+			"------------",
+			"------------",
+			"------------");
+
+	mutex_lock(&devfreq_list_lock);
+
+	list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
+#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
+		if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
+							DEVFREQ_NAME_LEN)) {
+			struct devfreq_passive_data *data = devfreq->data;
+			parent_devfreq = data->parent;
+		} else {
+			parent_devfreq = NULL;
+		}
+#endif
+		mutex_lock(&devfreq->lock);
+		cur_freq = devfreq->previous_freq,
+		get_freq_range(devfreq, &min_freq, &max_freq);
+		mutex_unlock(&devfreq->lock);
+
+		seq_printf(s, "%-30s %-10s %-10s %-15s %-12ld %-12ld %-12ld\n",
+			dev_name(devfreq->dev.parent),
+			dev_name(&devfreq->dev),
+			parent_devfreq ? dev_name(&parent_devfreq->dev) : "",
+			devfreq->governor_name,
+			cur_freq,
+			min_freq,
+			max_freq);
+	}
+
+	mutex_unlock(&devfreq_list_lock);
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
+
 static int __init devfreq_init(void)
 {
 	devfreq_class = class_create(THIS_MODULE, "devfreq");
@@ -1686,6 +1744,13 @@ static int __init devfreq_init(void)
 	}
 	devfreq_class->dev_groups = devfreq_groups;
 
+	devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
+	if (PTR_ERR(devfreq_debugfs) != -ENODEV && IS_ERR(devfreq_debugfs))
+		pr_warn("%s: couldn't create debugfs dir\n", __FILE__);
+
+	debugfs_create_file("devfreq_summary", 0444, devfreq_debugfs, NULL,
+			&devfreq_summary_fops);
+
 	return 0;
 }
 subsys_initcall(devfreq_init);
-- 
2.17.1


       reply	other threads:[~2019-12-26  6:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20191226060101epcas1p11a225c00bb7ab2f6b7895b4cb00b9871@epcas1p1.samsung.com>
2019-12-26  6:07 ` Chanwoo Choi [this message]
2019-12-30  3:26   ` [PATCH] PM / devfreq: Add debugfs support with devfreq_summary file Nathan Chancellor
2019-12-30  5:13     ` Chanwoo Choi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191226060749.13881-1-cw00.choi@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=chanwoo@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.