]> err.no Git - linux-2.6/commitdiff
[SPARC64]: Process dr-cpu events in a kthread instead of workqueue.
authorDavid S. Miller <davem@sunset.davemloft.net>
Sat, 14 Jul 2007 10:14:45 +0000 (03:14 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 16 Jul 2007 11:05:07 +0000 (04:05 -0700)
This will be necessary to handle unconfigure requests
properly.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc64/kernel/ds.c

index 0cb96dc399b7cd765a20a0b14c801e392e7e957d..d412cf876ab43cb71c9545802e0278b927586720 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
-#include <linux/workqueue.h>
+#include <linux/kthread.h>
 #include <linux/cpu.h>
 
 #include <asm/ldc.h>
@@ -395,6 +395,7 @@ struct dr_cpu_resp_entry {
  * ds_lock, and processed by dr_cpu_process() in order.
  */
 static LIST_HEAD(dr_cpu_work_list);
+static DECLARE_WAIT_QUEUE_HEAD(dr_cpu_wait);
 
 struct dr_cpu_queue_entry {
        struct list_head                list;
@@ -533,10 +534,13 @@ static int dr_cpu_configure(struct ds_cap_state *cp, u64 req_num,
 
                printk(KERN_INFO PFX "Starting cpu %d...\n", cpu);
                err = cpu_up(cpu);
-               if (err)
+               if (err) {
+                       printk(KERN_INFO PFX "CPU startup failed err=%d\n",
+                              err);
                        dr_cpu_mark(resp, cpu, ncpus,
                                    DR_CPU_RES_FAILURE,
                                    DR_CPU_STAT_UNCONFIGURED);
+               }
        }
 
        spin_lock_irqsave(&ds_lock, flags);
@@ -569,18 +573,16 @@ static int dr_cpu_unconfigure(struct ds_cap_state *cp, u64 req_num,
        return -EOPNOTSUPP;
 }
 
-static void dr_cpu_process(struct work_struct *work)
+static void process_dr_cpu_list(struct ds_cap_state *cp)
 {
        struct dr_cpu_queue_entry *qp, *tmp;
-       struct ds_cap_state *cp;
        unsigned long flags;
        LIST_HEAD(todo);
        cpumask_t mask;
 
-       cp = find_cap_by_string("dr-cpu");
-
        spin_lock_irqsave(&ds_lock, flags);
        list_splice(&dr_cpu_work_list, &todo);
+       INIT_LIST_HEAD(&dr_cpu_work_list);
        spin_unlock_irqrestore(&ds_lock, flags);
 
        list_for_each_entry_safe(qp, tmp, &todo, list) {
@@ -627,7 +629,27 @@ next:
        }
 }
 
-static DECLARE_WORK(dr_cpu_work, dr_cpu_process);
+static int dr_cpu_thread(void *__unused)
+{
+       struct ds_cap_state *cp;
+       DEFINE_WAIT(wait);
+
+       cp = find_cap_by_string("dr-cpu");
+
+       while (1) {
+               prepare_to_wait(&dr_cpu_wait, &wait, TASK_INTERRUPTIBLE);
+               if (list_empty(&dr_cpu_work_list))
+                       schedule();
+               finish_wait(&dr_cpu_wait, &wait);
+
+               if (kthread_should_stop())
+                       break;
+
+               process_dr_cpu_list(cp);
+       }
+
+       return 0;
+}
 
 static void dr_cpu_data(struct ldc_channel *lp,
                        struct ds_cap_state *dp,
@@ -648,7 +670,7 @@ static void dr_cpu_data(struct ldc_channel *lp,
        } else {
                memcpy(&qp->req, buf, len);
                list_add_tail(&qp->list, &dr_cpu_work_list);
-               schedule_work(&dr_cpu_work);
+               wake_up(&dr_cpu_wait);
        }
 }
 #endif
@@ -1095,6 +1117,10 @@ static int __init ds_init(void)
        for (i = 0; i < ARRAY_SIZE(ds_states); i++)
                ds_states[i].handle = ((u64)i << 32);
 
+#ifdef CONFIG_HOTPLUG_CPU
+       kthread_run(dr_cpu_thread, NULL, "kdrcpud");
+#endif
+
        return vio_register_driver(&ds_driver);
 }