Lines Matching refs:proc

111 BINDER_DEBUG_ENTRY(proc);
370 struct binder_proc *proc; member
454 struct binder_proc *proc; member
597 struct binder_proc *proc; member
647 #define binder_proc_lock(proc) _binder_proc_lock(proc, __LINE__) argument
649 _binder_proc_lock(struct binder_proc *proc, int line) in _binder_proc_lock() argument
653 spin_lock(&proc->outer_lock); in _binder_proc_lock()
664 _binder_proc_unlock(struct binder_proc *proc, int line) in _binder_proc_unlock() argument
668 spin_unlock(&proc->outer_lock); in _binder_proc_unlock()
677 #define binder_inner_proc_lock(proc) _binder_inner_proc_lock(proc, __LINE__) argument
679 _binder_inner_proc_lock(struct binder_proc *proc, int line) in _binder_inner_proc_lock() argument
683 spin_lock(&proc->inner_lock); in _binder_inner_proc_lock()
692 #define binder_inner_proc_unlock(proc) _binder_inner_proc_unlock(proc, __LINE__) argument
694 _binder_inner_proc_unlock(struct binder_proc *proc, int line) in _binder_inner_proc_unlock() argument
698 spin_unlock(&proc->inner_lock); in _binder_inner_proc_unlock()
745 if (node->proc) in _binder_node_inner_lock()
746 binder_inner_proc_lock(node->proc); in _binder_node_inner_lock()
759 struct binder_proc *proc = node->proc; in _binder_node_inner_unlock() local
763 if (proc) in _binder_node_inner_unlock()
764 binder_inner_proc_unlock(proc); in _binder_node_inner_unlock()
780 static bool binder_worklist_empty(struct binder_proc *proc, in binder_worklist_empty() argument
785 binder_inner_proc_lock(proc); in binder_worklist_empty()
787 binder_inner_proc_unlock(proc); in binder_worklist_empty()
858 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
860 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
878 binder_dequeue_work(struct binder_proc *proc, struct binder_work *work) in binder_dequeue_work() argument
880 binder_inner_proc_lock(proc); in binder_dequeue_work()
882 binder_inner_proc_unlock(proc); in binder_dequeue_work()
906 struct binder_proc *proc, in binder_dequeue_work_head() argument
911 binder_inner_proc_lock(proc); in binder_dequeue_work_head()
913 binder_inner_proc_unlock(proc); in binder_dequeue_work_head()
918 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
920 static void binder_free_proc(struct binder_proc *proc);
923 static int task_get_unused_fd_flags(struct binder_proc *proc, int flags) in task_get_unused_fd_flags() argument
929 mutex_lock(&proc->files_lock); in task_get_unused_fd_flags()
930 if (proc->files == NULL) { in task_get_unused_fd_flags()
934 if (!lock_task_sighand(proc->tsk, &irqs)) { in task_get_unused_fd_flags()
938 rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE); in task_get_unused_fd_flags()
939 unlock_task_sighand(proc->tsk, &irqs); in task_get_unused_fd_flags()
941 ret = __alloc_fd(proc->files, 0, rlim_cur, flags); in task_get_unused_fd_flags()
943 mutex_unlock(&proc->files_lock); in task_get_unused_fd_flags()
951 struct binder_proc *proc, unsigned int fd, struct file *file) in task_fd_install() argument
953 mutex_lock(&proc->files_lock); in task_fd_install()
954 if (proc->files) in task_fd_install()
955 __fd_install(proc->files, fd, file); in task_fd_install()
956 mutex_unlock(&proc->files_lock); in task_fd_install()
962 static long task_close_fd(struct binder_proc *proc, unsigned int fd) in task_close_fd() argument
966 mutex_lock(&proc->files_lock); in task_close_fd()
967 if (proc->files == NULL) { in task_close_fd()
971 retval = __close_fd(proc->files, fd); in task_close_fd()
979 mutex_unlock(&proc->files_lock); in task_close_fd()
989 !binder_worklist_empty_ilocked(&thread->proc->todo)); in binder_has_work_ilocked()
996 binder_inner_proc_lock(thread->proc); in binder_has_work()
998 binder_inner_proc_unlock(thread->proc); in binder_has_work()
1011 static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc, in binder_wakeup_poll_threads_ilocked() argument
1017 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_wakeup_poll_threads_ilocked()
1042 binder_select_thread_ilocked(struct binder_proc *proc) in binder_select_thread_ilocked() argument
1046 assert_spin_locked(&proc->inner_lock); in binder_select_thread_ilocked()
1047 thread = list_first_entry_or_null(&proc->waiting_threads, in binder_select_thread_ilocked()
1073 static void binder_wakeup_thread_ilocked(struct binder_proc *proc, in binder_wakeup_thread_ilocked() argument
1077 assert_spin_locked(&proc->inner_lock); in binder_wakeup_thread_ilocked()
1100 binder_wakeup_poll_threads_ilocked(proc, sync); in binder_wakeup_thread_ilocked()
1103 static void binder_wakeup_proc_ilocked(struct binder_proc *proc) in binder_wakeup_proc_ilocked() argument
1105 struct binder_thread *thread = binder_select_thread_ilocked(proc); in binder_wakeup_proc_ilocked()
1107 binder_wakeup_thread_ilocked(proc, thread, /* sync = */false); in binder_wakeup_proc_ilocked()
1128 static struct binder_node *binder_get_node_ilocked(struct binder_proc *proc, in binder_get_node_ilocked() argument
1131 struct rb_node *n = proc->nodes.rb_node; in binder_get_node_ilocked()
1134 assert_spin_locked(&proc->inner_lock); in binder_get_node_ilocked()
1156 static struct binder_node *binder_get_node(struct binder_proc *proc, in binder_get_node() argument
1161 binder_inner_proc_lock(proc); in binder_get_node()
1162 node = binder_get_node_ilocked(proc, ptr); in binder_get_node()
1163 binder_inner_proc_unlock(proc); in binder_get_node()
1168 struct binder_proc *proc, in binder_init_node_ilocked() argument
1172 struct rb_node **p = &proc->nodes.rb_node; in binder_init_node_ilocked()
1179 assert_spin_locked(&proc->inner_lock); in binder_init_node_ilocked()
1204 rb_insert_color(&node->rb_node, &proc->nodes); in binder_init_node_ilocked()
1206 node->proc = proc; in binder_init_node_ilocked()
1217 proc->pid, current->pid, node->debug_id, in binder_init_node_ilocked()
1223 static struct binder_node *binder_new_node(struct binder_proc *proc, in binder_new_node() argument
1231 binder_inner_proc_lock(proc); in binder_new_node()
1232 node = binder_init_node_ilocked(proc, new_node, fp); in binder_new_node()
1233 binder_inner_proc_unlock(proc); in binder_new_node()
1253 struct binder_proc *proc = node->proc; in binder_inc_node_nilocked() local
1256 if (proc) in binder_inc_node_nilocked()
1257 assert_spin_locked(&proc->inner_lock); in binder_inc_node_nilocked()
1262 !(node->proc && in binder_inc_node_nilocked()
1263 node == node->proc->context->binder_context_mgr_node && in binder_inc_node_nilocked()
1320 struct binder_proc *proc = node->proc; in binder_dec_node_nilocked() local
1323 if (proc) in binder_dec_node_nilocked()
1324 assert_spin_locked(&proc->inner_lock); in binder_dec_node_nilocked()
1340 if (proc && (node->has_strong_ref || node->has_weak_ref)) { in binder_dec_node_nilocked()
1342 binder_enqueue_work_ilocked(&node->work, &proc->todo); in binder_dec_node_nilocked()
1343 binder_wakeup_proc_ilocked(proc); in binder_dec_node_nilocked()
1348 if (proc) { in binder_dec_node_nilocked()
1350 rb_erase(&node->rb_node, &proc->nodes); in binder_dec_node_nilocked()
1414 if (node->proc) in binder_inc_node_tmpref()
1415 binder_inner_proc_lock(node->proc); in binder_inc_node_tmpref()
1419 if (node->proc) in binder_inc_node_tmpref()
1420 binder_inner_proc_unlock(node->proc); in binder_inc_node_tmpref()
1437 if (!node->proc) in binder_dec_node_tmpref()
1441 if (!node->proc) in binder_dec_node_tmpref()
1460 static struct binder_ref *binder_get_ref_olocked(struct binder_proc *proc, in binder_get_ref_olocked() argument
1463 struct rb_node *n = proc->refs_by_desc.rb_node; in binder_get_ref_olocked()
1502 struct binder_proc *proc, in binder_get_ref_for_node_olocked() argument
1506 struct binder_context *context = proc->context; in binder_get_ref_for_node_olocked()
1507 struct rb_node **p = &proc->refs_by_node.rb_node; in binder_get_ref_for_node_olocked()
1528 new_ref->proc = proc; in binder_get_ref_for_node_olocked()
1531 rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node); in binder_get_ref_for_node_olocked()
1534 for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { in binder_get_ref_for_node_olocked()
1541 p = &proc->refs_by_desc.rb_node; in binder_get_ref_for_node_olocked()
1554 rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); in binder_get_ref_for_node_olocked()
1561 proc->pid, new_ref->data.debug_id, new_ref->data.desc, in binder_get_ref_for_node_olocked()
1573 ref->proc->pid, ref->data.debug_id, ref->data.desc, in binder_cleanup_ref_olocked()
1576 rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); in binder_cleanup_ref_olocked()
1577 rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); in binder_cleanup_ref_olocked()
1601 ref->proc->pid, ref->data.debug_id, in binder_cleanup_ref_olocked()
1603 binder_dequeue_work(ref->proc, &ref->death->work); in binder_cleanup_ref_olocked()
1656 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1667 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1693 struct binder_proc *proc, in binder_get_node_from_ref() argument
1700 binder_proc_lock(proc); in binder_get_node_from_ref()
1701 ref = binder_get_ref_olocked(proc, desc, need_strong_ref); in binder_get_node_from_ref()
1712 binder_proc_unlock(proc); in binder_get_node_from_ref()
1717 binder_proc_unlock(proc); in binder_get_node_from_ref()
1749 static int binder_update_ref_for_handle(struct binder_proc *proc, in binder_update_ref_for_handle() argument
1757 binder_proc_lock(proc); in binder_update_ref_for_handle()
1758 ref = binder_get_ref_olocked(proc, desc, strong); in binder_update_ref_for_handle()
1770 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1777 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1792 static int binder_dec_ref_for_handle(struct binder_proc *proc, in binder_dec_ref_for_handle() argument
1795 return binder_update_ref_for_handle(proc, desc, false, strong, rdata); in binder_dec_ref_for_handle()
1812 static int binder_inc_ref_for_node(struct binder_proc *proc, in binder_inc_ref_for_node() argument
1822 binder_proc_lock(proc); in binder_inc_ref_for_node()
1823 ref = binder_get_ref_for_node_olocked(proc, node, NULL); in binder_inc_ref_for_node()
1825 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1829 binder_proc_lock(proc); in binder_inc_ref_for_node()
1830 ref = binder_get_ref_for_node_olocked(proc, node, new_ref); in binder_inc_ref_for_node()
1834 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1848 assert_spin_locked(&target_thread->proc->inner_lock); in binder_pop_transaction_ilocked()
1874 binder_inner_proc_lock(thread->proc); in binder_thread_dec_tmpref()
1877 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1881 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1896 static void binder_proc_dec_tmpref(struct binder_proc *proc) in binder_proc_dec_tmpref() argument
1898 binder_inner_proc_lock(proc); in binder_proc_dec_tmpref()
1899 proc->tmp_ref--; in binder_proc_dec_tmpref()
1900 if (proc->is_dead && RB_EMPTY_ROOT(&proc->threads) && in binder_proc_dec_tmpref()
1901 !proc->tmp_ref) { in binder_proc_dec_tmpref()
1902 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1903 binder_free_proc(proc); in binder_proc_dec_tmpref()
1906 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1951 binder_inner_proc_lock(from->proc); in binder_get_txn_from_and_acq_inner()
1956 binder_inner_proc_unlock(from->proc); in binder_get_txn_from_and_acq_inner()
1982 target_thread->proc->pid, in binder_send_failed_reply()
2002 binder_inner_proc_unlock(target_thread->proc); in binder_send_failed_reply()
2193 static void binder_transaction_buffer_release(struct binder_proc *proc, in binder_transaction_buffer_release() argument
2202 proc->pid, buffer->debug_id, in binder_transaction_buffer_release()
2231 node = binder_get_node(proc, fp->binder); in binder_transaction_buffer_release()
2251 ret = binder_dec_ref_for_handle(proc, fp->handle, in binder_transaction_buffer_release()
2270 task_close_fd(proc, fp->fd); in binder_transaction_buffer_release()
2301 &proc->alloc); in binder_transaction_buffer_release()
2318 task_close_fd(proc, fd_array[fd_index]); in binder_transaction_buffer_release()
2333 struct binder_proc *proc = thread->proc; in binder_translate_binder() local
2338 node = binder_get_node(proc, fp->binder); in binder_translate_binder()
2340 node = binder_new_node(proc, fp); in binder_translate_binder()
2346 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2352 if (security_binder_transfer_binder(proc->tsk, target_proc->tsk)) { in binder_translate_binder()
2385 struct binder_proc *proc = thread->proc; in binder_translate_handle() local
2391 node = binder_get_node_from_ref(proc, fp->handle, in binder_translate_handle()
2395 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2398 if (security_binder_transfer_binder(proc->tsk, target_proc->tsk)) { in binder_translate_handle()
2404 if (node->proc == target_proc) { in binder_translate_handle()
2411 if (node->proc) in binder_translate_handle()
2412 binder_inner_proc_lock(node->proc); in binder_translate_handle()
2416 if (node->proc) in binder_translate_handle()
2417 binder_inner_proc_unlock(node->proc); in binder_translate_handle()
2455 struct binder_proc *proc = thread->proc; in binder_translate_fd() local
2468 proc->pid, thread->pid, in binder_translate_fd()
2478 proc->pid, thread->pid, fd); in binder_translate_fd()
2482 ret = security_binder_transfer_file(proc->tsk, target_proc->tsk, file); in binder_translate_fd()
2518 struct binder_proc *proc = thread->proc; in binder_translate_fd_array() local
2524 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2531 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2543 proc->pid, thread->pid); in binder_translate_fd_array()
2577 struct binder_proc *proc = thread->proc; in binder_fixup_parent() local
2586 proc->pid, thread->pid); in binder_fixup_parent()
2595 proc->pid, thread->pid); in binder_fixup_parent()
2603 proc->pid, thread->pid); in binder_fixup_parent()
2632 struct binder_proc *proc, in binder_proc_transaction() argument
2650 binder_inner_proc_lock(proc); in binder_proc_transaction()
2652 if (proc->is_dead || (thread && thread->is_dead)) { in binder_proc_transaction()
2653 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2659 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2664 binder_enqueue_work_ilocked(&t->work, &proc->todo); in binder_proc_transaction()
2669 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2671 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2706 if (node->proc) { in binder_get_node_refs_for_txn()
2710 node->proc->tmp_ref++; in binder_get_node_refs_for_txn()
2711 *procp = node->proc; in binder_get_node_refs_for_txn()
2719 static void binder_transaction(struct binder_proc *proc, in binder_transaction() argument
2740 struct binder_context *context = proc->context; in binder_transaction()
2746 e->from_proc = proc->pid; in binder_transaction()
2751 e->context_name = proc->context->name; in binder_transaction()
2754 binder_inner_proc_lock(proc); in binder_transaction()
2757 binder_inner_proc_unlock(proc); in binder_transaction()
2759 proc->pid, thread->pid); in binder_transaction()
2768 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
2774 binder_inner_proc_unlock(proc); in binder_transaction()
2782 binder_inner_proc_unlock(proc); in binder_transaction()
2792 proc->pid, thread->pid, in binder_transaction()
2796 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
2804 target_proc = target_thread->proc; in binder_transaction()
2806 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
2818 binder_proc_lock(proc); in binder_transaction()
2819 ref = binder_get_ref_olocked(proc, tr->target.handle, in binder_transaction()
2827 proc->pid, thread->pid); in binder_transaction()
2830 binder_proc_unlock(proc); in binder_transaction()
2841 if (target_node && target_proc == proc) { in binder_transaction()
2843 proc->pid, thread->pid); in binder_transaction()
2859 if (security_binder_transaction(proc->tsk, in binder_transaction()
2866 binder_inner_proc_lock(proc); in binder_transaction()
2874 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
2879 binder_inner_proc_unlock(proc); in binder_transaction()
2890 if (from && from->proc == target_proc) { in binder_transaction()
2900 binder_inner_proc_unlock(proc); in binder_transaction()
2931 proc->pid, thread->pid, t->debug_id, in binder_transaction()
2940 proc->pid, thread->pid, t->debug_id, in binder_transaction()
2951 t->sender_euid = task_euid(proc->tsk); in binder_transaction()
2986 proc->pid, thread->pid); in binder_transaction()
2995 proc->pid, thread->pid); in binder_transaction()
3003 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3011 proc->pid, thread->pid, in binder_transaction()
3028 proc->pid, thread->pid, (u64)*offp, in binder_transaction()
3090 proc->pid, thread->pid); in binder_transaction()
3101 proc->pid, thread->pid); in binder_transaction()
3126 proc->pid, thread->pid); in binder_transaction()
3136 proc->pid, thread->pid); in binder_transaction()
3163 proc->pid, thread->pid, hdr->type); in binder_transaction()
3188 binder_inner_proc_lock(proc); in binder_transaction()
3200 binder_inner_proc_unlock(proc); in binder_transaction()
3202 binder_inner_proc_lock(proc); in binder_transaction()
3204 binder_inner_proc_unlock(proc); in binder_transaction()
3230 binder_dequeue_work(proc, tcomplete); in binder_transaction()
3265 proc->pid, thread->pid, return_error, return_error_param, in binder_transaction()
3297 static int binder_thread_write(struct binder_proc *proc, in binder_thread_write() argument
3303 struct binder_context *context = proc->context; in binder_thread_write()
3317 atomic_inc(&proc->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
3342 proc, ctx_mgr_node, in binder_thread_write()
3348 proc, target, increment, strong, in binder_thread_write()
3352 proc->pid, thread->pid, in binder_thread_write()
3372 proc->pid, thread->pid, debug_string, in binder_thread_write()
3378 proc->pid, thread->pid, debug_string, in binder_thread_write()
3396 node = binder_get_node(proc, node_ptr); in binder_thread_write()
3399 proc->pid, thread->pid, in binder_thread_write()
3408 proc->pid, thread->pid, in binder_thread_write()
3420 proc->pid, thread->pid, in binder_thread_write()
3430 proc->pid, thread->pid, in binder_thread_write()
3443 proc->pid, thread->pid, in binder_thread_write()
3466 buffer = binder_alloc_prepare_to_free(&proc->alloc, in binder_thread_write()
3470 proc->pid, thread->pid, (u64)data_ptr); in binder_thread_write()
3475 proc->pid, thread->pid, (u64)data_ptr); in binder_thread_write()
3480 proc->pid, thread->pid, (u64)data_ptr, in binder_thread_write()
3495 BUG_ON(buf_node->proc != proc); in binder_thread_write()
3502 w, &proc->todo); in binder_thread_write()
3503 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
3508 binder_transaction_buffer_release(proc, buffer, NULL); in binder_thread_write()
3509 binder_alloc_free_buf(&proc->alloc, buffer); in binder_thread_write()
3520 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
3531 binder_transaction(proc, thread, &tr, in binder_thread_write()
3539 proc->pid, thread->pid); in binder_thread_write()
3540 binder_inner_proc_lock(proc); in binder_thread_write()
3544 proc->pid, thread->pid); in binder_thread_write()
3545 } else if (proc->requested_threads == 0) { in binder_thread_write()
3548 proc->pid, thread->pid); in binder_thread_write()
3550 proc->requested_threads--; in binder_thread_write()
3551 proc->requested_threads_started++; in binder_thread_write()
3554 binder_inner_proc_unlock(proc); in binder_thread_write()
3559 proc->pid, thread->pid); in binder_thread_write()
3563 proc->pid, thread->pid); in binder_thread_write()
3570 proc->pid, thread->pid); in binder_thread_write()
3603 proc->pid, thread->pid); in binder_thread_write()
3607 binder_proc_lock(proc); in binder_thread_write()
3608 ref = binder_get_ref_olocked(proc, target, false); in binder_thread_write()
3611 proc->pid, thread->pid, in binder_thread_write()
3616 binder_proc_unlock(proc); in binder_thread_write()
3623 proc->pid, thread->pid, in binder_thread_write()
3635 proc->pid, thread->pid); in binder_thread_write()
3637 binder_proc_unlock(proc); in binder_thread_write()
3645 if (ref->node->proc == NULL) { in binder_thread_write()
3648 binder_inner_proc_lock(proc); in binder_thread_write()
3650 &ref->death->work, &proc->todo); in binder_thread_write()
3651 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
3652 binder_inner_proc_unlock(proc); in binder_thread_write()
3657 proc->pid, thread->pid); in binder_thread_write()
3659 binder_proc_unlock(proc); in binder_thread_write()
3665 proc->pid, thread->pid, in binder_thread_write()
3669 binder_proc_unlock(proc); in binder_thread_write()
3673 binder_inner_proc_lock(proc); in binder_thread_write()
3685 &proc->todo); in binder_thread_write()
3687 proc); in binder_thread_write()
3693 binder_inner_proc_unlock(proc); in binder_thread_write()
3696 binder_proc_unlock(proc); in binder_thread_write()
3707 binder_inner_proc_lock(proc); in binder_thread_write()
3708 list_for_each_entry(w, &proc->delivered_death, in binder_thread_write()
3722 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
3726 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
3727 binder_inner_proc_unlock(proc); in binder_thread_write()
3741 &proc->todo); in binder_thread_write()
3742 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
3745 binder_inner_proc_unlock(proc); in binder_thread_write()
3750 proc->pid, thread->pid, cmd); in binder_thread_write()
3758 static void binder_stat_br(struct binder_proc *proc, in binder_stat_br() argument
3764 atomic_inc(&proc->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
3769 static int binder_put_node_cmd(struct binder_proc *proc, in binder_put_node_cmd() argument
3791 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
3793 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
3804 struct binder_proc *proc = thread->proc; in binder_wait_for_work() local
3808 binder_inner_proc_lock(proc); in binder_wait_for_work()
3815 &proc->waiting_threads); in binder_wait_for_work()
3816 binder_inner_proc_unlock(proc); in binder_wait_for_work()
3818 binder_inner_proc_lock(proc); in binder_wait_for_work()
3826 binder_inner_proc_unlock(proc); in binder_wait_for_work()
3832 static int binder_thread_read(struct binder_proc *proc, in binder_thread_read() argument
3851 binder_inner_proc_lock(proc); in binder_thread_read()
3853 binder_inner_proc_unlock(proc); in binder_thread_read()
3859 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
3864 proc->pid, thread->pid, thread->looper); in binder_thread_read()
3868 binder_set_nice(proc->default_priority); in binder_thread_read()
3891 binder_inner_proc_lock(proc); in binder_thread_read()
3894 else if (!binder_worklist_empty_ilocked(&proc->todo) && in binder_thread_read()
3896 list = &proc->todo; in binder_thread_read()
3898 binder_inner_proc_unlock(proc); in binder_thread_read()
3907 binder_inner_proc_unlock(proc); in binder_thread_read()
3916 binder_inner_proc_unlock(proc); in binder_thread_read()
3924 binder_inner_proc_unlock(proc); in binder_thread_read()
3931 binder_stat_br(proc, thread, cmd); in binder_thread_read()
3934 binder_inner_proc_unlock(proc); in binder_thread_read()
3940 binder_stat_br(proc, thread, cmd); in binder_thread_read()
3943 proc->pid, thread->pid); in binder_thread_read()
3957 BUG_ON(proc != node->proc); in binder_thread_read()
3983 proc->pid, thread->pid, in binder_thread_read()
3987 rb_erase(&node->rb_node, &proc->nodes); in binder_thread_read()
3988 binder_inner_proc_unlock(proc); in binder_thread_read()
4002 binder_inner_proc_unlock(proc); in binder_thread_read()
4006 proc, thread, &ptr, node_ptr, in binder_thread_read()
4011 proc, thread, &ptr, node_ptr, in binder_thread_read()
4016 proc, thread, &ptr, node_ptr, in binder_thread_read()
4021 proc, thread, &ptr, node_ptr, in binder_thread_read()
4027 proc->pid, thread->pid, in binder_thread_read()
4050 proc->pid, thread->pid, in binder_thread_read()
4056 binder_inner_proc_unlock(proc); in binder_thread_read()
4061 w, &proc->delivered_death); in binder_thread_read()
4062 binder_inner_proc_unlock(proc); in binder_thread_read()
4071 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4105 struct task_struct *sender = t_from->proc->tsk; in binder_thread_read()
4117 binder_alloc_get_user_buffer_offset(&proc->alloc)); in binder_thread_read()
4144 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4147 proc->pid, thread->pid, in binder_thread_read()
4150 t->debug_id, t_from ? t_from->proc->pid : 0, in binder_thread_read()
4159 binder_inner_proc_lock(thread->proc); in binder_thread_read()
4163 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
4173 binder_inner_proc_lock(proc); in binder_thread_read()
4174 if (proc->requested_threads == 0 && in binder_thread_read()
4175 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
4176 proc->requested_threads_started < proc->max_threads && in binder_thread_read()
4180 proc->requested_threads++; in binder_thread_read()
4181 binder_inner_proc_unlock(proc); in binder_thread_read()
4184 proc->pid, thread->pid); in binder_thread_read()
4187 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
4189 binder_inner_proc_unlock(proc); in binder_thread_read()
4193 static void binder_release_work(struct binder_proc *proc, in binder_release_work() argument
4199 w = binder_dequeue_work_head(proc, list); in binder_release_work()
4247 struct binder_proc *proc, struct binder_thread *new_thread) in binder_get_thread_ilocked() argument
4251 struct rb_node **p = &proc->threads.rb_node; in binder_get_thread_ilocked()
4268 thread->proc = proc; in binder_get_thread_ilocked()
4274 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
4284 static struct binder_thread *binder_get_thread(struct binder_proc *proc) in binder_get_thread() argument
4289 binder_inner_proc_lock(proc); in binder_get_thread()
4290 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
4291 binder_inner_proc_unlock(proc); in binder_get_thread()
4296 binder_inner_proc_lock(proc); in binder_get_thread()
4297 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
4298 binder_inner_proc_unlock(proc); in binder_get_thread()
4305 static void binder_free_proc(struct binder_proc *proc) in binder_free_proc() argument
4307 BUG_ON(!list_empty(&proc->todo)); in binder_free_proc()
4308 BUG_ON(!list_empty(&proc->delivered_death)); in binder_free_proc()
4309 binder_alloc_deferred_release(&proc->alloc); in binder_free_proc()
4310 put_task_struct(proc->tsk); in binder_free_proc()
4312 kfree(proc); in binder_free_proc()
4319 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
4323 static int binder_thread_release(struct binder_proc *proc, in binder_thread_release() argument
4331 binder_inner_proc_lock(thread->proc); in binder_thread_release()
4338 proc->tmp_ref++; in binder_thread_release()
4344 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
4358 proc->pid, thread->pid, in binder_thread_release()
4391 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
4404 binder_release_work(proc, &thread->todo); in binder_thread_release()
4412 struct binder_proc *proc = filp->private_data; in binder_poll() local
4416 thread = binder_get_thread(proc); in binder_poll()
4420 binder_inner_proc_lock(thread->proc); in binder_poll()
4424 binder_inner_proc_unlock(thread->proc); in binder_poll()
4439 struct binder_proc *proc = filp->private_data; in binder_ioctl_write_read() local
4454 proc->pid, thread->pid, in binder_ioctl_write_read()
4459 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
4472 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
4477 binder_inner_proc_lock(proc); in binder_ioctl_write_read()
4478 if (!binder_worklist_empty_ilocked(&proc->todo)) in binder_ioctl_write_read()
4479 binder_wakeup_proc_ilocked(proc); in binder_ioctl_write_read()
4480 binder_inner_proc_unlock(proc); in binder_ioctl_write_read()
4489 proc->pid, thread->pid, in binder_ioctl_write_read()
4503 struct binder_proc *proc = filp->private_data; in binder_ioctl_set_ctx_mgr() local
4504 struct binder_context *context = proc->context; in binder_ioctl_set_ctx_mgr()
4514 ret = security_binder_set_context_mgr(proc->tsk); in binder_ioctl_set_ctx_mgr()
4529 new_node = binder_new_node(proc, NULL); in binder_ioctl_set_ctx_mgr()
4547 static int binder_ioctl_get_node_debug_info(struct binder_proc *proc, in binder_ioctl_get_node_debug_info() argument
4555 binder_inner_proc_lock(proc); in binder_ioctl_get_node_debug_info()
4556 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in binder_ioctl_get_node_debug_info()
4567 binder_inner_proc_unlock(proc); in binder_ioctl_get_node_debug_info()
4575 struct binder_proc *proc = filp->private_data; in binder_ioctl() local
4583 binder_selftest_alloc(&proc->alloc); in binder_ioctl()
4591 thread = binder_get_thread(proc); in binder_ioctl()
4611 binder_inner_proc_lock(proc); in binder_ioctl()
4612 proc->max_threads = max_threads; in binder_ioctl()
4613 binder_inner_proc_unlock(proc); in binder_ioctl()
4623 proc->pid, thread->pid); in binder_ioctl()
4624 binder_thread_release(proc, thread); in binder_ioctl()
4649 ret = binder_ioctl_get_node_debug_info(proc, &info); in binder_ioctl()
4669 pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); in binder_ioctl()
4677 struct binder_proc *proc = vma->vm_private_data; in binder_vma_open() local
4681 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_open()
4688 struct binder_proc *proc = vma->vm_private_data; in binder_vma_close() local
4692 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_close()
4695 binder_alloc_vma_close(&proc->alloc); in binder_vma_close()
4696 binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES); in binder_vma_close()
4713 struct binder_proc *proc = filp->private_data; in binder_mmap() local
4716 if (proc->tsk != current->group_leader) in binder_mmap()
4724 __func__, proc->pid, vma->vm_start, vma->vm_end, in binder_mmap()
4737 vma->vm_private_data = proc; in binder_mmap()
4739 ret = binder_alloc_mmap_handler(&proc->alloc, vma); in binder_mmap()
4742 mutex_lock(&proc->files_lock); in binder_mmap()
4743 proc->files = get_files_struct(current); in binder_mmap()
4744 mutex_unlock(&proc->files_lock); in binder_mmap()
4749 proc->pid, vma->vm_start, vma->vm_end, failure_string, ret); in binder_mmap()
4755 struct binder_proc *proc; in binder_open() local
4761 proc = kzalloc(sizeof(*proc), GFP_KERNEL); in binder_open()
4762 if (proc == NULL) in binder_open()
4764 spin_lock_init(&proc->inner_lock); in binder_open()
4765 spin_lock_init(&proc->outer_lock); in binder_open()
4767 proc->tsk = current->group_leader; in binder_open()
4768 mutex_init(&proc->files_lock); in binder_open()
4769 INIT_LIST_HEAD(&proc->todo); in binder_open()
4770 proc->default_priority = task_nice(current); in binder_open()
4773 proc->context = &binder_dev->context; in binder_open()
4774 binder_alloc_init(&proc->alloc); in binder_open()
4777 proc->pid = current->group_leader->pid; in binder_open()
4778 INIT_LIST_HEAD(&proc->delivered_death); in binder_open()
4779 INIT_LIST_HEAD(&proc->waiting_threads); in binder_open()
4780 filp->private_data = proc; in binder_open()
4783 hlist_add_head(&proc->proc_node, &binder_procs); in binder_open()
4789 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
4797 proc->debugfs_entry = debugfs_create_file(strbuf, 0444, in binder_open()
4799 (void *)(unsigned long)proc->pid, in binder_open()
4808 struct binder_proc *proc = filp->private_data; in binder_flush() local
4810 binder_defer_work(proc, BINDER_DEFERRED_FLUSH); in binder_flush()
4815 static void binder_deferred_flush(struct binder_proc *proc) in binder_deferred_flush() argument
4820 binder_inner_proc_lock(proc); in binder_deferred_flush()
4821 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_deferred_flush()
4830 binder_inner_proc_unlock(proc); in binder_deferred_flush()
4833 "binder_flush: %d woke %d threads\n", proc->pid, in binder_deferred_flush()
4839 struct binder_proc *proc = filp->private_data; in binder_release() local
4841 debugfs_remove(proc->debugfs_entry); in binder_release()
4842 binder_defer_work(proc, BINDER_DEFERRED_RELEASE); in binder_release()
4851 struct binder_proc *proc = node->proc; in binder_node_release() local
4853 binder_release_work(proc, &node->async_todo); in binder_node_release()
4856 binder_inner_proc_lock(proc); in binder_node_release()
4863 binder_inner_proc_unlock(proc); in binder_node_release()
4870 node->proc = NULL; in binder_node_release()
4873 binder_inner_proc_unlock(proc); in binder_node_release()
4887 binder_inner_proc_lock(ref->proc); in binder_node_release()
4889 binder_inner_proc_unlock(ref->proc); in binder_node_release()
4898 &ref->proc->todo); in binder_node_release()
4899 binder_wakeup_proc_ilocked(ref->proc); in binder_node_release()
4900 binder_inner_proc_unlock(ref->proc); in binder_node_release()
4912 static void binder_deferred_release(struct binder_proc *proc) in binder_deferred_release() argument
4914 struct binder_context *context = proc->context; in binder_deferred_release()
4918 BUG_ON(proc->files); in binder_deferred_release()
4921 hlist_del(&proc->proc_node); in binder_deferred_release()
4926 context->binder_context_mgr_node->proc == proc) { in binder_deferred_release()
4929 __func__, proc->pid); in binder_deferred_release()
4933 binder_inner_proc_lock(proc); in binder_deferred_release()
4938 proc->tmp_ref++; in binder_deferred_release()
4940 proc->is_dead = true; in binder_deferred_release()
4943 while ((n = rb_first(&proc->threads))) { in binder_deferred_release()
4947 binder_inner_proc_unlock(proc); in binder_deferred_release()
4949 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
4950 binder_inner_proc_lock(proc); in binder_deferred_release()
4955 while ((n = rb_first(&proc->nodes))) { in binder_deferred_release()
4966 rb_erase(&node->rb_node, &proc->nodes); in binder_deferred_release()
4967 binder_inner_proc_unlock(proc); in binder_deferred_release()
4969 binder_inner_proc_lock(proc); in binder_deferred_release()
4971 binder_inner_proc_unlock(proc); in binder_deferred_release()
4974 binder_proc_lock(proc); in binder_deferred_release()
4975 while ((n = rb_first(&proc->refs_by_desc))) { in binder_deferred_release()
4981 binder_proc_unlock(proc); in binder_deferred_release()
4983 binder_proc_lock(proc); in binder_deferred_release()
4985 binder_proc_unlock(proc); in binder_deferred_release()
4987 binder_release_work(proc, &proc->todo); in binder_deferred_release()
4988 binder_release_work(proc, &proc->delivered_death); in binder_deferred_release()
4992 __func__, proc->pid, threads, nodes, incoming_refs, in binder_deferred_release()
4995 binder_proc_dec_tmpref(proc); in binder_deferred_release()
5000 struct binder_proc *proc; in binder_deferred_func() local
5008 proc = hlist_entry(binder_deferred_list.first, in binder_deferred_func()
5010 hlist_del_init(&proc->deferred_work_node); in binder_deferred_func()
5011 defer = proc->deferred_work; in binder_deferred_func()
5012 proc->deferred_work = 0; in binder_deferred_func()
5014 proc = NULL; in binder_deferred_func()
5021 mutex_lock(&proc->files_lock); in binder_deferred_func()
5022 files = proc->files; in binder_deferred_func()
5024 proc->files = NULL; in binder_deferred_func()
5025 mutex_unlock(&proc->files_lock); in binder_deferred_func()
5029 binder_deferred_flush(proc); in binder_deferred_func()
5032 binder_deferred_release(proc); /* frees proc */ in binder_deferred_func()
5036 } while (proc); in binder_deferred_func()
5041 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) in binder_defer_work() argument
5044 proc->deferred_work |= defer; in binder_defer_work()
5045 if (hlist_unhashed(&proc->deferred_work_node)) { in binder_defer_work()
5046 hlist_add_head(&proc->deferred_work_node, in binder_defer_work()
5054 struct binder_proc *proc, in print_binder_transaction_ilocked() argument
5066 t->from ? t->from->proc->pid : 0, in print_binder_transaction_ilocked()
5073 if (proc != to_proc) { in print_binder_transaction_ilocked()
5094 struct binder_proc *proc, in print_binder_work_ilocked() argument
5106 m, proc, transaction_prefix, t); in print_binder_work_ilocked()
5156 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5160 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5164 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5170 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
5196 seq_printf(m, " %d", ref->proc->pid); in print_binder_node_nilocked()
5199 if (node->proc) { in print_binder_node_nilocked()
5201 print_binder_work_ilocked(m, node->proc, " ", in print_binder_node_nilocked()
5212 ref->node->proc ? "" : "dead ", in print_binder_ref_olocked()
5219 struct binder_proc *proc, int print_all) in print_binder_proc() argument
5227 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc()
5228 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc()
5231 binder_inner_proc_lock(proc); in print_binder_proc()
5232 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) in print_binder_proc()
5236 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in print_binder_proc()
5246 binder_inner_proc_unlock(proc); in print_binder_proc()
5253 binder_inner_proc_lock(proc); in print_binder_proc()
5255 binder_inner_proc_unlock(proc); in print_binder_proc()
5260 binder_proc_lock(proc); in print_binder_proc()
5261 for (n = rb_first(&proc->refs_by_desc); in print_binder_proc()
5267 binder_proc_unlock(proc); in print_binder_proc()
5269 binder_alloc_print_allocated(m, &proc->alloc); in print_binder_proc()
5270 binder_inner_proc_lock(proc); in print_binder_proc()
5271 list_for_each_entry(w, &proc->todo, entry) in print_binder_proc()
5272 print_binder_work_ilocked(m, proc, " ", in print_binder_proc()
5274 list_for_each_entry(w, &proc->delivered_death, entry) { in print_binder_proc()
5278 binder_inner_proc_unlock(proc); in print_binder_proc()
5379 struct binder_proc *proc) in print_binder_proc_stats() argument
5386 binder_alloc_get_free_async_space(&proc->alloc); in print_binder_proc_stats()
5388 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc_stats()
5389 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc_stats()
5392 binder_inner_proc_lock(proc); in print_binder_proc_stats()
5393 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) in print_binder_proc_stats()
5396 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()
5402 " free async space %zd\n", proc->requested_threads, in print_binder_proc_stats()
5403 proc->requested_threads_started, proc->max_threads, in print_binder_proc_stats()
5407 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) in print_binder_proc_stats()
5409 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
5414 binder_proc_lock(proc); in print_binder_proc_stats()
5415 for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { in print_binder_proc_stats()
5422 binder_proc_unlock(proc); in print_binder_proc_stats()
5425 count = binder_alloc_get_allocated_count(&proc->alloc); in print_binder_proc_stats()
5428 binder_alloc_print_pages(m, &proc->alloc); in print_binder_proc_stats()
5431 binder_inner_proc_lock(proc); in print_binder_proc_stats()
5432 list_for_each_entry(w, &proc->todo, entry) { in print_binder_proc_stats()
5436 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
5439 print_binder_stats(m, " ", &proc->stats); in print_binder_proc_stats()
5445 struct binder_proc *proc; in binder_state_show() local
5475 hlist_for_each_entry(proc, &binder_procs, proc_node) in binder_state_show()
5476 print_binder_proc(m, proc, 1); in binder_state_show()
5484 struct binder_proc *proc; in binder_stats_show() local
5491 hlist_for_each_entry(proc, &binder_procs, proc_node) in binder_stats_show()
5492 print_binder_proc_stats(m, proc); in binder_stats_show()
5500 struct binder_proc *proc; in binder_transactions_show() local
5504 hlist_for_each_entry(proc, &binder_procs, proc_node) in binder_transactions_show()
5505 print_binder_proc(m, proc, 0); in binder_transactions_show()