Commit 0287ebedfa032a57bb47f4bc5cb5e268ecd844ad
Committed by
Linus Torvalds
1 parent
233ccd0d04
Exists in
master
and in
4 other branches
[PATCH] ppc64: replace schedule_timeout() with msleep_interruptible()
Use msleep_interruptible() instead of schedule_timeout() in ppc64-specific code to cleanup/simplify the sleeping logic. Change the units of the parameter of do_event_scan_all_cpus() to milliseconds from jiffies. The return value of rtas_extended_busy_delay_time() was incorrectly being used as a jiffies value (it is actually milliseconds), which is fixed by using the value as a parameter to msleep_interruptible(). Also, use rtas_extended_busy_delay_time() in another case where similar logic is duplicated. Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 3 changed files with 12 additions and 22 deletions Side-by-side Diff
arch/ppc64/kernel/rtasd.c
| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | #include <linux/vmalloc.h> |
| 20 | 20 | #include <linux/spinlock.h> |
| 21 | 21 | #include <linux/cpu.h> |
| 22 | +#include <linux/delay.h> | |
| 22 | 23 | |
| 23 | 24 | #include <asm/uaccess.h> |
| 24 | 25 | #include <asm/io.h> |
| ... | ... | @@ -412,8 +413,7 @@ |
| 412 | 413 | |
| 413 | 414 | /* Drop hotplug lock, and sleep for the specified delay */ |
| 414 | 415 | unlock_cpu_hotplug(); |
| 415 | - set_current_state(TASK_INTERRUPTIBLE); | |
| 416 | - schedule_timeout(delay); | |
| 416 | + msleep_interruptible(delay); | |
| 417 | 417 | lock_cpu_hotplug(); |
| 418 | 418 | |
| 419 | 419 | cpu = next_cpu(cpu, cpu_online_map); |
| ... | ... | @@ -442,7 +442,7 @@ |
| 442 | 442 | |
| 443 | 443 | printk(KERN_INFO "RTAS daemon started\n"); |
| 444 | 444 | |
| 445 | - DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2); | |
| 445 | + DEBUG("will sleep for %d milliseconds\n", (30000/rtas_event_scan_rate)); | |
| 446 | 446 | |
| 447 | 447 | /* See if we have any error stored in NVRAM */ |
| 448 | 448 | memset(logdata, 0, rtas_error_log_max); |
| ... | ... | @@ -459,7 +459,7 @@ |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | /* First pass. */ |
| 462 | - do_event_scan_all_cpus(HZ); | |
| 462 | + do_event_scan_all_cpus(1000); | |
| 463 | 463 | |
| 464 | 464 | if (surveillance_timeout != -1) { |
| 465 | 465 | DEBUG("enabling surveillance\n"); |
| ... | ... | @@ -471,7 +471,7 @@ |
| 471 | 471 | * machines have problems if we call event-scan too |
| 472 | 472 | * quickly. */ |
| 473 | 473 | for (;;) |
| 474 | - do_event_scan_all_cpus((HZ*60/rtas_event_scan_rate) / 2); | |
| 474 | + do_event_scan_all_cpus(30000/rtas_event_scan_rate); | |
| 475 | 475 | |
| 476 | 476 | error: |
| 477 | 477 | /* Should delete proc entries */ |
arch/ppc64/kernel/rtc.c
| ... | ... | @@ -35,6 +35,7 @@ |
| 35 | 35 | #include <linux/spinlock.h> |
| 36 | 36 | #include <linux/bcd.h> |
| 37 | 37 | #include <linux/interrupt.h> |
| 38 | +#include <linux/delay.h> | |
| 38 | 39 | |
| 39 | 40 | #include <asm/io.h> |
| 40 | 41 | #include <asm/uaccess.h> |
| ... | ... | @@ -351,8 +352,7 @@ |
| 351 | 352 | return; /* delay not allowed */ |
| 352 | 353 | } |
| 353 | 354 | wait_time = rtas_extended_busy_delay_time(error); |
| 354 | - set_current_state(TASK_INTERRUPTIBLE); | |
| 355 | - schedule_timeout(wait_time); | |
| 355 | + msleep_interruptible(wait_time); | |
| 356 | 356 | error = RTAS_CLOCK_BUSY; |
| 357 | 357 | } |
| 358 | 358 | } while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb)); |
| ... | ... | @@ -386,8 +386,7 @@ |
| 386 | 386 | if (in_interrupt()) |
| 387 | 387 | return 1; /* probably decrementer */ |
| 388 | 388 | wait_time = rtas_extended_busy_delay_time(error); |
| 389 | - set_current_state(TASK_INTERRUPTIBLE); | |
| 390 | - schedule_timeout(wait_time); | |
| 389 | + msleep_interruptible(wait_time); | |
| 391 | 390 | error = RTAS_CLOCK_BUSY; |
| 392 | 391 | } |
| 393 | 392 | } while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb)); |
arch/ppc64/kernel/scanlog.c
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | #include <linux/errno.h> |
| 26 | 26 | #include <linux/proc_fs.h> |
| 27 | 27 | #include <linux/init.h> |
| 28 | +#include <linux/delay.h> | |
| 28 | 29 | #include <asm/uaccess.h> |
| 29 | 30 | #include <asm/rtas.h> |
| 30 | 31 | #include <asm/prom.h> |
| ... | ... | @@ -77,7 +78,7 @@ |
| 77 | 78 | return -EFAULT; |
| 78 | 79 | |
| 79 | 80 | for (;;) { |
| 80 | - wait_time = HZ/2; /* default wait if no data */ | |
| 81 | + wait_time = 500; /* default wait if no data */ | |
| 81 | 82 | spin_lock(&rtas_data_buf_lock); |
| 82 | 83 | memcpy(rtas_data_buf, data, RTAS_DATA_BUF_SIZE); |
| 83 | 84 | status = rtas_call(ibm_scan_log_dump, 2, 1, NULL, |
| 84 | 85 | |
| ... | ... | @@ -107,24 +108,14 @@ |
| 107 | 108 | break; |
| 108 | 109 | default: |
| 109 | 110 | if (status > 9900 && status <= 9905) { |
| 110 | - /* No data. RTAS is hinting at a delay required | |
| 111 | - * between 1-100000 milliseconds | |
| 112 | - */ | |
| 113 | - int ms = 1; | |
| 114 | - for (; status > 9900; status--) | |
| 115 | - ms = ms * 10; | |
| 116 | - /* Use microseconds for reasonable accuracy */ | |
| 117 | - ms *= 1000; | |
| 118 | - wait_time = ms / (1000000/HZ); /* round down is fine */ | |
| 119 | - /* Fall through to sleep */ | |
| 111 | + wait_time = rtas_extended_busy_delay_time(status); | |
| 120 | 112 | } else { |
| 121 | 113 | printk(KERN_ERR "scanlog: unknown error from rtas: %d\n", status); |
| 122 | 114 | return -EIO; |
| 123 | 115 | } |
| 124 | 116 | } |
| 125 | 117 | /* Apparently no data yet. Wait and try again. */ |
| 126 | - set_current_state(TASK_INTERRUPTIBLE); | |
| 127 | - schedule_timeout(wait_time); | |
| 118 | + msleep_interruptible(wait_time); | |
| 128 | 119 | } |
| 129 | 120 | /*NOTREACHED*/ |
| 130 | 121 | } |