diff options
Diffstat (limited to 'arch/i386/mach-voyager/voyager_thread.c')
-rw-r--r-- | arch/i386/mach-voyager/voyager_thread.c | 69 |
1 files changed, 21 insertions, 48 deletions
diff --git a/arch/i386/mach-voyager/voyager_thread.c b/arch/i386/mach-voyager/voyager_thread.c index f39887359e8e..fdc1d926fb2a 100644 --- a/arch/i386/mach-voyager/voyager_thread.c +++ b/arch/i386/mach-voyager/voyager_thread.c | |||
@@ -24,33 +24,16 @@ | |||
24 | #include <linux/kmod.h> | 24 | #include <linux/kmod.h> |
25 | #include <linux/completion.h> | 25 | #include <linux/completion.h> |
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <linux/kthread.h> | ||
27 | #include <asm/desc.h> | 28 | #include <asm/desc.h> |
28 | #include <asm/voyager.h> | 29 | #include <asm/voyager.h> |
29 | #include <asm/vic.h> | 30 | #include <asm/vic.h> |
30 | #include <asm/mtrr.h> | 31 | #include <asm/mtrr.h> |
31 | #include <asm/msr.h> | 32 | #include <asm/msr.h> |
32 | 33 | ||
33 | #define THREAD_NAME "kvoyagerd" | ||
34 | 34 | ||
35 | /* external variables */ | 35 | struct task_struct *voyager_thread; |
36 | int kvoyagerd_running = 0; | 36 | static __u8 set_timeout; |
37 | DECLARE_MUTEX_LOCKED(kvoyagerd_sem); | ||
38 | |||
39 | static int thread(void *); | ||
40 | |||
41 | static __u8 set_timeout = 0; | ||
42 | |||
43 | /* Start the machine monitor thread. Return 1 if OK, 0 if fail */ | ||
44 | static int __init | ||
45 | voyager_thread_start(void) | ||
46 | { | ||
47 | if(kernel_thread(thread, NULL, CLONE_KERNEL) < 0) { | ||
48 | /* This is serious, but not fatal */ | ||
49 | printk(KERN_ERR "Voyager: Failed to create system monitor thread!!!\n"); | ||
50 | return 1; | ||
51 | } | ||
52 | return 0; | ||
53 | } | ||
54 | 37 | ||
55 | static int | 38 | static int |
56 | execute(const char *string) | 39 | execute(const char *string) |
@@ -110,31 +93,15 @@ check_continuing_condition(void) | |||
110 | } | 93 | } |
111 | } | 94 | } |
112 | 95 | ||
113 | static void | ||
114 | wakeup(unsigned long unused) | ||
115 | { | ||
116 | up(&kvoyagerd_sem); | ||
117 | } | ||
118 | |||
119 | static int | 96 | static int |
120 | thread(void *unused) | 97 | thread(void *unused) |
121 | { | 98 | { |
122 | struct timer_list wakeup_timer; | ||
123 | |||
124 | kvoyagerd_running = 1; | ||
125 | |||
126 | daemonize(THREAD_NAME); | ||
127 | |||
128 | set_timeout = 0; | ||
129 | |||
130 | init_timer(&wakeup_timer); | ||
131 | |||
132 | sigfillset(¤t->blocked); | ||
133 | |||
134 | printk(KERN_NOTICE "Voyager starting monitor thread\n"); | 99 | printk(KERN_NOTICE "Voyager starting monitor thread\n"); |
135 | 100 | ||
136 | for(;;) { | 101 | for (;;) { |
137 | down_interruptible(&kvoyagerd_sem); | 102 | set_current_state(TASK_INTERRUPTIBLE); |
103 | schedule_timeout(set_timeout ? HZ : MAX_SCHEDULE_TIMEOUT); | ||
104 | |||
138 | VDEBUG(("Voyager Daemon awoken\n")); | 105 | VDEBUG(("Voyager Daemon awoken\n")); |
139 | if(voyager_status.request_from_kernel == 0) { | 106 | if(voyager_status.request_from_kernel == 0) { |
140 | /* probably awoken from timeout */ | 107 | /* probably awoken from timeout */ |
@@ -143,20 +110,26 @@ thread(void *unused) | |||
143 | check_from_kernel(); | 110 | check_from_kernel(); |
144 | voyager_status.request_from_kernel = 0; | 111 | voyager_status.request_from_kernel = 0; |
145 | } | 112 | } |
146 | if(set_timeout) { | ||
147 | del_timer(&wakeup_timer); | ||
148 | wakeup_timer.expires = HZ + jiffies; | ||
149 | wakeup_timer.function = wakeup; | ||
150 | add_timer(&wakeup_timer); | ||
151 | } | ||
152 | } | 113 | } |
153 | } | 114 | } |
154 | 115 | ||
116 | static int __init | ||
117 | voyager_thread_start(void) | ||
118 | { | ||
119 | voyager_thread = kthread_run(thread, NULL, "kvoyagerd"); | ||
120 | if (IS_ERR(voyager_thread)) { | ||
121 | printk(KERN_ERR "Voyager: Failed to create system monitor thread.\n"); | ||
122 | return PTR_ERR(voyager_thread); | ||
123 | } | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | |||
155 | static void __exit | 128 | static void __exit |
156 | voyager_thread_stop(void) | 129 | voyager_thread_stop(void) |
157 | { | 130 | { |
158 | /* FIXME: do nothing at the moment */ | 131 | kthread_stop(voyager_thread); |
159 | } | 132 | } |
160 | 133 | ||
161 | module_init(voyager_thread_start); | 134 | module_init(voyager_thread_start); |
162 | //module_exit(voyager_thread_stop); | 135 | module_exit(voyager_thread_stop); |