diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/cpuidle | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r-- | drivers/cpuidle/governor.c | 4 | ||||
-rw-r--r-- | drivers/cpuidle/governors/ladder.c | 3 | ||||
-rw-r--r-- | drivers/cpuidle/governors/menu.c | 21 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 9 |
4 files changed, 22 insertions, 15 deletions
diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c index 70b59642a708..724c164d31c9 100644 --- a/drivers/cpuidle/governor.c +++ b/drivers/cpuidle/governor.c | |||
@@ -21,7 +21,7 @@ struct cpuidle_governor *cpuidle_curr_governor; | |||
21 | * __cpuidle_find_governor - finds a governor of the specified name | 21 | * __cpuidle_find_governor - finds a governor of the specified name |
22 | * @str: the name | 22 | * @str: the name |
23 | * | 23 | * |
24 | * Must be called with cpuidle_lock aquired. | 24 | * Must be called with cpuidle_lock acquired. |
25 | */ | 25 | */ |
26 | static struct cpuidle_governor * __cpuidle_find_governor(const char *str) | 26 | static struct cpuidle_governor * __cpuidle_find_governor(const char *str) |
27 | { | 27 | { |
@@ -39,7 +39,7 @@ static struct cpuidle_governor * __cpuidle_find_governor(const char *str) | |||
39 | * @gov: the new target governor | 39 | * @gov: the new target governor |
40 | * | 40 | * |
41 | * NOTE: "gov" can be NULL to specify disabled | 41 | * NOTE: "gov" can be NULL to specify disabled |
42 | * Must be called with cpuidle_lock aquired. | 42 | * Must be called with cpuidle_lock acquired. |
43 | */ | 43 | */ |
44 | int cpuidle_switch_governor(struct cpuidle_governor *gov) | 44 | int cpuidle_switch_governor(struct cpuidle_governor *gov) |
45 | { | 45 | { |
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c index a4bec3f919aa..1c1ceb4f218f 100644 --- a/drivers/cpuidle/governors/ladder.c +++ b/drivers/cpuidle/governors/ladder.c | |||
@@ -69,9 +69,6 @@ static int ladder_select_state(struct cpuidle_device *dev) | |||
69 | int last_residency, last_idx = ldev->last_state_idx; | 69 | int last_residency, last_idx = ldev->last_state_idx; |
70 | int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY); | 70 | int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY); |
71 | 71 | ||
72 | if (unlikely(!ldev)) | ||
73 | return 0; | ||
74 | |||
75 | /* Special case when user has set very strict latency requirement */ | 72 | /* Special case when user has set very strict latency requirement */ |
76 | if (unlikely(latency_req == 0)) { | 73 | if (unlikely(latency_req == 0)) { |
77 | ladder_do_selection(ldev, last_idx, 0); | 74 | ladder_do_selection(ldev, last_idx, 0); |
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index 68104434ebb5..f8e57c6303f2 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/hrtimer.h> | 18 | #include <linux/hrtimer.h> |
19 | #include <linux/tick.h> | 19 | #include <linux/tick.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/math64.h> | ||
21 | 22 | ||
22 | #define BUCKETS 12 | 23 | #define BUCKETS 12 |
23 | #define RESOLUTION 1024 | 24 | #define RESOLUTION 1024 |
@@ -100,7 +101,6 @@ struct menu_device { | |||
100 | 101 | ||
101 | unsigned int expected_us; | 102 | unsigned int expected_us; |
102 | u64 predicted_us; | 103 | u64 predicted_us; |
103 | unsigned int measured_us; | ||
104 | unsigned int exit_us; | 104 | unsigned int exit_us; |
105 | unsigned int bucket; | 105 | unsigned int bucket; |
106 | u64 correction_factor[BUCKETS]; | 106 | u64 correction_factor[BUCKETS]; |
@@ -169,6 +169,12 @@ static DEFINE_PER_CPU(struct menu_device, menu_devices); | |||
169 | 169 | ||
170 | static void menu_update(struct cpuidle_device *dev); | 170 | static void menu_update(struct cpuidle_device *dev); |
171 | 171 | ||
172 | /* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */ | ||
173 | static u64 div_round64(u64 dividend, u32 divisor) | ||
174 | { | ||
175 | return div_u64(dividend + (divisor / 2), divisor); | ||
176 | } | ||
177 | |||
172 | /** | 178 | /** |
173 | * menu_select - selects the next idle state to enter | 179 | * menu_select - selects the next idle state to enter |
174 | * @dev: the CPU | 180 | * @dev: the CPU |
@@ -180,14 +186,14 @@ static int menu_select(struct cpuidle_device *dev) | |||
180 | int i; | 186 | int i; |
181 | int multiplier; | 187 | int multiplier; |
182 | 188 | ||
183 | data->last_state_idx = 0; | ||
184 | data->exit_us = 0; | ||
185 | |||
186 | if (data->needs_update) { | 189 | if (data->needs_update) { |
187 | menu_update(dev); | 190 | menu_update(dev); |
188 | data->needs_update = 0; | 191 | data->needs_update = 0; |
189 | } | 192 | } |
190 | 193 | ||
194 | data->last_state_idx = 0; | ||
195 | data->exit_us = 0; | ||
196 | |||
191 | /* Special case when user has set very strict latency requirement */ | 197 | /* Special case when user has set very strict latency requirement */ |
192 | if (unlikely(latency_req == 0)) | 198 | if (unlikely(latency_req == 0)) |
193 | return 0; | 199 | return 0; |
@@ -209,9 +215,8 @@ static int menu_select(struct cpuidle_device *dev) | |||
209 | data->correction_factor[data->bucket] = RESOLUTION * DECAY; | 215 | data->correction_factor[data->bucket] = RESOLUTION * DECAY; |
210 | 216 | ||
211 | /* Make sure to round up for half microseconds */ | 217 | /* Make sure to round up for half microseconds */ |
212 | data->predicted_us = DIV_ROUND_CLOSEST( | 218 | data->predicted_us = div_round64(data->expected_us * data->correction_factor[data->bucket], |
213 | data->expected_us * data->correction_factor[data->bucket], | 219 | RESOLUTION * DECAY); |
214 | RESOLUTION * DECAY); | ||
215 | 220 | ||
216 | /* | 221 | /* |
217 | * We want to default to C1 (hlt), not to busy polling | 222 | * We want to default to C1 (hlt), not to busy polling |
@@ -288,7 +293,7 @@ static void menu_update(struct cpuidle_device *dev) | |||
288 | new_factor = data->correction_factor[data->bucket] | 293 | new_factor = data->correction_factor[data->bucket] |
289 | * (DECAY - 1) / DECAY; | 294 | * (DECAY - 1) / DECAY; |
290 | 295 | ||
291 | if (data->expected_us > 0 && data->measured_us < MAX_INTERESTING) | 296 | if (data->expected_us > 0 && measured_us < MAX_INTERESTING) |
292 | new_factor += RESOLUTION * measured_us / data->expected_us; | 297 | new_factor += RESOLUTION * measured_us / data->expected_us; |
293 | else | 298 | else |
294 | /* | 299 | /* |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 97b003839fb6..0ba9c8b8ee74 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/cpuidle.h> | 10 | #include <linux/cpuidle.h> |
11 | #include <linux/sysfs.h> | 11 | #include <linux/sysfs.h> |
12 | #include <linux/slab.h> | ||
12 | #include <linux/cpu.h> | 13 | #include <linux/cpu.h> |
13 | 14 | ||
14 | #include "cpuidle.h" | 15 | #include "cpuidle.h" |
@@ -22,6 +23,7 @@ static int __init cpuidle_sysfs_setup(char *unused) | |||
22 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); | 23 | __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup); |
23 | 24 | ||
24 | static ssize_t show_available_governors(struct sysdev_class *class, | 25 | static ssize_t show_available_governors(struct sysdev_class *class, |
26 | struct sysdev_class_attribute *attr, | ||
25 | char *buf) | 27 | char *buf) |
26 | { | 28 | { |
27 | ssize_t i = 0; | 29 | ssize_t i = 0; |
@@ -41,6 +43,7 @@ out: | |||
41 | } | 43 | } |
42 | 44 | ||
43 | static ssize_t show_current_driver(struct sysdev_class *class, | 45 | static ssize_t show_current_driver(struct sysdev_class *class, |
46 | struct sysdev_class_attribute *attr, | ||
44 | char *buf) | 47 | char *buf) |
45 | { | 48 | { |
46 | ssize_t ret; | 49 | ssize_t ret; |
@@ -56,6 +59,7 @@ static ssize_t show_current_driver(struct sysdev_class *class, | |||
56 | } | 59 | } |
57 | 60 | ||
58 | static ssize_t show_current_governor(struct sysdev_class *class, | 61 | static ssize_t show_current_governor(struct sysdev_class *class, |
62 | struct sysdev_class_attribute *attr, | ||
59 | char *buf) | 63 | char *buf) |
60 | { | 64 | { |
61 | ssize_t ret; | 65 | ssize_t ret; |
@@ -71,6 +75,7 @@ static ssize_t show_current_governor(struct sysdev_class *class, | |||
71 | } | 75 | } |
72 | 76 | ||
73 | static ssize_t store_current_governor(struct sysdev_class *class, | 77 | static ssize_t store_current_governor(struct sysdev_class *class, |
78 | struct sysdev_class_attribute *attr, | ||
74 | const char *buf, size_t count) | 79 | const char *buf, size_t count) |
75 | { | 80 | { |
76 | char gov_name[CPUIDLE_NAME_LEN]; | 81 | char gov_name[CPUIDLE_NAME_LEN]; |
@@ -191,7 +196,7 @@ static ssize_t cpuidle_store(struct kobject * kobj, struct attribute * attr, | |||
191 | return ret; | 196 | return ret; |
192 | } | 197 | } |
193 | 198 | ||
194 | static struct sysfs_ops cpuidle_sysfs_ops = { | 199 | static const struct sysfs_ops cpuidle_sysfs_ops = { |
195 | .show = cpuidle_show, | 200 | .show = cpuidle_show, |
196 | .store = cpuidle_store, | 201 | .store = cpuidle_store, |
197 | }; | 202 | }; |
@@ -277,7 +282,7 @@ static ssize_t cpuidle_state_show(struct kobject * kobj, | |||
277 | return ret; | 282 | return ret; |
278 | } | 283 | } |
279 | 284 | ||
280 | static struct sysfs_ops cpuidle_state_sysfs_ops = { | 285 | static const struct sysfs_ops cpuidle_state_sysfs_ops = { |
281 | .show = cpuidle_state_show, | 286 | .show = cpuidle_state_show, |
282 | }; | 287 | }; |
283 | 288 | ||