linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamil Konieczny <k.konieczny@samsung.com>
To: k.konieczny@samsung.com
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Kukjin Kim <kgene@kernel.org>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>
Subject: [PATCH RESEND 2/3] PM / devfreq: exynos-bus: prepare for change in load calc in exynos-nocp
Date: Fri, 24 Jan 2020 15:14:48 +0100	[thread overview]
Message-ID: <20200124141449.19844-3-k.konieczny@samsung.com> (raw)
In-Reply-To: <20200124141449.19844-1-k.konieczny@samsung.com>

Add time to struct exynos_bus and time and current frequency to
struct devfreq_event_data. This will allow to calculate load and
max bandwidth in exynos-nocp driver.

Signed-off-by: Kamil Konieczny <k.konieczny@samsung.com>
---
 drivers/devfreq/exynos-bus.c  | 21 ++++++++++++++++++++-
 include/linux/devfreq-event.h |  4 ++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index 8fa8eb541373..f04ce5b84e75 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -14,6 +14,7 @@
 #include <linux/devfreq-event.h>
 #include <linux/device.h>
 #include <linux/export.h>
+#include <linux/jiffies.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/pm_opp.h>
@@ -31,6 +32,7 @@ struct exynos_bus {
 	struct mutex lock;
 
 	unsigned long curr_freq;
+	unsigned long prev_time;
 
 	struct opp_table *opp_table;
 	struct clk *clk;
@@ -57,7 +59,22 @@ static int exynos_bus_##ops(struct exynos_bus *bus)		\
 }
 exynos_bus_ops_edev(enable_edev);
 exynos_bus_ops_edev(disable_edev);
-exynos_bus_ops_edev(set_event);
+
+static int exynos_bus_set_event(struct exynos_bus *bus)
+{
+	int i, ret;
+
+	bus->prev_time = jiffies;
+	for (i = 0; i < bus->edev_count; i++) {
+		if (!bus->edev[i])
+			continue;
+		ret = devfreq_event_set_event(bus->edev[i]);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
 
 static int exynos_bus_get_event(struct exynos_bus *bus,
 				struct devfreq_event_data *edata)
@@ -66,6 +83,8 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
 	unsigned long load_count = 0, total_count = 0;
 	int i, ret = 0;
 
+	event_data.curr_freq = bus->curr_freq;
+	event_data.prev_time = bus->prev_time;
 	for (i = 0; i < bus->edev_count; i++) {
 		if (!bus->edev[i])
 			continue;
diff --git a/include/linux/devfreq-event.h b/include/linux/devfreq-event.h
index f14f17f8cb7f..b57ccfcb775b 100644
--- a/include/linux/devfreq-event.h
+++ b/include/linux/devfreq-event.h
@@ -41,12 +41,16 @@ struct devfreq_event_dev {
  *		  each count may represent a clock cycle, a time unit
  *		  (ns/us/...), or anything the device driver wants.
  *		  Generally, utilization is load_count / total_count.
+ * @prev_time	: jiffies for interval calculations with polling.
+ * @curr_freq	: current frequency for calculating max bandwidth.
  *
  * This structure contains the data of devfreq-event device for polling period.
  */
 struct devfreq_event_data {
 	unsigned long load_count;
 	unsigned long total_count;
+	unsigned long prev_time;
+	unsigned long curr_freq;
 };
 
 /**
-- 
2.25.0


  parent reply	other threads:[~2020-01-24 14:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200124141505eucas1p21ab7071b808c4ac6ef10c0d13adab49d@eucas1p2.samsung.com>
2020-01-24 14:14 ` [PATCH RESEND 0/3] PM / devfreq: change load calc in Exynos5422 Kamil Konieczny
     [not found]   ` <CGME20200124141506eucas1p2da00cf4424a6b5e5e6d3e245eda586a5@eucas1p2.samsung.com>
2020-01-24 14:14     ` [PATCH RESEND 1/3] PM / devfreq: exynos-nocp: fix debug print type Kamil Konieczny
     [not found]   ` <CGME20200124141506eucas1p1d2fdb3b5d26d123272cafeddecd5708a@eucas1p1.samsung.com>
2020-01-24 14:14     ` Kamil Konieczny [this message]
     [not found]   ` <CGME20200124141507eucas1p115e87fdd6eda4a5f320d5145f5960889@eucas1p1.samsung.com>
2020-01-24 14:14     ` [PATCH RESEND 3/3] PM / devfreq: exynos-nocp: change load and total calculations Kamil Konieczny
2020-03-02 14:59   ` [PATCH RESEND 0/3] PM / devfreq: change load calc in Exynos5422 Bartlomiej Zolnierkiewicz

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=20200124141449.19844-3-k.konieczny@samsung.com \
    --to=k.konieczny@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=cw00.choi@samsung.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --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 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).