Lines Matching refs:proc
98 DEFINE_SHOW_ATTRIBUTE(proc);
274 #define binder_proc_lock(proc) _binder_proc_lock(proc, __LINE__) argument
276 _binder_proc_lock(struct binder_proc *proc, int line) in _binder_proc_lock() argument
277 __acquires(&proc->outer_lock) in _binder_proc_lock()
281 spin_lock(&proc->outer_lock); in _binder_proc_lock()
290 #define binder_proc_unlock(proc) _binder_proc_unlock(proc, __LINE__) argument
292 _binder_proc_unlock(struct binder_proc *proc, int line) in _binder_proc_unlock() argument
293 __releases(&proc->outer_lock) in _binder_proc_unlock()
297 spin_unlock(&proc->outer_lock); in _binder_proc_unlock()
306 #define binder_inner_proc_lock(proc) _binder_inner_proc_lock(proc, __LINE__) argument
308 _binder_inner_proc_lock(struct binder_proc *proc, int line) in _binder_inner_proc_lock() argument
309 __acquires(&proc->inner_lock) in _binder_inner_proc_lock()
313 spin_lock(&proc->inner_lock); in _binder_inner_proc_lock()
322 #define binder_inner_proc_unlock(proc) _binder_inner_proc_unlock(proc, __LINE__) argument
324 _binder_inner_proc_unlock(struct binder_proc *proc, int line) in _binder_inner_proc_unlock() argument
325 __releases(&proc->inner_lock) in _binder_inner_proc_unlock()
329 spin_unlock(&proc->inner_lock); in _binder_inner_proc_unlock()
374 __acquires(&node->lock) __acquires(&node->proc->inner_lock) in _binder_node_inner_lock()
379 if (node->proc) in _binder_node_inner_lock()
380 binder_inner_proc_lock(node->proc); in _binder_node_inner_lock()
383 __acquire(&node->proc->inner_lock); in _binder_node_inner_lock()
395 __releases(&node->lock) __releases(&node->proc->inner_lock) in _binder_node_inner_unlock()
397 struct binder_proc *proc = node->proc; in _binder_node_inner_unlock() local
401 if (proc) in _binder_node_inner_unlock()
402 binder_inner_proc_unlock(proc); in _binder_node_inner_unlock()
405 __release(&node->proc->inner_lock); in _binder_node_inner_unlock()
421 static bool binder_worklist_empty(struct binder_proc *proc, in binder_worklist_empty() argument
426 binder_inner_proc_lock(proc); in binder_worklist_empty()
428 binder_inner_proc_unlock(proc); in binder_worklist_empty()
511 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
513 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
531 binder_dequeue_work(struct binder_proc *proc, struct binder_work *work) in binder_dequeue_work() argument
533 binder_inner_proc_lock(proc); in binder_dequeue_work()
535 binder_inner_proc_unlock(proc); in binder_dequeue_work()
550 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
552 static void binder_free_proc(struct binder_proc *proc);
561 !binder_worklist_empty_ilocked(&thread->proc->todo)); in binder_has_work_ilocked()
568 binder_inner_proc_lock(thread->proc); in binder_has_work()
570 binder_inner_proc_unlock(thread->proc); in binder_has_work()
581 static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc, in binder_wakeup_poll_threads_ilocked() argument
587 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_wakeup_poll_threads_ilocked()
612 binder_select_thread_ilocked(struct binder_proc *proc) in binder_select_thread_ilocked() argument
616 assert_spin_locked(&proc->inner_lock); in binder_select_thread_ilocked()
617 thread = list_first_entry_or_null(&proc->waiting_threads, in binder_select_thread_ilocked()
643 static void binder_wakeup_thread_ilocked(struct binder_proc *proc, in binder_wakeup_thread_ilocked() argument
647 assert_spin_locked(&proc->inner_lock); in binder_wakeup_thread_ilocked()
670 binder_wakeup_poll_threads_ilocked(proc, sync); in binder_wakeup_thread_ilocked()
673 static void binder_wakeup_proc_ilocked(struct binder_proc *proc) in binder_wakeup_proc_ilocked() argument
675 struct binder_thread *thread = binder_select_thread_ilocked(proc); in binder_wakeup_proc_ilocked()
677 binder_wakeup_thread_ilocked(proc, thread, /* sync = */false); in binder_wakeup_proc_ilocked()
698 static struct binder_node *binder_get_node_ilocked(struct binder_proc *proc, in binder_get_node_ilocked() argument
701 struct rb_node *n = proc->nodes.rb_node; in binder_get_node_ilocked()
704 assert_spin_locked(&proc->inner_lock); in binder_get_node_ilocked()
726 static struct binder_node *binder_get_node(struct binder_proc *proc, in binder_get_node() argument
731 binder_inner_proc_lock(proc); in binder_get_node()
732 node = binder_get_node_ilocked(proc, ptr); in binder_get_node()
733 binder_inner_proc_unlock(proc); in binder_get_node()
738 struct binder_proc *proc, in binder_init_node_ilocked() argument
742 struct rb_node **p = &proc->nodes.rb_node; in binder_init_node_ilocked()
749 assert_spin_locked(&proc->inner_lock); in binder_init_node_ilocked()
774 rb_insert_color(&node->rb_node, &proc->nodes); in binder_init_node_ilocked()
776 node->proc = proc; in binder_init_node_ilocked()
788 proc->pid, current->pid, node->debug_id, in binder_init_node_ilocked()
794 static struct binder_node *binder_new_node(struct binder_proc *proc, in binder_new_node() argument
802 binder_inner_proc_lock(proc); in binder_new_node()
803 node = binder_init_node_ilocked(proc, new_node, fp); in binder_new_node()
804 binder_inner_proc_unlock(proc); in binder_new_node()
824 struct binder_proc *proc = node->proc; in binder_inc_node_nilocked() local
827 if (proc) in binder_inc_node_nilocked()
828 assert_spin_locked(&proc->inner_lock); in binder_inc_node_nilocked()
833 !(node->proc && in binder_inc_node_nilocked()
834 node == node->proc->context->binder_context_mgr_node && in binder_inc_node_nilocked()
875 struct binder_proc *proc = node->proc; in binder_dec_node_nilocked() local
878 if (proc) in binder_dec_node_nilocked()
879 assert_spin_locked(&proc->inner_lock); in binder_dec_node_nilocked()
895 if (proc && (node->has_strong_ref || node->has_weak_ref)) { in binder_dec_node_nilocked()
897 binder_enqueue_work_ilocked(&node->work, &proc->todo); in binder_dec_node_nilocked()
898 binder_wakeup_proc_ilocked(proc); in binder_dec_node_nilocked()
903 if (proc) { in binder_dec_node_nilocked()
905 rb_erase(&node->rb_node, &proc->nodes); in binder_dec_node_nilocked()
969 if (node->proc) in binder_inc_node_tmpref()
970 binder_inner_proc_lock(node->proc); in binder_inc_node_tmpref()
974 if (node->proc) in binder_inc_node_tmpref()
975 binder_inner_proc_unlock(node->proc); in binder_inc_node_tmpref()
992 if (!node->proc) in binder_dec_node_tmpref()
998 if (!node->proc) in binder_dec_node_tmpref()
1019 static struct binder_ref *binder_get_ref_olocked(struct binder_proc *proc, in binder_get_ref_olocked() argument
1022 struct rb_node *n = proc->refs_by_desc.rb_node; in binder_get_ref_olocked()
1043 static u32 slow_desc_lookup_olocked(struct binder_proc *proc, u32 offset) in slow_desc_lookup_olocked() argument
1050 for (n = rb_first(&proc->refs_by_desc); n; n = rb_next(n)) { in slow_desc_lookup_olocked()
1065 static int get_ref_desc_olocked(struct binder_proc *proc, in get_ref_desc_olocked() argument
1069 struct dbitmap *dmap = &proc->dmap; in get_ref_desc_olocked()
1074 offset = (node == proc->context->binder_context_mgr_node) ? 0 : 1; in get_ref_desc_olocked()
1077 *desc = slow_desc_lookup_olocked(proc, offset); in get_ref_desc_olocked()
1091 binder_proc_unlock(proc); in get_ref_desc_olocked()
1093 binder_proc_lock(proc); in get_ref_desc_olocked()
1118 struct binder_proc *proc, in binder_get_ref_for_node_olocked() argument
1128 p = &proc->refs_by_node.rb_node; in binder_get_ref_for_node_olocked()
1145 if (get_ref_desc_olocked(proc, node, &desc) == -EAGAIN) in binder_get_ref_for_node_olocked()
1150 new_ref->proc = proc; in binder_get_ref_for_node_olocked()
1153 rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node); in binder_get_ref_for_node_olocked()
1156 p = &proc->refs_by_desc.rb_node; in binder_get_ref_for_node_olocked()
1169 rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); in binder_get_ref_for_node_olocked()
1176 proc->pid, new_ref->data.debug_id, new_ref->data.desc, in binder_get_ref_for_node_olocked()
1184 struct dbitmap *dmap = &ref->proc->dmap; in binder_cleanup_ref_olocked()
1189 ref->proc->pid, ref->data.debug_id, ref->data.desc, in binder_cleanup_ref_olocked()
1194 rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); in binder_cleanup_ref_olocked()
1195 rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); in binder_cleanup_ref_olocked()
1219 ref->proc->pid, ref->data.debug_id, in binder_cleanup_ref_olocked()
1221 binder_dequeue_work(ref->proc, &ref->death->work); in binder_cleanup_ref_olocked()
1226 binder_dequeue_work(ref->proc, &ref->freeze->work); in binder_cleanup_ref_olocked()
1280 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1291 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1317 struct binder_proc *proc, in binder_get_node_from_ref() argument
1324 binder_proc_lock(proc); in binder_get_node_from_ref()
1325 ref = binder_get_ref_olocked(proc, desc, need_strong_ref); in binder_get_node_from_ref()
1336 binder_proc_unlock(proc); in binder_get_node_from_ref()
1341 binder_proc_unlock(proc); in binder_get_node_from_ref()
1362 static void try_shrink_dmap(struct binder_proc *proc) in try_shrink_dmap() argument
1367 binder_proc_lock(proc); in try_shrink_dmap()
1368 nbits = dbitmap_shrink_nbits(&proc->dmap); in try_shrink_dmap()
1369 binder_proc_unlock(proc); in try_shrink_dmap()
1375 binder_proc_lock(proc); in try_shrink_dmap()
1376 dbitmap_shrink(&proc->dmap, new, nbits); in try_shrink_dmap()
1377 binder_proc_unlock(proc); in try_shrink_dmap()
1393 static int binder_update_ref_for_handle(struct binder_proc *proc, in binder_update_ref_for_handle() argument
1401 binder_proc_lock(proc); in binder_update_ref_for_handle()
1402 ref = binder_get_ref_olocked(proc, desc, strong); in binder_update_ref_for_handle()
1414 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1418 try_shrink_dmap(proc); in binder_update_ref_for_handle()
1423 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1438 static int binder_dec_ref_for_handle(struct binder_proc *proc, in binder_dec_ref_for_handle() argument
1441 return binder_update_ref_for_handle(proc, desc, false, strong, rdata); in binder_dec_ref_for_handle()
1458 static int binder_inc_ref_for_node(struct binder_proc *proc, in binder_inc_ref_for_node() argument
1468 binder_proc_lock(proc); in binder_inc_ref_for_node()
1469 ref = binder_get_ref_for_node_olocked(proc, node, NULL); in binder_inc_ref_for_node()
1471 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1475 binder_proc_lock(proc); in binder_inc_ref_for_node()
1476 ref = binder_get_ref_for_node_olocked(proc, node, new_ref); in binder_inc_ref_for_node()
1492 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1506 assert_spin_locked(&target_thread->proc->inner_lock); in binder_pop_transaction_ilocked()
1532 binder_inner_proc_lock(thread->proc); in binder_thread_dec_tmpref()
1535 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1539 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1554 static void binder_proc_dec_tmpref(struct binder_proc *proc) in binder_proc_dec_tmpref() argument
1556 binder_inner_proc_lock(proc); in binder_proc_dec_tmpref()
1557 proc->tmp_ref--; in binder_proc_dec_tmpref()
1558 if (proc->is_dead && RB_EMPTY_ROOT(&proc->threads) && in binder_proc_dec_tmpref()
1559 !proc->tmp_ref) { in binder_proc_dec_tmpref()
1560 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1561 binder_free_proc(proc); in binder_proc_dec_tmpref()
1564 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1602 __acquires(&t->from->proc->inner_lock) in binder_get_txn_from_and_acq_inner()
1608 __acquire(&from->proc->inner_lock); in binder_get_txn_from_and_acq_inner()
1611 binder_inner_proc_lock(from->proc); in binder_get_txn_from_and_acq_inner()
1616 binder_inner_proc_unlock(from->proc); in binder_get_txn_from_and_acq_inner()
1617 __acquire(&from->proc->inner_lock); in binder_get_txn_from_and_acq_inner()
1650 from_proc = t->from ? t->from->proc->pid : 0; in binder_txn_latency_free()
1699 target_thread->proc->pid, in binder_send_failed_reply()
1719 binder_inner_proc_unlock(target_thread->proc); in binder_send_failed_reply()
1724 __release(&target_thread->proc->inner_lock); in binder_send_failed_reply()
1780 static size_t binder_get_object(struct binder_proc *proc, in binder_get_object() argument
1799 if (binder_alloc_copy_from_buffer(&proc->alloc, object, buffer, in binder_get_object()
1855 struct binder_proc *proc, in binder_validate_ptr() argument
1871 if (binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_validate_ptr()
1875 object_size = binder_get_object(proc, NULL, b, object_offset, object); in binder_validate_ptr()
1923 static bool binder_validate_fixup(struct binder_proc *proc, in binder_validate_fixup() argument
1940 size_t object_size = binder_get_object(proc, NULL, b, in binder_validate_fixup()
1956 if (binder_alloc_copy_from_buffer(&proc->alloc, in binder_validate_fixup()
2027 static void binder_transaction_buffer_release(struct binder_proc *proc, in binder_transaction_buffer_release() argument
2038 proc->pid, buffer->debug_id, in binder_transaction_buffer_release()
2054 if (!binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_transaction_buffer_release()
2057 object_size = binder_get_object(proc, NULL, buffer, in binder_transaction_buffer_release()
2072 node = binder_get_node(proc, fp->binder); in binder_transaction_buffer_release()
2092 ret = binder_dec_ref_for_handle(proc, fp->handle, in binder_transaction_buffer_release()
2142 parent = binder_validate_ptr(proc, buffer, &ptr_object, in binder_transaction_buffer_release()
2182 &proc->alloc, &fd, buffer, in binder_transaction_buffer_release()
2206 static inline void binder_release_entire_buffer(struct binder_proc *proc, in binder_release_entire_buffer() argument
2216 binder_transaction_buffer_release(proc, thread, buffer, in binder_release_entire_buffer()
2225 struct binder_proc *proc = thread->proc; in binder_translate_binder() local
2230 node = binder_get_node(proc, fp->binder); in binder_translate_binder()
2232 node = binder_new_node(proc, fp); in binder_translate_binder()
2238 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2244 if (security_binder_transfer_binder(proc->cred, target_proc->cred)) { in binder_translate_binder()
2277 struct binder_proc *proc = thread->proc; in binder_translate_handle() local
2283 node = binder_get_node_from_ref(proc, fp->handle, in binder_translate_handle()
2287 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2290 if (security_binder_transfer_binder(proc->cred, target_proc->cred)) { in binder_translate_handle()
2296 if (node->proc == target_proc) { in binder_translate_handle()
2303 if (node->proc) in binder_translate_handle()
2304 binder_inner_proc_lock(node->proc); in binder_translate_handle()
2306 __acquire(&node->proc->inner_lock); in binder_translate_handle()
2310 if (node->proc) in binder_translate_handle()
2311 binder_inner_proc_unlock(node->proc); in binder_translate_handle()
2313 __release(&node->proc->inner_lock); in binder_translate_handle()
2351 struct binder_proc *proc = thread->proc; in binder_translate_fd() local
2364 proc->pid, thread->pid, in binder_translate_fd()
2374 proc->pid, thread->pid, fd); in binder_translate_fd()
2378 ret = security_binder_transfer_file(proc->cred, target_proc->cred, file); in binder_translate_fd()
2665 struct binder_proc *proc = thread->proc; in binder_translate_fd_array() local
2674 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2681 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2699 proc->pid, thread->pid); in binder_translate_fd_array()
2732 struct binder_proc *proc = thread->proc; in binder_fixup_parent() local
2746 proc->pid, thread->pid); in binder_fixup_parent()
2755 proc->pid, thread->pid); in binder_fixup_parent()
2763 proc->pid, thread->pid); in binder_fixup_parent()
2844 struct binder_proc *proc, in binder_proc_transaction() argument
2863 binder_inner_proc_lock(proc); in binder_proc_transaction()
2864 if (proc->is_frozen) { in binder_proc_transaction()
2866 proc->sync_recv |= !oneway; in binder_proc_transaction()
2867 proc->async_recv |= oneway; in binder_proc_transaction()
2870 if ((frozen && !oneway) || proc->is_dead || in binder_proc_transaction()
2872 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2878 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2883 binder_enqueue_work_ilocked(&t->work, &proc->todo); in binder_proc_transaction()
2893 proc->outstanding_txns--; in binder_proc_transaction()
2900 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2902 proc->outstanding_txns++; in binder_proc_transaction()
2903 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2916 binder_release_entire_buffer(proc, NULL, buffer, false); in binder_proc_transaction()
2917 binder_alloc_free_buf(&proc->alloc, buffer); in binder_proc_transaction()
2957 if (node->proc) { in binder_get_node_refs_for_txn()
2961 node->proc->tmp_ref++; in binder_get_node_refs_for_txn()
2962 *procp = node->proc; in binder_get_node_refs_for_txn()
2977 __release(&from->proc->inner_lock); in binder_set_txn_from_error()
2984 binder_inner_proc_unlock(from->proc); in binder_set_txn_from_error()
2999 static void binder_netlink_report(struct binder_proc *proc, in binder_netlink_report() argument
3004 const char *context = proc->context->name; in binder_netlink_report()
3055 static void binder_transaction(struct binder_proc *proc, in binder_transaction() argument
3079 struct binder_context *context = proc->context; in binder_transaction()
3093 e->from_proc = proc->pid; in binder_transaction()
3098 strscpy(e->context_name, proc->context->name, BINDERFS_MAX_NAME); in binder_transaction()
3100 binder_inner_proc_lock(proc); in binder_transaction()
3102 binder_inner_proc_unlock(proc); in binder_transaction()
3107 thread->pid, proc->pid); in binder_transaction()
3118 t->from_pid = proc->pid; in binder_transaction()
3131 binder_inner_proc_lock(proc); in binder_transaction()
3134 binder_inner_proc_unlock(proc); in binder_transaction()
3136 proc->pid, thread->pid); in binder_transaction()
3145 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
3151 binder_inner_proc_unlock(proc); in binder_transaction()
3159 binder_inner_proc_unlock(proc); in binder_transaction()
3164 __release(&target_thread->proc->inner_lock); in binder_transaction()
3166 thread->pid, proc->pid); in binder_transaction()
3173 proc->pid, thread->pid, in binder_transaction()
3177 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
3185 target_proc = target_thread->proc; in binder_transaction()
3187 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
3199 binder_proc_lock(proc); in binder_transaction()
3200 ref = binder_get_ref_olocked(proc, tr->target.handle, in binder_transaction()
3208 proc->pid, thread->pid, tr->target.handle); in binder_transaction()
3211 binder_proc_unlock(proc); in binder_transaction()
3222 if (target_node && target_proc->pid == proc->pid) { in binder_transaction()
3224 proc->pid, thread->pid); in binder_transaction()
3233 proc->pid, thread->pid); in binder_transaction()
3240 if (WARN_ON(proc == target_proc)) { in binder_transaction()
3242 thread->pid, proc->pid); in binder_transaction()
3248 if (security_binder_transaction(proc->cred, in binder_transaction()
3251 thread->pid, proc->pid); in binder_transaction()
3257 binder_inner_proc_lock(proc); in binder_transaction()
3273 proc->pid, thread->pid); in binder_transaction()
3274 binder_inner_proc_unlock(proc); in binder_transaction()
3288 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
3293 binder_inner_proc_unlock(proc); in binder_transaction()
3304 if (from && from->proc == target_proc) { in binder_transaction()
3314 binder_inner_proc_unlock(proc); in binder_transaction()
3326 thread->pid, proc->pid); in binder_transaction()
3337 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3344 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3353 security_cred_getsecid(proc->cred, &secid); in binder_transaction()
3357 thread->pid, proc->pid); in binder_transaction()
3367 thread->pid, proc->pid); in binder_transaction()
3429 proc->pid, thread->pid); in binder_transaction()
3437 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3445 proc->pid, thread->pid, in binder_transaction()
3473 thread->pid, proc->pid); in binder_transaction()
3493 proc->pid, thread->pid); in binder_transaction()
3503 proc->pid, thread->pid, in binder_transaction()
3534 thread->pid, proc->pid); in binder_transaction()
3553 thread->pid, proc->pid); in binder_transaction()
3575 thread->pid, proc->pid); in binder_transaction()
3599 proc->pid, thread->pid); in binder_transaction()
3612 proc->pid, thread->pid); in binder_transaction()
3623 binder_get_object(proc, user_buffer, t->buffer, in binder_transaction()
3627 proc->pid, thread->pid, in binder_transaction()
3646 thread->pid, proc->pid); in binder_transaction()
3664 proc->pid, thread->pid); in binder_transaction()
3675 thread->pid, proc->pid); in binder_transaction()
3699 thread->pid, proc->pid); in binder_transaction()
3710 proc->pid, thread->pid, hdr->type); in binder_transaction()
3724 proc->pid, thread->pid); in binder_transaction()
3735 proc->pid, thread->pid); in binder_transaction()
3743 binder_netlink_report(proc, t, tr->data_size, in binder_transaction()
3766 binder_inner_proc_lock(proc); in binder_transaction()
3777 binder_inner_proc_unlock(proc); in binder_transaction()
3781 binder_inner_proc_lock(proc); in binder_transaction()
3783 binder_inner_proc_unlock(proc); in binder_transaction()
3805 binder_netlink_report(proc, &t_copy, tr->data_size, in binder_transaction()
3828 proc->pid, thread->pid, in binder_transaction()
3831 binder_dequeue_work(proc, tcomplete); in binder_transaction()
3867 binder_netlink_report(proc, t, tr->data_size, return_error); in binder_transaction()
3874 proc->pid, thread->pid, reply ? "reply" : in binder_transaction()
3912 binder_inner_proc_lock(proc); in binder_transaction()
3915 binder_inner_proc_unlock(proc); in binder_transaction()
3922 binder_request_freeze_notification(struct binder_proc *proc, in binder_request_freeze_notification() argument
3932 binder_proc_lock(proc); in binder_request_freeze_notification()
3933 ref = binder_get_ref_olocked(proc, handle_cookie->handle, false); in binder_request_freeze_notification()
3936 proc->pid, thread->pid, handle_cookie->handle); in binder_request_freeze_notification()
3937 binder_proc_unlock(proc); in binder_request_freeze_notification()
3945 proc->pid, thread->pid); in binder_request_freeze_notification()
3947 binder_proc_unlock(proc); in binder_request_freeze_notification()
3958 if (ref->node->proc) { in binder_request_freeze_notification()
3959 binder_inner_proc_lock(ref->node->proc); in binder_request_freeze_notification()
3960 freeze->is_frozen = ref->node->proc->is_frozen; in binder_request_freeze_notification()
3961 binder_inner_proc_unlock(ref->node->proc); in binder_request_freeze_notification()
3963 binder_inner_proc_lock(proc); in binder_request_freeze_notification()
3964 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_request_freeze_notification()
3965 binder_wakeup_proc_ilocked(proc); in binder_request_freeze_notification()
3966 binder_inner_proc_unlock(proc); in binder_request_freeze_notification()
3970 binder_proc_unlock(proc); in binder_request_freeze_notification()
3975 binder_clear_freeze_notification(struct binder_proc *proc, in binder_clear_freeze_notification() argument
3982 binder_proc_lock(proc); in binder_clear_freeze_notification()
3983 ref = binder_get_ref_olocked(proc, handle_cookie->handle, false); in binder_clear_freeze_notification()
3986 proc->pid, thread->pid, handle_cookie->handle); in binder_clear_freeze_notification()
3987 binder_proc_unlock(proc); in binder_clear_freeze_notification()
3995 proc->pid, thread->pid); in binder_clear_freeze_notification()
3997 binder_proc_unlock(proc); in binder_clear_freeze_notification()
4001 binder_inner_proc_lock(proc); in binder_clear_freeze_notification()
4004 proc->pid, thread->pid, (u64)freeze->cookie, in binder_clear_freeze_notification()
4006 binder_inner_proc_unlock(proc); in binder_clear_freeze_notification()
4008 binder_proc_unlock(proc); in binder_clear_freeze_notification()
4022 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_clear_freeze_notification()
4023 binder_wakeup_proc_ilocked(proc); in binder_clear_freeze_notification()
4027 binder_inner_proc_unlock(proc); in binder_clear_freeze_notification()
4029 binder_proc_unlock(proc); in binder_clear_freeze_notification()
4034 binder_freeze_notification_done(struct binder_proc *proc, in binder_freeze_notification_done() argument
4041 binder_inner_proc_lock(proc); in binder_freeze_notification_done()
4042 list_for_each_entry(w, &proc->delivered_freeze, entry) { in binder_freeze_notification_done()
4053 proc->pid, thread->pid, (u64)cookie); in binder_freeze_notification_done()
4054 binder_inner_proc_unlock(proc); in binder_freeze_notification_done()
4061 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_freeze_notification_done()
4062 binder_wakeup_proc_ilocked(proc); in binder_freeze_notification_done()
4064 binder_inner_proc_unlock(proc); in binder_freeze_notification_done()
4081 binder_free_buf(struct binder_proc *proc, in binder_free_buf() argument
4085 binder_inner_proc_lock(proc); in binder_free_buf()
4090 binder_inner_proc_unlock(proc); in binder_free_buf()
4098 BUG_ON(buf_node->proc != proc); in binder_free_buf()
4105 w, &proc->todo); in binder_free_buf()
4106 binder_wakeup_proc_ilocked(proc); in binder_free_buf()
4111 binder_release_entire_buffer(proc, thread, buffer, is_failure); in binder_free_buf()
4112 binder_alloc_free_buf(&proc->alloc, buffer); in binder_free_buf()
4115 static int binder_thread_write(struct binder_proc *proc, in binder_thread_write() argument
4121 struct binder_context *context = proc->context; in binder_thread_write()
4135 atomic_inc(&proc->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
4160 if (ctx_mgr_node->proc == proc) { in binder_thread_write()
4162 proc->pid, thread->pid); in binder_thread_write()
4167 proc, ctx_mgr_node, in binder_thread_write()
4174 proc, target, increment, strong, in binder_thread_write()
4178 proc->pid, thread->pid, in binder_thread_write()
4198 proc->pid, thread->pid, debug_string, in binder_thread_write()
4204 proc->pid, thread->pid, debug_string, in binder_thread_write()
4222 node = binder_get_node(proc, node_ptr); in binder_thread_write()
4225 proc->pid, thread->pid, in binder_thread_write()
4234 proc->pid, thread->pid, in binder_thread_write()
4246 proc->pid, thread->pid, in binder_thread_write()
4256 proc->pid, thread->pid, in binder_thread_write()
4269 proc->pid, thread->pid, in binder_thread_write()
4292 buffer = binder_alloc_prepare_to_free(&proc->alloc, in binder_thread_write()
4298 proc->pid, thread->pid, in binder_thread_write()
4299 (unsigned long)data_ptr - proc->alloc.vm_start); in binder_thread_write()
4303 proc->pid, thread->pid, in binder_thread_write()
4304 (unsigned long)data_ptr - proc->alloc.vm_start); in binder_thread_write()
4310 proc->pid, thread->pid, in binder_thread_write()
4311 (unsigned long)data_ptr - proc->alloc.vm_start, in binder_thread_write()
4314 binder_free_buf(proc, thread, buffer, false); in binder_thread_write()
4325 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
4336 binder_transaction(proc, thread, &tr, in binder_thread_write()
4344 proc->pid, thread->pid); in binder_thread_write()
4345 binder_inner_proc_lock(proc); in binder_thread_write()
4349 proc->pid, thread->pid); in binder_thread_write()
4350 } else if (proc->requested_threads == 0) { in binder_thread_write()
4353 proc->pid, thread->pid); in binder_thread_write()
4355 proc->requested_threads--; in binder_thread_write()
4356 proc->requested_threads_started++; in binder_thread_write()
4359 binder_inner_proc_unlock(proc); in binder_thread_write()
4364 proc->pid, thread->pid); in binder_thread_write()
4368 proc->pid, thread->pid); in binder_thread_write()
4375 proc->pid, thread->pid); in binder_thread_write()
4408 proc->pid, thread->pid); in binder_thread_write()
4412 binder_proc_lock(proc); in binder_thread_write()
4413 ref = binder_get_ref_olocked(proc, target, false); in binder_thread_write()
4416 proc->pid, thread->pid, in binder_thread_write()
4421 binder_proc_unlock(proc); in binder_thread_write()
4428 proc->pid, thread->pid, in binder_thread_write()
4440 proc->pid, thread->pid); in binder_thread_write()
4442 binder_proc_unlock(proc); in binder_thread_write()
4450 if (ref->node->proc == NULL) { in binder_thread_write()
4453 binder_inner_proc_lock(proc); in binder_thread_write()
4455 &ref->death->work, &proc->todo); in binder_thread_write()
4456 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
4457 binder_inner_proc_unlock(proc); in binder_thread_write()
4462 proc->pid, thread->pid); in binder_thread_write()
4464 binder_proc_unlock(proc); in binder_thread_write()
4470 proc->pid, thread->pid, in binder_thread_write()
4474 binder_proc_unlock(proc); in binder_thread_write()
4478 binder_inner_proc_lock(proc); in binder_thread_write()
4490 &proc->todo); in binder_thread_write()
4492 proc); in binder_thread_write()
4498 binder_inner_proc_unlock(proc); in binder_thread_write()
4501 binder_proc_unlock(proc); in binder_thread_write()
4512 binder_inner_proc_lock(proc); in binder_thread_write()
4513 list_for_each_entry(w, &proc->delivered_death, in binder_thread_write()
4527 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
4531 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
4532 binder_inner_proc_unlock(proc); in binder_thread_write()
4546 &proc->todo); in binder_thread_write()
4547 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
4550 binder_inner_proc_unlock(proc); in binder_thread_write()
4560 error = binder_request_freeze_notification(proc, thread, in binder_thread_write()
4573 error = binder_clear_freeze_notification(proc, thread, &handle_cookie); in binder_thread_write()
4586 error = binder_freeze_notification_done(proc, thread, cookie); in binder_thread_write()
4593 proc->pid, thread->pid, cmd); in binder_thread_write()
4601 static void binder_stat_br(struct binder_proc *proc, in binder_stat_br() argument
4607 atomic_inc(&proc->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
4612 static int binder_put_node_cmd(struct binder_proc *proc, in binder_put_node_cmd() argument
4634 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
4636 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
4647 struct binder_proc *proc = thread->proc; in binder_wait_for_work() local
4650 binder_inner_proc_lock(proc); in binder_wait_for_work()
4657 &proc->waiting_threads); in binder_wait_for_work()
4658 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4660 binder_inner_proc_lock(proc); in binder_wait_for_work()
4668 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4688 static int binder_apply_fd_fixups(struct binder_proc *proc, in binder_apply_fd_fixups() argument
4709 if (binder_alloc_copy_to_buffer(&proc->alloc, t->buffer, in binder_apply_fd_fixups()
4729 static int binder_thread_read(struct binder_proc *proc, in binder_thread_read() argument
4748 binder_inner_proc_lock(proc); in binder_thread_read()
4750 binder_inner_proc_unlock(proc); in binder_thread_read()
4756 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
4761 proc->pid, thread->pid, thread->looper); in binder_thread_read()
4765 binder_set_nice(proc->default_priority); in binder_thread_read()
4790 binder_inner_proc_lock(proc); in binder_thread_read()
4793 else if (!binder_worklist_empty_ilocked(&proc->todo) && in binder_thread_read()
4795 list = &proc->todo; in binder_thread_read()
4797 binder_inner_proc_unlock(proc); in binder_thread_read()
4806 binder_inner_proc_unlock(proc); in binder_thread_read()
4815 binder_inner_proc_unlock(proc); in binder_thread_read()
4823 binder_inner_proc_unlock(proc); in binder_thread_read()
4830 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4835 if (proc->oneway_spam_detection_enabled && in binder_thread_read()
4842 binder_inner_proc_unlock(proc); in binder_thread_read()
4849 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4852 proc->pid, thread->pid); in binder_thread_read()
4864 BUG_ON(proc != node->proc); in binder_thread_read()
4890 proc->pid, thread->pid, in binder_thread_read()
4894 rb_erase(&node->rb_node, &proc->nodes); in binder_thread_read()
4895 binder_inner_proc_unlock(proc); in binder_thread_read()
4909 binder_inner_proc_unlock(proc); in binder_thread_read()
4913 proc, thread, &ptr, node_ptr, in binder_thread_read()
4918 proc, thread, &ptr, node_ptr, in binder_thread_read()
4923 proc, thread, &ptr, node_ptr, in binder_thread_read()
4928 proc, thread, &ptr, node_ptr, in binder_thread_read()
4934 proc->pid, thread->pid, in binder_thread_read()
4957 proc->pid, thread->pid, in binder_thread_read()
4963 binder_inner_proc_unlock(proc); in binder_thread_read()
4968 w, &proc->delivered_death); in binder_thread_read()
4969 binder_inner_proc_unlock(proc); in binder_thread_read()
4978 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4992 binder_enqueue_work_ilocked(w, &proc->delivered_freeze); in binder_thread_read()
4993 binder_inner_proc_unlock(proc); in binder_thread_read()
5001 binder_stat_br(proc, thread, BR_FROZEN_BINDER); in binder_thread_read()
5010 binder_inner_proc_unlock(proc); in binder_thread_read()
5019 binder_stat_br(proc, thread, BR_CLEAR_FREEZE_NOTIFICATION_DONE); in binder_thread_read()
5023 binder_inner_proc_unlock(proc); in binder_thread_read()
5025 proc->pid, thread->pid, w->type); in binder_thread_read()
5057 struct task_struct *sender = t_from->proc->tsk; in binder_thread_read()
5066 ret = binder_apply_fd_fixups(proc, t); in binder_thread_read()
5077 binder_free_buf(proc, thread, buffer, true); in binder_thread_read()
5080 proc->pid, thread->pid, in binder_thread_read()
5089 binder_stat_br(proc, thread, cmd); in binder_thread_read()
5128 binder_stat_br(proc, thread, cmd); in binder_thread_read()
5131 proc->pid, thread->pid, in binder_thread_read()
5135 t->debug_id, t_from ? t_from->proc->pid : 0, in binder_thread_read()
5143 binder_inner_proc_lock(thread->proc); in binder_thread_read()
5147 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
5157 binder_inner_proc_lock(proc); in binder_thread_read()
5158 if (proc->requested_threads == 0 && in binder_thread_read()
5159 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
5160 proc->requested_threads_started < proc->max_threads && in binder_thread_read()
5164 proc->requested_threads++; in binder_thread_read()
5165 binder_inner_proc_unlock(proc); in binder_thread_read()
5168 proc->pid, thread->pid); in binder_thread_read()
5171 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
5173 binder_inner_proc_unlock(proc); in binder_thread_read()
5177 static void binder_release_work(struct binder_proc *proc, in binder_release_work() argument
5184 binder_inner_proc_lock(proc); in binder_release_work()
5187 binder_inner_proc_unlock(proc); in binder_release_work()
5249 struct binder_proc *proc, struct binder_thread *new_thread) in binder_get_thread_ilocked() argument
5253 struct rb_node **p = &proc->threads.rb_node; in binder_get_thread_ilocked()
5270 thread->proc = proc; in binder_get_thread_ilocked()
5276 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
5287 static struct binder_thread *binder_get_thread(struct binder_proc *proc) in binder_get_thread() argument
5292 binder_inner_proc_lock(proc); in binder_get_thread()
5293 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
5294 binder_inner_proc_unlock(proc); in binder_get_thread()
5299 binder_inner_proc_lock(proc); in binder_get_thread()
5300 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
5301 binder_inner_proc_unlock(proc); in binder_get_thread()
5308 static void binder_free_proc(struct binder_proc *proc) in binder_free_proc() argument
5312 BUG_ON(!list_empty(&proc->todo)); in binder_free_proc()
5313 BUG_ON(!list_empty(&proc->delivered_death)); in binder_free_proc()
5314 if (proc->outstanding_txns) in binder_free_proc()
5316 __func__, proc->outstanding_txns); in binder_free_proc()
5317 device = container_of(proc->context, struct binder_device, context); in binder_free_proc()
5320 kfree(proc->context->name); in binder_free_proc()
5323 binder_alloc_deferred_release(&proc->alloc); in binder_free_proc()
5324 put_task_struct(proc->tsk); in binder_free_proc()
5325 put_cred(proc->cred); in binder_free_proc()
5327 dbitmap_free(&proc->dmap); in binder_free_proc()
5328 kfree(proc); in binder_free_proc()
5335 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
5339 static int binder_thread_release(struct binder_proc *proc, in binder_thread_release() argument
5347 binder_inner_proc_lock(thread->proc); in binder_thread_release()
5354 proc->tmp_ref++; in binder_thread_release()
5360 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
5376 proc->pid, thread->pid, in binder_thread_release()
5381 thread->proc->outstanding_txns--; in binder_thread_release()
5410 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
5424 binder_release_work(proc, &thread->todo); in binder_thread_release()
5432 struct binder_proc *proc = filp->private_data; in binder_poll() local
5436 thread = binder_get_thread(proc); in binder_poll()
5440 binder_inner_proc_lock(thread->proc); in binder_poll()
5444 binder_inner_proc_unlock(thread->proc); in binder_poll()
5458 struct binder_proc *proc = filp->private_data; in binder_ioctl_write_read() local
5467 proc->pid, thread->pid, in binder_ioctl_write_read()
5472 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
5483 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
5488 binder_inner_proc_lock(proc); in binder_ioctl_write_read()
5489 if (!binder_worklist_empty_ilocked(&proc->todo)) in binder_ioctl_write_read()
5490 binder_wakeup_proc_ilocked(proc); in binder_ioctl_write_read()
5491 binder_inner_proc_unlock(proc); in binder_ioctl_write_read()
5497 proc->pid, thread->pid, in binder_ioctl_write_read()
5510 struct binder_proc *proc = filp->private_data; in binder_ioctl_set_ctx_mgr() local
5511 struct binder_context *context = proc->context; in binder_ioctl_set_ctx_mgr()
5520 ret = security_binder_set_context_mgr(proc->cred); in binder_ioctl_set_ctx_mgr()
5534 new_node = binder_new_node(proc, fbo); in binder_ioctl_set_ctx_mgr()
5548 static int binder_ioctl_get_node_info_for_ref(struct binder_proc *proc, in binder_ioctl_get_node_info_for_ref() argument
5552 struct binder_context *context = proc->context; in binder_ioctl_get_node_info_for_ref()
5558 proc->pid); in binder_ioctl_get_node_info_for_ref()
5565 context->binder_context_mgr_node->proc != proc) { in binder_ioctl_get_node_info_for_ref()
5571 node = binder_get_node_from_ref(proc, handle, true, NULL); in binder_ioctl_get_node_info_for_ref()
5584 static int binder_ioctl_get_node_debug_info(struct binder_proc *proc, in binder_ioctl_get_node_debug_info() argument
5592 binder_inner_proc_lock(proc); in binder_ioctl_get_node_debug_info()
5593 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in binder_ioctl_get_node_debug_info()
5604 binder_inner_proc_unlock(proc); in binder_ioctl_get_node_debug_info()
5609 static bool binder_txns_pending_ilocked(struct binder_proc *proc) in binder_txns_pending_ilocked() argument
5614 if (proc->outstanding_txns > 0) in binder_txns_pending_ilocked()
5617 for (n = rb_first(&proc->threads); n; n = rb_next(n)) { in binder_txns_pending_ilocked()
5625 static void binder_add_freeze_work(struct binder_proc *proc, bool is_frozen) in binder_add_freeze_work() argument
5631 binder_inner_proc_lock(proc); in binder_add_freeze_work()
5632 for (n = rb_first(&proc->nodes); n; n = rb_next(n)) { in binder_add_freeze_work()
5637 binder_inner_proc_unlock(proc); in binder_add_freeze_work()
5648 binder_inner_proc_lock(ref->proc); in binder_add_freeze_work()
5650 binder_inner_proc_unlock(ref->proc); in binder_add_freeze_work()
5656 binder_enqueue_work_ilocked(&ref->freeze->work, &ref->proc->todo); in binder_add_freeze_work()
5657 binder_wakeup_proc_ilocked(ref->proc); in binder_add_freeze_work()
5663 binder_inner_proc_unlock(ref->proc); in binder_add_freeze_work()
5667 binder_inner_proc_lock(proc); in binder_add_freeze_work()
5668 if (proc->is_dead) in binder_add_freeze_work()
5671 binder_inner_proc_unlock(proc); in binder_add_freeze_work()
5762 binder_inner_proc_lock(thread->proc); in binder_ioctl_get_extended_error()
5765 binder_inner_proc_unlock(thread->proc); in binder_ioctl_get_extended_error()
5776 struct binder_proc *proc = filp->private_data; in binder_ioctl() local
5786 thread = binder_get_thread(proc); in binder_ioctl()
5806 binder_inner_proc_lock(proc); in binder_ioctl()
5807 proc->max_threads = max_threads; in binder_ioctl()
5808 binder_inner_proc_unlock(proc); in binder_ioctl()
5830 proc->pid, thread->pid); in binder_ioctl()
5831 binder_thread_release(proc, thread); in binder_ioctl()
5852 ret = binder_ioctl_get_node_info_for_ref(proc, &info); in binder_ioctl()
5871 ret = binder_ioctl_get_node_debug_info(proc, &info); in binder_ioctl()
5965 binder_inner_proc_lock(proc); in binder_ioctl()
5966 proc->oneway_spam_detection_enabled = (bool)enable; in binder_ioctl()
5967 binder_inner_proc_unlock(proc); in binder_ioctl()
5985 pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); in binder_ioctl()
5993 struct binder_proc *proc = vma->vm_private_data; in binder_vma_open() local
5997 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_open()
6004 struct binder_proc *proc = vma->vm_private_data; in binder_vma_close() local
6008 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_close()
6011 binder_alloc_vma_close(&proc->alloc); in binder_vma_close()
6028 struct binder_proc *proc = filp->private_data; in binder_mmap() local
6030 if (!same_thread_group(proc->tsk, current)) in binder_mmap()
6035 __func__, proc->pid, vma->vm_start, vma->vm_end, in binder_mmap()
6041 proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", -EPERM); in binder_mmap()
6047 vma->vm_private_data = proc; in binder_mmap()
6049 return binder_alloc_mmap_handler(&proc->alloc, vma); in binder_mmap()
6054 struct binder_proc *proc, *itr; in binder_open() local
6063 proc = kzalloc_obj(*proc); in binder_open()
6064 if (proc == NULL) in binder_open()
6067 dbitmap_init(&proc->dmap); in binder_open()
6068 spin_lock_init(&proc->inner_lock); in binder_open()
6069 spin_lock_init(&proc->outer_lock); in binder_open()
6070 proc->tsk = get_task_struct(current->group_leader); in binder_open()
6071 proc->pid = current->tgid; in binder_open()
6072 proc->cred = get_cred(filp->f_cred); in binder_open()
6073 INIT_LIST_HEAD(&proc->todo); in binder_open()
6074 init_waitqueue_head(&proc->freeze_wait); in binder_open()
6075 proc->default_priority = task_nice(current); in binder_open()
6086 proc->context = &binder_dev->context; in binder_open()
6087 binder_alloc_init(&proc->alloc); in binder_open()
6090 INIT_LIST_HEAD(&proc->delivered_death); in binder_open()
6091 INIT_LIST_HEAD(&proc->delivered_freeze); in binder_open()
6092 INIT_LIST_HEAD(&proc->waiting_threads); in binder_open()
6093 filp->private_data = proc; in binder_open()
6097 if (itr->pid == proc->pid) { in binder_open()
6102 hlist_add_head(&proc->proc_node, &binder_procs); in binder_open()
6108 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
6115 proc->debugfs_entry = debugfs_create_file(strbuf, 0444, in binder_open()
6117 (void *)(unsigned long)proc->pid, in binder_open()
6125 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
6133 strbuf, &proc_fops, (void *)(unsigned long)proc->pid); in binder_open()
6135 proc->binderfs_entry = binderfs_entry; in binder_open()
6150 struct binder_proc *proc = filp->private_data; in binder_flush() local
6152 binder_defer_work(proc, BINDER_DEFERRED_FLUSH); in binder_flush()
6157 static void binder_deferred_flush(struct binder_proc *proc) in binder_deferred_flush() argument
6162 binder_inner_proc_lock(proc); in binder_deferred_flush()
6163 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_deferred_flush()
6172 binder_inner_proc_unlock(proc); in binder_deferred_flush()
6175 "binder_flush: %d woke %d threads\n", proc->pid, in binder_deferred_flush()
6181 struct binder_proc *proc = filp->private_data; in binder_release() local
6183 debugfs_remove(proc->debugfs_entry); in binder_release()
6185 if (proc->binderfs_entry) { in binder_release()
6186 simple_recursive_removal(proc->binderfs_entry, NULL); in binder_release()
6187 proc->binderfs_entry = NULL; in binder_release()
6190 binder_defer_work(proc, BINDER_DEFERRED_RELEASE); in binder_release()
6199 struct binder_proc *proc = node->proc; in binder_node_release() local
6201 binder_release_work(proc, &node->async_todo); in binder_node_release()
6204 binder_inner_proc_lock(proc); in binder_node_release()
6211 binder_inner_proc_unlock(proc); in binder_node_release()
6218 node->proc = NULL; in binder_node_release()
6221 binder_inner_proc_unlock(proc); in binder_node_release()
6235 binder_inner_proc_lock(ref->proc); in binder_node_release()
6237 binder_inner_proc_unlock(ref->proc); in binder_node_release()
6246 &ref->proc->todo); in binder_node_release()
6247 binder_wakeup_proc_ilocked(ref->proc); in binder_node_release()
6248 binder_inner_proc_unlock(ref->proc); in binder_node_release()
6260 static void binder_deferred_release(struct binder_proc *proc) in binder_deferred_release() argument
6262 struct binder_context *context = proc->context; in binder_deferred_release()
6267 hlist_del(&proc->proc_node); in binder_deferred_release()
6272 context->binder_context_mgr_node->proc == proc) { in binder_deferred_release()
6275 __func__, proc->pid); in binder_deferred_release()
6279 binder_inner_proc_lock(proc); in binder_deferred_release()
6284 proc->tmp_ref++; in binder_deferred_release()
6286 proc->is_dead = true; in binder_deferred_release()
6287 proc->is_frozen = false; in binder_deferred_release()
6288 proc->sync_recv = false; in binder_deferred_release()
6289 proc->async_recv = false; in binder_deferred_release()
6292 while ((n = rb_first(&proc->threads))) { in binder_deferred_release()
6296 binder_inner_proc_unlock(proc); in binder_deferred_release()
6298 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
6299 binder_inner_proc_lock(proc); in binder_deferred_release()
6304 while ((n = rb_first(&proc->nodes))) { in binder_deferred_release()
6315 rb_erase(&node->rb_node, &proc->nodes); in binder_deferred_release()
6316 binder_inner_proc_unlock(proc); in binder_deferred_release()
6318 binder_inner_proc_lock(proc); in binder_deferred_release()
6320 binder_inner_proc_unlock(proc); in binder_deferred_release()
6323 binder_proc_lock(proc); in binder_deferred_release()
6324 while ((n = rb_first(&proc->refs_by_desc))) { in binder_deferred_release()
6330 binder_proc_unlock(proc); in binder_deferred_release()
6332 binder_proc_lock(proc); in binder_deferred_release()
6334 binder_proc_unlock(proc); in binder_deferred_release()
6336 binder_release_work(proc, &proc->todo); in binder_deferred_release()
6337 binder_release_work(proc, &proc->delivered_death); in binder_deferred_release()
6338 binder_release_work(proc, &proc->delivered_freeze); in binder_deferred_release()
6342 __func__, proc->pid, threads, nodes, incoming_refs, in binder_deferred_release()
6345 binder_proc_dec_tmpref(proc); in binder_deferred_release()
6350 struct binder_proc *proc; in binder_deferred_func() local
6357 proc = hlist_entry(binder_deferred_list.first, in binder_deferred_func()
6359 hlist_del_init(&proc->deferred_work_node); in binder_deferred_func()
6360 defer = proc->deferred_work; in binder_deferred_func()
6361 proc->deferred_work = 0; in binder_deferred_func()
6363 proc = NULL; in binder_deferred_func()
6369 binder_deferred_flush(proc); in binder_deferred_func()
6372 binder_deferred_release(proc); /* frees proc */ in binder_deferred_func()
6373 } while (proc); in binder_deferred_func()
6378 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) in binder_defer_work() argument
6381 proc->deferred_work |= defer; in binder_defer_work()
6382 if (hlist_unhashed(&proc->deferred_work_node)) { in binder_defer_work()
6383 hlist_add_head(&proc->deferred_work_node, in binder_defer_work()
6390 struct binder_proc *proc, in print_binder_transaction_ilocked() argument
6411 if (proc != to_proc) { in print_binder_transaction_ilocked()
6428 buffer->user_data - proc->alloc.vm_start); in print_binder_transaction_ilocked()
6432 struct binder_proc *proc, in print_binder_work_ilocked() argument
6444 m, proc, transaction_prefix, t); in print_binder_work_ilocked()
6506 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6510 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6514 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6520 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
6551 seq_printf(m, " %d", ref->proc->pid); in print_binder_node_nilocked()
6554 if (node->proc) { in print_binder_node_nilocked()
6556 print_binder_work_ilocked(m, node->proc, " ", in print_binder_node_nilocked()
6568 ref->node->proc ? "" : "dead ", in print_binder_ref_olocked()
6591 print_next_binder_node_ilocked(struct seq_file *m, struct binder_proc *proc, in print_next_binder_node_ilocked() argument
6604 if (proc) in print_next_binder_node_ilocked()
6605 binder_inner_proc_unlock(proc); in print_next_binder_node_ilocked()
6613 if (proc) in print_next_binder_node_ilocked()
6614 binder_inner_proc_lock(proc); in print_next_binder_node_ilocked()
6620 static void print_binder_proc(struct seq_file *m, struct binder_proc *proc, in print_binder_proc() argument
6629 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc()
6630 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc()
6633 binder_inner_proc_lock(proc); in print_binder_proc()
6634 for (n = rb_first(&proc->threads); n; n = rb_next(n)) in print_binder_proc()
6638 for (n = rb_first(&proc->nodes); n; n = rb_next(n)) { in print_binder_proc()
6644 last_node = print_next_binder_node_ilocked(m, proc, node, in print_binder_proc()
6648 binder_inner_proc_unlock(proc); in print_binder_proc()
6653 binder_proc_lock(proc); in print_binder_proc()
6654 for (n = rb_first(&proc->refs_by_desc); n; n = rb_next(n)) in print_binder_proc()
6658 binder_proc_unlock(proc); in print_binder_proc()
6660 binder_alloc_print_allocated(m, &proc->alloc); in print_binder_proc()
6661 binder_inner_proc_lock(proc); in print_binder_proc()
6662 list_for_each_entry(w, &proc->todo, entry) in print_binder_proc()
6663 print_binder_work_ilocked(m, proc, " ", in print_binder_proc()
6666 list_for_each_entry(w, &proc->delivered_death, entry) { in print_binder_proc()
6670 list_for_each_entry(w, &proc->delivered_freeze, entry) { in print_binder_proc()
6674 binder_inner_proc_unlock(proc); in print_binder_proc()
6784 struct binder_proc *proc) in print_binder_proc_stats() argument
6791 binder_alloc_get_free_async_space(&proc->alloc); in print_binder_proc_stats()
6793 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc_stats()
6794 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc_stats()
6797 binder_inner_proc_lock(proc); in print_binder_proc_stats()
6798 for (n = rb_first(&proc->threads); n; n = rb_next(n)) in print_binder_proc_stats()
6801 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()
6807 " free async space %zd\n", proc->requested_threads, in print_binder_proc_stats()
6808 proc->requested_threads_started, proc->max_threads, in print_binder_proc_stats()
6812 for (n = rb_first(&proc->nodes); n; n = rb_next(n)) in print_binder_proc_stats()
6814 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
6819 binder_proc_lock(proc); in print_binder_proc_stats()
6820 for (n = rb_first(&proc->refs_by_desc); n; n = rb_next(n)) { in print_binder_proc_stats()
6827 binder_proc_unlock(proc); in print_binder_proc_stats()
6830 count = binder_alloc_get_allocated_count(&proc->alloc); in print_binder_proc_stats()
6833 binder_alloc_print_pages(m, &proc->alloc); in print_binder_proc_stats()
6836 binder_inner_proc_lock(proc); in print_binder_proc_stats()
6837 list_for_each_entry(w, &proc->todo, entry) { in print_binder_proc_stats()
6841 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
6844 print_binder_stats(m, " ", &proc->stats); in print_binder_proc_stats()
6849 struct binder_proc *proc; in print_binder_state() local
6867 hlist_for_each_entry(proc, &binder_procs, proc_node) in print_binder_state()
6868 print_binder_proc(m, proc, true, hash_ptrs); in print_binder_state()
6874 struct binder_proc *proc; in print_binder_transactions() local
6878 hlist_for_each_entry(proc, &binder_procs, proc_node) in print_binder_transactions()
6879 print_binder_proc(m, proc, false, hash_ptrs); in print_binder_transactions()
6897 struct binder_proc *proc; in stats_show() local
6904 hlist_for_each_entry(proc, &binder_procs, proc_node) in stats_show()
6905 print_binder_proc_stats(m, proc); in stats_show()