Lines Matching full:thread
21 * 3) proc->inner_lock : protects the thread and node lists
24 * (proc->todo, thread->todo, proc->delivered_death and
25 * node->async_todo), as well as thread->transaction_stack
447 * binder_enqueue_deferred_thread_work_ilocked() - Add deferred thread work
448 * @thread: thread to queue work to
451 * Adds the work to the todo list of the thread. Doesn't set the process_todo
452 * flag, which means that (if it wasn't already set) the thread will go to
458 binder_enqueue_deferred_thread_work_ilocked(struct binder_thread *thread, in binder_enqueue_deferred_thread_work_ilocked() argument
461 WARN_ON(!list_empty(&thread->waiting_thread_node)); in binder_enqueue_deferred_thread_work_ilocked()
462 binder_enqueue_work_ilocked(work, &thread->todo); in binder_enqueue_deferred_thread_work_ilocked()
466 * binder_enqueue_thread_work_ilocked() - Add an item to the thread work list
467 * @thread: thread to queue work to
470 * Adds the work to the todo list of the thread, and enables processing
476 binder_enqueue_thread_work_ilocked(struct binder_thread *thread, in binder_enqueue_thread_work_ilocked() argument
479 WARN_ON(!list_empty(&thread->waiting_thread_node)); in binder_enqueue_thread_work_ilocked()
480 binder_enqueue_work_ilocked(work, &thread->todo); in binder_enqueue_thread_work_ilocked()
481 thread->process_todo = true; in binder_enqueue_thread_work_ilocked()
485 * binder_enqueue_thread_work() - Add an item to the thread work list
486 * @thread: thread to queue work to
489 * Adds the work to the todo list of the thread, and enables processing
493 binder_enqueue_thread_work(struct binder_thread *thread, in binder_enqueue_thread_work() argument
496 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
497 binder_enqueue_thread_work_ilocked(thread, work); in binder_enqueue_thread_work()
498 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
536 static void binder_free_thread(struct binder_thread *thread);
540 static bool binder_has_work_ilocked(struct binder_thread *thread, in binder_has_work_ilocked() argument
543 return thread->process_todo || in binder_has_work_ilocked()
544 thread->looper_need_return || in binder_has_work_ilocked()
546 !binder_worklist_empty_ilocked(&thread->proc->todo)); in binder_has_work_ilocked()
549 static bool binder_has_work(struct binder_thread *thread, bool do_proc_work) in binder_has_work() argument
553 binder_inner_proc_lock(thread->proc); in binder_has_work()
554 has_work = binder_has_work_ilocked(thread, do_proc_work); in binder_has_work()
555 binder_inner_proc_unlock(thread->proc); in binder_has_work()
560 static bool binder_available_for_proc_work_ilocked(struct binder_thread *thread) in binder_available_for_proc_work_ilocked() argument
562 return !thread->transaction_stack && in binder_available_for_proc_work_ilocked()
563 binder_worklist_empty_ilocked(&thread->todo) && in binder_available_for_proc_work_ilocked()
564 (thread->looper & (BINDER_LOOPER_STATE_ENTERED | in binder_available_for_proc_work_ilocked()
572 struct binder_thread *thread; in binder_wakeup_poll_threads_ilocked() local
575 thread = rb_entry(n, struct binder_thread, rb_node); in binder_wakeup_poll_threads_ilocked()
576 if (thread->looper & BINDER_LOOPER_STATE_POLL && in binder_wakeup_poll_threads_ilocked()
577 binder_available_for_proc_work_ilocked(thread)) { in binder_wakeup_poll_threads_ilocked()
579 wake_up_interruptible_sync(&thread->wait); in binder_wakeup_poll_threads_ilocked()
581 wake_up_interruptible(&thread->wait); in binder_wakeup_poll_threads_ilocked()
587 * binder_select_thread_ilocked() - selects a thread for doing proc work.
588 * @proc: process to select a thread from
590 * Note that calling this function moves the thread off the waiting_threads
592 * signal. Therefore, callers *should* always wake up the thread this function
595 * Return: If there's a thread currently waiting for process work,
596 * returns that thread. Otherwise returns NULL.
601 struct binder_thread *thread; in binder_select_thread_ilocked() local
604 thread = list_first_entry_or_null(&proc->waiting_threads, in binder_select_thread_ilocked()
608 if (thread) in binder_select_thread_ilocked()
609 list_del_init(&thread->waiting_thread_node); in binder_select_thread_ilocked()
611 return thread; in binder_select_thread_ilocked()
615 * binder_wakeup_thread_ilocked() - wakes up a thread for doing proc work.
616 * @proc: process to wake up a thread in
617 * @thread: specific thread to wake-up (may be NULL)
620 * This function wakes up a thread in the @proc process.
621 * The caller may provide a specific thread to wake-up in
622 * the @thread parameter. If @thread is NULL, this function
626 * should first call binder_select_thread() to find a thread
627 * to handle the work (if they don't have a thread already),
628 * and pass the result into the @thread parameter.
631 struct binder_thread *thread, in binder_wakeup_thread_ilocked() argument
636 if (thread) { in binder_wakeup_thread_ilocked()
638 wake_up_interruptible_sync(&thread->wait); in binder_wakeup_thread_ilocked()
640 wake_up_interruptible(&thread->wait); in binder_wakeup_thread_ilocked()
644 /* Didn't find a thread waiting for proc work; this can happen in binder_wakeup_thread_ilocked()
654 * a thread that called into (e)poll is handling non-binder in binder_wakeup_thread_ilocked()
662 struct binder_thread *thread = binder_select_thread_ilocked(proc); in binder_wakeup_proc_ilocked() local
664 binder_wakeup_thread_ilocked(proc, thread, /* sync = */false); in binder_wakeup_proc_ilocked()
794 * The node was already added by another thread in binder_new_node()
831 struct binder_thread *thread = container_of(target_list, in binder_inc_node_nilocked() local
834 BUG_ON(&thread->todo != target_list); in binder_inc_node_nilocked()
835 binder_enqueue_deferred_thread_work_ilocked(thread, in binder_inc_node_nilocked()
1050 * Return: the ref for node. It is possible that another thread
1404 * Another thread created the ref first so in binder_inc_ref_for_node()
1424 * binder_thread_dec_tmpref() - decrement thread->tmp_ref
1425 * @thread: thread to decrement
1427 * A thread needs to be kept alive while being used to create or
1429 * extract t->from from a binder_transaction and keep the thread
1432 * tmp_ref and free if appropriate (thread has been released
1435 static void binder_thread_dec_tmpref(struct binder_thread *thread) in binder_thread_dec_tmpref() argument
1439 * it cannot reach zero or thread->is_dead is false in binder_thread_dec_tmpref()
1441 binder_inner_proc_lock(thread->proc); in binder_thread_dec_tmpref()
1442 atomic_dec(&thread->tmp_ref); in binder_thread_dec_tmpref()
1443 if (thread->is_dead && !atomic_read(&thread->tmp_ref)) { in binder_thread_dec_tmpref()
1444 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1445 binder_free_thread(thread); in binder_thread_dec_tmpref()
1448 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1477 * binder_get_txn_from() - safely extract the "from" thread in transaction
1480 * Atomically return the "from" thread and increment the tmp_ref
1481 * count for the thread to ensure it stays alive until
1504 * to guarantee that the thread cannot be released while operating on it.
1644 "reply failed, no target thread at root\n"); in binder_send_failed_reply()
1649 "reply failed, no target thread -- retry %d\n", in binder_send_failed_reply()
1936 struct binder_thread *thread, in binder_transaction_buffer_release() argument
2097 * Need to make sure the thread goes in binder_transaction_buffer_release()
2101 if (thread) in binder_transaction_buffer_release()
2102 thread->looper_need_return = true; in binder_transaction_buffer_release()
2116 struct binder_thread *thread, in binder_release_entire_buffer() argument
2125 binder_transaction_buffer_release(proc, thread, buffer, in binder_release_entire_buffer()
2131 struct binder_thread *thread) in binder_translate_binder() argument
2134 struct binder_proc *proc = thread->proc; in binder_translate_binder()
2147 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2160 &thread->todo, &rdata); in binder_translate_binder()
2184 struct binder_thread *thread) in binder_translate_handle() argument
2186 struct binder_proc *proc = thread->proc; in binder_translate_handle()
2196 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2257 struct binder_thread *thread, in binder_translate_fd() argument
2260 struct binder_proc *proc = thread->proc; in binder_translate_fd()
2273 proc->pid, thread->pid, in binder_translate_fd()
2283 proc->pid, thread->pid, fd); in binder_translate_fd()
2296 * target thread. in binder_translate_fd()
2568 struct binder_thread *thread, in binder_translate_fd_array() argument
2574 struct binder_proc *proc = thread->proc; in binder_translate_fd_array()
2583 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2590 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2608 proc->pid, thread->pid); in binder_translate_fd_array()
2622 ret = binder_translate_fd(fd, offset, t, thread, in binder_translate_fd_array()
2632 struct binder_thread *thread, in binder_fixup_parent() argument
2641 struct binder_proc *proc = thread->proc; in binder_fixup_parent()
2655 proc->pid, thread->pid); in binder_fixup_parent()
2664 proc->pid, thread->pid); in binder_fixup_parent()
2672 proc->pid, thread->pid); in binder_fixup_parent()
2734 * @thread: thread in @proc to send the transaction to (may be NULL)
2737 * to find a thread in the target process to handle the transaction and
2738 * wake it up. If no thread is found, the work is queued to the proc
2741 * If the @thread parameter is not NULL, the transaction is always queued
2742 * to the waitlist of that specific thread.
2745 * BR_DEAD_REPLY if the target process or thread is dead
2746 * BR_FROZEN_REPLY if the target process or thread is frozen and
2753 struct binder_thread *thread) in binder_proc_transaction() argument
2764 BUG_ON(thread); in binder_proc_transaction()
2779 (thread && thread->is_dead)) { in binder_proc_transaction()
2785 if (!thread && !pending_async) in binder_proc_transaction()
2786 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2788 if (thread) { in binder_proc_transaction()
2789 binder_enqueue_thread_work_ilocked(thread, &t->work); in binder_proc_transaction()
2808 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2897 struct binder_thread *thread, in binder_transaction() argument
2936 e->from_thread = thread->pid; in binder_transaction()
2943 binder_set_extended_error(&thread->ee, t_debug_id, BR_OK, 0); in binder_transaction()
2948 in_reply_to = thread->transaction_stack; in binder_transaction()
2952 proc->pid, thread->pid); in binder_transaction()
2958 if (in_reply_to->to_thread != thread) { in binder_transaction()
2961 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
2974 thread->transaction_stack = in_reply_to->to_parent; in binder_transaction()
2982 thread->pid, proc->pid); in binder_transaction()
2989 proc->pid, thread->pid, in binder_transaction()
3024 proc->pid, thread->pid, tr->target.handle); in binder_transaction()
3040 proc->pid, thread->pid); in binder_transaction()
3049 thread->pid, proc->pid); in binder_transaction()
3060 thread->pid, proc->pid); in binder_transaction()
3069 thread->pid, proc->pid); in binder_transaction()
3077 w = list_first_entry_or_null(&thread->todo, in binder_transaction()
3083 * thread that has a transaction at the head of in binder_transaction()
3086 * thread from proc->waiting_threads to enqueue in binder_transaction()
3088 * todo list while the thread is on waiting_threads. in binder_transaction()
3090 …binder_user_error("%d:%d new transaction not allowed when there is a transaction on thread todo\n", in binder_transaction()
3091 proc->pid, thread->pid); in binder_transaction()
3099 if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) { in binder_transaction()
3102 tmp = thread->transaction_stack; in binder_transaction()
3103 if (tmp->to_thread != thread) { in binder_transaction()
3106 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
3142 thread->pid, proc->pid); in binder_transaction()
3155 thread->pid, proc->pid); in binder_transaction()
3169 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3178 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3186 t->from = thread; in binder_transaction()
3190 t->from_tid = thread->pid; in binder_transaction()
3206 thread->pid, proc->pid); in binder_transaction()
3216 thread->pid, proc->pid); in binder_transaction()
3278 proc->pid, thread->pid); in binder_transaction()
3286 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3294 proc->pid, thread->pid, in binder_transaction()
3322 thread->pid, proc->pid); in binder_transaction()
3341 proc->pid, thread->pid); in binder_transaction()
3351 proc->pid, thread->pid, in binder_transaction()
3374 ret = binder_translate_binder(fp, t, thread); in binder_transaction()
3382 thread->pid, proc->pid); in binder_transaction()
3394 ret = binder_translate_handle(fp, t, thread); in binder_transaction()
3401 thread->pid, proc->pid); in binder_transaction()
3414 thread, in_reply_to); in binder_transaction()
3423 thread->pid, proc->pid); in binder_transaction()
3447 proc->pid, thread->pid); in binder_transaction()
3460 proc->pid, thread->pid); in binder_transaction()
3475 proc->pid, thread->pid, in binder_transaction()
3486 thread, in_reply_to); in binder_transaction()
3494 thread->pid, proc->pid); in binder_transaction()
3512 proc->pid, thread->pid); in binder_transaction()
3523 thread->pid, proc->pid); in binder_transaction()
3537 thread, bp, in binder_transaction()
3548 thread->pid, proc->pid); in binder_transaction()
3559 proc->pid, thread->pid, hdr->type); in binder_transaction()
3573 proc->pid, thread->pid); in binder_transaction()
3584 proc->pid, thread->pid); in binder_transaction()
3597 binder_enqueue_thread_work(thread, tcomplete); in binder_transaction()
3621 binder_enqueue_deferred_thread_work_ilocked(thread, tcomplete); in binder_transaction()
3623 t->from_parent = thread->transaction_stack; in binder_transaction()
3624 thread->transaction_stack = t; in binder_transaction()
3630 binder_pop_transaction_ilocked(thread, t); in binder_transaction()
3645 binder_enqueue_thread_work(thread, tcomplete); in binder_transaction()
3664 binder_txn_error("%d:%d dead process or thread\n", in binder_transaction()
3665 thread->pid, proc->pid); in binder_transaction()
3708 proc->pid, thread->pid, reply ? "reply" : in binder_transaction()
3738 BUG_ON(thread->return_error.cmd != BR_OK); in binder_transaction()
3742 thread->return_error.cmd = BR_TRANSACTION_COMPLETE; in binder_transaction()
3743 binder_enqueue_thread_work(thread, &thread->return_error.work); in binder_transaction()
3747 binder_set_extended_error(&thread->ee, t_debug_id, in binder_transaction()
3750 thread->return_error.cmd = return_error; in binder_transaction()
3751 binder_enqueue_thread_work(thread, &thread->return_error.work); in binder_transaction()
3768 struct binder_thread *thread, in binder_free_buf() argument
3797 binder_release_entire_buffer(proc, thread, buffer, is_failure); in binder_free_buf()
3802 struct binder_thread *thread, in binder_thread_write() argument
3812 while (ptr < end && thread->return_error.cmd == BR_OK) { in binder_thread_write()
3822 atomic_inc(&thread->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
3848 proc->pid, thread->pid); in binder_thread_write()
3864 proc->pid, thread->pid, in binder_thread_write()
3884 proc->pid, thread->pid, debug_string, in binder_thread_write()
3890 proc->pid, thread->pid, debug_string, in binder_thread_write()
3911 proc->pid, thread->pid, in binder_thread_write()
3920 proc->pid, thread->pid, in binder_thread_write()
3932 proc->pid, thread->pid, in binder_thread_write()
3942 proc->pid, thread->pid, in binder_thread_write()
3955 proc->pid, thread->pid, in binder_thread_write()
3984 proc->pid, thread->pid, in binder_thread_write()
3989 proc->pid, thread->pid, in binder_thread_write()
3996 proc->pid, thread->pid, (u64)data_ptr, in binder_thread_write()
3999 binder_free_buf(proc, thread, buffer, false); in binder_thread_write()
4010 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
4021 binder_transaction(proc, thread, &tr, in binder_thread_write()
4029 proc->pid, thread->pid); in binder_thread_write()
4031 if (thread->looper & BINDER_LOOPER_STATE_ENTERED) { in binder_thread_write()
4032 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
4034 proc->pid, thread->pid); in binder_thread_write()
4036 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
4038 proc->pid, thread->pid); in binder_thread_write()
4043 thread->looper |= BINDER_LOOPER_STATE_REGISTERED; in binder_thread_write()
4049 proc->pid, thread->pid); in binder_thread_write()
4050 if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) { in binder_thread_write()
4051 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
4053 proc->pid, thread->pid); in binder_thread_write()
4055 thread->looper |= BINDER_LOOPER_STATE_ENTERED; in binder_thread_write()
4060 proc->pid, thread->pid); in binder_thread_write()
4061 thread->looper |= BINDER_LOOPER_STATE_EXITED; in binder_thread_write()
4084 WARN_ON(thread->return_error.cmd != in binder_thread_write()
4086 thread->return_error.cmd = BR_ERROR; in binder_thread_write()
4088 thread, in binder_thread_write()
4089 &thread->return_error.work); in binder_thread_write()
4093 proc->pid, thread->pid); in binder_thread_write()
4101 proc->pid, thread->pid, in binder_thread_write()
4113 proc->pid, thread->pid, in binder_thread_write()
4125 proc->pid, thread->pid); in binder_thread_write()
4147 proc->pid, thread->pid); in binder_thread_write()
4155 proc->pid, thread->pid, in binder_thread_write()
4166 if (thread->looper & in binder_thread_write()
4170 thread, in binder_thread_write()
4212 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
4216 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
4223 if (thread->looper & in binder_thread_write()
4227 thread, &death->work); in binder_thread_write()
4240 proc->pid, thread->pid, cmd); in binder_thread_write()
4249 struct binder_thread *thread, uint32_t cmd) in binder_stat_br() argument
4255 atomic_inc(&thread->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
4260 struct binder_thread *thread, in binder_put_node_cmd() argument
4281 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
4283 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
4290 static int binder_wait_for_work(struct binder_thread *thread, in binder_wait_for_work() argument
4294 struct binder_proc *proc = thread->proc; in binder_wait_for_work()
4299 prepare_to_wait(&thread->wait, &wait, TASK_INTERRUPTIBLE|TASK_FREEZABLE); in binder_wait_for_work()
4300 if (binder_has_work_ilocked(thread, do_proc_work)) in binder_wait_for_work()
4303 list_add(&thread->waiting_thread_node, in binder_wait_for_work()
4308 list_del_init(&thread->waiting_thread_node); in binder_wait_for_work()
4314 finish_wait(&thread->wait, &wait); in binder_wait_for_work()
4375 struct binder_thread *thread, in binder_thread_read() argument
4394 wait_for_proc_work = binder_available_for_proc_work_ilocked(thread); in binder_thread_read()
4397 thread->looper |= BINDER_LOOPER_STATE_WAITING; in binder_thread_read()
4400 !!thread->transaction_stack, in binder_thread_read()
4401 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
4403 if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED | in binder_thread_read()
4405 …binder_user_error("%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER … in binder_thread_read()
4406 proc->pid, thread->pid, thread->looper); in binder_thread_read()
4414 if (!binder_has_work(thread, wait_for_proc_work)) in binder_thread_read()
4417 ret = binder_wait_for_work(thread, wait_for_proc_work); in binder_thread_read()
4420 thread->looper &= ~BINDER_LOOPER_STATE_WAITING; in binder_thread_read()
4436 if (!binder_worklist_empty_ilocked(&thread->todo)) in binder_thread_read()
4437 list = &thread->todo; in binder_thread_read()
4445 if (ptr - buffer == 4 && !thread->looper_need_return) in binder_thread_read()
4455 if (binder_worklist_empty_ilocked(&thread->todo)) in binder_thread_read()
4456 thread->process_todo = false; in binder_thread_read()
4475 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4494 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4497 proc->pid, thread->pid); in binder_thread_read()
4535 proc->pid, thread->pid, in binder_thread_read()
4547 * this thread frees while the other thread in binder_thread_read()
4558 proc, thread, &ptr, node_ptr, in binder_thread_read()
4563 proc, thread, &ptr, node_ptr, in binder_thread_read()
4568 proc, thread, &ptr, node_ptr, in binder_thread_read()
4573 proc, thread, &ptr, node_ptr, in binder_thread_read()
4579 proc->pid, thread->pid, in binder_thread_read()
4602 proc->pid, thread->pid, in binder_thread_read()
4623 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4630 proc->pid, thread->pid, w->type); in binder_thread_read()
4682 binder_free_buf(proc, thread, buffer, true); in binder_thread_read()
4685 proc->pid, thread->pid, in binder_thread_read()
4694 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4733 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4736 proc->pid, thread->pid, in binder_thread_read()
4750 binder_inner_proc_lock(thread->proc); in binder_thread_read()
4751 t->to_parent = thread->transaction_stack; in binder_thread_read()
4752 t->to_thread = thread; in binder_thread_read()
4753 thread->transaction_stack = t; in binder_thread_read()
4754 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
4766 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
4768 (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | in binder_thread_read()
4770 /*spawn a new thread if we leave this out */) { in binder_thread_read()
4775 proc->pid, thread->pid); in binder_thread_read()
4778 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
4848 struct binder_thread *thread = NULL; in binder_get_thread_ilocked() local
4854 thread = rb_entry(parent, struct binder_thread, rb_node); in binder_get_thread_ilocked()
4856 if (current->pid < thread->pid) in binder_get_thread_ilocked()
4858 else if (current->pid > thread->pid) in binder_get_thread_ilocked()
4861 return thread; in binder_get_thread_ilocked()
4865 thread = new_thread; in binder_get_thread_ilocked()
4867 thread->proc = proc; in binder_get_thread_ilocked()
4868 thread->pid = current->pid; in binder_get_thread_ilocked()
4869 atomic_set(&thread->tmp_ref, 0); in binder_get_thread_ilocked()
4870 init_waitqueue_head(&thread->wait); in binder_get_thread_ilocked()
4871 INIT_LIST_HEAD(&thread->todo); in binder_get_thread_ilocked()
4872 rb_link_node(&thread->rb_node, parent, p); in binder_get_thread_ilocked()
4873 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
4874 thread->looper_need_return = true; in binder_get_thread_ilocked()
4875 thread->return_error.work.type = BINDER_WORK_RETURN_ERROR; in binder_get_thread_ilocked()
4876 thread->return_error.cmd = BR_OK; in binder_get_thread_ilocked()
4877 thread->reply_error.work.type = BINDER_WORK_RETURN_ERROR; in binder_get_thread_ilocked()
4878 thread->reply_error.cmd = BR_OK; in binder_get_thread_ilocked()
4879 thread->ee.command = BR_OK; in binder_get_thread_ilocked()
4881 return thread; in binder_get_thread_ilocked()
4886 struct binder_thread *thread; in binder_get_thread() local
4890 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
4892 if (!thread) { in binder_get_thread()
4893 new_thread = kzalloc(sizeof(*thread), GFP_KERNEL); in binder_get_thread()
4897 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
4899 if (thread != new_thread) in binder_get_thread()
4902 return thread; in binder_get_thread()
4926 static void binder_free_thread(struct binder_thread *thread) in binder_free_thread() argument
4928 BUG_ON(!list_empty(&thread->todo)); in binder_free_thread()
4930 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
4931 kfree(thread); in binder_free_thread()
4935 struct binder_thread *thread) in binder_thread_release() argument
4942 binder_inner_proc_lock(thread->proc); in binder_thread_release()
4945 * after we remove this thread from proc->threads. in binder_thread_release()
4947 * free the thread in binder_free_thread() in binder_thread_release()
4951 * take a ref on this thread to ensure it in binder_thread_release()
4954 atomic_inc(&thread->tmp_ref); in binder_thread_release()
4955 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
4956 t = thread->transaction_stack; in binder_thread_release()
4959 if (t->to_thread == thread) in binder_thread_release()
4964 thread->is_dead = true; in binder_thread_release()
4971 proc->pid, thread->pid, in binder_thread_release()
4973 (t->to_thread == thread) ? "in" : "out"); in binder_thread_release()
4975 if (t->to_thread == thread) { in binder_thread_release()
4976 thread->proc->outstanding_txns--; in binder_thread_release()
4984 } else if (t->from == thread) { in binder_thread_release()
4999 * If this thread used poll, make sure we remove the waitqueue from any in binder_thread_release()
5002 if (thread->looper & BINDER_LOOPER_STATE_POLL) in binder_thread_release()
5003 wake_up_pollfree(&thread->wait); in binder_thread_release()
5005 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
5014 if (thread->looper & BINDER_LOOPER_STATE_POLL) in binder_thread_release()
5019 binder_release_work(proc, &thread->todo); in binder_thread_release()
5020 binder_thread_dec_tmpref(thread); in binder_thread_release()
5028 struct binder_thread *thread = NULL; in binder_poll() local
5031 thread = binder_get_thread(proc); in binder_poll()
5032 if (!thread) in binder_poll()
5035 binder_inner_proc_lock(thread->proc); in binder_poll()
5036 thread->looper |= BINDER_LOOPER_STATE_POLL; in binder_poll()
5037 wait_for_proc_work = binder_available_for_proc_work_ilocked(thread); in binder_poll()
5039 binder_inner_proc_unlock(thread->proc); in binder_poll()
5041 poll_wait(filp, &thread->wait, wait); in binder_poll()
5043 if (binder_has_work(thread, wait_for_proc_work)) in binder_poll()
5050 struct binder_thread *thread) in binder_ioctl_write_read() argument
5063 proc->pid, thread->pid, in binder_ioctl_write_read()
5068 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
5081 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
5098 proc->pid, thread->pid, in binder_ioctl_write_read()
5221 struct binder_thread *thread; in binder_txns_pending_ilocked() local
5227 thread = rb_entry(n, struct binder_thread, rb_node); in binder_txns_pending_ilocked()
5228 if (thread->transaction_stack) in binder_txns_pending_ilocked()
5312 static int binder_ioctl_get_extended_error(struct binder_thread *thread, in binder_ioctl_get_extended_error() argument
5317 binder_inner_proc_lock(thread->proc); in binder_ioctl_get_extended_error()
5318 ee = thread->ee; in binder_ioctl_get_extended_error()
5319 binder_set_extended_error(&thread->ee, 0, BR_OK, 0); in binder_ioctl_get_extended_error()
5320 binder_inner_proc_unlock(thread->proc); in binder_ioctl_get_extended_error()
5332 struct binder_thread *thread; in binder_ioctl() local
5346 thread = binder_get_thread(proc); in binder_ioctl()
5347 if (thread == NULL) { in binder_ioctl()
5354 ret = binder_ioctl_write_read(filp, arg, thread); in binder_ioctl()
5390 proc->pid, thread->pid); in binder_ioctl()
5391 binder_thread_release(proc, thread); in binder_ioctl()
5392 thread = NULL; in binder_ioctl()
5532 ret = binder_ioctl_get_extended_error(thread, ubuf); in binder_ioctl()
5542 if (thread) in binder_ioctl()
5543 thread->looper_need_return = false; in binder_ioctl()
5722 struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); in binder_deferred_flush() local
5724 thread->looper_need_return = true; in binder_deferred_flush()
5725 if (thread->looper & BINDER_LOOPER_STATE_WAITING) { in binder_deferred_flush()
5726 wake_up_interruptible(&thread->wait); in binder_deferred_flush()
5851 struct binder_thread *thread; in binder_deferred_release() local
5853 thread = rb_entry(n, struct binder_thread, rb_node); in binder_deferred_release()
5856 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
6036 struct binder_thread *thread, in print_binder_thread_ilocked() argument
6044 seq_printf(m, " thread %d: l %02x need_return %d tr %d\n", in print_binder_thread_ilocked()
6045 thread->pid, thread->looper, in print_binder_thread_ilocked()
6046 thread->looper_need_return, in print_binder_thread_ilocked()
6047 atomic_read(&thread->tmp_ref)); in print_binder_thread_ilocked()
6049 t = thread->transaction_stack; in print_binder_thread_ilocked()
6051 if (t->from == thread) { in print_binder_thread_ilocked()
6052 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6055 } else if (t->to_thread == thread) { in print_binder_thread_ilocked()
6056 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6060 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6065 list_for_each_entry(w, &thread->todo, entry) { in print_binder_thread_ilocked()
6066 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
6230 "thread",
6284 struct binder_thread *thread; in print_binder_proc_stats() local
6298 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()