summaryrefslogtreecommitdiff
path: root/drivers/android
diff options
context:
space:
mode:
authorTao Huang <huangtao@rock-chips.com>2017-12-14 15:18:56 +0800
committerTao Huang <huangtao@rock-chips.com>2017-12-15 09:06:15 +0800
commitf121419cf847d2296a994c2fd51b29dbb8e731d9 (patch)
tree48ce8f4d26ad32e6bfe93d4ffee29e9e4472f208 /drivers/android
parenta979f578cc0d54205c814e4db7e0e80f4d6488f2 (diff)
Revert "ANDROID: binder: Add thread->process_todo flag."
This reverts commit 6c70907428dd5f2b44c9e7b06f18411f81f9119b. Which unable to pass VtsKernelBinderTest#BinderDriverInterfaceTest.Transaction_IPC64_64bit VtsKernelBinderTest#BinderDriverInterfaceTest.Transaction_IPC64_32bit frameworks/native/libs/binder/tests/binderDriverInterfaceTest.cpp:84 Value of: ret Actual: -1 Expected: expect_ret Which is: 0 Google Test trace: frameworks/native/libs/binder/tests/binderDriverInterfaceTest.cpp:252: 1st WriteRead frameworks/native/libs/binder/tests/binderDriverInterfaceTest.cpp:87 Value of: (*__errno()) Actual: 11 Expected: expect_errno Which is: 0 Google Test trace: frameworks/native/libs/binder/tests/binderDriverInterfaceTest.cpp:252: 1st WriteRead Change-Id: I982d7a2a8690c9d1ae7533e91bf7d41e814cdc54 Signed-off-by: Tao Huang <huangtao@rock-chips.com>
Diffstat (limited to 'drivers/android')
-rw-r--r--drivers/android/binder.c144
1 files changed, 44 insertions, 100 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index fddb10c27f10..bd9d7861c22f 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -597,8 +597,6 @@ enum {
* (protected by @proc->inner_lock)
* @todo: list of work to do for this thread
* (protected by @proc->inner_lock)
- * @process_todo: whether work in @todo should be processed
- * (protected by @proc->inner_lock)
* @return_error: transaction errors reported by this thread
* (only accessed by this thread)
* @reply_error: transaction errors reported by target thread
@@ -625,7 +623,6 @@ struct binder_thread {
bool looper_need_return; /* can be written by other thread */
struct binder_transaction *transaction_stack;
struct list_head todo;
- bool process_todo;
struct binder_error return_error;
struct binder_error reply_error;
wait_queue_head_t wait;
@@ -813,16 +810,6 @@ static bool binder_worklist_empty(struct binder_proc *proc,
return ret;
}
-/**
- * binder_enqueue_work_ilocked() - Add an item to the work list
- * @work: struct binder_work to add to list
- * @target_list: list to add work to
- *
- * Adds the work to the specified list. Asserts that work
- * is not already on a list.
- *
- * Requires the proc->inner_lock to be held.
- */
static void
binder_enqueue_work_ilocked(struct binder_work *work,
struct list_head *target_list)
@@ -833,56 +820,22 @@ binder_enqueue_work_ilocked(struct binder_work *work,
}
/**
- * binder_enqueue_thread_work_ilocked_nowake() - Add thread work
- * @thread: thread to queue work to
- * @work: struct binder_work to add to list
- *
- * Adds the work to the todo list of the thread. Doesn't set the process_todo
- * flag, which means that (if it wasn't already set) the thread will go to
- * sleep without handling this work when it calls read.
- *
- * Requires the proc->inner_lock to be held.
- */
-static void
-binder_enqueue_thread_work_ilocked_nowake(struct binder_thread *thread,
- struct binder_work *work)
-{
- binder_enqueue_work_ilocked(work, &thread->todo);
-}
-
-/**
- * binder_enqueue_thread_work_ilocked() - Add an item to the thread work list
- * @thread: thread to queue work to
- * @work: struct binder_work to add to list
- *
- * Adds the work to the todo list of the thread, and enables processing
- * of the todo queue.
- *
- * Requires the proc->inner_lock to be held.
- */
-static void
-binder_enqueue_thread_work_ilocked(struct binder_thread *thread,
- struct binder_work *work)
-{
- binder_enqueue_work_ilocked(work, &thread->todo);
- thread->process_todo = true;
-}
-
-/**
- * binder_enqueue_thread_work() - Add an item to the thread work list
- * @thread: thread to queue work to
+ * binder_enqueue_work() - Add an item to the work list
+ * @proc: binder_proc associated with list
* @work: struct binder_work to add to list
+ * @target_list: list to add work to
*
- * Adds the work to the todo list of the thread, and enables processing
- * of the todo queue.
+ * Adds the work to the specified list. Asserts that work
+ * is not already on a list.
*/
static void
-binder_enqueue_thread_work(struct binder_thread *thread,
- struct binder_work *work)
+binder_enqueue_work(struct binder_proc *proc,
+ struct binder_work *work,
+ struct list_head *target_list)
{
- binder_inner_proc_lock(thread->proc);
- binder_enqueue_thread_work_ilocked(thread, work);
- binder_inner_proc_unlock(thread->proc);
+ binder_inner_proc_lock(proc);
+ binder_enqueue_work_ilocked(work, target_list);
+ binder_inner_proc_unlock(proc);
}
static void
@@ -1015,7 +968,7 @@ static long task_close_fd(struct binder_proc *proc, unsigned int fd)
static bool binder_has_work_ilocked(struct binder_thread *thread,
bool do_proc_work)
{
- return thread->process_todo ||
+ return !binder_worklist_empty_ilocked(&thread->todo) ||
thread->looper_need_return ||
(do_proc_work &&
!binder_worklist_empty_ilocked(&thread->proc->todo));
@@ -1432,17 +1385,6 @@ static int binder_inc_node_nilocked(struct binder_node *node, int strong,
node->local_strong_refs++;
if (!node->has_strong_ref && target_list) {
binder_dequeue_work_ilocked(&node->work);
- /*
- * Note: this function is the only place where we queue
- * directly to a thread->todo without using the
- * corresponding binder_enqueue_thread_work() helper
- * functions; in this case it's ok to not set the
- * process_todo flag, since we know this node work will
- * always be followed by other work that starts queue
- * processing: in case of synchronous transactions, a
- * BR_REPLY or BR_ERROR; in case of oneway
- * transactions, a BR_TRANSACTION_COMPLETE.
- */
binder_enqueue_work_ilocked(&node->work, target_list);
}
} else {
@@ -1454,9 +1396,6 @@ static int binder_inc_node_nilocked(struct binder_node *node, int strong,
node->debug_id);
return -EINVAL;
}
- /*
- * See comment above
- */
binder_enqueue_work_ilocked(&node->work, target_list);
}
}
@@ -2146,9 +2085,9 @@ static void binder_send_failed_reply(struct binder_transaction *t,
binder_pop_transaction_ilocked(target_thread, t);
if (target_thread->reply_error.cmd == BR_OK) {
target_thread->reply_error.cmd = error_code;
- binder_enqueue_thread_work_ilocked(
- target_thread,
- &target_thread->reply_error.work);
+ binder_enqueue_work_ilocked(
+ &target_thread->reply_error.work,
+ &target_thread->todo);
wake_up_interruptible(&target_thread->wait);
} else {
WARN(1, "Unexpected reply error: %u\n",
@@ -2787,10 +2726,11 @@ static bool binder_proc_transaction(struct binder_transaction *t,
struct binder_proc *proc,
struct binder_thread *thread)
{
+ struct list_head *target_list = NULL;
struct binder_node *node = t->buffer->target_node;
struct binder_priority node_prio;
bool oneway = !!(t->flags & TF_ONE_WAY);
- bool pending_async = false;
+ bool wakeup = true;
BUG_ON(!node);
binder_node_lock(node);
@@ -2800,7 +2740,8 @@ static bool binder_proc_transaction(struct binder_transaction *t,
if (oneway) {
BUG_ON(thread);
if (node->has_async_transaction) {
- pending_async = true;
+ target_list = &node->async_todo;
+ wakeup = false;
} else {
node->has_async_transaction = 1;
}
@@ -2814,20 +2755,22 @@ static bool binder_proc_transaction(struct binder_transaction *t,
return false;
}
- if (!thread && !pending_async)
+ if (!thread && !target_list)
thread = binder_select_thread_ilocked(proc);
if (thread) {
+ target_list = &thread->todo;
binder_transaction_priority(thread->task, t, node_prio,
node->inherit_rt);
- binder_enqueue_thread_work_ilocked(thread, &t->work);
- } else if (!pending_async) {
- binder_enqueue_work_ilocked(&t->work, &proc->todo);
+ } else if (!target_list) {
+ target_list = &proc->todo;
} else {
- binder_enqueue_work_ilocked(&t->work, &node->async_todo);
+ BUG_ON(target_list != &node->async_todo);
}
- if (!pending_async)
+ binder_enqueue_work_ilocked(&t->work, target_list);
+
+ if (wakeup)
binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */);
binder_inner_proc_unlock(proc);
@@ -3329,10 +3272,10 @@ static void binder_transaction(struct binder_proc *proc,
}
}
tcomplete->type = BINDER_WORK_TRANSACTION_COMPLETE;
+ binder_enqueue_work(proc, tcomplete, &thread->todo);
t->work.type = BINDER_WORK_TRANSACTION;
if (reply) {
- binder_enqueue_thread_work(thread, tcomplete);
binder_inner_proc_lock(target_proc);
if (target_thread->is_dead) {
binder_inner_proc_unlock(target_proc);
@@ -3340,7 +3283,7 @@ static void binder_transaction(struct binder_proc *proc,
}
BUG_ON(t->buffer->async_transaction != 0);
binder_pop_transaction_ilocked(target_thread, in_reply_to);
- binder_enqueue_thread_work_ilocked(target_thread, &t->work);
+ binder_enqueue_work_ilocked(&t->work, &target_thread->todo);
binder_inner_proc_unlock(target_proc);
wake_up_interruptible_sync(&target_thread->wait);
binder_restore_priority(current, in_reply_to->saved_priority);
@@ -3348,7 +3291,6 @@ static void binder_transaction(struct binder_proc *proc,
} else if (!(t->flags & TF_ONE_WAY)) {
BUG_ON(t->buffer->async_transaction != 0);
binder_inner_proc_lock(proc);
- binder_enqueue_thread_work_ilocked_nowake(thread, tcomplete);
t->need_reply = 1;
t->from_parent = thread->transaction_stack;
thread->transaction_stack = t;
@@ -3362,7 +3304,6 @@ static void binder_transaction(struct binder_proc *proc,
} else {
BUG_ON(target_node == NULL);
BUG_ON(t->buffer->async_transaction != 1);
- binder_enqueue_thread_work(thread, tcomplete);
if (!binder_proc_transaction(t, target_proc, NULL))
goto err_dead_proc_or_thread;
}
@@ -3442,11 +3383,15 @@ err_invalid_target_handle:
if (in_reply_to) {
binder_restore_priority(current, in_reply_to->saved_priority);
thread->return_error.cmd = BR_TRANSACTION_COMPLETE;
- binder_enqueue_thread_work(thread, &thread->return_error.work);
+ binder_enqueue_work(thread->proc,
+ &thread->return_error.work,
+ &thread->todo);
binder_send_failed_reply(in_reply_to, return_error);
} else {
thread->return_error.cmd = return_error;
- binder_enqueue_thread_work(thread, &thread->return_error.work);
+ binder_enqueue_work(thread->proc,
+ &thread->return_error.work,
+ &thread->todo);
}
}
@@ -3750,9 +3695,10 @@ static int binder_thread_write(struct binder_proc *proc,
WARN_ON(thread->return_error.cmd !=
BR_OK);
thread->return_error.cmd = BR_ERROR;
- binder_enqueue_thread_work(
- thread,
- &thread->return_error.work);
+ binder_enqueue_work(
+ thread->proc,
+ &thread->return_error.work,
+ &thread->todo);
binder_debug(
BINDER_DEBUG_FAILED_TRANSACTION,
"%d:%d BC_REQUEST_DEATH_NOTIFICATION failed\n",
@@ -3832,9 +3778,9 @@ static int binder_thread_write(struct binder_proc *proc,
if (thread->looper &
(BINDER_LOOPER_STATE_REGISTERED |
BINDER_LOOPER_STATE_ENTERED))
- binder_enqueue_thread_work_ilocked(
- thread,
- &death->work);
+ binder_enqueue_work_ilocked(
+ &death->work,
+ &thread->todo);
else {
binder_enqueue_work_ilocked(
&death->work,
@@ -3889,8 +3835,8 @@ static int binder_thread_write(struct binder_proc *proc,
if (thread->looper &
(BINDER_LOOPER_STATE_REGISTERED |
BINDER_LOOPER_STATE_ENTERED))
- binder_enqueue_thread_work_ilocked(
- thread, &death->work);
+ binder_enqueue_work_ilocked(
+ &death->work, &thread->todo);
else {
binder_enqueue_work_ilocked(
&death->work,
@@ -4064,8 +4010,6 @@ retry:
break;
}
w = binder_dequeue_work_head_ilocked(list);
- if (binder_worklist_empty_ilocked(&thread->todo))
- thread->process_todo = false;
switch (w->type) {
case BINDER_WORK_TRANSACTION: {