Skip to content

Commit

Permalink
[SPARC64]: Process dr-cpu events in a kthread instead of workqueue.
Browse files Browse the repository at this point in the history
This will be necessary to handle unconfigure requests
properly.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jul 16, 2007
1 parent 8b99cfb commit bd0e11f
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions arch/sparc64/kernel/ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -627,7 +629,27 @@ static void dr_cpu_process(struct work_struct *work)
}
}

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,
Expand All @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit bd0e11f

Please sign in to comment.