Lines Matching refs:proc
93 DEFINE_SHOW_ATTRIBUTE(proc);
314 struct binder_proc *proc; member
399 struct binder_proc *proc; member
538 struct binder_proc *proc; member
627 #define binder_proc_lock(proc) _binder_proc_lock(proc, __LINE__) argument
629 _binder_proc_lock(struct binder_proc *proc, int line) in _binder_proc_lock() argument
630 __acquires(&proc->outer_lock) in _binder_proc_lock()
634 spin_lock(&proc->outer_lock); in _binder_proc_lock()
645 _binder_proc_unlock(struct binder_proc *proc, int line) in _binder_proc_unlock() argument
646 __releases(&proc->outer_lock) in _binder_proc_unlock()
650 spin_unlock(&proc->outer_lock); in _binder_proc_unlock()
659 #define binder_inner_proc_lock(proc) _binder_inner_proc_lock(proc, __LINE__) argument
661 _binder_inner_proc_lock(struct binder_proc *proc, int line) in _binder_inner_proc_lock() argument
662 __acquires(&proc->inner_lock) in _binder_inner_proc_lock()
666 spin_lock(&proc->inner_lock); in _binder_inner_proc_lock()
675 #define binder_inner_proc_unlock(proc) _binder_inner_proc_unlock(proc, __LINE__) argument
677 _binder_inner_proc_unlock(struct binder_proc *proc, int line) in _binder_inner_proc_unlock() argument
678 __releases(&proc->inner_lock) in _binder_inner_proc_unlock()
682 spin_unlock(&proc->inner_lock); in _binder_inner_proc_unlock()
727 __acquires(&node->lock) __acquires(&node->proc->inner_lock) in _binder_node_inner_lock()
732 if (node->proc) in _binder_node_inner_lock()
733 binder_inner_proc_lock(node->proc); in _binder_node_inner_lock()
736 __acquire(&node->proc->inner_lock); in _binder_node_inner_lock()
748 __releases(&node->lock) __releases(&node->proc->inner_lock) in _binder_node_inner_unlock()
750 struct binder_proc *proc = node->proc; in _binder_node_inner_unlock() local
754 if (proc) in _binder_node_inner_unlock()
755 binder_inner_proc_unlock(proc); in _binder_node_inner_unlock()
758 __release(&node->proc->inner_lock); in _binder_node_inner_unlock()
774 static bool binder_worklist_empty(struct binder_proc *proc, in binder_worklist_empty() argument
779 binder_inner_proc_lock(proc); in binder_worklist_empty()
781 binder_inner_proc_unlock(proc); in binder_worklist_empty()
854 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
856 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
874 binder_dequeue_work(struct binder_proc *proc, struct binder_work *work) in binder_dequeue_work() argument
876 binder_inner_proc_lock(proc); in binder_dequeue_work()
878 binder_inner_proc_unlock(proc); in binder_dequeue_work()
902 struct binder_proc *proc, in binder_dequeue_work_head() argument
907 binder_inner_proc_lock(proc); in binder_dequeue_work_head()
909 binder_inner_proc_unlock(proc); in binder_dequeue_work_head()
914 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
916 static void binder_free_proc(struct binder_proc *proc);
925 !binder_worklist_empty_ilocked(&thread->proc->todo)); in binder_has_work_ilocked()
932 binder_inner_proc_lock(thread->proc); in binder_has_work()
934 binder_inner_proc_unlock(thread->proc); in binder_has_work()
947 static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc, in binder_wakeup_poll_threads_ilocked() argument
953 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_wakeup_poll_threads_ilocked()
978 binder_select_thread_ilocked(struct binder_proc *proc) in binder_select_thread_ilocked() argument
982 assert_spin_locked(&proc->inner_lock); in binder_select_thread_ilocked()
983 thread = list_first_entry_or_null(&proc->waiting_threads, in binder_select_thread_ilocked()
1009 static void binder_wakeup_thread_ilocked(struct binder_proc *proc, in binder_wakeup_thread_ilocked() argument
1013 assert_spin_locked(&proc->inner_lock); in binder_wakeup_thread_ilocked()
1036 binder_wakeup_poll_threads_ilocked(proc, sync); in binder_wakeup_thread_ilocked()
1039 static void binder_wakeup_proc_ilocked(struct binder_proc *proc) in binder_wakeup_proc_ilocked() argument
1041 struct binder_thread *thread = binder_select_thread_ilocked(proc); in binder_wakeup_proc_ilocked()
1043 binder_wakeup_thread_ilocked(proc, thread, /* sync = */false); in binder_wakeup_proc_ilocked()
1064 static struct binder_node *binder_get_node_ilocked(struct binder_proc *proc, in binder_get_node_ilocked() argument
1067 struct rb_node *n = proc->nodes.rb_node; in binder_get_node_ilocked()
1070 assert_spin_locked(&proc->inner_lock); in binder_get_node_ilocked()
1092 static struct binder_node *binder_get_node(struct binder_proc *proc, in binder_get_node() argument
1097 binder_inner_proc_lock(proc); in binder_get_node()
1098 node = binder_get_node_ilocked(proc, ptr); in binder_get_node()
1099 binder_inner_proc_unlock(proc); in binder_get_node()
1104 struct binder_proc *proc, in binder_init_node_ilocked() argument
1108 struct rb_node **p = &proc->nodes.rb_node; in binder_init_node_ilocked()
1115 assert_spin_locked(&proc->inner_lock); in binder_init_node_ilocked()
1140 rb_insert_color(&node->rb_node, &proc->nodes); in binder_init_node_ilocked()
1142 node->proc = proc; in binder_init_node_ilocked()
1154 proc->pid, current->pid, node->debug_id, in binder_init_node_ilocked()
1160 static struct binder_node *binder_new_node(struct binder_proc *proc, in binder_new_node() argument
1168 binder_inner_proc_lock(proc); in binder_new_node()
1169 node = binder_init_node_ilocked(proc, new_node, fp); in binder_new_node()
1170 binder_inner_proc_unlock(proc); in binder_new_node()
1190 struct binder_proc *proc = node->proc; in binder_inc_node_nilocked() local
1193 if (proc) in binder_inc_node_nilocked()
1194 assert_spin_locked(&proc->inner_lock); in binder_inc_node_nilocked()
1199 !(node->proc && in binder_inc_node_nilocked()
1200 node == node->proc->context->binder_context_mgr_node && in binder_inc_node_nilocked()
1250 struct binder_proc *proc = node->proc; in binder_dec_node_nilocked() local
1253 if (proc) in binder_dec_node_nilocked()
1254 assert_spin_locked(&proc->inner_lock); in binder_dec_node_nilocked()
1270 if (proc && (node->has_strong_ref || node->has_weak_ref)) { in binder_dec_node_nilocked()
1272 binder_enqueue_work_ilocked(&node->work, &proc->todo); in binder_dec_node_nilocked()
1273 binder_wakeup_proc_ilocked(proc); in binder_dec_node_nilocked()
1278 if (proc) { in binder_dec_node_nilocked()
1280 rb_erase(&node->rb_node, &proc->nodes); in binder_dec_node_nilocked()
1344 if (node->proc) in binder_inc_node_tmpref()
1345 binder_inner_proc_lock(node->proc); in binder_inc_node_tmpref()
1349 if (node->proc) in binder_inc_node_tmpref()
1350 binder_inner_proc_unlock(node->proc); in binder_inc_node_tmpref()
1367 if (!node->proc) in binder_dec_node_tmpref()
1373 if (!node->proc) in binder_dec_node_tmpref()
1394 static struct binder_ref *binder_get_ref_olocked(struct binder_proc *proc, in binder_get_ref_olocked() argument
1397 struct rb_node *n = proc->refs_by_desc.rb_node; in binder_get_ref_olocked()
1436 struct binder_proc *proc, in binder_get_ref_for_node_olocked() argument
1440 struct binder_context *context = proc->context; in binder_get_ref_for_node_olocked()
1441 struct rb_node **p = &proc->refs_by_node.rb_node; in binder_get_ref_for_node_olocked()
1462 new_ref->proc = proc; in binder_get_ref_for_node_olocked()
1465 rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node); in binder_get_ref_for_node_olocked()
1468 for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { in binder_get_ref_for_node_olocked()
1475 p = &proc->refs_by_desc.rb_node; in binder_get_ref_for_node_olocked()
1488 rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); in binder_get_ref_for_node_olocked()
1495 proc->pid, new_ref->data.debug_id, new_ref->data.desc, in binder_get_ref_for_node_olocked()
1507 ref->proc->pid, ref->data.debug_id, ref->data.desc, in binder_cleanup_ref_olocked()
1510 rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); in binder_cleanup_ref_olocked()
1511 rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); in binder_cleanup_ref_olocked()
1535 ref->proc->pid, ref->data.debug_id, in binder_cleanup_ref_olocked()
1537 binder_dequeue_work(ref->proc, &ref->death->work); in binder_cleanup_ref_olocked()
1590 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1601 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1627 struct binder_proc *proc, in binder_get_node_from_ref() argument
1634 binder_proc_lock(proc); in binder_get_node_from_ref()
1635 ref = binder_get_ref_olocked(proc, desc, need_strong_ref); in binder_get_node_from_ref()
1646 binder_proc_unlock(proc); in binder_get_node_from_ref()
1651 binder_proc_unlock(proc); in binder_get_node_from_ref()
1683 static int binder_update_ref_for_handle(struct binder_proc *proc, in binder_update_ref_for_handle() argument
1691 binder_proc_lock(proc); in binder_update_ref_for_handle()
1692 ref = binder_get_ref_olocked(proc, desc, strong); in binder_update_ref_for_handle()
1704 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1711 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1726 static int binder_dec_ref_for_handle(struct binder_proc *proc, in binder_dec_ref_for_handle() argument
1729 return binder_update_ref_for_handle(proc, desc, false, strong, rdata); in binder_dec_ref_for_handle()
1746 static int binder_inc_ref_for_node(struct binder_proc *proc, in binder_inc_ref_for_node() argument
1756 binder_proc_lock(proc); in binder_inc_ref_for_node()
1757 ref = binder_get_ref_for_node_olocked(proc, node, NULL); in binder_inc_ref_for_node()
1759 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1763 binder_proc_lock(proc); in binder_inc_ref_for_node()
1764 ref = binder_get_ref_for_node_olocked(proc, node, new_ref); in binder_inc_ref_for_node()
1768 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1782 assert_spin_locked(&target_thread->proc->inner_lock); in binder_pop_transaction_ilocked()
1808 binder_inner_proc_lock(thread->proc); in binder_thread_dec_tmpref()
1811 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1815 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1830 static void binder_proc_dec_tmpref(struct binder_proc *proc) in binder_proc_dec_tmpref() argument
1832 binder_inner_proc_lock(proc); in binder_proc_dec_tmpref()
1833 proc->tmp_ref--; in binder_proc_dec_tmpref()
1834 if (proc->is_dead && RB_EMPTY_ROOT(&proc->threads) && in binder_proc_dec_tmpref()
1835 !proc->tmp_ref) { in binder_proc_dec_tmpref()
1836 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1837 binder_free_proc(proc); in binder_proc_dec_tmpref()
1840 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1879 __acquires(&t->from->proc->inner_lock) in binder_get_txn_from_and_acq_inner()
1885 __acquire(&from->proc->inner_lock); in binder_get_txn_from_and_acq_inner()
1888 binder_inner_proc_lock(from->proc); in binder_get_txn_from_and_acq_inner()
1893 binder_inner_proc_unlock(from->proc); in binder_get_txn_from_and_acq_inner()
1894 __acquire(&from->proc->inner_lock); in binder_get_txn_from_and_acq_inner()
1952 target_thread->proc->pid, in binder_send_failed_reply()
1972 binder_inner_proc_unlock(target_thread->proc); in binder_send_failed_reply()
1977 __release(&target_thread->proc->inner_lock); in binder_send_failed_reply()
2029 static size_t binder_get_object(struct binder_proc *proc, in binder_get_object() argument
2040 binder_alloc_copy_from_buffer(&proc->alloc, object, buffer, in binder_get_object()
2095 struct binder_proc *proc, in binder_validate_ptr() argument
2111 if (binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_validate_ptr()
2115 object_size = binder_get_object(proc, b, object_offset, object); in binder_validate_ptr()
2163 static bool binder_validate_fixup(struct binder_proc *proc, in binder_validate_fixup() argument
2180 size_t object_size = binder_get_object(proc, b, last_obj_offset, in binder_validate_fixup()
2195 if (binder_alloc_copy_from_buffer(&proc->alloc, in binder_validate_fixup()
2262 static void binder_transaction_buffer_release(struct binder_proc *proc, in binder_transaction_buffer_release() argument
2272 proc->pid, buffer->debug_id, in binder_transaction_buffer_release()
2289 if (!binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_transaction_buffer_release()
2292 object_size = binder_get_object(proc, buffer, in binder_transaction_buffer_release()
2307 node = binder_get_node(proc, fp->binder); in binder_transaction_buffer_release()
2327 ret = binder_dec_ref_for_handle(proc, fp->handle, in binder_transaction_buffer_release()
2351 proc->tsk == current->group_leader); in binder_transaction_buffer_release()
2368 if (proc->tsk != current->group_leader) { in binder_transaction_buffer_release()
2380 parent = binder_validate_ptr(proc, buffer, &ptr_object, in binder_transaction_buffer_release()
2421 &proc->alloc, &fd, buffer, in binder_transaction_buffer_release()
2441 struct binder_proc *proc = thread->proc; in binder_translate_binder() local
2446 node = binder_get_node(proc, fp->binder); in binder_translate_binder()
2448 node = binder_new_node(proc, fp); in binder_translate_binder()
2454 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2460 if (security_binder_transfer_binder(proc->tsk, target_proc->tsk)) { in binder_translate_binder()
2493 struct binder_proc *proc = thread->proc; in binder_translate_handle() local
2499 node = binder_get_node_from_ref(proc, fp->handle, in binder_translate_handle()
2503 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2506 if (security_binder_transfer_binder(proc->tsk, target_proc->tsk)) { in binder_translate_handle()
2512 if (node->proc == target_proc) { in binder_translate_handle()
2519 if (node->proc) in binder_translate_handle()
2520 binder_inner_proc_lock(node->proc); in binder_translate_handle()
2522 __acquire(&node->proc->inner_lock); in binder_translate_handle()
2526 if (node->proc) in binder_translate_handle()
2527 binder_inner_proc_unlock(node->proc); in binder_translate_handle()
2529 __release(&node->proc->inner_lock); in binder_translate_handle()
2567 struct binder_proc *proc = thread->proc; in binder_translate_fd() local
2580 proc->pid, thread->pid, in binder_translate_fd()
2590 proc->pid, thread->pid, fd); in binder_translate_fd()
2594 ret = security_binder_transfer_file(proc->tsk, target_proc->tsk, file); in binder_translate_fd()
2633 struct binder_proc *proc = thread->proc; in binder_translate_fd_array() local
2639 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2646 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2660 proc->pid, thread->pid); in binder_translate_fd_array()
2690 struct binder_proc *proc = thread->proc; in binder_fixup_parent() local
2704 proc->pid, thread->pid); in binder_fixup_parent()
2713 proc->pid, thread->pid); in binder_fixup_parent()
2721 proc->pid, thread->pid); in binder_fixup_parent()
2729 proc->pid, thread->pid); in binder_fixup_parent()
2754 struct binder_proc *proc, in binder_proc_transaction() argument
2772 binder_inner_proc_lock(proc); in binder_proc_transaction()
2774 if (proc->is_dead || (thread && thread->is_dead)) { in binder_proc_transaction()
2775 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2781 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2786 binder_enqueue_work_ilocked(&t->work, &proc->todo); in binder_proc_transaction()
2791 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2793 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2828 if (node->proc) { in binder_get_node_refs_for_txn()
2832 node->proc->tmp_ref++; in binder_get_node_refs_for_txn()
2833 *procp = node->proc; in binder_get_node_refs_for_txn()
2841 static void binder_transaction(struct binder_proc *proc, in binder_transaction() argument
2864 struct binder_context *context = proc->context; in binder_transaction()
2872 e->from_proc = proc->pid; in binder_transaction()
2877 strscpy(e->context_name, proc->context->name, BINDERFS_MAX_NAME); in binder_transaction()
2880 binder_inner_proc_lock(proc); in binder_transaction()
2883 binder_inner_proc_unlock(proc); in binder_transaction()
2885 proc->pid, thread->pid); in binder_transaction()
2894 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
2900 binder_inner_proc_unlock(proc); in binder_transaction()
2908 binder_inner_proc_unlock(proc); in binder_transaction()
2913 __release(&target_thread->proc->inner_lock); in binder_transaction()
2920 proc->pid, thread->pid, in binder_transaction()
2924 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
2932 target_proc = target_thread->proc; in binder_transaction()
2934 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
2946 binder_proc_lock(proc); in binder_transaction()
2947 ref = binder_get_ref_olocked(proc, tr->target.handle, in binder_transaction()
2955 proc->pid, thread->pid); in binder_transaction()
2958 binder_proc_unlock(proc); in binder_transaction()
2969 if (target_node && target_proc->pid == proc->pid) { in binder_transaction()
2971 proc->pid, thread->pid); in binder_transaction()
2987 if (security_binder_transaction(proc->tsk, in binder_transaction()
2994 binder_inner_proc_lock(proc); in binder_transaction()
3010 proc->pid, thread->pid); in binder_transaction()
3011 binder_inner_proc_unlock(proc); in binder_transaction()
3025 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
3030 binder_inner_proc_unlock(proc); in binder_transaction()
3041 if (from && from->proc == target_proc) { in binder_transaction()
3051 binder_inner_proc_unlock(proc); in binder_transaction()
3083 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3092 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3103 t->sender_euid = task_euid(proc->tsk); in binder_transaction()
3114 security_task_getsecid(proc->tsk, &secid); in binder_transaction()
3179 proc->pid, thread->pid); in binder_transaction()
3193 proc->pid, thread->pid); in binder_transaction()
3201 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3209 proc->pid, thread->pid, in binder_transaction()
3244 proc->pid, thread->pid, in binder_transaction()
3327 proc->pid, thread->pid); in binder_transaction()
3340 proc->pid, thread->pid); in binder_transaction()
3366 proc->pid, thread->pid); in binder_transaction()
3380 proc->pid, thread->pid); in binder_transaction()
3413 proc->pid, thread->pid, hdr->type); in binder_transaction()
3438 binder_inner_proc_lock(proc); in binder_transaction()
3450 binder_inner_proc_unlock(proc); in binder_transaction()
3452 binder_inner_proc_lock(proc); in binder_transaction()
3454 binder_inner_proc_unlock(proc); in binder_transaction()
3480 binder_dequeue_work(proc, tcomplete); in binder_transaction()
3522 proc->pid, thread->pid, return_error, return_error_param, in binder_transaction()
3565 binder_free_buf(struct binder_proc *proc, struct binder_buffer *buffer) in binder_free_buf() argument
3567 binder_inner_proc_lock(proc); in binder_free_buf()
3572 binder_inner_proc_unlock(proc); in binder_free_buf()
3580 BUG_ON(buf_node->proc != proc); in binder_free_buf()
3587 w, &proc->todo); in binder_free_buf()
3588 binder_wakeup_proc_ilocked(proc); in binder_free_buf()
3593 binder_transaction_buffer_release(proc, buffer, 0, false); in binder_free_buf()
3594 binder_alloc_free_buf(&proc->alloc, buffer); in binder_free_buf()
3597 static int binder_thread_write(struct binder_proc *proc, in binder_thread_write() argument
3603 struct binder_context *context = proc->context; in binder_thread_write()
3617 atomic_inc(&proc->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
3642 proc, ctx_mgr_node, in binder_thread_write()
3648 proc, target, increment, strong, in binder_thread_write()
3652 proc->pid, thread->pid, in binder_thread_write()
3672 proc->pid, thread->pid, debug_string, in binder_thread_write()
3678 proc->pid, thread->pid, debug_string, in binder_thread_write()
3696 node = binder_get_node(proc, node_ptr); in binder_thread_write()
3699 proc->pid, thread->pid, in binder_thread_write()
3708 proc->pid, thread->pid, in binder_thread_write()
3720 proc->pid, thread->pid, in binder_thread_write()
3730 proc->pid, thread->pid, in binder_thread_write()
3743 proc->pid, thread->pid, in binder_thread_write()
3766 buffer = binder_alloc_prepare_to_free(&proc->alloc, in binder_thread_write()
3772 proc->pid, thread->pid, in binder_thread_write()
3777 proc->pid, thread->pid, in binder_thread_write()
3784 proc->pid, thread->pid, (u64)data_ptr, in binder_thread_write()
3787 binder_free_buf(proc, buffer); in binder_thread_write()
3798 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
3809 binder_transaction(proc, thread, &tr, in binder_thread_write()
3817 proc->pid, thread->pid); in binder_thread_write()
3818 binder_inner_proc_lock(proc); in binder_thread_write()
3822 proc->pid, thread->pid); in binder_thread_write()
3823 } else if (proc->requested_threads == 0) { in binder_thread_write()
3826 proc->pid, thread->pid); in binder_thread_write()
3828 proc->requested_threads--; in binder_thread_write()
3829 proc->requested_threads_started++; in binder_thread_write()
3832 binder_inner_proc_unlock(proc); in binder_thread_write()
3837 proc->pid, thread->pid); in binder_thread_write()
3841 proc->pid, thread->pid); in binder_thread_write()
3848 proc->pid, thread->pid); in binder_thread_write()
3881 proc->pid, thread->pid); in binder_thread_write()
3885 binder_proc_lock(proc); in binder_thread_write()
3886 ref = binder_get_ref_olocked(proc, target, false); in binder_thread_write()
3889 proc->pid, thread->pid, in binder_thread_write()
3894 binder_proc_unlock(proc); in binder_thread_write()
3901 proc->pid, thread->pid, in binder_thread_write()
3913 proc->pid, thread->pid); in binder_thread_write()
3915 binder_proc_unlock(proc); in binder_thread_write()
3923 if (ref->node->proc == NULL) { in binder_thread_write()
3926 binder_inner_proc_lock(proc); in binder_thread_write()
3928 &ref->death->work, &proc->todo); in binder_thread_write()
3929 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
3930 binder_inner_proc_unlock(proc); in binder_thread_write()
3935 proc->pid, thread->pid); in binder_thread_write()
3937 binder_proc_unlock(proc); in binder_thread_write()
3943 proc->pid, thread->pid, in binder_thread_write()
3947 binder_proc_unlock(proc); in binder_thread_write()
3951 binder_inner_proc_lock(proc); in binder_thread_write()
3963 &proc->todo); in binder_thread_write()
3965 proc); in binder_thread_write()
3971 binder_inner_proc_unlock(proc); in binder_thread_write()
3974 binder_proc_unlock(proc); in binder_thread_write()
3985 binder_inner_proc_lock(proc); in binder_thread_write()
3986 list_for_each_entry(w, &proc->delivered_death, in binder_thread_write()
4000 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
4004 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
4005 binder_inner_proc_unlock(proc); in binder_thread_write()
4019 &proc->todo); in binder_thread_write()
4020 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
4023 binder_inner_proc_unlock(proc); in binder_thread_write()
4028 proc->pid, thread->pid, cmd); in binder_thread_write()
4036 static void binder_stat_br(struct binder_proc *proc, in binder_stat_br() argument
4042 atomic_inc(&proc->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
4047 static int binder_put_node_cmd(struct binder_proc *proc, in binder_put_node_cmd() argument
4069 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
4071 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
4082 struct binder_proc *proc = thread->proc; in binder_wait_for_work() local
4086 binder_inner_proc_lock(proc); in binder_wait_for_work()
4093 &proc->waiting_threads); in binder_wait_for_work()
4094 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4096 binder_inner_proc_lock(proc); in binder_wait_for_work()
4104 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4124 static int binder_apply_fd_fixups(struct binder_proc *proc, in binder_apply_fd_fixups() argument
4146 if (binder_alloc_copy_to_buffer(&proc->alloc, t->buffer, in binder_apply_fd_fixups()
4160 err = binder_alloc_copy_from_buffer(&proc->alloc, &fd, in binder_apply_fd_fixups()
4175 static int binder_thread_read(struct binder_proc *proc, in binder_thread_read() argument
4194 binder_inner_proc_lock(proc); in binder_thread_read()
4196 binder_inner_proc_unlock(proc); in binder_thread_read()
4202 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
4207 proc->pid, thread->pid, thread->looper); in binder_thread_read()
4211 binder_set_nice(proc->default_priority); in binder_thread_read()
4236 binder_inner_proc_lock(proc); in binder_thread_read()
4239 else if (!binder_worklist_empty_ilocked(&proc->todo) && in binder_thread_read()
4241 list = &proc->todo; in binder_thread_read()
4243 binder_inner_proc_unlock(proc); in binder_thread_read()
4252 binder_inner_proc_unlock(proc); in binder_thread_read()
4261 binder_inner_proc_unlock(proc); in binder_thread_read()
4269 binder_inner_proc_unlock(proc); in binder_thread_read()
4276 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4279 binder_inner_proc_unlock(proc); in binder_thread_read()
4287 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4290 proc->pid, thread->pid); in binder_thread_read()
4302 BUG_ON(proc != node->proc); in binder_thread_read()
4328 proc->pid, thread->pid, in binder_thread_read()
4332 rb_erase(&node->rb_node, &proc->nodes); in binder_thread_read()
4333 binder_inner_proc_unlock(proc); in binder_thread_read()
4347 binder_inner_proc_unlock(proc); in binder_thread_read()
4351 proc, thread, &ptr, node_ptr, in binder_thread_read()
4356 proc, thread, &ptr, node_ptr, in binder_thread_read()
4361 proc, thread, &ptr, node_ptr, in binder_thread_read()
4366 proc, thread, &ptr, node_ptr, in binder_thread_read()
4372 proc->pid, thread->pid, in binder_thread_read()
4395 proc->pid, thread->pid, in binder_thread_read()
4401 binder_inner_proc_unlock(proc); in binder_thread_read()
4406 w, &proc->delivered_death); in binder_thread_read()
4407 binder_inner_proc_unlock(proc); in binder_thread_read()
4416 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4421 binder_inner_proc_unlock(proc); in binder_thread_read()
4423 proc->pid, thread->pid, w->type); in binder_thread_read()
4455 struct task_struct *sender = t_from->proc->tsk; in binder_thread_read()
4464 ret = binder_apply_fd_fixups(proc, t); in binder_thread_read()
4475 binder_free_buf(proc, buffer); in binder_thread_read()
4478 proc->pid, thread->pid, in binder_thread_read()
4487 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4526 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4529 proc->pid, thread->pid, in binder_thread_read()
4533 t->debug_id, t_from ? t_from->proc->pid : 0, in binder_thread_read()
4543 binder_inner_proc_lock(thread->proc); in binder_thread_read()
4547 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
4557 binder_inner_proc_lock(proc); in binder_thread_read()
4558 if (proc->requested_threads == 0 && in binder_thread_read()
4559 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
4560 proc->requested_threads_started < proc->max_threads && in binder_thread_read()
4564 proc->requested_threads++; in binder_thread_read()
4565 binder_inner_proc_unlock(proc); in binder_thread_read()
4568 proc->pid, thread->pid); in binder_thread_read()
4571 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
4573 binder_inner_proc_unlock(proc); in binder_thread_read()
4577 static void binder_release_work(struct binder_proc *proc, in binder_release_work() argument
4583 w = binder_dequeue_work_head(proc, list); in binder_release_work()
4631 struct binder_proc *proc, struct binder_thread *new_thread) in binder_get_thread_ilocked() argument
4635 struct rb_node **p = &proc->threads.rb_node; in binder_get_thread_ilocked()
4652 thread->proc = proc; in binder_get_thread_ilocked()
4658 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
4668 static struct binder_thread *binder_get_thread(struct binder_proc *proc) in binder_get_thread() argument
4673 binder_inner_proc_lock(proc); in binder_get_thread()
4674 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
4675 binder_inner_proc_unlock(proc); in binder_get_thread()
4680 binder_inner_proc_lock(proc); in binder_get_thread()
4681 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
4682 binder_inner_proc_unlock(proc); in binder_get_thread()
4689 static void binder_free_proc(struct binder_proc *proc) in binder_free_proc() argument
4691 BUG_ON(!list_empty(&proc->todo)); in binder_free_proc()
4692 BUG_ON(!list_empty(&proc->delivered_death)); in binder_free_proc()
4693 binder_alloc_deferred_release(&proc->alloc); in binder_free_proc()
4694 put_task_struct(proc->tsk); in binder_free_proc()
4696 kfree(proc); in binder_free_proc()
4703 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
4707 static int binder_thread_release(struct binder_proc *proc, in binder_thread_release() argument
4715 binder_inner_proc_lock(thread->proc); in binder_thread_release()
4722 proc->tmp_ref++; in binder_thread_release()
4728 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
4744 proc->pid, thread->pid, in binder_thread_release()
4781 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
4794 binder_release_work(proc, &thread->todo); in binder_thread_release()
4802 struct binder_proc *proc = filp->private_data; in binder_poll() local
4806 thread = binder_get_thread(proc); in binder_poll()
4810 binder_inner_proc_lock(thread->proc); in binder_poll()
4814 binder_inner_proc_unlock(thread->proc); in binder_poll()
4829 struct binder_proc *proc = filp->private_data; in binder_ioctl_write_read() local
4844 proc->pid, thread->pid, in binder_ioctl_write_read()
4849 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
4862 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
4867 binder_inner_proc_lock(proc); in binder_ioctl_write_read()
4868 if (!binder_worklist_empty_ilocked(&proc->todo)) in binder_ioctl_write_read()
4869 binder_wakeup_proc_ilocked(proc); in binder_ioctl_write_read()
4870 binder_inner_proc_unlock(proc); in binder_ioctl_write_read()
4879 proc->pid, thread->pid, in binder_ioctl_write_read()
4894 struct binder_proc *proc = filp->private_data; in binder_ioctl_set_ctx_mgr() local
4895 struct binder_context *context = proc->context; in binder_ioctl_set_ctx_mgr()
4905 ret = security_binder_set_context_mgr(proc->tsk); in binder_ioctl_set_ctx_mgr()
4920 new_node = binder_new_node(proc, fbo); in binder_ioctl_set_ctx_mgr()
4938 static int binder_ioctl_get_node_info_for_ref(struct binder_proc *proc, in binder_ioctl_get_node_info_for_ref() argument
4942 struct binder_context *context = proc->context; in binder_ioctl_get_node_info_for_ref()
4948 proc->pid); in binder_ioctl_get_node_info_for_ref()
4955 context->binder_context_mgr_node->proc != proc) { in binder_ioctl_get_node_info_for_ref()
4961 node = binder_get_node_from_ref(proc, handle, true, NULL); in binder_ioctl_get_node_info_for_ref()
4974 static int binder_ioctl_get_node_debug_info(struct binder_proc *proc, in binder_ioctl_get_node_debug_info() argument
4982 binder_inner_proc_lock(proc); in binder_ioctl_get_node_debug_info()
4983 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in binder_ioctl_get_node_debug_info()
4994 binder_inner_proc_unlock(proc); in binder_ioctl_get_node_debug_info()
5002 struct binder_proc *proc = filp->private_data; in binder_ioctl() local
5010 binder_selftest_alloc(&proc->alloc); in binder_ioctl()
5018 thread = binder_get_thread(proc); in binder_ioctl()
5038 binder_inner_proc_lock(proc); in binder_ioctl()
5039 proc->max_threads = max_threads; in binder_ioctl()
5040 binder_inner_proc_unlock(proc); in binder_ioctl()
5062 proc->pid, thread->pid); in binder_ioctl()
5063 binder_thread_release(proc, thread); in binder_ioctl()
5088 ret = binder_ioctl_get_node_info_for_ref(proc, &info); in binder_ioctl()
5107 ret = binder_ioctl_get_node_debug_info(proc, &info); in binder_ioctl()
5127 pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); in binder_ioctl()
5135 struct binder_proc *proc = vma->vm_private_data; in binder_vma_open() local
5139 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_open()
5146 struct binder_proc *proc = vma->vm_private_data; in binder_vma_close() local
5150 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_close()
5153 binder_alloc_vma_close(&proc->alloc); in binder_vma_close()
5170 struct binder_proc *proc = filp->private_data; in binder_mmap() local
5173 if (proc->tsk != current->group_leader) in binder_mmap()
5178 __func__, proc->pid, vma->vm_start, vma->vm_end, in binder_mmap()
5191 vma->vm_private_data = proc; in binder_mmap()
5193 ret = binder_alloc_mmap_handler(&proc->alloc, vma); in binder_mmap()
5200 proc->pid, vma->vm_start, vma->vm_end, failure_string, ret); in binder_mmap()
5206 struct binder_proc *proc; in binder_open() local
5214 proc = kzalloc(sizeof(*proc), GFP_KERNEL); in binder_open()
5215 if (proc == NULL) in binder_open()
5217 spin_lock_init(&proc->inner_lock); in binder_open()
5218 spin_lock_init(&proc->outer_lock); in binder_open()
5220 proc->tsk = current->group_leader; in binder_open()
5221 INIT_LIST_HEAD(&proc->todo); in binder_open()
5222 proc->default_priority = task_nice(current); in binder_open()
5232 proc->context = &binder_dev->context; in binder_open()
5233 binder_alloc_init(&proc->alloc); in binder_open()
5236 proc->pid = current->group_leader->pid; in binder_open()
5237 INIT_LIST_HEAD(&proc->delivered_death); in binder_open()
5238 INIT_LIST_HEAD(&proc->waiting_threads); in binder_open()
5239 filp->private_data = proc; in binder_open()
5242 hlist_add_head(&proc->proc_node, &binder_procs); in binder_open()
5248 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
5256 proc->debugfs_entry = debugfs_create_file(strbuf, 0444, in binder_open()
5258 (void *)(unsigned long)proc->pid, in binder_open()
5266 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
5277 strbuf, &proc_fops, (void *)(unsigned long)proc->pid); in binder_open()
5279 proc->binderfs_entry = binderfs_entry; in binder_open()
5296 struct binder_proc *proc = filp->private_data; in binder_flush() local
5298 binder_defer_work(proc, BINDER_DEFERRED_FLUSH); in binder_flush()
5303 static void binder_deferred_flush(struct binder_proc *proc) in binder_deferred_flush() argument
5308 binder_inner_proc_lock(proc); in binder_deferred_flush()
5309 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_deferred_flush()
5318 binder_inner_proc_unlock(proc); in binder_deferred_flush()
5321 "binder_flush: %d woke %d threads\n", proc->pid, in binder_deferred_flush()
5327 struct binder_proc *proc = filp->private_data; in binder_release() local
5329 debugfs_remove(proc->debugfs_entry); in binder_release()
5331 if (proc->binderfs_entry) { in binder_release()
5332 binderfs_remove_file(proc->binderfs_entry); in binder_release()
5333 proc->binderfs_entry = NULL; in binder_release()
5336 binder_defer_work(proc, BINDER_DEFERRED_RELEASE); in binder_release()
5345 struct binder_proc *proc = node->proc; in binder_node_release() local
5347 binder_release_work(proc, &node->async_todo); in binder_node_release()
5350 binder_inner_proc_lock(proc); in binder_node_release()
5357 binder_inner_proc_unlock(proc); in binder_node_release()
5364 node->proc = NULL; in binder_node_release()
5367 binder_inner_proc_unlock(proc); in binder_node_release()
5381 binder_inner_proc_lock(ref->proc); in binder_node_release()
5383 binder_inner_proc_unlock(ref->proc); in binder_node_release()
5392 &ref->proc->todo); in binder_node_release()
5393 binder_wakeup_proc_ilocked(ref->proc); in binder_node_release()
5394 binder_inner_proc_unlock(ref->proc); in binder_node_release()
5406 static void binder_deferred_release(struct binder_proc *proc) in binder_deferred_release() argument
5408 struct binder_context *context = proc->context; in binder_deferred_release()
5413 hlist_del(&proc->proc_node); in binder_deferred_release()
5418 context->binder_context_mgr_node->proc == proc) { in binder_deferred_release()
5421 __func__, proc->pid); in binder_deferred_release()
5425 binder_inner_proc_lock(proc); in binder_deferred_release()
5430 proc->tmp_ref++; in binder_deferred_release()
5432 proc->is_dead = true; in binder_deferred_release()
5435 while ((n = rb_first(&proc->threads))) { in binder_deferred_release()
5439 binder_inner_proc_unlock(proc); in binder_deferred_release()
5441 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
5442 binder_inner_proc_lock(proc); in binder_deferred_release()
5447 while ((n = rb_first(&proc->nodes))) { in binder_deferred_release()
5458 rb_erase(&node->rb_node, &proc->nodes); in binder_deferred_release()
5459 binder_inner_proc_unlock(proc); in binder_deferred_release()
5461 binder_inner_proc_lock(proc); in binder_deferred_release()
5463 binder_inner_proc_unlock(proc); in binder_deferred_release()
5466 binder_proc_lock(proc); in binder_deferred_release()
5467 while ((n = rb_first(&proc->refs_by_desc))) { in binder_deferred_release()
5473 binder_proc_unlock(proc); in binder_deferred_release()
5475 binder_proc_lock(proc); in binder_deferred_release()
5477 binder_proc_unlock(proc); in binder_deferred_release()
5479 binder_release_work(proc, &proc->todo); in binder_deferred_release()
5480 binder_release_work(proc, &proc->delivered_death); in binder_deferred_release()
5484 __func__, proc->pid, threads, nodes, incoming_refs, in binder_deferred_release()
5487 binder_proc_dec_tmpref(proc); in binder_deferred_release()
5492 struct binder_proc *proc; in binder_deferred_func() local
5499 proc = hlist_entry(binder_deferred_list.first, in binder_deferred_func()
5501 hlist_del_init(&proc->deferred_work_node); in binder_deferred_func()
5502 defer = proc->deferred_work; in binder_deferred_func()
5503 proc->deferred_work = 0; in binder_deferred_func()
5505 proc = NULL; in binder_deferred_func()
5511 binder_deferred_flush(proc); in binder_deferred_func()
5514 binder_deferred_release(proc); /* frees proc */ in binder_deferred_func()
5515 } while (proc); in binder_deferred_func()
5520 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) in binder_defer_work() argument
5523 proc->deferred_work |= defer; in binder_defer_work()
5524 if (hlist_unhashed(&proc->deferred_work_node)) { in binder_defer_work()
5525 hlist_add_head(&proc->deferred_work_node, in binder_defer_work()
5533 struct binder_proc *proc, in print_binder_transaction_ilocked() argument
5545 t->from ? t->from->proc->pid : 0, in print_binder_transaction_ilocked()
5552 if (proc != to_proc) { in print_binder_transaction_ilocked()
5573 struct binder_proc *proc, in print_binder_work_ilocked() argument
5585 m, proc, transaction_prefix, t); in print_binder_work_ilocked()
5635 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5639 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5643 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
5649 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
5675 seq_printf(m, " %d", ref->proc->pid); in print_binder_node_nilocked()
5678 if (node->proc) { in print_binder_node_nilocked()
5680 print_binder_work_ilocked(m, node->proc, " ", in print_binder_node_nilocked()
5691 ref->node->proc ? "" : "dead ", in print_binder_ref_olocked()
5698 struct binder_proc *proc, int print_all) in print_binder_proc() argument
5706 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc()
5707 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc()
5710 binder_inner_proc_lock(proc); in print_binder_proc()
5711 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) in print_binder_proc()
5715 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in print_binder_proc()
5728 binder_inner_proc_unlock(proc); in print_binder_proc()
5735 binder_inner_proc_lock(proc); in print_binder_proc()
5737 binder_inner_proc_unlock(proc); in print_binder_proc()
5742 binder_proc_lock(proc); in print_binder_proc()
5743 for (n = rb_first(&proc->refs_by_desc); in print_binder_proc()
5749 binder_proc_unlock(proc); in print_binder_proc()
5751 binder_alloc_print_allocated(m, &proc->alloc); in print_binder_proc()
5752 binder_inner_proc_lock(proc); in print_binder_proc()
5753 list_for_each_entry(w, &proc->todo, entry) in print_binder_proc()
5754 print_binder_work_ilocked(m, proc, " ", in print_binder_proc()
5756 list_for_each_entry(w, &proc->delivered_death, entry) { in print_binder_proc()
5760 binder_inner_proc_unlock(proc); in print_binder_proc()
5861 struct binder_proc *proc) in print_binder_proc_stats() argument
5868 binder_alloc_get_free_async_space(&proc->alloc); in print_binder_proc_stats()
5870 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc_stats()
5871 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc_stats()
5874 binder_inner_proc_lock(proc); in print_binder_proc_stats()
5875 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) in print_binder_proc_stats()
5878 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()
5884 " free async space %zd\n", proc->requested_threads, in print_binder_proc_stats()
5885 proc->requested_threads_started, proc->max_threads, in print_binder_proc_stats()
5889 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) in print_binder_proc_stats()
5891 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
5896 binder_proc_lock(proc); in print_binder_proc_stats()
5897 for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { in print_binder_proc_stats()
5904 binder_proc_unlock(proc); in print_binder_proc_stats()
5907 count = binder_alloc_get_allocated_count(&proc->alloc); in print_binder_proc_stats()
5910 binder_alloc_print_pages(m, &proc->alloc); in print_binder_proc_stats()
5913 binder_inner_proc_lock(proc); in print_binder_proc_stats()
5914 list_for_each_entry(w, &proc->todo, entry) { in print_binder_proc_stats()
5918 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
5921 print_binder_stats(m, " ", &proc->stats); in print_binder_proc_stats()
5927 struct binder_proc *proc; in binder_state_show() local
5957 hlist_for_each_entry(proc, &binder_procs, proc_node) in binder_state_show()
5958 print_binder_proc(m, proc, 1); in binder_state_show()
5966 struct binder_proc *proc; in binder_stats_show() local
5973 hlist_for_each_entry(proc, &binder_procs, proc_node) in binder_stats_show()
5974 print_binder_proc_stats(m, proc); in binder_stats_show()
5982 struct binder_proc *proc; in binder_transactions_show() local
5986 hlist_for_each_entry(proc, &binder_procs, proc_node) in binder_transactions_show()
5987 print_binder_proc(m, proc, 0); in binder_transactions_show()