aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-07-03 13:07:42 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-03 13:07:42 -0400
commitcbc9ef0287ab764d3da0129efa673808df641fe3 (patch)
tree43f128194beaeeda86dcc962a28af8c03f924404 /include/linux
parente3b8cdd8e4ea51e46d3ff54d7e3568afc24654ec (diff)
PM / Domains: Add preliminary support for cpuidle, v2
On some systems there are CPU cores located in the same power domains as I/O devices. Then, power can only be removed from the domain if all I/O devices in it are not in use and the CPU core is idle. Add preliminary support for that to the generic PM domains framework. First, the platform is expected to provide a cpuidle driver with one extra state designated for use with the generic PM domains code. This state should be initially disabled and its exit_latency value should be set to whatever time is needed to bring up the CPU core itself after restoring power to it, not including the domain's power on latency. Its .enter() callback should point to a procedure that will remove power from the domain containing the CPU core at the end of the CPU power transition. The remaining characteristics of the extra cpuidle state, referred to as the "domain" cpuidle state below, (e.g. power usage, target residency) should be populated in accordance with the properties of the hardware. Next, the platform should execute genpd_attach_cpuidle() on the PM domain containing the CPU core. That will cause the generic PM domains framework to treat that domain in a special way such that: * When all devices in the domain have been suspended and it is about to be turned off, the states of the devices will be saved, but power will not be removed from the domain. Instead, the "domain" cpuidle state will be enabled so that power can be removed from the domain when the CPU core is idle and the state has been chosen as the target by the cpuidle governor. * When the first I/O device in the domain is resumed and __pm_genpd_poweron(() is called for the first time after power has been removed from the domain, the "domain" cpuidle state will be disabled to avoid subsequent surprise power removals via cpuidle. The effective exit_latency value of the "domain" cpuidle state depends on the time needed to bring up the CPU core itself after restoring power to it as well as on the power on latency of the domain containing the CPU core. Thus the "domain" cpuidle state's exit_latency has to be recomputed every time the domain's power on latency is updated, which may happen every time power is restored to the domain, if the measured power on latency is greater than the latency stored in the corresponding generic_pm_domain structure. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reviewed-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cpuidle.h1
-rw-r--r--include/linux/pm_domain.h17
2 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 27cfced7b57b..8684a0d07b87 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -47,6 +47,7 @@ struct cpuidle_state {
47 unsigned int exit_latency; /* in US */ 47 unsigned int exit_latency; /* in US */
48 int power_usage; /* in mW */ 48 int power_usage; /* in mW */
49 unsigned int target_residency; /* in US */ 49 unsigned int target_residency; /* in US */
50 bool disabled; /* disabled on all CPUs */
50 51
51 int (*enter) (struct cpuidle_device *dev, 52 int (*enter) (struct cpuidle_device *dev,
52 struct cpuidle_driver *drv, 53 struct cpuidle_driver *drv,
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 30f794eb3826..2febe31d2675 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -15,6 +15,7 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/notifier.h> 17#include <linux/notifier.h>
18#include <linux/cpuidle.h>
18 19
19enum gpd_status { 20enum gpd_status {
20 GPD_STATE_ACTIVE = 0, /* PM domain is active */ 21 GPD_STATE_ACTIVE = 0, /* PM domain is active */
@@ -45,6 +46,11 @@ struct gpd_dev_ops {
45 bool (*active_wakeup)(struct device *dev); 46 bool (*active_wakeup)(struct device *dev);
46}; 47};
47 48
49struct gpd_cpu_data {
50 unsigned int saved_exit_latency;
51 struct cpuidle_state *idle_state;
52};
53
48struct generic_pm_domain { 54struct generic_pm_domain {
49 struct dev_pm_domain domain; /* PM domain operations */ 55 struct dev_pm_domain domain; /* PM domain operations */
50 struct list_head gpd_list_node; /* Node in the global PM domains list */ 56 struct list_head gpd_list_node; /* Node in the global PM domains list */
@@ -75,6 +81,7 @@ struct generic_pm_domain {
75 bool max_off_time_changed; 81 bool max_off_time_changed;
76 bool cached_power_down_ok; 82 bool cached_power_down_ok;
77 struct device_node *of_node; /* Node in device tree */ 83 struct device_node *of_node; /* Node in device tree */
84 struct gpd_cpu_data *cpu_data;
78}; 85};
79 86
80static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) 87static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
@@ -155,6 +162,8 @@ extern int pm_genpd_add_callbacks(struct device *dev,
155 struct gpd_dev_ops *ops, 162 struct gpd_dev_ops *ops,
156 struct gpd_timing_data *td); 163 struct gpd_timing_data *td);
157extern int __pm_genpd_remove_callbacks(struct device *dev, bool clear_td); 164extern int __pm_genpd_remove_callbacks(struct device *dev, bool clear_td);
165extern int genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state);
166extern int genpd_detach_cpuidle(struct generic_pm_domain *genpd);
158extern void pm_genpd_init(struct generic_pm_domain *genpd, 167extern void pm_genpd_init(struct generic_pm_domain *genpd,
159 struct dev_power_governor *gov, bool is_off); 168 struct dev_power_governor *gov, bool is_off);
160 169
@@ -211,6 +220,14 @@ static inline int __pm_genpd_remove_callbacks(struct device *dev, bool clear_td)
211{ 220{
212 return -ENOSYS; 221 return -ENOSYS;
213} 222}
223static inline int genpd_attach_cpuidle(struct generic_pm_domain *genpd, int st)
224{
225 return -ENOSYS;
226}
227static inline int genpd_detach_cpuidle(struct generic_pm_domain *genpd)
228{
229 return -ENOSYS;
230}
214static inline void pm_genpd_init(struct generic_pm_domain *genpd, 231static inline void pm_genpd_init(struct generic_pm_domain *genpd,
215 struct dev_power_governor *gov, bool is_off) 232 struct dev_power_governor *gov, bool is_off)
216{ 233{