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()
487 if (thread->looper & BINDER_LOOPER_STATE_POLL && in binder_enqueue_thread_work_ilocked()
488 thread->pid == current->pid && !thread->process_todo) in binder_enqueue_thread_work_ilocked()
489 wake_up_interruptible_sync(&thread->wait); in binder_enqueue_thread_work_ilocked()
491 thread->process_todo = true; in binder_enqueue_thread_work_ilocked()
495 * binder_enqueue_thread_work() - Add an item to the thread work list
496 * @thread: thread to queue work to
499 * Adds the work to the todo list of the thread, and enables processing
503 binder_enqueue_thread_work(struct binder_thread *thread, in binder_enqueue_thread_work() argument
506 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
507 binder_enqueue_thread_work_ilocked(thread, work); in binder_enqueue_thread_work()
508 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
546 static void binder_free_thread(struct binder_thread *thread);
550 static bool binder_has_work_ilocked(struct binder_thread *thread, in binder_has_work_ilocked() argument
553 return thread->process_todo || in binder_has_work_ilocked()
554 thread->looper_need_return || in binder_has_work_ilocked()
556 !binder_worklist_empty_ilocked(&thread->proc->todo)); in binder_has_work_ilocked()
559 static bool binder_has_work(struct binder_thread *thread, bool do_proc_work) in binder_has_work() argument
563 binder_inner_proc_lock(thread->proc); in binder_has_work()
564 has_work = binder_has_work_ilocked(thread, do_proc_work); in binder_has_work()
565 binder_inner_proc_unlock(thread->proc); in binder_has_work()
570 static bool binder_available_for_proc_work_ilocked(struct binder_thread *thread) in binder_available_for_proc_work_ilocked() argument
572 return !thread->transaction_stack && in binder_available_for_proc_work_ilocked()
573 binder_worklist_empty_ilocked(&thread->todo) && in binder_available_for_proc_work_ilocked()
574 (thread->looper & (BINDER_LOOPER_STATE_ENTERED | in binder_available_for_proc_work_ilocked()
582 struct binder_thread *thread; in binder_wakeup_poll_threads_ilocked() local
585 thread = rb_entry(n, struct binder_thread, rb_node); in binder_wakeup_poll_threads_ilocked()
586 if (thread->looper & BINDER_LOOPER_STATE_POLL && in binder_wakeup_poll_threads_ilocked()
587 binder_available_for_proc_work_ilocked(thread)) { in binder_wakeup_poll_threads_ilocked()
589 wake_up_interruptible_sync(&thread->wait); in binder_wakeup_poll_threads_ilocked()
591 wake_up_interruptible(&thread->wait); in binder_wakeup_poll_threads_ilocked()
597 * binder_select_thread_ilocked() - selects a thread for doing proc work.
598 * @proc: process to select a thread from
600 * Note that calling this function moves the thread off the waiting_threads
602 * signal. Therefore, callers *should* always wake up the thread this function
605 * Return: If there's a thread currently waiting for process work,
606 * returns that thread. Otherwise returns NULL.
611 struct binder_thread *thread; in binder_select_thread_ilocked() local
614 thread = list_first_entry_or_null(&proc->waiting_threads, in binder_select_thread_ilocked()
618 if (thread) in binder_select_thread_ilocked()
619 list_del_init(&thread->waiting_thread_node); in binder_select_thread_ilocked()
621 return thread; in binder_select_thread_ilocked()
625 * binder_wakeup_thread_ilocked() - wakes up a thread for doing proc work.
626 * @proc: process to wake up a thread in
627 * @thread: specific thread to wake-up (may be NULL)
630 * This function wakes up a thread in the @proc process.
631 * The caller may provide a specific thread to wake-up in
632 * the @thread parameter. If @thread is NULL, this function
636 * should first call binder_select_thread() to find a thread
637 * to handle the work (if they don't have a thread already),
638 * and pass the result into the @thread parameter.
641 struct binder_thread *thread, in binder_wakeup_thread_ilocked() argument
646 if (thread) { in binder_wakeup_thread_ilocked()
648 wake_up_interruptible_sync(&thread->wait); in binder_wakeup_thread_ilocked()
650 wake_up_interruptible(&thread->wait); in binder_wakeup_thread_ilocked()
654 /* Didn't find a thread waiting for proc work; this can happen in binder_wakeup_thread_ilocked()
664 * a thread that called into (e)poll is handling non-binder in binder_wakeup_thread_ilocked()
672 struct binder_thread *thread = binder_select_thread_ilocked(proc); in binder_wakeup_proc_ilocked() local
674 binder_wakeup_thread_ilocked(proc, thread, /* sync = */false); in binder_wakeup_proc_ilocked()
804 * The node was already added by another thread in binder_new_node()
841 struct binder_thread *thread = container_of(target_list, in binder_inc_node_nilocked() local
844 BUG_ON(&thread->todo != target_list); in binder_inc_node_nilocked()
845 binder_enqueue_deferred_thread_work_ilocked(thread, in binder_inc_node_nilocked()
1060 * Return: the ref for node. It is possible that another thread
1414 * Another thread created the ref first so in binder_inc_ref_for_node()
1434 * binder_thread_dec_tmpref() - decrement thread->tmp_ref
1435 * @thread: thread to decrement
1437 * A thread needs to be kept alive while being used to create or
1439 * extract t->from from a binder_transaction and keep the thread
1442 * tmp_ref and free if appropriate (thread has been released
1445 static void binder_thread_dec_tmpref(struct binder_thread *thread) in binder_thread_dec_tmpref() argument
1449 * it cannot reach zero or thread->is_dead is false in binder_thread_dec_tmpref()
1451 binder_inner_proc_lock(thread->proc); in binder_thread_dec_tmpref()
1452 atomic_dec(&thread->tmp_ref); in binder_thread_dec_tmpref()
1453 if (thread->is_dead && !atomic_read(&thread->tmp_ref)) { in binder_thread_dec_tmpref()
1454 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1455 binder_free_thread(thread); in binder_thread_dec_tmpref()
1458 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1487 * binder_get_txn_from() - safely extract the "from" thread in transaction
1490 * Atomically return the "from" thread and increment the tmp_ref
1491 * count for the thread to ensure it stays alive until
1514 * to guarantee that the thread cannot be released while operating on it.
1654 "reply failed, no target thread at root\n"); in binder_send_failed_reply()
1659 "reply failed, no target thread -- retry %d\n", in binder_send_failed_reply()
1946 struct binder_thread *thread, in binder_transaction_buffer_release() argument
2106 * Need to make sure the thread goes in binder_transaction_buffer_release()
2110 if (thread) in binder_transaction_buffer_release()
2111 thread->looper_need_return = true; in binder_transaction_buffer_release()
2125 struct binder_thread *thread, in binder_release_entire_buffer() argument
2134 binder_transaction_buffer_release(proc, thread, buffer, in binder_release_entire_buffer()
2140 struct binder_thread *thread) in binder_translate_binder() argument
2143 struct binder_proc *proc = thread->proc; in binder_translate_binder()
2156 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2169 &thread->todo, &rdata); in binder_translate_binder()
2193 struct binder_thread *thread) in binder_translate_handle() argument
2195 struct binder_proc *proc = thread->proc; in binder_translate_handle()
2205 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2266 struct binder_thread *thread, in binder_translate_fd() argument
2269 struct binder_proc *proc = thread->proc; in binder_translate_fd()
2282 proc->pid, thread->pid, in binder_translate_fd()
2292 proc->pid, thread->pid, fd); in binder_translate_fd()
2305 * target thread. in binder_translate_fd()
2577 struct binder_thread *thread, in binder_translate_fd_array() argument
2583 struct binder_proc *proc = thread->proc; in binder_translate_fd_array()
2592 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2599 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2617 proc->pid, thread->pid); in binder_translate_fd_array()
2631 ret = binder_translate_fd(fd, offset, t, thread, in binder_translate_fd_array()
2641 struct binder_thread *thread, in binder_fixup_parent() argument
2650 struct binder_proc *proc = thread->proc; in binder_fixup_parent()
2664 proc->pid, thread->pid); in binder_fixup_parent()
2673 proc->pid, thread->pid); in binder_fixup_parent()
2681 proc->pid, thread->pid); in binder_fixup_parent()
2744 * @thread: thread in @proc to send the transaction to (may be NULL)
2747 * to find a thread in the target process to handle the transaction and
2748 * wake it up. If no thread is found, the work is queued to the proc
2751 * If the @thread parameter is not NULL, the transaction is always queued
2752 * to the waitlist of that specific thread.
2755 * BR_DEAD_REPLY if the target process or thread is dead
2756 * BR_FROZEN_REPLY if the target process or thread is frozen and
2763 struct binder_thread *thread) in binder_proc_transaction() argument
2774 BUG_ON(thread); in binder_proc_transaction()
2789 (thread && thread->is_dead)) { in binder_proc_transaction()
2795 if (!thread && !pending_async) in binder_proc_transaction()
2796 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2798 if (thread) { in binder_proc_transaction()
2799 binder_enqueue_thread_work_ilocked(thread, &t->work); in binder_proc_transaction()
2818 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2907 struct binder_thread *thread, in binder_transaction() argument
2946 e->from_thread = thread->pid; in binder_transaction()
2953 binder_set_extended_error(&thread->ee, t_debug_id, BR_OK, 0); in binder_transaction()
2958 in_reply_to = thread->transaction_stack; in binder_transaction()
2962 proc->pid, thread->pid); in binder_transaction()
2968 if (in_reply_to->to_thread != thread) { in binder_transaction()
2971 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
2984 thread->transaction_stack = in_reply_to->to_parent; in binder_transaction()
2992 thread->pid, proc->pid); in binder_transaction()
2999 proc->pid, thread->pid, in binder_transaction()
3034 proc->pid, thread->pid, tr->target.handle); in binder_transaction()
3050 proc->pid, thread->pid); in binder_transaction()
3059 thread->pid, proc->pid); in binder_transaction()
3070 thread->pid, proc->pid); in binder_transaction()
3079 thread->pid, proc->pid); in binder_transaction()
3087 w = list_first_entry_or_null(&thread->todo, in binder_transaction()
3093 * thread that has a transaction at the head of in binder_transaction()
3096 * thread from proc->waiting_threads to enqueue in binder_transaction()
3098 * todo list while the thread is on waiting_threads. in binder_transaction()
3100 …binder_user_error("%d:%d new transaction not allowed when there is a transaction on thread todo\n", in binder_transaction()
3101 proc->pid, thread->pid); in binder_transaction()
3109 if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) { in binder_transaction()
3112 tmp = thread->transaction_stack; in binder_transaction()
3113 if (tmp->to_thread != thread) { in binder_transaction()
3116 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
3152 thread->pid, proc->pid); in binder_transaction()
3165 thread->pid, proc->pid); in binder_transaction()
3179 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3188 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3196 t->from = thread; in binder_transaction()
3200 t->from_tid = thread->pid; in binder_transaction()
3216 thread->pid, proc->pid); in binder_transaction()
3226 thread->pid, proc->pid); in binder_transaction()
3288 proc->pid, thread->pid); in binder_transaction()
3296 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3304 proc->pid, thread->pid, in binder_transaction()
3332 thread->pid, proc->pid); in binder_transaction()
3351 proc->pid, thread->pid); in binder_transaction()
3361 proc->pid, thread->pid, in binder_transaction()
3384 ret = binder_translate_binder(fp, t, thread); in binder_transaction()
3392 thread->pid, proc->pid); in binder_transaction()
3404 ret = binder_translate_handle(fp, t, thread); in binder_transaction()
3411 thread->pid, proc->pid); in binder_transaction()
3424 thread, in_reply_to); in binder_transaction()
3433 thread->pid, proc->pid); in binder_transaction()
3457 proc->pid, thread->pid); in binder_transaction()
3470 proc->pid, thread->pid); in binder_transaction()
3485 proc->pid, thread->pid, in binder_transaction()
3496 thread, in_reply_to); in binder_transaction()
3504 thread->pid, proc->pid); in binder_transaction()
3522 proc->pid, thread->pid); in binder_transaction()
3533 thread->pid, proc->pid); in binder_transaction()
3546 thread, bp, in binder_transaction()
3557 thread->pid, proc->pid); in binder_transaction()
3568 proc->pid, thread->pid, hdr->type); in binder_transaction()
3582 proc->pid, thread->pid); in binder_transaction()
3593 proc->pid, thread->pid); in binder_transaction()
3606 binder_enqueue_thread_work(thread, tcomplete); in binder_transaction()
3630 binder_enqueue_deferred_thread_work_ilocked(thread, tcomplete); in binder_transaction()
3632 t->from_parent = thread->transaction_stack; in binder_transaction()
3633 thread->transaction_stack = t; in binder_transaction()
3639 binder_pop_transaction_ilocked(thread, t); in binder_transaction()
3654 binder_enqueue_thread_work(thread, tcomplete); in binder_transaction()
3673 binder_txn_error("%d:%d dead process or thread\n", in binder_transaction()
3674 thread->pid, proc->pid); in binder_transaction()
3717 proc->pid, thread->pid, reply ? "reply" : in binder_transaction()
3747 BUG_ON(thread->return_error.cmd != BR_OK); in binder_transaction()
3751 thread->return_error.cmd = BR_TRANSACTION_COMPLETE; in binder_transaction()
3752 binder_enqueue_thread_work(thread, &thread->return_error.work); in binder_transaction()
3756 binder_set_extended_error(&thread->ee, t_debug_id, in binder_transaction()
3759 thread->return_error.cmd = return_error; in binder_transaction()
3760 binder_enqueue_thread_work(thread, &thread->return_error.work); in binder_transaction()
3777 struct binder_thread *thread, in binder_free_buf() argument
3806 binder_release_entire_buffer(proc, thread, buffer, is_failure); in binder_free_buf()
3811 struct binder_thread *thread, in binder_thread_write() argument
3821 while (ptr < end && thread->return_error.cmd == BR_OK) { in binder_thread_write()
3831 atomic_inc(&thread->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
3857 proc->pid, thread->pid); in binder_thread_write()
3873 proc->pid, thread->pid, in binder_thread_write()
3893 proc->pid, thread->pid, debug_string, in binder_thread_write()
3899 proc->pid, thread->pid, debug_string, in binder_thread_write()
3920 proc->pid, thread->pid, in binder_thread_write()
3929 proc->pid, thread->pid, in binder_thread_write()
3941 proc->pid, thread->pid, in binder_thread_write()
3951 proc->pid, thread->pid, in binder_thread_write()
3964 proc->pid, thread->pid, in binder_thread_write()
3993 proc->pid, thread->pid, in binder_thread_write()
3998 proc->pid, thread->pid, in binder_thread_write()
4005 proc->pid, thread->pid, (u64)data_ptr, in binder_thread_write()
4008 binder_free_buf(proc, thread, buffer, false); in binder_thread_write()
4019 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
4030 binder_transaction(proc, thread, &tr, in binder_thread_write()
4038 proc->pid, thread->pid); in binder_thread_write()
4040 if (thread->looper & BINDER_LOOPER_STATE_ENTERED) { in binder_thread_write()
4041 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
4043 proc->pid, thread->pid); in binder_thread_write()
4045 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
4047 proc->pid, thread->pid); in binder_thread_write()
4052 thread->looper |= BINDER_LOOPER_STATE_REGISTERED; in binder_thread_write()
4058 proc->pid, thread->pid); in binder_thread_write()
4059 if (thread->looper & BINDER_LOOPER_STATE_REGISTERED) { in binder_thread_write()
4060 thread->looper |= BINDER_LOOPER_STATE_INVALID; in binder_thread_write()
4062 proc->pid, thread->pid); in binder_thread_write()
4064 thread->looper |= BINDER_LOOPER_STATE_ENTERED; in binder_thread_write()
4069 proc->pid, thread->pid); in binder_thread_write()
4070 thread->looper |= BINDER_LOOPER_STATE_EXITED; in binder_thread_write()
4093 WARN_ON(thread->return_error.cmd != in binder_thread_write()
4095 thread->return_error.cmd = BR_ERROR; in binder_thread_write()
4097 thread, in binder_thread_write()
4098 &thread->return_error.work); in binder_thread_write()
4102 proc->pid, thread->pid); in binder_thread_write()
4110 proc->pid, thread->pid, in binder_thread_write()
4122 proc->pid, thread->pid, in binder_thread_write()
4134 proc->pid, thread->pid); in binder_thread_write()
4156 proc->pid, thread->pid); in binder_thread_write()
4164 proc->pid, thread->pid, in binder_thread_write()
4175 if (thread->looper & in binder_thread_write()
4179 thread, in binder_thread_write()
4221 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
4225 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
4232 if (thread->looper & in binder_thread_write()
4236 thread, &death->work); in binder_thread_write()
4249 proc->pid, thread->pid, cmd); in binder_thread_write()
4258 struct binder_thread *thread, uint32_t cmd) in binder_stat_br() argument
4264 atomic_inc(&thread->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
4269 struct binder_thread *thread, in binder_put_node_cmd() argument
4290 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
4292 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
4299 static int binder_wait_for_work(struct binder_thread *thread, in binder_wait_for_work() argument
4303 struct binder_proc *proc = thread->proc; in binder_wait_for_work()
4308 prepare_to_wait(&thread->wait, &wait, TASK_INTERRUPTIBLE|TASK_FREEZABLE); in binder_wait_for_work()
4309 if (binder_has_work_ilocked(thread, do_proc_work)) in binder_wait_for_work()
4312 list_add(&thread->waiting_thread_node, in binder_wait_for_work()
4317 list_del_init(&thread->waiting_thread_node); in binder_wait_for_work()
4323 finish_wait(&thread->wait, &wait); in binder_wait_for_work()
4384 struct binder_thread *thread, in binder_thread_read() argument
4403 wait_for_proc_work = binder_available_for_proc_work_ilocked(thread); in binder_thread_read()
4406 thread->looper |= BINDER_LOOPER_STATE_WAITING; in binder_thread_read()
4409 !!thread->transaction_stack, in binder_thread_read()
4410 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
4412 if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED | in binder_thread_read()
4414 …binder_user_error("%d:%d ERROR: Thread waiting for process work before calling BC_REGISTER_LOOPER … in binder_thread_read()
4415 proc->pid, thread->pid, thread->looper); in binder_thread_read()
4423 if (!binder_has_work(thread, wait_for_proc_work)) in binder_thread_read()
4426 ret = binder_wait_for_work(thread, wait_for_proc_work); in binder_thread_read()
4429 thread->looper &= ~BINDER_LOOPER_STATE_WAITING; in binder_thread_read()
4445 if (!binder_worklist_empty_ilocked(&thread->todo)) in binder_thread_read()
4446 list = &thread->todo; in binder_thread_read()
4454 if (ptr - buffer == 4 && !thread->looper_need_return) in binder_thread_read()
4464 if (binder_worklist_empty_ilocked(&thread->todo)) in binder_thread_read()
4465 thread->process_todo = false; in binder_thread_read()
4484 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4503 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4506 proc->pid, thread->pid); in binder_thread_read()
4544 proc->pid, thread->pid, in binder_thread_read()
4556 * this thread frees while the other thread in binder_thread_read()
4567 proc, thread, &ptr, node_ptr, in binder_thread_read()
4572 proc, thread, &ptr, node_ptr, in binder_thread_read()
4577 proc, thread, &ptr, node_ptr, in binder_thread_read()
4582 proc, thread, &ptr, node_ptr, in binder_thread_read()
4588 proc->pid, thread->pid, in binder_thread_read()
4611 proc->pid, thread->pid, in binder_thread_read()
4632 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4639 proc->pid, thread->pid, w->type); in binder_thread_read()
4691 binder_free_buf(proc, thread, buffer, true); in binder_thread_read()
4694 proc->pid, thread->pid, in binder_thread_read()
4703 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4742 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4745 proc->pid, thread->pid, in binder_thread_read()
4759 binder_inner_proc_lock(thread->proc); in binder_thread_read()
4760 t->to_parent = thread->transaction_stack; in binder_thread_read()
4761 t->to_thread = thread; in binder_thread_read()
4762 thread->transaction_stack = t; in binder_thread_read()
4763 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
4775 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
4777 (thread->looper & (BINDER_LOOPER_STATE_REGISTERED | in binder_thread_read()
4779 /*spawn a new thread if we leave this out */) { in binder_thread_read()
4784 proc->pid, thread->pid); in binder_thread_read()
4787 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
4857 struct binder_thread *thread = NULL; in binder_get_thread_ilocked() local
4863 thread = rb_entry(parent, struct binder_thread, rb_node); in binder_get_thread_ilocked()
4865 if (current->pid < thread->pid) in binder_get_thread_ilocked()
4867 else if (current->pid > thread->pid) in binder_get_thread_ilocked()
4870 return thread; in binder_get_thread_ilocked()
4874 thread = new_thread; in binder_get_thread_ilocked()
4876 thread->proc = proc; in binder_get_thread_ilocked()
4877 thread->pid = current->pid; in binder_get_thread_ilocked()
4878 atomic_set(&thread->tmp_ref, 0); in binder_get_thread_ilocked()
4879 init_waitqueue_head(&thread->wait); in binder_get_thread_ilocked()
4880 INIT_LIST_HEAD(&thread->todo); in binder_get_thread_ilocked()
4881 rb_link_node(&thread->rb_node, parent, p); in binder_get_thread_ilocked()
4882 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
4883 thread->looper_need_return = true; in binder_get_thread_ilocked()
4884 thread->return_error.work.type = BINDER_WORK_RETURN_ERROR; in binder_get_thread_ilocked()
4885 thread->return_error.cmd = BR_OK; in binder_get_thread_ilocked()
4886 thread->reply_error.work.type = BINDER_WORK_RETURN_ERROR; in binder_get_thread_ilocked()
4887 thread->reply_error.cmd = BR_OK; in binder_get_thread_ilocked()
4888 thread->ee.command = BR_OK; in binder_get_thread_ilocked()
4890 return thread; in binder_get_thread_ilocked()
4895 struct binder_thread *thread; in binder_get_thread() local
4899 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
4901 if (!thread) { in binder_get_thread()
4902 new_thread = kzalloc(sizeof(*thread), GFP_KERNEL); in binder_get_thread()
4906 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
4908 if (thread != new_thread) in binder_get_thread()
4911 return thread; in binder_get_thread()
4935 static void binder_free_thread(struct binder_thread *thread) in binder_free_thread() argument
4937 BUG_ON(!list_empty(&thread->todo)); in binder_free_thread()
4939 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
4940 kfree(thread); in binder_free_thread()
4944 struct binder_thread *thread) in binder_thread_release() argument
4951 binder_inner_proc_lock(thread->proc); in binder_thread_release()
4954 * after we remove this thread from proc->threads. in binder_thread_release()
4956 * free the thread in binder_free_thread() in binder_thread_release()
4960 * take a ref on this thread to ensure it in binder_thread_release()
4963 atomic_inc(&thread->tmp_ref); in binder_thread_release()
4964 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
4965 t = thread->transaction_stack; in binder_thread_release()
4968 if (t->to_thread == thread) in binder_thread_release()
4973 thread->is_dead = true; in binder_thread_release()
4980 proc->pid, thread->pid, in binder_thread_release()
4982 (t->to_thread == thread) ? "in" : "out"); in binder_thread_release()
4984 if (t->to_thread == thread) { in binder_thread_release()
4985 thread->proc->outstanding_txns--; in binder_thread_release()
4993 } else if (t->from == thread) { in binder_thread_release()
5008 * If this thread used poll, make sure we remove the waitqueue from any in binder_thread_release()
5011 if (thread->looper & BINDER_LOOPER_STATE_POLL) in binder_thread_release()
5012 wake_up_pollfree(&thread->wait); in binder_thread_release()
5014 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
5023 if (thread->looper & BINDER_LOOPER_STATE_POLL) in binder_thread_release()
5028 binder_release_work(proc, &thread->todo); in binder_thread_release()
5029 binder_thread_dec_tmpref(thread); in binder_thread_release()
5037 struct binder_thread *thread = NULL; in binder_poll() local
5040 thread = binder_get_thread(proc); in binder_poll()
5041 if (!thread) in binder_poll()
5044 binder_inner_proc_lock(thread->proc); in binder_poll()
5045 thread->looper |= BINDER_LOOPER_STATE_POLL; in binder_poll()
5046 wait_for_proc_work = binder_available_for_proc_work_ilocked(thread); in binder_poll()
5048 binder_inner_proc_unlock(thread->proc); in binder_poll()
5050 poll_wait(filp, &thread->wait, wait); in binder_poll()
5052 if (binder_has_work(thread, wait_for_proc_work)) in binder_poll()
5059 struct binder_thread *thread) in binder_ioctl_write_read() argument
5072 proc->pid, thread->pid, in binder_ioctl_write_read()
5077 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
5090 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
5107 proc->pid, thread->pid, in binder_ioctl_write_read()
5230 struct binder_thread *thread; in binder_txns_pending_ilocked() local
5236 thread = rb_entry(n, struct binder_thread, rb_node); in binder_txns_pending_ilocked()
5237 if (thread->transaction_stack) in binder_txns_pending_ilocked()
5321 static int binder_ioctl_get_extended_error(struct binder_thread *thread, in binder_ioctl_get_extended_error() argument
5326 binder_inner_proc_lock(thread->proc); in binder_ioctl_get_extended_error()
5327 ee = thread->ee; in binder_ioctl_get_extended_error()
5328 binder_set_extended_error(&thread->ee, 0, BR_OK, 0); in binder_ioctl_get_extended_error()
5329 binder_inner_proc_unlock(thread->proc); in binder_ioctl_get_extended_error()
5341 struct binder_thread *thread; in binder_ioctl() local
5355 thread = binder_get_thread(proc); in binder_ioctl()
5356 if (thread == NULL) { in binder_ioctl()
5363 ret = binder_ioctl_write_read(filp, arg, thread); in binder_ioctl()
5399 proc->pid, thread->pid); in binder_ioctl()
5400 binder_thread_release(proc, thread); in binder_ioctl()
5401 thread = NULL; in binder_ioctl()
5541 ret = binder_ioctl_get_extended_error(thread, ubuf); in binder_ioctl()
5551 if (thread) in binder_ioctl()
5552 thread->looper_need_return = false; in binder_ioctl()
5731 struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); in binder_deferred_flush() local
5733 thread->looper_need_return = true; in binder_deferred_flush()
5734 if (thread->looper & BINDER_LOOPER_STATE_WAITING) { in binder_deferred_flush()
5735 wake_up_interruptible(&thread->wait); in binder_deferred_flush()
5860 struct binder_thread *thread; in binder_deferred_release() local
5862 thread = rb_entry(n, struct binder_thread, rb_node); in binder_deferred_release()
5865 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
6045 struct binder_thread *thread, in print_binder_thread_ilocked() argument
6053 seq_printf(m, " thread %d: l %02x need_return %d tr %d\n", in print_binder_thread_ilocked()
6054 thread->pid, thread->looper, in print_binder_thread_ilocked()
6055 thread->looper_need_return, in print_binder_thread_ilocked()
6056 atomic_read(&thread->tmp_ref)); in print_binder_thread_ilocked()
6058 t = thread->transaction_stack; in print_binder_thread_ilocked()
6060 if (t->from == thread) { in print_binder_thread_ilocked()
6061 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6064 } else if (t->to_thread == thread) { in print_binder_thread_ilocked()
6065 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6069 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6074 list_for_each_entry(w, &thread->todo, entry) { in print_binder_thread_ilocked()
6075 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
6239 "thread",
6293 struct binder_thread *thread; in print_binder_proc_stats() local
6307 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()