Lines Matching full:proc
15 * 1) proc->outer_lock : protects binder_ref
21 * 3) proc->inner_lock : protects the thread and node lists
22 * (proc->threads, proc->waiting_threads, proc->nodes)
24 * (proc->todo, thread->todo, proc->delivered_death and
37 * foo_ilocked() : requires proc->inner_lock
38 * foo_oilocked(): requires proc->outer_lock and proc->inner_lock
39 * foo_nilocked(): requires node->lock and proc->inner_lock
93 DEFINE_SHOW_ATTRIBUTE(proc);
264 * @proc: struct binder_proc to acquire
266 * Acquires proc->outer_lock. Used to protect binder_ref
267 * structures associated with the given proc.
269 #define binder_proc_lock(proc) _binder_proc_lock(proc, __LINE__) argument
271 _binder_proc_lock(struct binder_proc *proc, int line) in _binder_proc_lock() argument
272 __acquires(&proc->outer_lock) in _binder_proc_lock()
276 spin_lock(&proc->outer_lock); in _binder_proc_lock()
281 * @proc: struct binder_proc to acquire
285 #define binder_proc_unlock(proc) _binder_proc_unlock(proc, __LINE__) argument
287 _binder_proc_unlock(struct binder_proc *proc, int line) in _binder_proc_unlock() argument
288 __releases(&proc->outer_lock) in _binder_proc_unlock()
292 spin_unlock(&proc->outer_lock); in _binder_proc_unlock()
297 * @proc: struct binder_proc to acquire
299 * Acquires proc->inner_lock. Used to protect todo lists
301 #define binder_inner_proc_lock(proc) _binder_inner_proc_lock(proc, __LINE__) argument
303 _binder_inner_proc_lock(struct binder_proc *proc, int line) in _binder_inner_proc_lock() argument
304 __acquires(&proc->inner_lock) in _binder_inner_proc_lock()
308 spin_lock(&proc->inner_lock); in _binder_inner_proc_lock()
313 * @proc: struct binder_proc to acquire
317 #define binder_inner_proc_unlock(proc) _binder_inner_proc_unlock(proc, __LINE__) argument
319 _binder_inner_proc_unlock(struct binder_proc *proc, int line) in _binder_inner_proc_unlock() argument
320 __releases(&proc->inner_lock) in _binder_inner_proc_unlock()
324 spin_unlock(&proc->inner_lock); in _binder_inner_proc_unlock()
363 * Acquires node->lock. If node->proc also acquires
364 * proc->inner_lock. Used to protect binder_node fields
369 __acquires(&node->lock) __acquires(&node->proc->inner_lock) in _binder_node_inner_lock()
374 if (node->proc) in _binder_node_inner_lock()
375 binder_inner_proc_lock(node->proc); in _binder_node_inner_lock()
378 __acquire(&node->proc->inner_lock); in _binder_node_inner_lock()
390 __releases(&node->lock) __releases(&node->proc->inner_lock) in _binder_node_inner_unlock()
392 struct binder_proc *proc = node->proc; in _binder_node_inner_unlock() local
396 if (proc) in _binder_node_inner_unlock()
397 binder_inner_proc_unlock(proc); in _binder_node_inner_unlock()
400 __release(&node->proc->inner_lock); in _binder_node_inner_unlock()
411 * @proc: binder_proc associated with list
416 static bool binder_worklist_empty(struct binder_proc *proc, in binder_worklist_empty() argument
421 binder_inner_proc_lock(proc); in binder_worklist_empty()
423 binder_inner_proc_unlock(proc); in binder_worklist_empty()
435 * Requires the proc->inner_lock to be held.
455 * Requires the proc->inner_lock to be held.
473 * Requires the proc->inner_lock to be held.
506 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
508 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
519 * @proc: binder_proc associated with list
526 binder_dequeue_work(struct binder_proc *proc, struct binder_work *work) in binder_dequeue_work() argument
528 binder_inner_proc_lock(proc); in binder_dequeue_work()
530 binder_inner_proc_unlock(proc); in binder_dequeue_work()
545 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer);
547 static void binder_free_proc(struct binder_proc *proc);
556 !binder_worklist_empty_ilocked(&thread->proc->todo)); in binder_has_work_ilocked()
563 binder_inner_proc_lock(thread->proc); in binder_has_work()
565 binder_inner_proc_unlock(thread->proc); in binder_has_work()
576 static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc, in binder_wakeup_poll_threads_ilocked() argument
582 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_wakeup_poll_threads_ilocked()
595 * binder_select_thread_ilocked() - selects a thread for doing proc work.
596 * @proc: process to select a thread from
607 binder_select_thread_ilocked(struct binder_proc *proc) in binder_select_thread_ilocked() argument
611 assert_spin_locked(&proc->inner_lock); in binder_select_thread_ilocked()
612 thread = list_first_entry_or_null(&proc->waiting_threads, in binder_select_thread_ilocked()
623 * binder_wakeup_thread_ilocked() - wakes up a thread for doing proc work.
624 * @proc: process to wake up a thread in
628 * This function wakes up a thread in the @proc process.
638 static void binder_wakeup_thread_ilocked(struct binder_proc *proc, in binder_wakeup_thread_ilocked() argument
642 assert_spin_locked(&proc->inner_lock); in binder_wakeup_thread_ilocked()
652 /* Didn't find a thread waiting for proc work; this can happen in binder_wakeup_thread_ilocked()
665 binder_wakeup_poll_threads_ilocked(proc, sync); in binder_wakeup_thread_ilocked()
668 static void binder_wakeup_proc_ilocked(struct binder_proc *proc) in binder_wakeup_proc_ilocked() argument
670 struct binder_thread *thread = binder_select_thread_ilocked(proc); in binder_wakeup_proc_ilocked()
672 binder_wakeup_thread_ilocked(proc, thread, /* sync = */false); in binder_wakeup_proc_ilocked()
693 static struct binder_node *binder_get_node_ilocked(struct binder_proc *proc, in binder_get_node_ilocked() argument
696 struct rb_node *n = proc->nodes.rb_node; in binder_get_node_ilocked()
699 assert_spin_locked(&proc->inner_lock); in binder_get_node_ilocked()
721 static struct binder_node *binder_get_node(struct binder_proc *proc, in binder_get_node() argument
726 binder_inner_proc_lock(proc); in binder_get_node()
727 node = binder_get_node_ilocked(proc, ptr); in binder_get_node()
728 binder_inner_proc_unlock(proc); in binder_get_node()
733 struct binder_proc *proc, in binder_init_node_ilocked() argument
737 struct rb_node **p = &proc->nodes.rb_node; in binder_init_node_ilocked()
744 assert_spin_locked(&proc->inner_lock); in binder_init_node_ilocked()
769 rb_insert_color(&node->rb_node, &proc->nodes); in binder_init_node_ilocked()
771 node->proc = proc; in binder_init_node_ilocked()
783 proc->pid, current->pid, node->debug_id, in binder_init_node_ilocked()
789 static struct binder_node *binder_new_node(struct binder_proc *proc, in binder_new_node() argument
797 binder_inner_proc_lock(proc); in binder_new_node()
798 node = binder_init_node_ilocked(proc, new_node, fp); in binder_new_node()
799 binder_inner_proc_unlock(proc); in binder_new_node()
819 struct binder_proc *proc = node->proc; in binder_inc_node_nilocked() local
822 if (proc) in binder_inc_node_nilocked()
823 assert_spin_locked(&proc->inner_lock); in binder_inc_node_nilocked()
828 !(node->proc && in binder_inc_node_nilocked()
829 node == node->proc->context->binder_context_mgr_node && in binder_inc_node_nilocked()
879 struct binder_proc *proc = node->proc; in binder_dec_node_nilocked() local
882 if (proc) in binder_dec_node_nilocked()
883 assert_spin_locked(&proc->inner_lock); in binder_dec_node_nilocked()
899 if (proc && (node->has_strong_ref || node->has_weak_ref)) { in binder_dec_node_nilocked()
901 binder_enqueue_work_ilocked(&node->work, &proc->todo); in binder_dec_node_nilocked()
902 binder_wakeup_proc_ilocked(proc); in binder_dec_node_nilocked()
907 if (proc) { in binder_dec_node_nilocked()
909 rb_erase(&node->rb_node, &proc->nodes); in binder_dec_node_nilocked()
965 * (node->proc is NULL), use binder_dead_nodes_lock to protect
973 if (node->proc) in binder_inc_node_tmpref()
974 binder_inner_proc_lock(node->proc); in binder_inc_node_tmpref()
978 if (node->proc) in binder_inc_node_tmpref()
979 binder_inner_proc_unlock(node->proc); in binder_inc_node_tmpref()
996 if (!node->proc) in binder_dec_node_tmpref()
1002 if (!node->proc) in binder_dec_node_tmpref()
1023 static struct binder_ref *binder_get_ref_olocked(struct binder_proc *proc, in binder_get_ref_olocked() argument
1026 struct rb_node *n = proc->refs_by_desc.rb_node; in binder_get_ref_olocked()
1047 static u32 slow_desc_lookup_olocked(struct binder_proc *proc, u32 offset) in slow_desc_lookup_olocked() argument
1054 for (n = rb_first(&proc->refs_by_desc); n; n = rb_next(n)) { in slow_desc_lookup_olocked()
1065 * Find an available reference descriptor ID. The proc->outer_lock might
1069 static int get_ref_desc_olocked(struct binder_proc *proc, in get_ref_desc_olocked() argument
1073 struct dbitmap *dmap = &proc->dmap; in get_ref_desc_olocked()
1078 offset = (node == proc->context->binder_context_mgr_node) ? 0 : 1; in get_ref_desc_olocked()
1081 *desc = slow_desc_lookup_olocked(proc, offset); in get_ref_desc_olocked()
1091 * The dbitmap is full and needs to grow. The proc->outer_lock in get_ref_desc_olocked()
1095 binder_proc_unlock(proc); in get_ref_desc_olocked()
1097 binder_proc_lock(proc); in get_ref_desc_olocked()
1105 * @proc: binder_proc that owns the ref
1113 * into the given proc rb_trees and node refs list.
1122 struct binder_proc *proc, in binder_get_ref_for_node_olocked() argument
1132 p = &proc->refs_by_node.rb_node; in binder_get_ref_for_node_olocked()
1148 /* might release the proc->outer_lock */ in binder_get_ref_for_node_olocked()
1149 if (get_ref_desc_olocked(proc, node, &desc) == -EAGAIN) in binder_get_ref_for_node_olocked()
1154 new_ref->proc = proc; in binder_get_ref_for_node_olocked()
1157 rb_insert_color(&new_ref->rb_node_node, &proc->refs_by_node); in binder_get_ref_for_node_olocked()
1160 p = &proc->refs_by_desc.rb_node; in binder_get_ref_for_node_olocked()
1173 rb_insert_color(&new_ref->rb_node_desc, &proc->refs_by_desc); in binder_get_ref_for_node_olocked()
1180 proc->pid, new_ref->data.debug_id, new_ref->data.desc, in binder_get_ref_for_node_olocked()
1188 struct dbitmap *dmap = &ref->proc->dmap; in binder_cleanup_ref_olocked()
1193 ref->proc->pid, ref->data.debug_id, ref->data.desc, in binder_cleanup_ref_olocked()
1198 rb_erase(&ref->rb_node_desc, &ref->proc->refs_by_desc); in binder_cleanup_ref_olocked()
1199 rb_erase(&ref->rb_node_node, &ref->proc->refs_by_node); in binder_cleanup_ref_olocked()
1223 ref->proc->pid, ref->data.debug_id, in binder_cleanup_ref_olocked()
1225 binder_dequeue_work(ref->proc, &ref->death->work); in binder_cleanup_ref_olocked()
1237 * Increment the ref. @ref->proc->outer_lock must be held on entry
1278 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1289 ref->proc->pid, ref->data.debug_id, in binder_dec_ref_olocked()
1304 * binder_get_node_from_ref() - get the node from the given proc/desc
1305 * @proc: proc containing the ref
1310 * Given a proc and ref handle, return the associated binder_node
1315 struct binder_proc *proc, in binder_get_node_from_ref() argument
1322 binder_proc_lock(proc); in binder_get_node_from_ref()
1323 ref = binder_get_ref_olocked(proc, desc, need_strong_ref); in binder_get_node_from_ref()
1334 binder_proc_unlock(proc); in binder_get_node_from_ref()
1339 binder_proc_unlock(proc); in binder_get_node_from_ref()
1360 static void try_shrink_dmap(struct binder_proc *proc) in try_shrink_dmap() argument
1365 binder_proc_lock(proc); in try_shrink_dmap()
1366 nbits = dbitmap_shrink_nbits(&proc->dmap); in try_shrink_dmap()
1367 binder_proc_unlock(proc); in try_shrink_dmap()
1373 binder_proc_lock(proc); in try_shrink_dmap()
1374 dbitmap_shrink(&proc->dmap, new, nbits); in try_shrink_dmap()
1375 binder_proc_unlock(proc); in try_shrink_dmap()
1380 * @proc: proc containing the ref
1386 * Given a proc and ref handle, increment or decrement the ref
1391 static int binder_update_ref_for_handle(struct binder_proc *proc, in binder_update_ref_for_handle() argument
1399 binder_proc_lock(proc); in binder_update_ref_for_handle()
1400 ref = binder_get_ref_olocked(proc, desc, strong); in binder_update_ref_for_handle()
1412 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1416 try_shrink_dmap(proc); in binder_update_ref_for_handle()
1421 binder_proc_unlock(proc); in binder_update_ref_for_handle()
1427 * @proc: proc containing the ref
1436 static int binder_dec_ref_for_handle(struct binder_proc *proc, in binder_dec_ref_for_handle() argument
1439 return binder_update_ref_for_handle(proc, desc, false, strong, rdata); in binder_dec_ref_for_handle()
1444 * binder_inc_ref_for_node() - increment the ref for given proc/node
1445 * @proc: proc containing the ref
1451 * Given a proc and node, increment the ref. Create the ref if it
1456 static int binder_inc_ref_for_node(struct binder_proc *proc, in binder_inc_ref_for_node() argument
1466 binder_proc_lock(proc); in binder_inc_ref_for_node()
1467 ref = binder_get_ref_for_node_olocked(proc, node, NULL); in binder_inc_ref_for_node()
1469 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1473 binder_proc_lock(proc); in binder_inc_ref_for_node()
1474 ref = binder_get_ref_for_node_olocked(proc, node, new_ref); in binder_inc_ref_for_node()
1490 binder_proc_unlock(proc); in binder_inc_ref_for_node()
1504 assert_spin_locked(&target_thread->proc->inner_lock); in binder_pop_transaction_ilocked()
1530 binder_inner_proc_lock(thread->proc); in binder_thread_dec_tmpref()
1533 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1537 binder_inner_proc_unlock(thread->proc); in binder_thread_dec_tmpref()
1541 * binder_proc_dec_tmpref() - decrement proc->tmp_ref
1542 * @proc: proc to decrement
1545 * handle a transaction. proc->tmp_ref is incremented when
1549 * proc if appropriate (proc has been released, all threads have
1552 static void binder_proc_dec_tmpref(struct binder_proc *proc) in binder_proc_dec_tmpref() argument
1554 binder_inner_proc_lock(proc); in binder_proc_dec_tmpref()
1555 proc->tmp_ref--; in binder_proc_dec_tmpref()
1556 if (proc->is_dead && RB_EMPTY_ROOT(&proc->threads) && in binder_proc_dec_tmpref()
1557 !proc->tmp_ref) { in binder_proc_dec_tmpref()
1558 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1559 binder_free_proc(proc); in binder_proc_dec_tmpref()
1562 binder_inner_proc_unlock(proc); in binder_proc_dec_tmpref()
1592 * Same as binder_get_txn_from() except it also acquires the proc->inner_lock
1601 __acquires(&t->from->proc->inner_lock) in binder_get_txn_from_and_acq_inner()
1607 __acquire(&from->proc->inner_lock); in binder_get_txn_from_and_acq_inner()
1610 binder_inner_proc_lock(from->proc); in binder_get_txn_from_and_acq_inner()
1615 binder_inner_proc_unlock(from->proc); in binder_get_txn_from_and_acq_inner()
1616 __acquire(&from->proc->inner_lock); in binder_get_txn_from_and_acq_inner()
1649 from_proc = t->from ? t->from->proc->pid : 0; in binder_txn_latency_free()
1698 target_thread->proc->pid, in binder_send_failed_reply()
1718 binder_inner_proc_unlock(target_thread->proc); in binder_send_failed_reply()
1723 __release(&target_thread->proc->inner_lock); in binder_send_failed_reply()
1765 * @proc: binder_proc owning the buffer
1779 static size_t binder_get_object(struct binder_proc *proc, in binder_get_object() argument
1798 if (binder_alloc_copy_from_buffer(&proc->alloc, object, buffer, in binder_get_object()
1833 * @proc: binder_proc owning the buffer
1854 struct binder_proc *proc, in binder_validate_ptr() argument
1870 if (binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_validate_ptr()
1874 object_size = binder_get_object(proc, NULL, b, object_offset, object); in binder_validate_ptr()
1885 * @proc: binder_proc owning the buffer
1922 static bool binder_validate_fixup(struct binder_proc *proc, in binder_validate_fixup() argument
1939 size_t object_size = binder_get_object(proc, NULL, b, in binder_validate_fixup()
1955 if (binder_alloc_copy_from_buffer(&proc->alloc, in binder_validate_fixup()
2026 static void binder_transaction_buffer_release(struct binder_proc *proc, in binder_transaction_buffer_release() argument
2037 proc->pid, buffer->debug_id, in binder_transaction_buffer_release()
2053 if (!binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_transaction_buffer_release()
2056 object_size = binder_get_object(proc, NULL, buffer, in binder_transaction_buffer_release()
2071 node = binder_get_node(proc, fp->binder); in binder_transaction_buffer_release()
2091 ret = binder_dec_ref_for_handle(proc, fp->handle, in binder_transaction_buffer_release()
2141 parent = binder_validate_ptr(proc, buffer, &ptr_object, in binder_transaction_buffer_release()
2181 &proc->alloc, &fd, buffer, in binder_transaction_buffer_release()
2205 static inline void binder_release_entire_buffer(struct binder_proc *proc, in binder_release_entire_buffer() argument
2215 binder_transaction_buffer_release(proc, thread, buffer, in binder_release_entire_buffer()
2224 struct binder_proc *proc = thread->proc; in binder_translate_binder() local
2229 node = binder_get_node(proc, fp->binder); in binder_translate_binder()
2231 node = binder_new_node(proc, fp); in binder_translate_binder()
2237 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2243 if (security_binder_transfer_binder(proc->cred, target_proc->cred)) { in binder_translate_binder()
2276 struct binder_proc *proc = thread->proc; in binder_translate_handle() local
2282 node = binder_get_node_from_ref(proc, fp->handle, in binder_translate_handle()
2286 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2289 if (security_binder_transfer_binder(proc->cred, target_proc->cred)) { in binder_translate_handle()
2295 if (node->proc == target_proc) { in binder_translate_handle()
2302 if (node->proc) in binder_translate_handle()
2303 binder_inner_proc_lock(node->proc); in binder_translate_handle()
2305 __acquire(&node->proc->inner_lock); in binder_translate_handle()
2309 if (node->proc) in binder_translate_handle()
2310 binder_inner_proc_unlock(node->proc); in binder_translate_handle()
2312 __release(&node->proc->inner_lock); in binder_translate_handle()
2350 struct binder_proc *proc = thread->proc; in binder_translate_fd() local
2363 proc->pid, thread->pid, in binder_translate_fd()
2373 proc->pid, thread->pid, fd); in binder_translate_fd()
2377 ret = security_binder_transfer_file(proc->cred, target_proc->cred, file); in binder_translate_fd()
2664 struct binder_proc *proc = thread->proc; in binder_translate_fd_array() local
2673 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2680 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2698 proc->pid, thread->pid); in binder_translate_fd_array()
2731 struct binder_proc *proc = thread->proc; in binder_fixup_parent() local
2745 proc->pid, thread->pid); in binder_fixup_parent()
2754 proc->pid, thread->pid); in binder_fixup_parent()
2762 proc->pid, thread->pid); in binder_fixup_parent()
2801 * Requires the proc->inner_lock to be held.
2824 * @proc: process to send the transaction to
2825 * @thread: thread in @proc to send the transaction to (may be NULL)
2829 * wake it up. If no thread is found, the work is queued to the proc
2843 struct binder_proc *proc, in binder_proc_transaction() argument
2862 binder_inner_proc_lock(proc); in binder_proc_transaction()
2863 if (proc->is_frozen) { in binder_proc_transaction()
2865 proc->sync_recv |= !oneway; in binder_proc_transaction()
2866 proc->async_recv |= oneway; in binder_proc_transaction()
2869 if ((frozen && !oneway) || proc->is_dead || in binder_proc_transaction()
2871 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2877 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2882 binder_enqueue_work_ilocked(&t->work, &proc->todo); in binder_proc_transaction()
2892 proc->outstanding_txns--; in binder_proc_transaction()
2899 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2901 proc->outstanding_txns++; in binder_proc_transaction()
2902 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2915 binder_release_entire_buffer(proc, NULL, buffer, false); in binder_proc_transaction()
2916 binder_alloc_free_buf(&proc->alloc, buffer); in binder_proc_transaction()
2930 * @procp: returns @node->proc if valid
2941 * the transaction. We also need a tmpref on the proc while we are
2944 * Return: The target_node with refs taken or NULL if no @node->proc is NULL.
2945 * Also sets @procp if valid. If the @node->proc is NULL indicating that the
2946 * target proc has died, @error is set to BR_DEAD_REPLY.
2956 if (node->proc) { in binder_get_node_refs_for_txn()
2960 node->proc->tmp_ref++; in binder_get_node_refs_for_txn()
2961 *procp = node->proc; in binder_get_node_refs_for_txn()
2976 __release(&from->proc->inner_lock); in binder_set_txn_from_error()
2983 binder_inner_proc_unlock(from->proc); in binder_set_txn_from_error()
2987 static void binder_transaction(struct binder_proc *proc, in binder_transaction() argument
3011 struct binder_context *context = proc->context; in binder_transaction()
3026 e->from_proc = proc->pid; in binder_transaction()
3031 strscpy(e->context_name, proc->context->name, BINDERFS_MAX_NAME); in binder_transaction()
3033 binder_inner_proc_lock(proc); in binder_transaction()
3035 binder_inner_proc_unlock(proc); in binder_transaction()
3038 binder_inner_proc_lock(proc); in binder_transaction()
3041 binder_inner_proc_unlock(proc); in binder_transaction()
3043 proc->pid, thread->pid); in binder_transaction()
3052 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
3058 binder_inner_proc_unlock(proc); in binder_transaction()
3066 binder_inner_proc_unlock(proc); in binder_transaction()
3071 __release(&target_thread->proc->inner_lock); in binder_transaction()
3073 thread->pid, proc->pid); in binder_transaction()
3080 proc->pid, thread->pid, in binder_transaction()
3084 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
3092 target_proc = target_thread->proc; in binder_transaction()
3094 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
3106 binder_proc_lock(proc); in binder_transaction()
3107 ref = binder_get_ref_olocked(proc, tr->target.handle, in binder_transaction()
3115 proc->pid, thread->pid, tr->target.handle); in binder_transaction()
3118 binder_proc_unlock(proc); in binder_transaction()
3129 if (target_node && target_proc->pid == proc->pid) { in binder_transaction()
3131 proc->pid, thread->pid); in binder_transaction()
3140 thread->pid, proc->pid); in binder_transaction()
3149 if (WARN_ON(proc == target_proc)) { in binder_transaction()
3151 thread->pid, proc->pid); in binder_transaction()
3157 if (security_binder_transaction(proc->cred, in binder_transaction()
3160 thread->pid, proc->pid); in binder_transaction()
3166 binder_inner_proc_lock(proc); in binder_transaction()
3177 * thread from proc->waiting_threads to enqueue in binder_transaction()
3182 proc->pid, thread->pid); in binder_transaction()
3183 binder_inner_proc_unlock(proc); in binder_transaction()
3197 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
3202 binder_inner_proc_unlock(proc); in binder_transaction()
3213 if (from && from->proc == target_proc) { in binder_transaction()
3223 binder_inner_proc_unlock(proc); in binder_transaction()
3233 thread->pid, proc->pid); in binder_transaction()
3246 thread->pid, proc->pid); in binder_transaction()
3260 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3269 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3280 t->from_pid = proc->pid; in binder_transaction()
3282 t->sender_euid = task_euid(proc->tsk); in binder_transaction()
3293 security_cred_getsecid(proc->cred, &secid); in binder_transaction()
3297 thread->pid, proc->pid); in binder_transaction()
3307 thread->pid, proc->pid); in binder_transaction()
3369 proc->pid, thread->pid); in binder_transaction()
3377 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3385 proc->pid, thread->pid, in binder_transaction()
3413 thread->pid, proc->pid); in binder_transaction()
3433 proc->pid, thread->pid); in binder_transaction()
3443 proc->pid, thread->pid, in binder_transaction()
3474 thread->pid, proc->pid); in binder_transaction()
3493 thread->pid, proc->pid); in binder_transaction()
3515 thread->pid, proc->pid); in binder_transaction()
3539 proc->pid, thread->pid); in binder_transaction()
3552 proc->pid, thread->pid); in binder_transaction()
3563 binder_get_object(proc, user_buffer, t->buffer, in binder_transaction()
3567 proc->pid, thread->pid, in binder_transaction()
3586 thread->pid, proc->pid); in binder_transaction()
3604 proc->pid, thread->pid); in binder_transaction()
3615 thread->pid, proc->pid); in binder_transaction()
3621 /* Fixup buffer pointer to target proc address space */ in binder_transaction()
3639 thread->pid, proc->pid); in binder_transaction()
3650 proc->pid, thread->pid, hdr->type); in binder_transaction()
3664 proc->pid, thread->pid); in binder_transaction()
3675 proc->pid, thread->pid); in binder_transaction()
3704 binder_inner_proc_lock(proc); in binder_transaction()
3716 binder_inner_proc_unlock(proc); in binder_transaction()
3720 binder_inner_proc_lock(proc); in binder_transaction()
3722 binder_inner_proc_unlock(proc); in binder_transaction()
3756 thread->pid, proc->pid); in binder_transaction()
3758 binder_dequeue_work(proc, tcomplete); in binder_transaction()
3799 proc->pid, thread->pid, reply ? "reply" : in binder_transaction()
3837 binder_inner_proc_lock(proc); in binder_transaction()
3840 binder_inner_proc_unlock(proc); in binder_transaction()
3847 binder_request_freeze_notification(struct binder_proc *proc, in binder_request_freeze_notification() argument
3858 binder_proc_lock(proc); in binder_request_freeze_notification()
3859 ref = binder_get_ref_olocked(proc, handle_cookie->handle, false); in binder_request_freeze_notification()
3862 proc->pid, thread->pid, handle_cookie->handle); in binder_request_freeze_notification()
3863 binder_proc_unlock(proc); in binder_request_freeze_notification()
3870 if (ref->freeze || !ref->node->proc) { in binder_request_freeze_notification()
3872 proc->pid, thread->pid, in binder_request_freeze_notification()
3875 binder_proc_unlock(proc); in binder_request_freeze_notification()
3879 binder_inner_proc_lock(ref->node->proc); in binder_request_freeze_notification()
3880 is_frozen = ref->node->proc->is_frozen; in binder_request_freeze_notification()
3881 binder_inner_proc_unlock(ref->node->proc); in binder_request_freeze_notification()
3891 binder_inner_proc_lock(proc); in binder_request_freeze_notification()
3892 binder_enqueue_work_ilocked(&ref->freeze->work, &proc->todo); in binder_request_freeze_notification()
3893 binder_wakeup_proc_ilocked(proc); in binder_request_freeze_notification()
3894 binder_inner_proc_unlock(proc); in binder_request_freeze_notification()
3897 binder_proc_unlock(proc); in binder_request_freeze_notification()
3902 binder_clear_freeze_notification(struct binder_proc *proc, in binder_clear_freeze_notification() argument
3909 binder_proc_lock(proc); in binder_clear_freeze_notification()
3910 ref = binder_get_ref_olocked(proc, handle_cookie->handle, false); in binder_clear_freeze_notification()
3913 proc->pid, thread->pid, handle_cookie->handle); in binder_clear_freeze_notification()
3914 binder_proc_unlock(proc); in binder_clear_freeze_notification()
3922 proc->pid, thread->pid); in binder_clear_freeze_notification()
3924 binder_proc_unlock(proc); in binder_clear_freeze_notification()
3928 binder_inner_proc_lock(proc); in binder_clear_freeze_notification()
3931 proc->pid, thread->pid, (u64)freeze->cookie, in binder_clear_freeze_notification()
3933 binder_inner_proc_unlock(proc); in binder_clear_freeze_notification()
3935 binder_proc_unlock(proc); in binder_clear_freeze_notification()
3949 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_clear_freeze_notification()
3950 binder_wakeup_proc_ilocked(proc); in binder_clear_freeze_notification()
3954 binder_inner_proc_unlock(proc); in binder_clear_freeze_notification()
3956 binder_proc_unlock(proc); in binder_clear_freeze_notification()
3961 binder_freeze_notification_done(struct binder_proc *proc, in binder_freeze_notification_done() argument
3968 binder_inner_proc_lock(proc); in binder_freeze_notification_done()
3969 list_for_each_entry(w, &proc->delivered_freeze, entry) { in binder_freeze_notification_done()
3980 proc->pid, thread->pid, (u64)cookie); in binder_freeze_notification_done()
3981 binder_inner_proc_unlock(proc); in binder_freeze_notification_done()
3988 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_freeze_notification_done()
3989 binder_wakeup_proc_ilocked(proc); in binder_freeze_notification_done()
3991 binder_inner_proc_unlock(proc); in binder_freeze_notification_done()
3997 * @proc: binder proc that owns buffer
4007 binder_free_buf(struct binder_proc *proc, in binder_free_buf() argument
4011 binder_inner_proc_lock(proc); in binder_free_buf()
4016 binder_inner_proc_unlock(proc); in binder_free_buf()
4024 BUG_ON(buf_node->proc != proc); in binder_free_buf()
4031 w, &proc->todo); in binder_free_buf()
4032 binder_wakeup_proc_ilocked(proc); in binder_free_buf()
4037 binder_release_entire_buffer(proc, thread, buffer, is_failure); in binder_free_buf()
4038 binder_alloc_free_buf(&proc->alloc, buffer); in binder_free_buf()
4041 static int binder_thread_write(struct binder_proc *proc, in binder_thread_write() argument
4047 struct binder_context *context = proc->context; in binder_thread_write()
4061 atomic_inc(&proc->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
4086 if (ctx_mgr_node->proc == proc) { in binder_thread_write()
4088 proc->pid, thread->pid); in binder_thread_write()
4093 proc, ctx_mgr_node, in binder_thread_write()
4100 proc, target, increment, strong, in binder_thread_write()
4104 proc->pid, thread->pid, in binder_thread_write()
4124 proc->pid, thread->pid, debug_string, in binder_thread_write()
4130 proc->pid, thread->pid, debug_string, in binder_thread_write()
4148 node = binder_get_node(proc, node_ptr); in binder_thread_write()
4151 proc->pid, thread->pid, in binder_thread_write()
4160 proc->pid, thread->pid, in binder_thread_write()
4172 proc->pid, thread->pid, in binder_thread_write()
4182 proc->pid, thread->pid, in binder_thread_write()
4195 proc->pid, thread->pid, in binder_thread_write()
4218 buffer = binder_alloc_prepare_to_free(&proc->alloc, in binder_thread_write()
4224 proc->pid, thread->pid, in binder_thread_write()
4229 proc->pid, thread->pid, in binder_thread_write()
4236 proc->pid, thread->pid, (u64)data_ptr, in binder_thread_write()
4239 binder_free_buf(proc, thread, buffer, false); in binder_thread_write()
4250 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
4261 binder_transaction(proc, thread, &tr, in binder_thread_write()
4269 proc->pid, thread->pid); in binder_thread_write()
4270 binder_inner_proc_lock(proc); in binder_thread_write()
4274 proc->pid, thread->pid); in binder_thread_write()
4275 } else if (proc->requested_threads == 0) { in binder_thread_write()
4278 proc->pid, thread->pid); in binder_thread_write()
4280 proc->requested_threads--; in binder_thread_write()
4281 proc->requested_threads_started++; in binder_thread_write()
4284 binder_inner_proc_unlock(proc); in binder_thread_write()
4289 proc->pid, thread->pid); in binder_thread_write()
4293 proc->pid, thread->pid); in binder_thread_write()
4300 proc->pid, thread->pid); in binder_thread_write()
4333 proc->pid, thread->pid); in binder_thread_write()
4337 binder_proc_lock(proc); in binder_thread_write()
4338 ref = binder_get_ref_olocked(proc, target, false); in binder_thread_write()
4341 proc->pid, thread->pid, in binder_thread_write()
4346 binder_proc_unlock(proc); in binder_thread_write()
4353 proc->pid, thread->pid, in binder_thread_write()
4365 proc->pid, thread->pid); in binder_thread_write()
4367 binder_proc_unlock(proc); in binder_thread_write()
4375 if (ref->node->proc == NULL) { in binder_thread_write()
4378 binder_inner_proc_lock(proc); in binder_thread_write()
4380 &ref->death->work, &proc->todo); in binder_thread_write()
4381 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
4382 binder_inner_proc_unlock(proc); in binder_thread_write()
4387 proc->pid, thread->pid); in binder_thread_write()
4389 binder_proc_unlock(proc); in binder_thread_write()
4395 proc->pid, thread->pid, in binder_thread_write()
4399 binder_proc_unlock(proc); in binder_thread_write()
4403 binder_inner_proc_lock(proc); in binder_thread_write()
4415 &proc->todo); in binder_thread_write()
4417 proc); in binder_thread_write()
4423 binder_inner_proc_unlock(proc); in binder_thread_write()
4426 binder_proc_unlock(proc); in binder_thread_write()
4437 binder_inner_proc_lock(proc); in binder_thread_write()
4438 list_for_each_entry(w, &proc->delivered_death, in binder_thread_write()
4452 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
4456 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
4457 binder_inner_proc_unlock(proc); in binder_thread_write()
4471 &proc->todo); in binder_thread_write()
4472 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
4475 binder_inner_proc_unlock(proc); in binder_thread_write()
4485 error = binder_request_freeze_notification(proc, thread, in binder_thread_write()
4498 error = binder_clear_freeze_notification(proc, thread, &handle_cookie); in binder_thread_write()
4511 error = binder_freeze_notification_done(proc, thread, cookie); in binder_thread_write()
4518 proc->pid, thread->pid, cmd); in binder_thread_write()
4526 static void binder_stat_br(struct binder_proc *proc, in binder_stat_br() argument
4532 atomic_inc(&proc->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
4537 static int binder_put_node_cmd(struct binder_proc *proc, in binder_put_node_cmd() argument
4559 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
4561 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
4572 struct binder_proc *proc = thread->proc; in binder_wait_for_work() local
4575 binder_inner_proc_lock(proc); in binder_wait_for_work()
4582 &proc->waiting_threads); in binder_wait_for_work()
4583 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4585 binder_inner_proc_lock(proc); in binder_wait_for_work()
4593 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4600 * @proc: binder_proc associated @t->buffer
4611 static int binder_apply_fd_fixups(struct binder_proc *proc, in binder_apply_fd_fixups() argument
4632 if (binder_alloc_copy_to_buffer(&proc->alloc, t->buffer, in binder_apply_fd_fixups()
4652 static int binder_thread_read(struct binder_proc *proc, in binder_thread_read() argument
4671 binder_inner_proc_lock(proc); in binder_thread_read()
4673 binder_inner_proc_unlock(proc); in binder_thread_read()
4679 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
4684 proc->pid, thread->pid, thread->looper); in binder_thread_read()
4688 binder_set_nice(proc->default_priority); in binder_thread_read()
4713 binder_inner_proc_lock(proc); in binder_thread_read()
4716 else if (!binder_worklist_empty_ilocked(&proc->todo) && in binder_thread_read()
4718 list = &proc->todo; in binder_thread_read()
4720 binder_inner_proc_unlock(proc); in binder_thread_read()
4729 binder_inner_proc_unlock(proc); in binder_thread_read()
4738 binder_inner_proc_unlock(proc); in binder_thread_read()
4746 binder_inner_proc_unlock(proc); in binder_thread_read()
4753 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4758 if (proc->oneway_spam_detection_enabled && in binder_thread_read()
4765 binder_inner_proc_unlock(proc); in binder_thread_read()
4772 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4775 proc->pid, thread->pid); in binder_thread_read()
4787 BUG_ON(proc != node->proc); in binder_thread_read()
4813 proc->pid, thread->pid, in binder_thread_read()
4817 rb_erase(&node->rb_node, &proc->nodes); in binder_thread_read()
4818 binder_inner_proc_unlock(proc); in binder_thread_read()
4832 binder_inner_proc_unlock(proc); in binder_thread_read()
4836 proc, thread, &ptr, node_ptr, in binder_thread_read()
4841 proc, thread, &ptr, node_ptr, in binder_thread_read()
4846 proc, thread, &ptr, node_ptr, in binder_thread_read()
4851 proc, thread, &ptr, node_ptr, in binder_thread_read()
4857 proc->pid, thread->pid, in binder_thread_read()
4880 proc->pid, thread->pid, in binder_thread_read()
4886 binder_inner_proc_unlock(proc); in binder_thread_read()
4891 w, &proc->delivered_death); in binder_thread_read()
4892 binder_inner_proc_unlock(proc); in binder_thread_read()
4901 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4915 binder_enqueue_work_ilocked(w, &proc->delivered_freeze); in binder_thread_read()
4916 binder_inner_proc_unlock(proc); in binder_thread_read()
4924 binder_stat_br(proc, thread, BR_FROZEN_BINDER); in binder_thread_read()
4933 binder_inner_proc_unlock(proc); in binder_thread_read()
4942 binder_stat_br(proc, thread, BR_CLEAR_FREEZE_NOTIFICATION_DONE); in binder_thread_read()
4946 binder_inner_proc_unlock(proc); in binder_thread_read()
4948 proc->pid, thread->pid, w->type); in binder_thread_read()
4980 struct task_struct *sender = t_from->proc->tsk; in binder_thread_read()
4989 ret = binder_apply_fd_fixups(proc, t); in binder_thread_read()
5000 binder_free_buf(proc, thread, buffer, true); in binder_thread_read()
5003 proc->pid, thread->pid, in binder_thread_read()
5012 binder_stat_br(proc, thread, cmd); in binder_thread_read()
5051 binder_stat_br(proc, thread, cmd); in binder_thread_read()
5054 proc->pid, thread->pid, in binder_thread_read()
5058 t->debug_id, t_from ? t_from->proc->pid : 0, in binder_thread_read()
5068 binder_inner_proc_lock(thread->proc); in binder_thread_read()
5072 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
5082 binder_inner_proc_lock(proc); in binder_thread_read()
5083 if (proc->requested_threads == 0 && in binder_thread_read()
5084 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
5085 proc->requested_threads_started < proc->max_threads && in binder_thread_read()
5089 proc->requested_threads++; in binder_thread_read()
5090 binder_inner_proc_unlock(proc); in binder_thread_read()
5093 proc->pid, thread->pid); in binder_thread_read()
5096 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
5098 binder_inner_proc_unlock(proc); in binder_thread_read()
5102 static void binder_release_work(struct binder_proc *proc, in binder_release_work() argument
5109 binder_inner_proc_lock(proc); in binder_release_work()
5112 binder_inner_proc_unlock(proc); in binder_release_work()
5164 struct binder_proc *proc, struct binder_thread *new_thread) in binder_get_thread_ilocked() argument
5168 struct rb_node **p = &proc->threads.rb_node; in binder_get_thread_ilocked()
5185 thread->proc = proc; in binder_get_thread_ilocked()
5191 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
5202 static struct binder_thread *binder_get_thread(struct binder_proc *proc) in binder_get_thread() argument
5207 binder_inner_proc_lock(proc); in binder_get_thread()
5208 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
5209 binder_inner_proc_unlock(proc); in binder_get_thread()
5214 binder_inner_proc_lock(proc); in binder_get_thread()
5215 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
5216 binder_inner_proc_unlock(proc); in binder_get_thread()
5223 static void binder_free_proc(struct binder_proc *proc) in binder_free_proc() argument
5227 BUG_ON(!list_empty(&proc->todo)); in binder_free_proc()
5228 BUG_ON(!list_empty(&proc->delivered_death)); in binder_free_proc()
5229 if (proc->outstanding_txns) in binder_free_proc()
5231 __func__, proc->outstanding_txns); in binder_free_proc()
5232 device = container_of(proc->context, struct binder_device, context); in binder_free_proc()
5234 kfree(proc->context->name); in binder_free_proc()
5237 binder_alloc_deferred_release(&proc->alloc); in binder_free_proc()
5238 put_task_struct(proc->tsk); in binder_free_proc()
5239 put_cred(proc->cred); in binder_free_proc()
5241 dbitmap_free(&proc->dmap); in binder_free_proc()
5242 kfree(proc); in binder_free_proc()
5249 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
5253 static int binder_thread_release(struct binder_proc *proc, in binder_thread_release() argument
5261 binder_inner_proc_lock(thread->proc); in binder_thread_release()
5263 * take a ref on the proc so it survives in binder_thread_release()
5264 * after we remove this thread from proc->threads. in binder_thread_release()
5268 proc->tmp_ref++; in binder_thread_release()
5274 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
5290 proc->pid, thread->pid, in binder_thread_release()
5295 thread->proc->outstanding_txns--; in binder_thread_release()
5324 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
5338 binder_release_work(proc, &thread->todo); in binder_thread_release()
5346 struct binder_proc *proc = filp->private_data; in binder_poll() local
5350 thread = binder_get_thread(proc); in binder_poll()
5354 binder_inner_proc_lock(thread->proc); in binder_poll()
5358 binder_inner_proc_unlock(thread->proc); in binder_poll()
5372 struct binder_proc *proc = filp->private_data; in binder_ioctl_write_read() local
5382 proc->pid, thread->pid, in binder_ioctl_write_read()
5387 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
5400 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
5405 binder_inner_proc_lock(proc); in binder_ioctl_write_read()
5406 if (!binder_worklist_empty_ilocked(&proc->todo)) in binder_ioctl_write_read()
5407 binder_wakeup_proc_ilocked(proc); in binder_ioctl_write_read()
5408 binder_inner_proc_unlock(proc); in binder_ioctl_write_read()
5417 proc->pid, thread->pid, in binder_ioctl_write_read()
5432 struct binder_proc *proc = filp->private_data; in binder_ioctl_set_ctx_mgr() local
5433 struct binder_context *context = proc->context; in binder_ioctl_set_ctx_mgr()
5443 ret = security_binder_set_context_mgr(proc->cred); in binder_ioctl_set_ctx_mgr()
5458 new_node = binder_new_node(proc, fbo); in binder_ioctl_set_ctx_mgr()
5476 static int binder_ioctl_get_node_info_for_ref(struct binder_proc *proc, in binder_ioctl_get_node_info_for_ref() argument
5480 struct binder_context *context = proc->context; in binder_ioctl_get_node_info_for_ref()
5486 proc->pid); in binder_ioctl_get_node_info_for_ref()
5493 context->binder_context_mgr_node->proc != proc) { in binder_ioctl_get_node_info_for_ref()
5499 node = binder_get_node_from_ref(proc, handle, true, NULL); in binder_ioctl_get_node_info_for_ref()
5512 static int binder_ioctl_get_node_debug_info(struct binder_proc *proc, in binder_ioctl_get_node_debug_info() argument
5520 binder_inner_proc_lock(proc); in binder_ioctl_get_node_debug_info()
5521 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in binder_ioctl_get_node_debug_info()
5532 binder_inner_proc_unlock(proc); in binder_ioctl_get_node_debug_info()
5537 static bool binder_txns_pending_ilocked(struct binder_proc *proc) in binder_txns_pending_ilocked() argument
5542 if (proc->outstanding_txns > 0) in binder_txns_pending_ilocked()
5545 for (n = rb_first(&proc->threads); n; n = rb_next(n)) { in binder_txns_pending_ilocked()
5553 static void binder_add_freeze_work(struct binder_proc *proc, bool is_frozen) in binder_add_freeze_work() argument
5558 binder_inner_proc_lock(proc); in binder_add_freeze_work()
5559 for (n = rb_first(&proc->nodes); n; n = rb_next(n)) { in binder_add_freeze_work()
5563 binder_inner_proc_unlock(proc); in binder_add_freeze_work()
5572 binder_inner_proc_lock(ref->proc); in binder_add_freeze_work()
5574 binder_inner_proc_unlock(ref->proc); in binder_add_freeze_work()
5580 binder_enqueue_work_ilocked(&ref->freeze->work, &ref->proc->todo); in binder_add_freeze_work()
5581 binder_wakeup_proc_ilocked(ref->proc); in binder_add_freeze_work()
5587 binder_inner_proc_unlock(ref->proc); in binder_add_freeze_work()
5590 binder_inner_proc_lock(proc); in binder_add_freeze_work()
5592 binder_inner_proc_unlock(proc); in binder_add_freeze_work()
5681 binder_inner_proc_lock(thread->proc); in binder_ioctl_get_extended_error()
5684 binder_inner_proc_unlock(thread->proc); in binder_ioctl_get_extended_error()
5695 struct binder_proc *proc = filp->private_data; in binder_ioctl() local
5700 proc->pid, current->pid, cmd, arg);*/ in binder_ioctl()
5702 binder_selftest_alloc(&proc->alloc); in binder_ioctl()
5710 thread = binder_get_thread(proc); in binder_ioctl()
5730 binder_inner_proc_lock(proc); in binder_ioctl()
5731 proc->max_threads = max_threads; in binder_ioctl()
5732 binder_inner_proc_unlock(proc); in binder_ioctl()
5754 proc->pid, thread->pid); in binder_ioctl()
5755 binder_thread_release(proc, thread); in binder_ioctl()
5776 ret = binder_ioctl_get_node_info_for_ref(proc, &info); in binder_ioctl()
5795 ret = binder_ioctl_get_node_debug_info(proc, &info); in binder_ioctl()
5890 binder_inner_proc_lock(proc); in binder_ioctl()
5891 proc->oneway_spam_detection_enabled = (bool)enable; in binder_ioctl()
5892 binder_inner_proc_unlock(proc); in binder_ioctl()
5910 pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); in binder_ioctl()
5918 struct binder_proc *proc = vma->vm_private_data; in binder_vma_open() local
5922 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_open()
5929 struct binder_proc *proc = vma->vm_private_data; in binder_vma_close() local
5933 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_close()
5936 binder_alloc_vma_close(&proc->alloc); in binder_vma_close()
5952 struct binder_proc *proc = filp->private_data; in binder_mmap() local
5954 if (proc->tsk != current->group_leader) in binder_mmap()
5959 __func__, proc->pid, vma->vm_start, vma->vm_end, in binder_mmap()
5965 proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", -EPERM); in binder_mmap()
5971 vma->vm_private_data = proc; in binder_mmap()
5973 return binder_alloc_mmap_handler(&proc->alloc, vma); in binder_mmap()
5978 struct binder_proc *proc, *itr; in binder_open() local
5987 proc = kzalloc(sizeof(*proc), GFP_KERNEL); in binder_open()
5988 if (proc == NULL) in binder_open()
5991 dbitmap_init(&proc->dmap); in binder_open()
5992 spin_lock_init(&proc->inner_lock); in binder_open()
5993 spin_lock_init(&proc->outer_lock); in binder_open()
5995 proc->tsk = current->group_leader; in binder_open()
5996 proc->cred = get_cred(filp->f_cred); in binder_open()
5997 INIT_LIST_HEAD(&proc->todo); in binder_open()
5998 init_waitqueue_head(&proc->freeze_wait); in binder_open()
5999 proc->default_priority = task_nice(current); in binder_open()
6010 proc->context = &binder_dev->context; in binder_open()
6011 binder_alloc_init(&proc->alloc); in binder_open()
6014 proc->pid = current->group_leader->pid; in binder_open()
6015 INIT_LIST_HEAD(&proc->delivered_death); in binder_open()
6016 INIT_LIST_HEAD(&proc->delivered_freeze); in binder_open()
6017 INIT_LIST_HEAD(&proc->waiting_threads); in binder_open()
6018 filp->private_data = proc; in binder_open()
6022 if (itr->pid == proc->pid) { in binder_open()
6027 hlist_add_head(&proc->proc_node, &binder_procs); in binder_open()
6033 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
6035 * proc debug entries are shared between contexts. in binder_open()
6040 proc->debugfs_entry = debugfs_create_file(strbuf, 0444, in binder_open()
6042 (void *)(unsigned long)proc->pid, in binder_open()
6050 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
6058 strbuf, &proc_fops, (void *)(unsigned long)proc->pid); in binder_open()
6060 proc->binderfs_entry = binderfs_entry; in binder_open()
6075 struct binder_proc *proc = filp->private_data; in binder_flush() local
6077 binder_defer_work(proc, BINDER_DEFERRED_FLUSH); in binder_flush()
6082 static void binder_deferred_flush(struct binder_proc *proc) in binder_deferred_flush() argument
6087 binder_inner_proc_lock(proc); in binder_deferred_flush()
6088 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_deferred_flush()
6097 binder_inner_proc_unlock(proc); in binder_deferred_flush()
6100 "binder_flush: %d woke %d threads\n", proc->pid, in binder_deferred_flush()
6106 struct binder_proc *proc = filp->private_data; in binder_release() local
6108 debugfs_remove(proc->debugfs_entry); in binder_release()
6110 if (proc->binderfs_entry) { in binder_release()
6111 binderfs_remove_file(proc->binderfs_entry); in binder_release()
6112 proc->binderfs_entry = NULL; in binder_release()
6115 binder_defer_work(proc, BINDER_DEFERRED_RELEASE); in binder_release()
6124 struct binder_proc *proc = node->proc; in binder_node_release() local
6126 binder_release_work(proc, &node->async_todo); in binder_node_release()
6129 binder_inner_proc_lock(proc); in binder_node_release()
6136 binder_inner_proc_unlock(proc); in binder_node_release()
6143 node->proc = NULL; in binder_node_release()
6146 binder_inner_proc_unlock(proc); in binder_node_release()
6160 binder_inner_proc_lock(ref->proc); in binder_node_release()
6162 binder_inner_proc_unlock(ref->proc); in binder_node_release()
6171 &ref->proc->todo); in binder_node_release()
6172 binder_wakeup_proc_ilocked(ref->proc); in binder_node_release()
6173 binder_inner_proc_unlock(ref->proc); in binder_node_release()
6185 static void binder_deferred_release(struct binder_proc *proc) in binder_deferred_release() argument
6187 struct binder_context *context = proc->context; in binder_deferred_release()
6192 hlist_del(&proc->proc_node); in binder_deferred_release()
6197 context->binder_context_mgr_node->proc == proc) { in binder_deferred_release()
6200 __func__, proc->pid); in binder_deferred_release()
6204 binder_inner_proc_lock(proc); in binder_deferred_release()
6206 * Make sure proc stays alive after we in binder_deferred_release()
6209 proc->tmp_ref++; in binder_deferred_release()
6211 proc->is_dead = true; in binder_deferred_release()
6212 proc->is_frozen = false; in binder_deferred_release()
6213 proc->sync_recv = false; in binder_deferred_release()
6214 proc->async_recv = false; in binder_deferred_release()
6217 while ((n = rb_first(&proc->threads))) { in binder_deferred_release()
6221 binder_inner_proc_unlock(proc); in binder_deferred_release()
6223 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
6224 binder_inner_proc_lock(proc); in binder_deferred_release()
6229 while ((n = rb_first(&proc->nodes))) { in binder_deferred_release()
6240 rb_erase(&node->rb_node, &proc->nodes); in binder_deferred_release()
6241 binder_inner_proc_unlock(proc); in binder_deferred_release()
6243 binder_inner_proc_lock(proc); in binder_deferred_release()
6245 binder_inner_proc_unlock(proc); in binder_deferred_release()
6248 binder_proc_lock(proc); in binder_deferred_release()
6249 while ((n = rb_first(&proc->refs_by_desc))) { in binder_deferred_release()
6255 binder_proc_unlock(proc); in binder_deferred_release()
6257 binder_proc_lock(proc); in binder_deferred_release()
6259 binder_proc_unlock(proc); in binder_deferred_release()
6261 binder_release_work(proc, &proc->todo); in binder_deferred_release()
6262 binder_release_work(proc, &proc->delivered_death); in binder_deferred_release()
6266 __func__, proc->pid, threads, nodes, incoming_refs, in binder_deferred_release()
6269 binder_proc_dec_tmpref(proc); in binder_deferred_release()
6274 struct binder_proc *proc; in binder_deferred_func() local
6281 proc = hlist_entry(binder_deferred_list.first, in binder_deferred_func()
6283 hlist_del_init(&proc->deferred_work_node); in binder_deferred_func()
6284 defer = proc->deferred_work; in binder_deferred_func()
6285 proc->deferred_work = 0; in binder_deferred_func()
6287 proc = NULL; in binder_deferred_func()
6293 binder_deferred_flush(proc); in binder_deferred_func()
6296 binder_deferred_release(proc); /* frees proc */ in binder_deferred_func()
6297 } while (proc); in binder_deferred_func()
6302 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) in binder_defer_work() argument
6305 proc->deferred_work |= defer; in binder_defer_work()
6306 if (hlist_unhashed(&proc->deferred_work_node)) { in binder_defer_work()
6307 hlist_add_head(&proc->deferred_work_node, in binder_defer_work()
6315 struct binder_proc *proc, in print_binder_transaction_ilocked() argument
6336 if (proc != to_proc) { in print_binder_transaction_ilocked()
6339 * correct proc inner lock for this node in print_binder_transaction_ilocked()
6353 proc->alloc.buffer - buffer->user_data); in print_binder_transaction_ilocked()
6357 struct binder_proc *proc, in print_binder_work_ilocked() argument
6369 m, proc, transaction_prefix, t); in print_binder_work_ilocked()
6419 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6423 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6427 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6433 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
6455 seq_puts(m, " proc"); in print_binder_node_nilocked()
6457 seq_printf(m, " %d", ref->proc->pid); in print_binder_node_nilocked()
6460 if (node->proc) { in print_binder_node_nilocked()
6462 print_binder_work_ilocked(m, node->proc, " ", in print_binder_node_nilocked()
6473 ref->node->proc ? "" : "dead ", in print_binder_ref_olocked()
6480 struct binder_proc *proc, int print_all) in print_binder_proc() argument
6488 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc()
6489 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc()
6492 binder_inner_proc_lock(proc); in print_binder_proc()
6493 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) in print_binder_proc()
6497 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in print_binder_proc()
6510 binder_inner_proc_unlock(proc); in print_binder_proc()
6517 binder_inner_proc_lock(proc); in print_binder_proc()
6519 binder_inner_proc_unlock(proc); in print_binder_proc()
6524 binder_proc_lock(proc); in print_binder_proc()
6525 for (n = rb_first(&proc->refs_by_desc); in print_binder_proc()
6531 binder_proc_unlock(proc); in print_binder_proc()
6533 binder_alloc_print_allocated(m, &proc->alloc); in print_binder_proc()
6534 binder_inner_proc_lock(proc); in print_binder_proc()
6535 list_for_each_entry(w, &proc->todo, entry) in print_binder_proc()
6536 print_binder_work_ilocked(m, proc, " ", in print_binder_proc()
6538 list_for_each_entry(w, &proc->delivered_death, entry) { in print_binder_proc()
6542 binder_inner_proc_unlock(proc); in print_binder_proc()
6599 "proc",
6652 struct binder_proc *proc) in print_binder_proc_stats() argument
6659 binder_alloc_get_free_async_space(&proc->alloc); in print_binder_proc_stats()
6661 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc_stats()
6662 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc_stats()
6665 binder_inner_proc_lock(proc); in print_binder_proc_stats()
6666 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) in print_binder_proc_stats()
6669 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()
6675 " free async space %zd\n", proc->requested_threads, in print_binder_proc_stats()
6676 proc->requested_threads_started, proc->max_threads, in print_binder_proc_stats()
6680 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) in print_binder_proc_stats()
6682 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
6687 binder_proc_lock(proc); in print_binder_proc_stats()
6688 for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { in print_binder_proc_stats()
6695 binder_proc_unlock(proc); in print_binder_proc_stats()
6698 count = binder_alloc_get_allocated_count(&proc->alloc); in print_binder_proc_stats()
6701 binder_alloc_print_pages(m, &proc->alloc); in print_binder_proc_stats()
6704 binder_inner_proc_lock(proc); in print_binder_proc_stats()
6705 list_for_each_entry(w, &proc->todo, entry) { in print_binder_proc_stats()
6709 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
6712 print_binder_stats(m, " ", &proc->stats); in print_binder_proc_stats()
6717 struct binder_proc *proc; in state_show() local
6747 hlist_for_each_entry(proc, &binder_procs, proc_node) in state_show()
6748 print_binder_proc(m, proc, 1); in state_show()
6756 struct binder_proc *proc; in stats_show() local
6763 hlist_for_each_entry(proc, &binder_procs, proc_node) in stats_show()
6764 print_binder_proc_stats(m, proc); in stats_show()
6772 struct binder_proc *proc; in transactions_show() local
6776 hlist_for_each_entry(proc, &binder_procs, proc_node) in transactions_show()
6777 print_binder_proc(m, proc, 0); in transactions_show()
6791 seq_puts(m, "binder proc state:\n"); in proc_show()
6951 binder_debugfs_dir_entry_proc = debugfs_create_dir("proc", in binder_init()