[COMMON] cpuidle: Add to get target residency for cpu.
authorlakkyung.jung <lakkyung.jung@samsung.com>
Wed, 14 Mar 2018 04:18:58 +0000 (13:18 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:30:48 +0000 (17:30 +0900)
Change-Id: I9c59acd8bdda34d7071d8512c8551dcb76eee5b5
Signed-off-by: lakkyung.jung <lakkyung.jung@samsung.com>
drivers/cpuidle/cpuidle.c
include/linux/cpuidle.h

index 6158f57ebdb8b8048f51958f4d793a1697123e90..3adf36b56c2bd9bab85f4ff315f4eca820cc1cab 100644 (file)
@@ -51,6 +51,23 @@ bool cpuidle_not_available(struct cpuidle_driver *drv,
        return off || !initialized || !drv || !dev || !dev->enabled;
 }
 
+unsigned int cpuidle_get_target_residency(int cpu, int state)
+{
+       struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
+       struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
+       struct cpuidle_state *s;
+       unsigned int target_residency = INT_MAX;
+
+       if (!drv)
+               goto exit_func;
+
+       s = &drv->states[state];
+       target_residency = s->target_residency;
+
+exit_func:
+       return target_residency;
+}
+
 /**
  * cpuidle_play_dead - cpu off-lining
  *
index ad33507b34be206abd45495f741a28c1c0883c35..fc115a352fe4d300a77350992c025032e2abb206 100644 (file)
@@ -157,6 +157,7 @@ extern int cpuidle_play_dead(void);
 extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
 static inline struct cpuidle_device *cpuidle_get_device(void)
 {return __this_cpu_read(cpuidle_devices); }
+extern unsigned int cpuidle_get_target_residency(int cpu, int state);
 #else
 static inline void disable_cpuidle(void) { }
 static inline bool cpuidle_not_available(struct cpuidle_driver *drv,
@@ -193,6 +194,7 @@ static inline int cpuidle_play_dead(void) {return -ENODEV; }
 static inline struct cpuidle_driver *cpuidle_get_cpu_driver(
        struct cpuidle_device *dev) {return NULL; }
 static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; }
+static inline unsigned int cpuidle_get_target_residency(int cpu, int state) {return UINT_MAX;}
 #endif
 
 #ifdef CONFIG_CPU_IDLE