[RESEND,2/3] PM / devfreq: exynos-bus: prepare for change in load calc in exynos-nocp
diff mbox series

Message ID 20200124141449.19844-3-k.konieczny@samsung.com
State New
Headers show
Series
  • [RESEND,1/3] PM / devfreq: exynos-nocp: fix debug print type
Related show

Commit Message

Kamil Konieczny Jan. 24, 2020, 2:14 p.m. UTC
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(-)

Patch
diff mbox series

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;
 };
 
 /**