Staging: android: binder: Create dedicated workqueue for binder deferred work
authorArve Hjønnevåg <arve@android.com>
Thu, 22 Apr 2010 22:53:23 +0000 (15:53 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 30 Nov 2011 11:51:36 +0000 (20:51 +0900)
Some drivers flush the global workqueue when closed. This would deadlock if
the last reference to the file was released from the binder.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/android/binder.c

index 669e2a6d611b792f75459829d9352d9a7274ec98..6d6fe7bdebd3a6eee748330d517fa502887e4a60 100644 (file)
@@ -48,6 +48,7 @@ static struct dentry *binder_debugfs_dir_entry_proc;
 static struct binder_node *binder_context_mgr_node;
 static uid_t binder_context_mgr_uid = -1;
 static int binder_last_id;
+static struct workqueue_struct *binder_deferred_workqueue;
 
 #define BINDER_DEBUG_ENTRY(name) \
 static int binder_##name##_open(struct inode *inode, struct file *file) \
@@ -3109,7 +3110,7 @@ binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer)
        if (hlist_unhashed(&proc->deferred_work_node)) {
                hlist_add_head(&proc->deferred_work_node,
                                &binder_deferred_list);
-               schedule_work(&binder_deferred_work);
+               queue_work(binder_deferred_workqueue, &binder_deferred_work);
        }
        mutex_unlock(&binder_deferred_lock);
 }
@@ -3552,6 +3553,10 @@ static int __init binder_init(void)
 {
        int ret;
 
+       binder_deferred_workqueue = create_singlethread_workqueue("binder");
+       if (!binder_deferred_workqueue)
+               return -ENOMEM;
+
        binder_debugfs_dir_entry_root = debugfs_create_dir("binder", NULL);
        if (binder_debugfs_dir_entry_root)
                binder_debugfs_dir_entry_proc = debugfs_create_dir("proc",