aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Domsch <Matt_Domsch@dell.com>2005-11-07 04:00:04 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:53:45 -0500
commite9a705a0a0ed99833cfef40d509f63a052638f00 (patch)
tree5daf234aca37a1f15c563b1d781973f6a127de15
parenta9a2c44ff0a1350f8bfe3a162ecf71b1c9ce5cc2 (diff)
[PATCH] ipmi: use kthread API
Convert ipmi driver thread to kthread API, only sleep when interface is idle. Signed-off-by: Matt Domsch <Matt_Domsch@dell.com> Cc: Corey Minyard <minyard@acm.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index fa3be622ca97..ea89dca3dbb5 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -52,6 +52,7 @@
52#include <linux/pci.h> 52#include <linux/pci.h>
53#include <linux/ioport.h> 53#include <linux/ioport.h>
54#include <linux/notifier.h> 54#include <linux/notifier.h>
55#include <linux/kthread.h>
55#include <asm/irq.h> 56#include <asm/irq.h>
56#ifdef CONFIG_HIGH_RES_TIMERS 57#ifdef CONFIG_HIGH_RES_TIMERS
57#include <linux/hrtime.h> 58#include <linux/hrtime.h>
@@ -222,8 +223,7 @@ struct smi_info
222 unsigned long watchdog_pretimeouts; 223 unsigned long watchdog_pretimeouts;
223 unsigned long incoming_messages; 224 unsigned long incoming_messages;
224 225
225 struct completion exiting; 226 struct task_struct *thread;
226 long thread_pid;
227}; 227};
228 228
229static struct notifier_block *xaction_notifier_list; 229static struct notifier_block *xaction_notifier_list;
@@ -785,31 +785,22 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion)
785static int ipmi_thread(void *data) 785static int ipmi_thread(void *data)
786{ 786{
787 struct smi_info *smi_info = data; 787 struct smi_info *smi_info = data;
788 unsigned long flags, last=1; 788 unsigned long flags;
789 enum si_sm_result smi_result; 789 enum si_sm_result smi_result;
790 790
791 daemonize("kipmi%d", smi_info->intf_num);
792 allow_signal(SIGKILL);
793 set_user_nice(current, 19); 791 set_user_nice(current, 19);
794 while (!atomic_read(&smi_info->stop_operation)) { 792 while (!kthread_should_stop()) {
795 schedule_timeout(last);
796 spin_lock_irqsave(&(smi_info->si_lock), flags); 793 spin_lock_irqsave(&(smi_info->si_lock), flags);
797 smi_result=smi_event_handler(smi_info, 0); 794 smi_result=smi_event_handler(smi_info, 0);
798 spin_unlock_irqrestore(&(smi_info->si_lock), flags); 795 spin_unlock_irqrestore(&(smi_info->si_lock), flags);
799 if (smi_result == SI_SM_CALL_WITHOUT_DELAY) 796 if (smi_result == SI_SM_CALL_WITHOUT_DELAY) {
800 last = 0; 797 /* do nothing */
801 else if (smi_result == SI_SM_CALL_WITH_DELAY) {
802 udelay(1);
803 last = 0;
804 }
805 else {
806 /* System is idle; go to sleep */
807 last = 1;
808 current->state = TASK_INTERRUPTIBLE;
809 } 798 }
799 else if (smi_result == SI_SM_CALL_WITH_DELAY)
800 udelay(1);
801 else
802 schedule_timeout_interruptible(1);
810 } 803 }
811 smi_info->thread_pid = 0;
812 complete_and_exit(&(smi_info->exiting), 0);
813 return 0; 804 return 0;
814} 805}
815 806
@@ -2212,11 +2203,8 @@ static void setup_xaction_handlers(struct smi_info *smi_info)
2212 2203
2213static inline void wait_for_timer_and_thread(struct smi_info *smi_info) 2204static inline void wait_for_timer_and_thread(struct smi_info *smi_info)
2214{ 2205{
2215 if (smi_info->thread_pid > 0) { 2206 if (smi_info->thread != ERR_PTR(-ENOMEM))
2216 /* wake the potentially sleeping thread */ 2207 kthread_stop(smi_info->thread);
2217 kill_proc(smi_info->thread_pid, SIGKILL, 0);
2218 wait_for_completion(&(smi_info->exiting));
2219 }
2220 del_timer_sync(&smi_info->si_timer); 2208 del_timer_sync(&smi_info->si_timer);
2221} 2209}
2222 2210
@@ -2348,12 +2336,9 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2348 new_smi->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; 2336 new_smi->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;
2349 2337
2350 add_timer(&(new_smi->si_timer)); 2338 add_timer(&(new_smi->si_timer));
2351 if (new_smi->si_type != SI_BT) { 2339 if (new_smi->si_type != SI_BT)
2352 init_completion(&(new_smi->exiting)); 2340 new_smi->thread = kthread_run(ipmi_thread, new_smi,
2353 new_smi->thread_pid = kernel_thread(ipmi_thread, new_smi, 2341 "kipmi%d", new_smi->intf_num);
2354 CLONE_FS|CLONE_FILES|
2355 CLONE_SIGHAND);
2356 }
2357 2342
2358 rv = ipmi_register_smi(&handlers, 2343 rv = ipmi_register_smi(&handlers,
2359 new_smi, 2344 new_smi,