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
221 * There are separate work lists for proc, thread, and node (async).
498 * struct binder_thread - binder thread bookkeeping
499 * @proc: binder process for this thread
505 * @pid: PID for this thread
508 * (only accessed by this thread)
509 * @looper_needs_return: looping thread needs to exit driver
511 * @transaction_stack: stack of in-progress transactions for this thread
513 * @todo: list of work to do for this thread
517 * @return_error: transaction errors reported by this thread
518 * (only accessed by this thread)
519 * @reply_error: transaction errors reported by target thread
521 * @wait: wait queue for thread work
522 * @stats: per-thread statistics
524 * @tmp_ref: temporary reference to indicate thread is in use
527 * @is_dead: thread is dead and awaiting free
538 int looper; /* only modified by this thread */
539 bool looper_need_return; /* can be written by other thread */
591 * during thread teardown
801 * binder_enqueue_deferred_thread_work_ilocked() - Add deferred thread work
802 * @thread: thread to queue work to
805 * Adds the work to the todo list of the thread. Doesn't set the process_todo
806 * flag, which means that (if it wasn't already set) the thread will go to
812 binder_enqueue_deferred_thread_work_ilocked(struct binder_thread *thread, in binder_enqueue_deferred_thread_work_ilocked() argument
815 WARN_ON(!list_empty(&thread->waiting_thread_node)); in binder_enqueue_deferred_thread_work_ilocked()
816 binder_enqueue_work_ilocked(work, &thread->todo); in binder_enqueue_deferred_thread_work_ilocked()
820 * binder_enqueue_thread_work_ilocked() - Add an item to the thread work list
821 * @thread: thread to queue work to
824 * Adds the work to the todo list of the thread, and enables processing
830 binder_enqueue_thread_work_ilocked(struct binder_thread *thread, in binder_enqueue_thread_work_ilocked() argument
833 WARN_ON(!list_empty(&thread->waiting_thread_node)); in binder_enqueue_thread_work_ilocked()
834 binder_enqueue_work_ilocked(work, &thread->todo); in binder_enqueue_thread_work_ilocked()
835 thread->process_todo = true; in binder_enqueue_thread_work_ilocked()
839 * binder_enqueue_thread_work() - Add an item to the thread work list
840 * @thread: thread to queue work to
843 * Adds the work to the todo list of the thread, and enables processing
847 binder_enqueue_thread_work(struct binder_thread *thread, in binder_enqueue_thread_work() argument
850 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
851 binder_enqueue_thread_work_ilocked(thread, work); in binder_enqueue_thread_work()
852 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
890 static void binder_free_thread(struct binder_thread *thread);
894 static bool binder_has_work_ilocked(struct binder_thread *thread, in binder_has_work_ilocked() argument
897 return thread->process_todo || in binder_has_work_ilocked()
898 thread->looper_need_return || in binder_has_work_ilocked()
900 !binder_worklist_empty_ilocked(&thread->proc->todo)); in binder_has_work_ilocked()
903 static bool binder_has_work(struct binder_thread *thread, bool do_proc_work) in binder_has_work() argument
907 binder_inner_proc_lock(thread->proc); in binder_has_work()
908 has_work = binder_has_work_ilocked(thread, do_proc_work); in binder_has_work()
909 binder_inner_proc_unlock(thread->proc); in binder_has_work()
914 static bool binder_available_for_proc_work_ilocked(struct binder_thread *thread) in binder_available_for_proc_work_ilocked() argument
916 return !thread->transaction_stack && in binder_available_for_proc_work_ilocked()
917 binder_worklist_empty_ilocked(&thread->todo) && in binder_available_for_proc_work_ilocked()
918 (thread->looper & (BINDER_LOOPER_STATE_ENTERED | in binder_available_for_proc_work_ilocked()
926 struct binder_thread *thread; in binder_wakeup_poll_threads_ilocked() local
929 thread = rb_entry(n, struct binder_thread, rb_node); in binder_wakeup_poll_threads_ilocked()
930 if (thread->looper & BINDER_LOOPER_STATE_POLL && in binder_wakeup_poll_threads_ilocked()
931 binder_available_for_proc_work_ilocked(thread)) { in binder_wakeup_poll_threads_ilocked()
933 wake_up_interruptible_sync(&thread->wait); in binder_wakeup_poll_threads_ilocked()
935 wake_up_interruptible(&thread->wait); in binder_wakeup_poll_threads_ilocked()
941 * binder_select_thread_ilocked() - selects a thread for doing proc work.
942 * @proc: process to select a thread from
944 * Note that calling this function moves the thread off the waiting_threads
946 * signal. Therefore, callers *should* always wake up the thread this function
949 * Return: If there's a thread currently waiting for process work,
950 * returns that thread. Otherwise returns NULL.
955 struct binder_thread *thread; in binder_select_thread_ilocked() local
958 thread = list_first_entry_or_null(&proc->waiting_threads, in binder_select_thread_ilocked()
962 if (thread) in binder_select_thread_ilocked()
963 list_del_init(&thread->waiting_thread_node); in binder_select_thread_ilocked()
965 return thread; in binder_select_thread_ilocked()
969 * binder_wakeup_thread_ilocked() - wakes up a thread for doing proc work.
970 * @proc: process to wake up a thread in
971 * @thread: specific thread to wake-up (may be NULL)
974 * This function wakes up a thread in the @proc process.
975 * The caller may provide a specific thread to wake-up in
976 * the @thread parameter. If @thread is NULL, this function
980 * should first call binder_select_thread() to find a thread
981 * to handle the work (if they don't have a thread already),
982 * and pass the result into the @thread parameter.
985 struct binder_thread *thread, in binder_wakeup_thread_ilocked() argument
990 if (thread) { in binder_wakeup_thread_ilocked()
992 wake_up_interruptible_sync(&thread->wait); in binder_wakeup_thread_ilocked()
994 wake_up_interruptible(&thread->wait); in binder_wakeup_thread_ilocked()
998 /* Didn't find a thread waiting for proc work; this can happen in binder_wakeup_thread_ilocked()
1008 * a thread that called into (e)poll is handling non-binder in binder_wakeup_thread_ilocked()
1016 struct binder_thread *thread = binder_select_thread_ilocked(proc); in binder_wakeup_proc_ilocked() local
1018 binder_wakeup_thread_ilocked(proc, thread, /* sync = */false); in binder_wakeup_proc_ilocked()
1148 * The node was already added by another thread in binder_new_node()
1185 struct binder_thread *thread = container_of(target_list, in binder_inc_node_nilocked() local
1188 BUG_ON(&thread->todo != target_list); in binder_inc_node_nilocked()
1189 binder_enqueue_deferred_thread_work_ilocked(thread, in binder_inc_node_nilocked()
1404 * Return: the ref for node. It is possible that another thread
1746 * Another thread created the ref first so in binder_inc_ref_for_node()
1766 * binder_thread_dec_tmpref() - decrement thread->tmp_ref
1767 * @thread: thread to decrement
1769 * A thread needs to be kept alive while being used to create or
1771 * extract t->from from a binder_transaction and keep the thread
1774 * tmp_ref and free if appropriate (thread has been released
1777 static void binder_thread_dec_tmpref(struct binder_thread *thread) in binder_thread_dec_tmpref() argument
1781 * it cannot reach zero or thread->is_dead is false in binder_thread_dec_tmpref()
1783 binder_inner_proc_lock(thread->proc); in binder_thread_dec_tmpref()
1784 atomic_dec(&thread->tmp_ref); in binder_thread_dec_tmpref()
1785 if (thread->is_dead && !atomic_read(&thread->tmp_ref)) { in binder_thread_dec_tmpref()
1786 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1787 binder_free_thread(thread); in binder_thread_dec_tmpref()
1790 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1819 * binder_get_txn_from() - safely extract the "from" thread in transaction
1822 * Atomically return the "from" thread and increment the tmp_ref
1823 * count for the thread to ensure it stays alive until
1846 * to guarantee that the thread cannot be released while operating on it.
1962 "reply failed, no target thread at root\n"); in binder_send_failed_reply()
1967 "reply failed, no target thread -- retry %d\n", in binder_send_failed_reply()
2412 struct binder_thread *thread) in binder_translate_binder() argument
2415 struct binder_proc *proc = thread->proc; in binder_translate_binder()
2428 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2441 &thread->todo, &rdata); in binder_translate_binder()
2465 struct binder_thread *thread) in binder_translate_handle() argument
2467 struct binder_proc *proc = thread->proc; in binder_translate_handle()
2477 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2538 struct binder_thread *thread, in binder_translate_fd() argument
2541 struct binder_proc *proc = thread->proc; in binder_translate_fd()
2554 proc->pid, thread->pid, in binder_translate_fd()
2564 proc->pid, thread->pid, fd); in binder_translate_fd()
2577 * target thread. in binder_translate_fd()
2602 struct binder_thread *thread, in binder_translate_fd_array() argument
2607 struct binder_proc *proc = thread->proc; in binder_translate_fd_array()
2613 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2620 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2634 proc->pid, thread->pid); in binder_translate_fd_array()
2646 ret = binder_translate_fd(fd, offset, t, thread, in binder_translate_fd_array()
2655 struct binder_thread *thread, in binder_fixup_parent() argument
2664 struct binder_proc *proc = thread->proc; in binder_fixup_parent()
2678 proc->pid, thread->pid); in binder_fixup_parent()
2687 proc->pid, thread->pid); in binder_fixup_parent()
2695 proc->pid, thread->pid); in binder_fixup_parent()
2703 proc->pid, thread->pid); in binder_fixup_parent()
2714 * @thread: thread in @proc to send the transaction to (may be NULL)
2717 * to find a thread in the target process to handle the transaction and
2718 * wake it up. If no thread is found, the work is queued to the proc
2721 * If the @thread parameter is not NULL, the transaction is always queued
2722 * to the waitlist of that specific thread.
2725 * false if the target process or thread is dead
2729 struct binder_thread *thread) in binder_proc_transaction() argument
2738 BUG_ON(thread); in binder_proc_transaction()
2747 if (proc->is_dead || (thread && thread->is_dead)) { in binder_proc_transaction()
2753 if (!thread && !pending_async) in binder_proc_transaction()
2754 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2756 if (thread) in binder_proc_transaction()
2757 binder_enqueue_thread_work_ilocked(thread, &t->work); in binder_proc_transaction()
2764 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2815 struct binder_thread *thread, in binder_transaction() argument
2846 e->from_thread = thread->pid; in binder_transaction()
2854 in_reply_to = thread->transaction_stack; in binder_transaction()
2858 proc->pid, thread->pid); in binder_transaction()
2864 if (in_reply_to->to_thread != thread) { in binder_transaction()
2867 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
2880 thread->transaction_stack = in_reply_to->to_parent; in binder_transaction()
2893 proc->pid, thread->pid, in binder_transaction()
2928 proc->pid, thread->pid); in binder_transaction()
2944 proc->pid, thread->pid); in binder_transaction()
2975 w = list_first_entry_or_null(&thread->todo, in binder_transaction()
2981 * thread that has a transaction at the head of in binder_transaction()
2984 * thread from proc->waiting_threads to enqueue in binder_transaction()
2986 * todo list while the thread is on waiting_threads. in binder_transaction()
2988 …binder_user_error("%d:%d new transaction not allowed when there is a transaction on thread todo\n", in binder_transaction()
2989 proc->pid, thread->pid); in binder_transaction()
2997 if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) { in binder_transaction()
3000 tmp = thread->transaction_stack; in binder_transaction()
3001 if (tmp->to_thread != thread) { in binder_transaction()
3004 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
3062 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3071 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3079 t->from = thread; in binder_transaction()
3158 proc->pid, thread->pid); in binder_transaction()
3172 proc->pid, thread->pid); in binder_transaction()
3180 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3188 proc->pid, thread->pid, in binder_transaction()
3223 proc->pid, thread->pid, in binder_transaction()
3241 ret = binder_translate_binder(fp, t, thread); in binder_transaction()
3259 ret = binder_translate_handle(fp, t, thread); in binder_transaction()
3277 thread, in_reply_to); in binder_transaction()
3306 proc->pid, thread->pid); in binder_transaction()
3319 proc->pid, thread->pid); in binder_transaction()
3325 ret = binder_translate_fd_array(fda, parent, t, thread, in binder_transaction()
3345 proc->pid, thread->pid); in binder_transaction()
3359 proc->pid, thread->pid); in binder_transaction()
3372 ret = binder_fixup_parent(t, thread, bp, in binder_transaction()
3392 proc->pid, thread->pid, hdr->type); in binder_transaction()
3403 binder_enqueue_thread_work(thread, tcomplete); in binder_transaction()
3425 binder_enqueue_deferred_thread_work_ilocked(thread, tcomplete); in binder_transaction()
3427 t->from_parent = thread->transaction_stack; in binder_transaction()
3428 thread->transaction_stack = t; in binder_transaction()
3432 binder_pop_transaction_ilocked(thread, t); in binder_transaction()
3439 binder_enqueue_thread_work(thread, tcomplete); in binder_transaction()
3501 proc->pid, thread->pid, return_error, return_error_param, in binder_transaction()
3522 BUG_ON(thread->return_error.cmd != BR_OK); in binder_transaction()
3524 thread->return_error.cmd = BR_TRANSACTION_COMPLETE; in binder_transaction()
3525 binder_enqueue_thread_work(thread, &thread->return_error.work); in binder_transaction()
3528 thread->return_error.cmd = return_error; in binder_transaction()
3529 binder_enqueue_thread_work(thread, &thread->return_error.work); in binder_transaction()
3577 struct binder_thread *thread, in binder_thread_write() argument
3587 while (ptr < end && thread->return_error.cmd == BR_OK) { in binder_thread_write()
3597 atomic_inc(&thread->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
3622 proc->pid, thread->pid); in binder_thread_write()
3638 proc->pid, thread->pid, in binder_thread_write()
3658 proc->pid, thread->pid, debug_string, in binder_thread_write()
3664 proc->pid, thread->pid, debug_string, in binder_thread_write()
3685 proc->pid, thread->pid, in binder_thread_write()
3694 proc->pid, thread->pid, in binder_thread_write()
3706 proc->pid, thread->pid, in binder_thread_write()
3716 proc->pid, thread->pid, in binder_thread_write()
3729 proc->pid, thread->pid, in binder_thread_write()
3758 proc->pid, thread->pid, in binder_thread_write()
3763 proc->pid, thread->pid, in binder_thread_write()
3770 proc->pid, thread->pid, (u64)data_ptr, in binder_thread_write()
3784 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
3795 binder_transaction(proc, thread, &tr, in binder_thread_write()
3803 proc->pid, thread->pid); in binder_thread_write()
3805 if (thread->looper & BINDER_LOOPER_STATE_ENTERED) { in binder_thread_write()
3806 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
3808 proc->pid, thread->pid); in binder_thread_write()
3810 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
3812 proc->pid, thread->pid); in binder_thread_write()
3817 thread->looper |= BINDER_LOOPER_STATE_REGISTERED; in binder_thread_write()
3823 proc->pid, thread->pid); in binder_thread_write()
3824 if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) { in binder_thread_write()
3825 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
3827 proc->pid, thread->pid); in binder_thread_write()
3829 thread->looper |= BINDER_LOOPER_STATE_ENTERED; in binder_thread_write()
3834 proc->pid, thread->pid); in binder_thread_write()
3835 thread->looper |= BINDER_LOOPER_STATE_EXITED; in binder_thread_write()
3858 WARN_ON(thread->return_error.cmd != in binder_thread_write()
3860 thread->return_error.cmd = BR_ERROR; in binder_thread_write()
3862 thread, in binder_thread_write()
3863 &thread->return_error.work); in binder_thread_write()
3867 proc->pid, thread->pid); in binder_thread_write()
3875 proc->pid, thread->pid, in binder_thread_write()
3887 proc->pid, thread->pid, in binder_thread_write()
3899 proc->pid, thread->pid); in binder_thread_write()
3921 proc->pid, thread->pid); in binder_thread_write()
3929 proc->pid, thread->pid, in binder_thread_write()
3940 if (thread->looper & in binder_thread_write()
3944 thread, in binder_thread_write()
3986 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
3990 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
3997 if (thread->looper & in binder_thread_write()
4001 thread, &death->work); in binder_thread_write()
4014 proc->pid, thread->pid, cmd); in binder_thread_write()
4023 struct binder_thread *thread, uint32_t cmd) in binder_stat_br() argument
4029 atomic_inc(&thread->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
4034 struct binder_thread *thread, in binder_put_node_cmd() argument
4055 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
4057 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
4064 static int binder_wait_for_work(struct binder_thread *thread, in binder_wait_for_work() argument
4068 struct binder_proc *proc = thread->proc; in binder_wait_for_work()
4074 prepare_to_wait(&thread->wait, &wait, TASK_INTERRUPTIBLE); in binder_wait_for_work()
4075 if (binder_has_work_ilocked(thread, do_proc_work)) in binder_wait_for_work()
4078 list_add(&thread->waiting_thread_node, in binder_wait_for_work()
4083 list_del_init(&thread->waiting_thread_node); in binder_wait_for_work()
4089 finish_wait(&thread->wait, &wait); in binder_wait_for_work()
4162 struct binder_thread *thread, in binder_thread_read() argument
4181 wait_for_proc_work = binder_available_for_proc_work_ilocked(thread); in binder_thread_read()
4184 thread->looper |= BINDER_LOOPER_STATE_WAITING; in binder_thread_read()
4187 !!thread->transaction_stack, in binder_thread_read()
4188 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
4190 if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED | in binder_thread_read()
4192 …binder_user_error("%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER … in binder_thread_read()
4193 proc->pid, thread->pid, thread->looper); in binder_thread_read()
4201 if (!binder_has_work(thread, wait_for_proc_work)) in binder_thread_read()
4204 ret = binder_wait_for_work(thread, wait_for_proc_work); in binder_thread_read()
4207 thread->looper &= ~BINDER_LOOPER_STATE_WAITING; in binder_thread_read()
4223 if (!binder_worklist_empty_ilocked(&thread->todo)) in binder_thread_read()
4224 list = &thread->todo; in binder_thread_read()
4232 if (ptr - buffer == 4 && !thread->looper_need_return) in binder_thread_read()
4242 if (binder_worklist_empty_ilocked(&thread->todo)) in binder_thread_read()
4243 thread->process_todo = false; in binder_thread_read()
4262 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4273 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4276 proc->pid, thread->pid); in binder_thread_read()
4314 proc->pid, thread->pid, in binder_thread_read()
4326 * this thread frees while the other thread in binder_thread_read()
4337 proc, thread, &ptr, node_ptr, in binder_thread_read()
4342 proc, thread, &ptr, node_ptr, in binder_thread_read()
4347 proc, thread, &ptr, node_ptr, in binder_thread_read()
4352 proc, thread, &ptr, node_ptr, in binder_thread_read()
4358 proc->pid, thread->pid, in binder_thread_read()
4381 proc->pid, thread->pid, in binder_thread_read()
4402 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4409 proc->pid, thread->pid, w->type); in binder_thread_read()
4464 proc->pid, thread->pid, in binder_thread_read()
4473 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4512 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4515 proc->pid, thread->pid, in binder_thread_read()
4529 binder_inner_proc_lock(thread->proc); in binder_thread_read()
4530 t->to_parent = thread->transaction_stack; in binder_thread_read()
4531 t->to_thread = thread; in binder_thread_read()
4532 thread->transaction_stack = t; in binder_thread_read()
4533 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
4545 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
4547 (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | in binder_thread_read()
4549 /*spawn a new thread if we leave this out */) { in binder_thread_read()
4554 proc->pid, thread->pid); in binder_thread_read()
4557 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
4625 struct binder_thread *thread = NULL; in binder_get_thread_ilocked() local
4631 thread = rb_entry(parent, struct binder_thread, rb_node); in binder_get_thread_ilocked()
4633 if (current->pid < thread->pid) in binder_get_thread_ilocked()
4635 else if (current->pid > thread->pid) in binder_get_thread_ilocked()
4638 return thread; in binder_get_thread_ilocked()
4642 thread = new_thread; in binder_get_thread_ilocked()
4644 thread->proc = proc; in binder_get_thread_ilocked()
4645 thread->pid = current->pid; in binder_get_thread_ilocked()
4646 atomic_set(&thread->tmp_ref, 0); in binder_get_thread_ilocked()
4647 init_waitqueue_head(&thread->wait); in binder_get_thread_ilocked()
4648 INIT_LIST_HEAD(&thread->todo); in binder_get_thread_ilocked()
4649 rb_link_node(&thread->rb_node, parent, p); in binder_get_thread_ilocked()
4650 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
4651 thread->looper_need_return = true; in binder_get_thread_ilocked()
4652 thread->return_error.work.type = BINDER_WORK_RETURN_ERROR; in binder_get_thread_ilocked()
4653 thread->return_error.cmd = BR_OK; in binder_get_thread_ilocked()
4654 thread->reply_error.work.type = BINDER_WORK_RETURN_ERROR; in binder_get_thread_ilocked()
4655 thread->reply_error.cmd = BR_OK; in binder_get_thread_ilocked()
4657 return thread; in binder_get_thread_ilocked()
4662 struct binder_thread *thread; in binder_get_thread() local
4666 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
4668 if (!thread) { in binder_get_thread()
4669 new_thread = kzalloc(sizeof(*thread), GFP_KERNEL); in binder_get_thread()
4673 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
4675 if (thread != new_thread) in binder_get_thread()
4678 return thread; in binder_get_thread()
4698 static void binder_free_thread(struct binder_thread *thread) in binder_free_thread() argument
4700 BUG_ON(!list_empty(&thread->todo)); in binder_free_thread()
4702 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
4703 kfree(thread); in binder_free_thread()
4707 struct binder_thread *thread) in binder_thread_release() argument
4714 binder_inner_proc_lock(thread->proc); in binder_thread_release()
4717 * after we remove this thread from proc->threads. in binder_thread_release()
4719 * free the thread in binder_free_thread() in binder_thread_release()
4723 * take a ref on this thread to ensure it in binder_thread_release()
4726 atomic_inc(&thread->tmp_ref); in binder_thread_release()
4727 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
4728 t = thread->transaction_stack; in binder_thread_release()
4731 if (t->to_thread == thread) in binder_thread_release()
4736 thread->is_dead = true; in binder_thread_release()
4743 proc->pid, thread->pid, in binder_thread_release()
4745 (t->to_thread == thread) ? "in" : "out"); in binder_thread_release()
4747 if (t->to_thread == thread) { in binder_thread_release()
4755 } else if (t->from == thread) { in binder_thread_release()
4770 * If this thread used poll, make sure we remove the waitqueue in binder_thread_release()
4775 if ((thread->looper & BINDER_LOOPER_STATE_POLL) && in binder_thread_release()
4776 waitqueue_active(&thread->wait)) { in binder_thread_release()
4777 wake_up_poll(&thread->wait, EPOLLHUP | POLLFREE); in binder_thread_release()
4780 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
4788 if (thread->looper & BINDER_LOOPER_STATE_POLL) in binder_thread_release()
4793 binder_release_work(proc, &thread->todo); in binder_thread_release()
4794 binder_thread_dec_tmpref(thread); in binder_thread_release()
4802 struct binder_thread *thread = NULL; in binder_poll() local
4805 thread = binder_get_thread(proc); in binder_poll()
4806 if (!thread) in binder_poll()
4809 binder_inner_proc_lock(thread->proc); in binder_poll()
4810 thread->looper |= BINDER_LOOPER_STATE_POLL; in binder_poll()
4811 wait_for_proc_work = binder_available_for_proc_work_ilocked(thread); in binder_poll()
4813 binder_inner_proc_unlock(thread->proc); in binder_poll()
4815 poll_wait(filp, &thread->wait, wait); in binder_poll()
4817 if (binder_has_work(thread, wait_for_proc_work)) in binder_poll()
4825 struct binder_thread *thread) in binder_ioctl_write_read() argument
4843 proc->pid, thread->pid, in binder_ioctl_write_read()
4848 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
4861 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
4878 proc->pid, thread->pid, in binder_ioctl_write_read()
5002 struct binder_thread *thread; in binder_ioctl() local
5017 thread = binder_get_thread(proc); in binder_ioctl()
5018 if (thread == NULL) { in binder_ioctl()
5025 ret = binder_ioctl_write_read(filp, cmd, arg, thread); in binder_ioctl()
5061 proc->pid, thread->pid); in binder_ioctl()
5062 binder_thread_release(proc, thread); in binder_ioctl()
5063 thread = NULL; in binder_ioctl()
5122 if (thread) in binder_ioctl()
5123 thread->looper_need_return = false; in binder_ioctl()
5301 struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); in binder_deferred_flush() local
5303 thread->looper_need_return = true; in binder_deferred_flush()
5304 if (thread->looper & BINDER_LOOPER_STATE_WAITING) { in binder_deferred_flush()
5305 wake_up_interruptible(&thread->wait); in binder_deferred_flush()
5427 struct binder_thread *thread; in binder_deferred_release() local
5429 thread = rb_entry(n, struct binder_thread, rb_node); in binder_deferred_release()
5432 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
5610 struct binder_thread *thread, in print_binder_thread_ilocked() argument
5618 seq_printf(m, " thread %d: l %02x need_return %d tr %d\n", in print_binder_thread_ilocked()
5619 thread->pid, thread->looper, in print_binder_thread_ilocked()
5620 thread->looper_need_return, in print_binder_thread_ilocked()
5621 atomic_read(&thread->tmp_ref)); in print_binder_thread_ilocked()
5623 t = thread->transaction_stack; in print_binder_thread_ilocked()
5625 if (t->from == thread) { in print_binder_thread_ilocked()
5626 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5629 } else if (t->to_thread == thread) { in print_binder_thread_ilocked()
5630 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5634 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5639 list_for_each_entry(w, &thread->todo, entry) { in print_binder_thread_ilocked()
5640 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
5801 "thread",
5855 struct binder_thread *thread; in print_binder_proc_stats() local
5869 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()