Bluetooth: Enable Atheros 0cf3:311e for firmware upload
[pandora-kernel.git] / kernel / workqueue.c
index 0ad2420..563820c 100644 (file)
@@ -1474,12 +1474,19 @@ static void destroy_worker(struct worker *worker)
        if (worker->flags & WORKER_IDLE)
                gcwq->nr_idle--;
 
+       /*
+        * Once WORKER_DIE is set, the kworker may destroy itself at any
+        * point.  Pin to ensure the task stays until we're done with it.
+        */
+       get_task_struct(worker->task);
+
        list_del_init(&worker->entry);
        worker->flags |= WORKER_DIE;
 
        spin_unlock_irq(&gcwq->lock);
 
        kthread_stop(worker->task);
+       put_task_struct(worker->task);
        kfree(worker);
 
        spin_lock_irq(&gcwq->lock);
@@ -1920,6 +1927,15 @@ __acquires(&gcwq->lock)
                dump_stack();
        }
 
+       /*
+        * The following prevents a kworker from hogging CPU on !PREEMPT
+        * kernels, where a requeueing work item waiting for something to
+        * happen could deadlock with stop_machine as such work item could
+        * indefinitely requeue itself while all other CPUs are trapped in
+        * stop_machine.
+        */
+       cond_resched();
+
        spin_lock_irq(&gcwq->lock);
 
        /* clear cpu intensive status */