diff options
author | Len Brown <len.brown@intel.com> | 2010-01-20 01:14:30 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2010-01-20 01:14:30 -0500 |
commit | 9c6a6b3cbcbbe39a018aba7f1b2b76e67cba0e9f (patch) | |
tree | e8c3da3057b2c046e00a6b4b8c77706e15eca1da /drivers | |
parent | 24bc7347da73a9ed3383056c3d0f28c0e361621e (diff) | |
parent | 3b8cb427e9281790f36e847e46cb1d005a50cec0 (diff) |
Merge branch 'acpi-pad' into release
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/acpi_pad.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 97991ac6f5fc..7e52295f1ecc 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c | |||
@@ -208,7 +208,7 @@ static int power_saving_thread(void *data) | |||
208 | * the mechanism only works when all CPUs have RT task running, | 208 | * the mechanism only works when all CPUs have RT task running, |
209 | * as if one CPU hasn't RT task, RT task from other CPUs will | 209 | * as if one CPU hasn't RT task, RT task from other CPUs will |
210 | * borrow CPU time from this CPU and cause RT task use > 95% | 210 | * borrow CPU time from this CPU and cause RT task use > 95% |
211 | * CPU time. To make 'avoid staration' work, takes a nap here. | 211 | * CPU time. To make 'avoid starvation' work, takes a nap here. |
212 | */ | 212 | */ |
213 | if (do_sleep) | 213 | if (do_sleep) |
214 | schedule_timeout_killable(HZ * idle_pct / 100); | 214 | schedule_timeout_killable(HZ * idle_pct / 100); |
@@ -222,14 +222,18 @@ static struct task_struct *ps_tsks[NR_CPUS]; | |||
222 | static unsigned int ps_tsk_num; | 222 | static unsigned int ps_tsk_num; |
223 | static int create_power_saving_task(void) | 223 | static int create_power_saving_task(void) |
224 | { | 224 | { |
225 | int rc = -ENOMEM; | ||
226 | |||
225 | ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, | 227 | ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, |
226 | (void *)(unsigned long)ps_tsk_num, | 228 | (void *)(unsigned long)ps_tsk_num, |
227 | "power_saving/%d", ps_tsk_num); | 229 | "power_saving/%d", ps_tsk_num); |
228 | if (ps_tsks[ps_tsk_num]) { | 230 | rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0; |
231 | if (!rc) | ||
229 | ps_tsk_num++; | 232 | ps_tsk_num++; |
230 | return 0; | 233 | else |
231 | } | 234 | ps_tsks[ps_tsk_num] = NULL; |
232 | return -EINVAL; | 235 | |
236 | return rc; | ||
233 | } | 237 | } |
234 | 238 | ||
235 | static void destroy_power_saving_task(void) | 239 | static void destroy_power_saving_task(void) |
@@ -237,6 +241,7 @@ static void destroy_power_saving_task(void) | |||
237 | if (ps_tsk_num > 0) { | 241 | if (ps_tsk_num > 0) { |
238 | ps_tsk_num--; | 242 | ps_tsk_num--; |
239 | kthread_stop(ps_tsks[ps_tsk_num]); | 243 | kthread_stop(ps_tsks[ps_tsk_num]); |
244 | ps_tsks[ps_tsk_num] = NULL; | ||
240 | } | 245 | } |
241 | } | 246 | } |
242 | 247 | ||
@@ -253,7 +258,7 @@ static void set_power_saving_task_num(unsigned int num) | |||
253 | } | 258 | } |
254 | } | 259 | } |
255 | 260 | ||
256 | static int acpi_pad_idle_cpus(unsigned int num_cpus) | 261 | static void acpi_pad_idle_cpus(unsigned int num_cpus) |
257 | { | 262 | { |
258 | get_online_cpus(); | 263 | get_online_cpus(); |
259 | 264 | ||
@@ -261,7 +266,6 @@ static int acpi_pad_idle_cpus(unsigned int num_cpus) | |||
261 | set_power_saving_task_num(num_cpus); | 266 | set_power_saving_task_num(num_cpus); |
262 | 267 | ||
263 | put_online_cpus(); | 268 | put_online_cpus(); |
264 | return 0; | ||
265 | } | 269 | } |
266 | 270 | ||
267 | static uint32_t acpi_pad_idle_cpus_num(void) | 271 | static uint32_t acpi_pad_idle_cpus_num(void) |
@@ -369,19 +373,21 @@ static void acpi_pad_remove_sysfs(struct acpi_device *device) | |||
369 | static int acpi_pad_pur(acpi_handle handle, int *num_cpus) | 373 | static int acpi_pad_pur(acpi_handle handle, int *num_cpus) |
370 | { | 374 | { |
371 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 375 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
372 | acpi_status status; | ||
373 | union acpi_object *package; | 376 | union acpi_object *package; |
374 | int rev, num, ret = -EINVAL; | 377 | int rev, num, ret = -EINVAL; |
375 | 378 | ||
376 | status = acpi_evaluate_object(handle, "_PUR", NULL, &buffer); | 379 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PUR", NULL, &buffer))) |
377 | if (ACPI_FAILURE(status)) | 380 | return -EINVAL; |
381 | |||
382 | if (!buffer.length || !buffer.pointer) | ||
378 | return -EINVAL; | 383 | return -EINVAL; |
384 | |||
379 | package = buffer.pointer; | 385 | package = buffer.pointer; |
380 | if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2) | 386 | if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2) |
381 | goto out; | 387 | goto out; |
382 | rev = package->package.elements[0].integer.value; | 388 | rev = package->package.elements[0].integer.value; |
383 | num = package->package.elements[1].integer.value; | 389 | num = package->package.elements[1].integer.value; |
384 | if (rev != 1) | 390 | if (rev != 1 || num < 0) |
385 | goto out; | 391 | goto out; |
386 | *num_cpus = num; | 392 | *num_cpus = num; |
387 | ret = 0; | 393 | ret = 0; |
@@ -410,7 +416,7 @@ static void acpi_pad_ost(acpi_handle handle, int stat, | |||
410 | 416 | ||
411 | static void acpi_pad_handle_notify(acpi_handle handle) | 417 | static void acpi_pad_handle_notify(acpi_handle handle) |
412 | { | 418 | { |
413 | int num_cpus, ret; | 419 | int num_cpus; |
414 | uint32_t idle_cpus; | 420 | uint32_t idle_cpus; |
415 | 421 | ||
416 | mutex_lock(&isolated_cpus_lock); | 422 | mutex_lock(&isolated_cpus_lock); |
@@ -418,12 +424,9 @@ static void acpi_pad_handle_notify(acpi_handle handle) | |||
418 | mutex_unlock(&isolated_cpus_lock); | 424 | mutex_unlock(&isolated_cpus_lock); |
419 | return; | 425 | return; |
420 | } | 426 | } |
421 | ret = acpi_pad_idle_cpus(num_cpus); | 427 | acpi_pad_idle_cpus(num_cpus); |
422 | idle_cpus = acpi_pad_idle_cpus_num(); | 428 | idle_cpus = acpi_pad_idle_cpus_num(); |
423 | if (!ret) | 429 | acpi_pad_ost(handle, 0, idle_cpus); |
424 | acpi_pad_ost(handle, 0, idle_cpus); | ||
425 | else | ||
426 | acpi_pad_ost(handle, 1, 0); | ||
427 | mutex_unlock(&isolated_cpus_lock); | 430 | mutex_unlock(&isolated_cpus_lock); |
428 | } | 431 | } |
429 | 432 | ||