linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Rafael Wysocki <rjw@rjwysocki.net>,
	Georgi Djakov <georgi.djakov@linaro.org>,
	Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] opp: Expose bandwidth information via debugfs
Date: Mon, 18 May 2020 17:11:02 +0530	[thread overview]
Message-ID: <c2ac269c4fd07059963ab973f9dd40ee869d9f5e.1589802005.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org>

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>
---
@Georgi: I am applying this along with your series.

 drivers/interconnect/core.c  | 18 ++++++++++++++++
 drivers/opp/debugfs.c        | 42 ++++++++++++++++++++++++++++++++++++
 include/linux/interconnect.h |  6 ++++++
 3 files changed, 66 insertions(+)

diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index 2d2e49780511..a56349c14985 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -514,6 +514,24 @@ void icc_set_tag(struct icc_path *path, u32 tag)
 }
 EXPORT_SYMBOL_GPL(icc_set_tag);
 
+/**
+ * icc_get_name() - Get name of the icc path
+ * @path: reference to the path returned by icc_get()
+ *
+ * This function is used by an interconnect consumer to get the name of the icc
+ * path.
+ *
+ * Returns a valid pointer on success, or NULL otherwise.
+ */
+const char *icc_get_name(struct icc_path *path)
+{
+	if (!path)
+		return NULL;
+
+	return path->name;
+}
+EXPORT_SYMBOL_GPL(icc_get_name);
+
 /**
  * icc_set_bw() - set bandwidth constraints on an interconnect path
  * @path: reference to the path returned by icc_get()
diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index 609665e339b6..596c185b5dda 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -32,6 +32,47 @@ void opp_debug_remove_one(struct dev_pm_opp *opp)
 	debugfs_remove_recursive(opp->dentry);
 }
 
+static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
+			    size_t count, loff_t *ppos)
+{
+	struct icc_path *path = fp->private_data;
+	char buf[64];
+	int i;
+
+	i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path));
+
+	return simple_read_from_buffer(userbuf, count, ppos, buf, i);
+}
+
+static const struct file_operations bw_name_fops = {
+	.open = simple_open,
+	.read = bw_name_read,
+	.llseek = default_llseek,
+};
+
+static void opp_debug_create_bw(struct dev_pm_opp *opp,
+				struct opp_table *opp_table,
+				struct dentry *pdentry)
+{
+	struct dentry *d;
+	char name[11];
+	int i;
+
+	for (i = 0; i < opp_table->path_count; i++) {
+		snprintf(name, sizeof(name), "icc-path-%.1d", i);
+
+		/* Create per-path directory */
+		d = debugfs_create_dir(name, pdentry);
+
+		debugfs_create_file("name", S_IRUGO, d, opp_table->paths[i],
+				    &bw_name_fops);
+		debugfs_create_u32("peak_bw", S_IRUGO, d,
+				   &opp->bandwidth[i].peak);
+		debugfs_create_u32("avg_bw", S_IRUGO, d,
+				   &opp->bandwidth[i].avg);
+	}
+}
+
 static void opp_debug_create_supplies(struct dev_pm_opp *opp,
 				      struct opp_table *opp_table,
 				      struct dentry *pdentry)
@@ -94,6 +135,7 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
 			     &opp->clock_latency_ns);
 
 	opp_debug_create_supplies(opp, opp_table, d);
+	opp_debug_create_bw(opp, opp_table, d);
 
 	opp->dentry = d;
 }
diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h
index 34e97231a6ab..1ad09efd296e 100644
--- a/include/linux/interconnect.h
+++ b/include/linux/interconnect.h
@@ -32,6 +32,7 @@ struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
 void icc_put(struct icc_path *path);
 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
 void icc_set_tag(struct icc_path *path, u32 tag);
+const char *icc_get_name(struct icc_path *path);
 
 #else
 
@@ -65,6 +66,11 @@ static inline void icc_set_tag(struct icc_path *path, u32 tag)
 {
 }
 
+static inline const char *icc_get_name(struct icc_path *path)
+{
+	return NULL;
+}
+
 #endif /* CONFIG_INTERCONNECT */
 
 #endif /* __LINUX_INTERCONNECT_H */
-- 
2.25.0.rc1.19.g042ed3e048af


  parent reply	other threads:[~2020-05-18 11:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 12:53 [PATCH v8 00/10] Introduce OPP bandwidth bindings Georgi Djakov
2020-05-12 12:53 ` [PATCH v8 01/10] dt-bindings: opp: Introduce opp-peak-kBps and opp-avg-kBps bindings Georgi Djakov
2020-05-12 12:53 ` [PATCH v8 02/10] OPP: Add helpers for reading the binding properties Georgi Djakov
2020-05-13  6:40   ` Viresh Kumar
2020-05-12 12:53 ` [PATCH v8 03/10] interconnect: Add of_icc_get_by_index() helper function Georgi Djakov
2020-05-12 12:53 ` [PATCH v8 04/10] OPP: Add support for parsing interconnect bandwidth Georgi Djakov
2020-05-12 21:35   ` Matthias Kaehlcke
2020-05-13  6:41   ` Viresh Kumar
2020-05-13  7:01     ` Viresh Kumar
2020-05-29  4:44   ` Viresh Kumar
2020-05-29 11:39     ` Sibi Sankar
2020-05-12 12:53 ` [PATCH v8 05/10] OPP: Add sanity checks in _read_opp_key() Georgi Djakov
2020-05-12 12:53 ` [PATCH v8 06/10] OPP: Update the bandwidth on OPP frequency changes Georgi Djakov
2020-05-12 12:53 ` [PATCH v8 07/10] cpufreq: dt: Add support for interconnect bandwidth scaling Georgi Djakov
2020-05-12 12:53 ` [PATCH v8 08/10] cpufreq: dt: Validate all interconnect paths Georgi Djakov
2020-05-12 21:47   ` Matthias Kaehlcke
2020-05-13  6:42   ` Viresh Kumar
2020-05-12 12:53 ` [PATCH v8 09/10] dt-bindings: interconnect: Add interconnect-tags bindings Georgi Djakov
2020-05-13 10:19   ` Viresh Kumar
2020-05-19 18:58   ` Rob Herring
2020-05-19 19:57     ` Saravana Kannan
2020-05-20 18:51       ` Sibi Sankar
2020-05-20 19:13         ` Saravana Kannan
2020-05-26 17:08           ` Sibi Sankar
2020-05-12 12:53 ` [PATCH v8 10/10] OPP: Add support for setting interconnect-tags Georgi Djakov
2020-05-13  6:43   ` Viresh Kumar
2020-05-13  6:55 ` [PATCH v8 00/10] Introduce OPP bandwidth bindings Viresh Kumar
2020-05-13 10:10   ` Georgi Djakov
2020-05-13 10:18     ` Viresh Kumar
2020-05-18 11:41 ` Viresh Kumar [this message]
2020-05-27  4:07 ` [PATCH] opp: Remove bandwidth votes when target_freq is zero Viresh Kumar
2020-05-27  4:13 ` [PATCH V2] " Viresh Kumar
2020-05-27  8:11   ` Georgi Djakov
2020-05-27 18:31   ` Sibi Sankar

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=c2ac269c4fd07059963ab973f9dd40ee869d9f5e.1589802005.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=georgi.djakov@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rjw@rjwysocki.net \
    --cc=sboyd@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vireshk@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).