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
98 DEFINE_SHOW_ATTRIBUTE(proc);
269 * @proc: struct binder_proc to acquire
271 * Acquires proc->outer_lock. Used to protect binder_ref
272 * structures associated with the given 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()
286 * @proc: struct binder_proc to acquire
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()
302 * @proc: struct binder_proc to acquire
304 * Acquires proc->inner_lock. Used to protect todo lists
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()
318 * @proc: struct binder_proc to acquire
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()
368 * Acquires node->lock. If node->proc also acquires
369 * proc->inner_lock. Used to protect binder_node fields
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()
416 * @proc: binder_proc associated with list
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()
440 * Requires the proc->inner_lock to be held.
460 * Requires the proc->inner_lock to be held.
478 * Requires the proc->inner_lock to be held.
511 binder_inner_proc_lock(thread->proc); in binder_enqueue_thread_work()
513 binder_inner_proc_unlock(thread->proc); in binder_enqueue_thread_work()
524 * @proc: binder_proc associated with list
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()
600 * binder_select_thread_ilocked() - selects a thread for doing proc work.
601 * @proc: process to select a thread from
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()
628 * binder_wakeup_thread_ilocked() - wakes up a thread for doing proc work.
629 * @proc: process to wake up a thread in
633 * This function wakes up a thread in the @proc process.
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()
657 /* Didn't find a thread waiting for proc work; this can happen 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()
961 * (node->proc is NULL), use binder_dead_nodes_lock to protect
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()
1061 * Find an available reference descriptor ID. The proc->outer_lock might
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()
1087 * The dbitmap is full and needs to grow. The proc->outer_lock 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()
1101 * @proc: binder_proc that owns the ref
1109 * into the given proc rb_trees and node refs list.
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()
1144 /* might release the proc->outer_lock */ 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()
1239 * Increment the ref. @ref->proc->outer_lock must be held on entry
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()
1306 * binder_get_node_from_ref() - get the node from the given proc/desc
1307 * @proc: proc containing the ref
1312 * Given a proc and ref handle, return the associated binder_node
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()
1382 * @proc: proc containing the ref
1388 * Given a proc and ref handle, increment or decrement the ref
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()
1429 * @proc: proc containing the ref
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()
1446 * binder_inc_ref_for_node() - increment the ref for given proc/node
1447 * @proc: proc containing the ref
1453 * Given a proc and node, increment the ref. Create the ref if it
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()
1543 * binder_proc_dec_tmpref() - decrement proc->tmp_ref
1544 * @proc: proc to decrement
1547 * handle a transaction. proc->tmp_ref is incremented when
1551 * proc if appropriate (proc has been released, all threads have
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()
1593 * Same as binder_get_txn_from() except it also acquires the proc->inner_lock
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()
1716 target_thread->proc->pid, in binder_send_failed_reply()
1736 binder_inner_proc_unlock(target_thread->proc); in binder_send_failed_reply()
1741 __release(&target_thread->proc->inner_lock); in binder_send_failed_reply()
1783 * @proc: binder_proc owning the buffer
1797 static size_t binder_get_object(struct binder_proc *proc, in binder_get_object() argument
1816 if (binder_alloc_copy_from_buffer(&proc->alloc, object, buffer, in binder_get_object()
1851 * @proc: binder_proc owning the buffer
1872 struct binder_proc *proc, in binder_validate_ptr() argument
1888 if (binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_validate_ptr()
1892 object_size = binder_get_object(proc, NULL, b, object_offset, object); in binder_validate_ptr()
1903 * @proc: binder_proc owning the buffer
1940 static bool binder_validate_fixup(struct binder_proc *proc, in binder_validate_fixup() argument
1957 size_t object_size = binder_get_object(proc, NULL, b, in binder_validate_fixup()
1973 if (binder_alloc_copy_from_buffer(&proc->alloc, in binder_validate_fixup()
2044 static void binder_transaction_buffer_release(struct binder_proc *proc, in binder_transaction_buffer_release() argument
2055 proc->pid, buffer->debug_id, in binder_transaction_buffer_release()
2071 if (!binder_alloc_copy_from_buffer(&proc->alloc, &object_offset, in binder_transaction_buffer_release()
2074 object_size = binder_get_object(proc, NULL, buffer, in binder_transaction_buffer_release()
2089 node = binder_get_node(proc, fp->binder); in binder_transaction_buffer_release()
2109 ret = binder_dec_ref_for_handle(proc, fp->handle, in binder_transaction_buffer_release()
2159 parent = binder_validate_ptr(proc, buffer, &ptr_object, in binder_transaction_buffer_release()
2199 &proc->alloc, &fd, buffer, in binder_transaction_buffer_release()
2223 static inline void binder_release_entire_buffer(struct binder_proc *proc, in binder_release_entire_buffer() argument
2233 binder_transaction_buffer_release(proc, thread, buffer, in binder_release_entire_buffer()
2242 struct binder_proc *proc = thread->proc; in binder_translate_binder() local
2247 node = binder_get_node(proc, fp->binder); in binder_translate_binder()
2249 node = binder_new_node(proc, fp); in binder_translate_binder()
2255 proc->pid, thread->pid, (u64)fp->binder, in binder_translate_binder()
2261 if (security_binder_transfer_binder(proc->cred, target_proc->cred)) { in binder_translate_binder()
2294 struct binder_proc *proc = thread->proc; in binder_translate_handle() local
2300 node = binder_get_node_from_ref(proc, fp->handle, in binder_translate_handle()
2304 proc->pid, thread->pid, fp->handle); in binder_translate_handle()
2307 if (security_binder_transfer_binder(proc->cred, target_proc->cred)) { in binder_translate_handle()
2313 if (node->proc == target_proc) { in binder_translate_handle()
2320 if (node->proc) in binder_translate_handle()
2321 binder_inner_proc_lock(node->proc); in binder_translate_handle()
2323 __acquire(&node->proc->inner_lock); in binder_translate_handle()
2327 if (node->proc) in binder_translate_handle()
2328 binder_inner_proc_unlock(node->proc); in binder_translate_handle()
2330 __release(&node->proc->inner_lock); in binder_translate_handle()
2368 struct binder_proc *proc = thread->proc; in binder_translate_fd() local
2381 proc->pid, thread->pid, in binder_translate_fd()
2391 proc->pid, thread->pid, fd); in binder_translate_fd()
2395 ret = security_binder_transfer_file(proc->cred, target_proc->cred, file); in binder_translate_fd()
2682 struct binder_proc *proc = thread->proc; in binder_translate_fd_array() local
2691 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2698 proc->pid, thread->pid, (u64)fda->num_fds); in binder_translate_fd_array()
2716 proc->pid, thread->pid); in binder_translate_fd_array()
2749 struct binder_proc *proc = thread->proc; in binder_fixup_parent() local
2763 proc->pid, thread->pid); in binder_fixup_parent()
2772 proc->pid, thread->pid); in binder_fixup_parent()
2780 proc->pid, thread->pid); in binder_fixup_parent()
2819 * Requires the proc->inner_lock to be held.
2842 * @proc: process to send the transaction to
2843 * @thread: thread in @proc to send the transaction to (may be NULL)
2847 * wake it up. If no thread is found, the work is queued to the proc
2861 struct binder_proc *proc, in binder_proc_transaction() argument
2880 binder_inner_proc_lock(proc); in binder_proc_transaction()
2881 if (proc->is_frozen) { in binder_proc_transaction()
2883 proc->sync_recv |= !oneway; in binder_proc_transaction()
2884 proc->async_recv |= oneway; in binder_proc_transaction()
2887 if ((frozen && !oneway) || proc->is_dead || in binder_proc_transaction()
2889 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2895 thread = binder_select_thread_ilocked(proc); in binder_proc_transaction()
2900 binder_enqueue_work_ilocked(&t->work, &proc->todo); in binder_proc_transaction()
2910 proc->outstanding_txns--; in binder_proc_transaction()
2917 binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); in binder_proc_transaction()
2919 proc->outstanding_txns++; in binder_proc_transaction()
2920 binder_inner_proc_unlock(proc); in binder_proc_transaction()
2933 binder_release_entire_buffer(proc, NULL, buffer, false); in binder_proc_transaction()
2934 binder_alloc_free_buf(&proc->alloc, buffer); in binder_proc_transaction()
2948 * @procp: returns @node->proc if valid
2959 * the transaction. We also need a tmpref on the proc while we are
2962 * Return: The target_node with refs taken or NULL if no @node->proc is NULL.
2963 * Also sets @procp if valid. If the @node->proc is NULL indicating that the
2964 * target proc has died, @error is set to BR_DEAD_REPLY.
2974 if (node->proc) { in binder_get_node_refs_for_txn()
2978 node->proc->tmp_ref++; in binder_get_node_refs_for_txn()
2979 *procp = node->proc; in binder_get_node_refs_for_txn()
2994 __release(&from->proc->inner_lock); in binder_set_txn_from_error()
3001 binder_inner_proc_unlock(from->proc); in binder_set_txn_from_error()
3007 * @proc: the binder proc sending the transaction
3016 static void binder_netlink_report(struct binder_proc *proc, in binder_netlink_report() argument
3021 const char *context = proc->context->name; in binder_netlink_report()
3072 static void binder_transaction(struct binder_proc *proc, in binder_transaction() argument
3096 struct binder_context *context = proc->context; in binder_transaction()
3109 e->from_proc = proc->pid; in binder_transaction()
3114 strscpy(e->context_name, proc->context->name, BINDERFS_MAX_NAME); in binder_transaction()
3116 binder_inner_proc_lock(proc); in binder_transaction()
3118 binder_inner_proc_unlock(proc); in binder_transaction()
3123 thread->pid, proc->pid); in binder_transaction()
3134 t->from_pid = proc->pid; in binder_transaction()
3147 binder_inner_proc_lock(proc); in binder_transaction()
3150 binder_inner_proc_unlock(proc); in binder_transaction()
3152 proc->pid, thread->pid); in binder_transaction()
3161 proc->pid, thread->pid, in_reply_to->debug_id, in binder_transaction()
3167 binder_inner_proc_unlock(proc); in binder_transaction()
3175 binder_inner_proc_unlock(proc); in binder_transaction()
3180 __release(&target_thread->proc->inner_lock); in binder_transaction()
3182 thread->pid, proc->pid); in binder_transaction()
3189 proc->pid, thread->pid, in binder_transaction()
3193 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
3201 target_proc = target_thread->proc; in binder_transaction()
3203 binder_inner_proc_unlock(target_thread->proc); in binder_transaction()
3215 binder_proc_lock(proc); in binder_transaction()
3216 ref = binder_get_ref_olocked(proc, tr->target.handle, in binder_transaction()
3224 proc->pid, thread->pid, tr->target.handle); in binder_transaction()
3227 binder_proc_unlock(proc); in binder_transaction()
3238 if (target_node && target_proc->pid == proc->pid) { in binder_transaction()
3240 proc->pid, thread->pid); in binder_transaction()
3249 proc->pid, thread->pid); in binder_transaction()
3256 if (WARN_ON(proc == target_proc)) { in binder_transaction()
3258 thread->pid, proc->pid); in binder_transaction()
3264 if (security_binder_transaction(proc->cred, in binder_transaction()
3267 thread->pid, proc->pid); in binder_transaction()
3273 binder_inner_proc_lock(proc); in binder_transaction()
3284 * thread from proc->waiting_threads to enqueue in binder_transaction()
3289 proc->pid, thread->pid); in binder_transaction()
3290 binder_inner_proc_unlock(proc); in binder_transaction()
3304 proc->pid, thread->pid, tmp->debug_id, in binder_transaction()
3309 binder_inner_proc_unlock(proc); in binder_transaction()
3320 if (from && from->proc == target_proc) { in binder_transaction()
3330 binder_inner_proc_unlock(proc); in binder_transaction()
3342 thread->pid, proc->pid); in binder_transaction()
3353 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3360 proc->pid, thread->pid, t->debug_id, in binder_transaction()
3368 security_cred_getsecid(proc->cred, &secid); in binder_transaction()
3372 thread->pid, proc->pid); in binder_transaction()
3382 thread->pid, proc->pid); in binder_transaction()
3444 proc->pid, thread->pid); in binder_transaction()
3452 proc->pid, thread->pid, (u64)tr->offsets_size); in binder_transaction()
3460 proc->pid, thread->pid, in binder_transaction()
3488 thread->pid, proc->pid); in binder_transaction()
3508 proc->pid, thread->pid); in binder_transaction()
3518 proc->pid, thread->pid, in binder_transaction()
3549 thread->pid, proc->pid); in binder_transaction()
3568 thread->pid, proc->pid); in binder_transaction()
3590 thread->pid, proc->pid); in binder_transaction()
3614 proc->pid, thread->pid); in binder_transaction()
3627 proc->pid, thread->pid); in binder_transaction()
3638 binder_get_object(proc, user_buffer, t->buffer, in binder_transaction()
3642 proc->pid, thread->pid, in binder_transaction()
3661 thread->pid, proc->pid); in binder_transaction()
3679 proc->pid, thread->pid); in binder_transaction()
3690 thread->pid, proc->pid); in binder_transaction()
3696 /* Fixup buffer pointer to target proc address space */ in binder_transaction()
3714 thread->pid, proc->pid); in binder_transaction()
3725 proc->pid, thread->pid, hdr->type); in binder_transaction()
3739 proc->pid, thread->pid); in binder_transaction()
3750 proc->pid, thread->pid); in binder_transaction()
3758 binder_netlink_report(proc, t, tr->data_size, in binder_transaction()
3781 binder_inner_proc_lock(proc); in binder_transaction()
3792 binder_inner_proc_unlock(proc); in binder_transaction()
3796 binder_inner_proc_lock(proc); in binder_transaction()
3798 binder_inner_proc_unlock(proc); in binder_transaction()
3820 binder_netlink_report(proc, &t_copy, tr->data_size, in binder_transaction()
3843 proc->pid, thread->pid, in binder_transaction()
3846 binder_dequeue_work(proc, tcomplete); in binder_transaction()
3882 binder_netlink_report(proc, t, tr->data_size, return_error); in binder_transaction()
3889 proc->pid, thread->pid, reply ? "reply" : in binder_transaction()
3927 binder_inner_proc_lock(proc); in binder_transaction()
3930 binder_inner_proc_unlock(proc); in binder_transaction()
3937 binder_request_freeze_notification(struct binder_proc *proc, in binder_request_freeze_notification() argument
3947 binder_proc_lock(proc); in binder_request_freeze_notification()
3948 ref = binder_get_ref_olocked(proc, handle_cookie->handle, false); in binder_request_freeze_notification()
3951 proc->pid, thread->pid, handle_cookie->handle); in binder_request_freeze_notification()
3952 binder_proc_unlock(proc); in binder_request_freeze_notification()
3960 proc->pid, thread->pid); in binder_request_freeze_notification()
3962 binder_proc_unlock(proc); in binder_request_freeze_notification()
3973 if (ref->node->proc) { in binder_request_freeze_notification()
3974 binder_inner_proc_lock(ref->node->proc); in binder_request_freeze_notification()
3975 freeze->is_frozen = ref->node->proc->is_frozen; in binder_request_freeze_notification()
3976 binder_inner_proc_unlock(ref->node->proc); in binder_request_freeze_notification()
3978 binder_inner_proc_lock(proc); in binder_request_freeze_notification()
3979 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_request_freeze_notification()
3980 binder_wakeup_proc_ilocked(proc); in binder_request_freeze_notification()
3981 binder_inner_proc_unlock(proc); in binder_request_freeze_notification()
3985 binder_proc_unlock(proc); in binder_request_freeze_notification()
3990 binder_clear_freeze_notification(struct binder_proc *proc, in binder_clear_freeze_notification() argument
3997 binder_proc_lock(proc); in binder_clear_freeze_notification()
3998 ref = binder_get_ref_olocked(proc, handle_cookie->handle, false); in binder_clear_freeze_notification()
4001 proc->pid, thread->pid, handle_cookie->handle); in binder_clear_freeze_notification()
4002 binder_proc_unlock(proc); in binder_clear_freeze_notification()
4010 proc->pid, thread->pid); in binder_clear_freeze_notification()
4012 binder_proc_unlock(proc); in binder_clear_freeze_notification()
4016 binder_inner_proc_lock(proc); in binder_clear_freeze_notification()
4019 proc->pid, thread->pid, (u64)freeze->cookie, in binder_clear_freeze_notification()
4021 binder_inner_proc_unlock(proc); in binder_clear_freeze_notification()
4023 binder_proc_unlock(proc); in binder_clear_freeze_notification()
4037 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_clear_freeze_notification()
4038 binder_wakeup_proc_ilocked(proc); in binder_clear_freeze_notification()
4042 binder_inner_proc_unlock(proc); in binder_clear_freeze_notification()
4044 binder_proc_unlock(proc); in binder_clear_freeze_notification()
4049 binder_freeze_notification_done(struct binder_proc *proc, in binder_freeze_notification_done() argument
4056 binder_inner_proc_lock(proc); in binder_freeze_notification_done()
4057 list_for_each_entry(w, &proc->delivered_freeze, entry) { in binder_freeze_notification_done()
4068 proc->pid, thread->pid, (u64)cookie); in binder_freeze_notification_done()
4069 binder_inner_proc_unlock(proc); in binder_freeze_notification_done()
4076 binder_enqueue_work_ilocked(&freeze->work, &proc->todo); in binder_freeze_notification_done()
4077 binder_wakeup_proc_ilocked(proc); in binder_freeze_notification_done()
4079 binder_inner_proc_unlock(proc); in binder_freeze_notification_done()
4085 * @proc: binder proc that owns buffer
4096 binder_free_buf(struct binder_proc *proc, in binder_free_buf() argument
4100 binder_inner_proc_lock(proc); in binder_free_buf()
4105 binder_inner_proc_unlock(proc); in binder_free_buf()
4113 BUG_ON(buf_node->proc != proc); in binder_free_buf()
4120 w, &proc->todo); in binder_free_buf()
4121 binder_wakeup_proc_ilocked(proc); in binder_free_buf()
4126 binder_release_entire_buffer(proc, thread, buffer, is_failure); in binder_free_buf()
4127 binder_alloc_free_buf(&proc->alloc, buffer); in binder_free_buf()
4130 static int binder_thread_write(struct binder_proc *proc, in binder_thread_write() argument
4136 struct binder_context *context = proc->context; in binder_thread_write()
4150 atomic_inc(&proc->stats.bc[_IOC_NR(cmd)]); in binder_thread_write()
4175 if (ctx_mgr_node->proc == proc) { in binder_thread_write()
4177 proc->pid, thread->pid); in binder_thread_write()
4182 proc, ctx_mgr_node, in binder_thread_write()
4189 proc, target, increment, strong, in binder_thread_write()
4193 proc->pid, thread->pid, in binder_thread_write()
4213 proc->pid, thread->pid, debug_string, in binder_thread_write()
4219 proc->pid, thread->pid, debug_string, in binder_thread_write()
4237 node = binder_get_node(proc, node_ptr); in binder_thread_write()
4240 proc->pid, thread->pid, in binder_thread_write()
4249 proc->pid, thread->pid, in binder_thread_write()
4261 proc->pid, thread->pid, in binder_thread_write()
4271 proc->pid, thread->pid, in binder_thread_write()
4284 proc->pid, thread->pid, in binder_thread_write()
4307 buffer = binder_alloc_prepare_to_free(&proc->alloc, in binder_thread_write()
4313 proc->pid, thread->pid, in binder_thread_write()
4314 (unsigned long)data_ptr - proc->alloc.vm_start); in binder_thread_write()
4318 proc->pid, thread->pid, in binder_thread_write()
4319 (unsigned long)data_ptr - proc->alloc.vm_start); in binder_thread_write()
4325 proc->pid, thread->pid, in binder_thread_write()
4326 (unsigned long)data_ptr - proc->alloc.vm_start, in binder_thread_write()
4329 binder_free_buf(proc, thread, buffer, false); in binder_thread_write()
4340 binder_transaction(proc, thread, &tr.transaction_data, in binder_thread_write()
4351 binder_transaction(proc, thread, &tr, in binder_thread_write()
4359 proc->pid, thread->pid); in binder_thread_write()
4360 binder_inner_proc_lock(proc); in binder_thread_write()
4364 proc->pid, thread->pid); in binder_thread_write()
4365 } else if (proc->requested_threads == 0) { in binder_thread_write()
4368 proc->pid, thread->pid); in binder_thread_write()
4370 proc->requested_threads--; in binder_thread_write()
4371 proc->requested_threads_started++; in binder_thread_write()
4374 binder_inner_proc_unlock(proc); in binder_thread_write()
4379 proc->pid, thread->pid); in binder_thread_write()
4383 proc->pid, thread->pid); in binder_thread_write()
4390 proc->pid, thread->pid); in binder_thread_write()
4423 proc->pid, thread->pid); in binder_thread_write()
4427 binder_proc_lock(proc); in binder_thread_write()
4428 ref = binder_get_ref_olocked(proc, target, false); in binder_thread_write()
4431 proc->pid, thread->pid, in binder_thread_write()
4436 binder_proc_unlock(proc); in binder_thread_write()
4443 proc->pid, thread->pid, in binder_thread_write()
4455 proc->pid, thread->pid); in binder_thread_write()
4457 binder_proc_unlock(proc); in binder_thread_write()
4465 if (ref->node->proc == NULL) { in binder_thread_write()
4468 binder_inner_proc_lock(proc); in binder_thread_write()
4470 &ref->death->work, &proc->todo); in binder_thread_write()
4471 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
4472 binder_inner_proc_unlock(proc); in binder_thread_write()
4477 proc->pid, thread->pid); in binder_thread_write()
4479 binder_proc_unlock(proc); in binder_thread_write()
4485 proc->pid, thread->pid, in binder_thread_write()
4489 binder_proc_unlock(proc); in binder_thread_write()
4493 binder_inner_proc_lock(proc); in binder_thread_write()
4505 &proc->todo); in binder_thread_write()
4507 proc); in binder_thread_write()
4513 binder_inner_proc_unlock(proc); in binder_thread_write()
4516 binder_proc_unlock(proc); in binder_thread_write()
4527 binder_inner_proc_lock(proc); in binder_thread_write()
4528 list_for_each_entry(w, &proc->delivered_death, in binder_thread_write()
4542 proc->pid, thread->pid, (u64)cookie, in binder_thread_write()
4546 proc->pid, thread->pid, (u64)cookie); in binder_thread_write()
4547 binder_inner_proc_unlock(proc); in binder_thread_write()
4561 &proc->todo); in binder_thread_write()
4562 binder_wakeup_proc_ilocked(proc); in binder_thread_write()
4565 binder_inner_proc_unlock(proc); in binder_thread_write()
4575 error = binder_request_freeze_notification(proc, thread, in binder_thread_write()
4588 error = binder_clear_freeze_notification(proc, thread, &handle_cookie); in binder_thread_write()
4601 error = binder_freeze_notification_done(proc, thread, cookie); in binder_thread_write()
4608 proc->pid, thread->pid, cmd); in binder_thread_write()
4616 static void binder_stat_br(struct binder_proc *proc, in binder_stat_br() argument
4622 atomic_inc(&proc->stats.br[_IOC_NR(cmd)]); in binder_stat_br()
4627 static int binder_put_node_cmd(struct binder_proc *proc, in binder_put_node_cmd() argument
4649 binder_stat_br(proc, thread, cmd); in binder_put_node_cmd()
4651 proc->pid, thread->pid, cmd_name, node_debug_id, in binder_put_node_cmd()
4662 struct binder_proc *proc = thread->proc; in binder_wait_for_work() local
4665 binder_inner_proc_lock(proc); in binder_wait_for_work()
4672 &proc->waiting_threads); in binder_wait_for_work()
4673 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4675 binder_inner_proc_lock(proc); in binder_wait_for_work()
4683 binder_inner_proc_unlock(proc); in binder_wait_for_work()
4690 * @proc: binder_proc associated @t->buffer
4703 static int binder_apply_fd_fixups(struct binder_proc *proc, in binder_apply_fd_fixups() argument
4724 if (binder_alloc_copy_to_buffer(&proc->alloc, t->buffer, in binder_apply_fd_fixups()
4744 static int binder_thread_read(struct binder_proc *proc, in binder_thread_read() argument
4763 binder_inner_proc_lock(proc); in binder_thread_read()
4765 binder_inner_proc_unlock(proc); in binder_thread_read()
4771 !binder_worklist_empty(proc, &thread->todo)); in binder_thread_read()
4776 proc->pid, thread->pid, thread->looper); in binder_thread_read()
4780 binder_set_nice(proc->default_priority); in binder_thread_read()
4805 binder_inner_proc_lock(proc); in binder_thread_read()
4808 else if (!binder_worklist_empty_ilocked(&proc->todo) && in binder_thread_read()
4810 list = &proc->todo; in binder_thread_read()
4812 binder_inner_proc_unlock(proc); in binder_thread_read()
4821 binder_inner_proc_unlock(proc); in binder_thread_read()
4830 binder_inner_proc_unlock(proc); in binder_thread_read()
4838 binder_inner_proc_unlock(proc); in binder_thread_read()
4845 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4850 if (proc->oneway_spam_detection_enabled && in binder_thread_read()
4857 binder_inner_proc_unlock(proc); in binder_thread_read()
4864 binder_stat_br(proc, thread, cmd); in binder_thread_read()
4867 proc->pid, thread->pid); in binder_thread_read()
4879 BUG_ON(proc != node->proc); in binder_thread_read()
4905 proc->pid, thread->pid, in binder_thread_read()
4909 rb_erase(&node->rb_node, &proc->nodes); in binder_thread_read()
4910 binder_inner_proc_unlock(proc); in binder_thread_read()
4924 binder_inner_proc_unlock(proc); in binder_thread_read()
4928 proc, thread, &ptr, node_ptr, in binder_thread_read()
4933 proc, thread, &ptr, node_ptr, in binder_thread_read()
4938 proc, thread, &ptr, node_ptr, in binder_thread_read()
4943 proc, thread, &ptr, node_ptr, in binder_thread_read()
4949 proc->pid, thread->pid, in binder_thread_read()
4972 proc->pid, thread->pid, in binder_thread_read()
4978 binder_inner_proc_unlock(proc); in binder_thread_read()
4983 w, &proc->delivered_death); in binder_thread_read()
4984 binder_inner_proc_unlock(proc); in binder_thread_read()
4993 binder_stat_br(proc, thread, cmd); in binder_thread_read()
5007 binder_enqueue_work_ilocked(w, &proc->delivered_freeze); in binder_thread_read()
5008 binder_inner_proc_unlock(proc); in binder_thread_read()
5016 binder_stat_br(proc, thread, BR_FROZEN_BINDER); in binder_thread_read()
5025 binder_inner_proc_unlock(proc); in binder_thread_read()
5034 binder_stat_br(proc, thread, BR_CLEAR_FREEZE_NOTIFICATION_DONE); in binder_thread_read()
5038 binder_inner_proc_unlock(proc); in binder_thread_read()
5040 proc->pid, thread->pid, w->type); in binder_thread_read()
5072 struct task_struct *sender = t_from->proc->tsk; in binder_thread_read()
5081 ret = binder_apply_fd_fixups(proc, t); in binder_thread_read()
5092 binder_free_buf(proc, thread, buffer, true); in binder_thread_read()
5095 proc->pid, thread->pid, in binder_thread_read()
5104 binder_stat_br(proc, thread, cmd); in binder_thread_read()
5143 binder_stat_br(proc, thread, cmd); in binder_thread_read()
5146 proc->pid, thread->pid, in binder_thread_read()
5150 t->debug_id, t_from ? t_from->proc->pid : 0, in binder_thread_read()
5158 binder_inner_proc_lock(thread->proc); in binder_thread_read()
5162 binder_inner_proc_unlock(thread->proc); in binder_thread_read()
5172 binder_inner_proc_lock(proc); in binder_thread_read()
5173 if (proc->requested_threads == 0 && in binder_thread_read()
5174 list_empty(&thread->proc->waiting_threads) && in binder_thread_read()
5175 proc->requested_threads_started < proc->max_threads && in binder_thread_read()
5179 proc->requested_threads++; in binder_thread_read()
5180 binder_inner_proc_unlock(proc); in binder_thread_read()
5183 proc->pid, thread->pid); in binder_thread_read()
5186 binder_stat_br(proc, thread, BR_SPAWN_LOOPER); in binder_thread_read()
5188 binder_inner_proc_unlock(proc); in binder_thread_read()
5192 static void binder_release_work(struct binder_proc *proc, in binder_release_work() argument
5199 binder_inner_proc_lock(proc); in binder_release_work()
5202 binder_inner_proc_unlock(proc); in binder_release_work()
5264 struct binder_proc *proc, struct binder_thread *new_thread) in binder_get_thread_ilocked() argument
5268 struct rb_node **p = &proc->threads.rb_node; in binder_get_thread_ilocked()
5285 thread->proc = proc; in binder_get_thread_ilocked()
5291 rb_insert_color(&thread->rb_node, &proc->threads); in binder_get_thread_ilocked()
5302 static struct binder_thread *binder_get_thread(struct binder_proc *proc) in binder_get_thread() argument
5307 binder_inner_proc_lock(proc); in binder_get_thread()
5308 thread = binder_get_thread_ilocked(proc, NULL); in binder_get_thread()
5309 binder_inner_proc_unlock(proc); in binder_get_thread()
5314 binder_inner_proc_lock(proc); in binder_get_thread()
5315 thread = binder_get_thread_ilocked(proc, new_thread); in binder_get_thread()
5316 binder_inner_proc_unlock(proc); in binder_get_thread()
5323 static void binder_free_proc(struct binder_proc *proc) in binder_free_proc() argument
5327 BUG_ON(!list_empty(&proc->todo)); in binder_free_proc()
5328 BUG_ON(!list_empty(&proc->delivered_death)); in binder_free_proc()
5329 if (proc->outstanding_txns) in binder_free_proc()
5331 __func__, proc->outstanding_txns); in binder_free_proc()
5332 device = container_of(proc->context, struct binder_device, context); in binder_free_proc()
5335 kfree(proc->context->name); in binder_free_proc()
5338 binder_alloc_deferred_release(&proc->alloc); in binder_free_proc()
5339 put_task_struct(proc->tsk); in binder_free_proc()
5340 put_cred(proc->cred); in binder_free_proc()
5342 dbitmap_free(&proc->dmap); in binder_free_proc()
5343 kfree(proc); in binder_free_proc()
5350 binder_proc_dec_tmpref(thread->proc); in binder_free_thread()
5354 static int binder_thread_release(struct binder_proc *proc, in binder_thread_release() argument
5362 binder_inner_proc_lock(thread->proc); in binder_thread_release()
5364 * take a ref on the proc so it survives in binder_thread_release()
5365 * after we remove this thread from proc->threads. in binder_thread_release()
5369 proc->tmp_ref++; in binder_thread_release()
5375 rb_erase(&thread->rb_node, &proc->threads); in binder_thread_release()
5391 proc->pid, thread->pid, in binder_thread_release()
5396 thread->proc->outstanding_txns--; in binder_thread_release()
5425 binder_inner_proc_unlock(thread->proc); in binder_thread_release()
5439 binder_release_work(proc, &thread->todo); in binder_thread_release()
5447 struct binder_proc *proc = filp->private_data; in binder_poll() local
5451 thread = binder_get_thread(proc); in binder_poll()
5455 binder_inner_proc_lock(thread->proc); in binder_poll()
5459 binder_inner_proc_unlock(thread->proc); in binder_poll()
5473 struct binder_proc *proc = filp->private_data; in binder_ioctl_write_read() local
5482 proc->pid, thread->pid, in binder_ioctl_write_read()
5487 ret = binder_thread_write(proc, thread, in binder_ioctl_write_read()
5498 ret = binder_thread_read(proc, thread, bwr.read_buffer, in binder_ioctl_write_read()
5503 binder_inner_proc_lock(proc); in binder_ioctl_write_read()
5504 if (!binder_worklist_empty_ilocked(&proc->todo)) in binder_ioctl_write_read()
5505 binder_wakeup_proc_ilocked(proc); in binder_ioctl_write_read()
5506 binder_inner_proc_unlock(proc); in binder_ioctl_write_read()
5512 proc->pid, thread->pid, in binder_ioctl_write_read()
5525 struct binder_proc *proc = filp->private_data; in binder_ioctl_set_ctx_mgr() local
5526 struct binder_context *context = proc->context; in binder_ioctl_set_ctx_mgr()
5535 ret = security_binder_set_context_mgr(proc->cred); in binder_ioctl_set_ctx_mgr()
5549 new_node = binder_new_node(proc, fbo); in binder_ioctl_set_ctx_mgr()
5563 static int binder_ioctl_get_node_info_for_ref(struct binder_proc *proc, in binder_ioctl_get_node_info_for_ref() argument
5567 struct binder_context *context = proc->context; in binder_ioctl_get_node_info_for_ref()
5573 proc->pid); in binder_ioctl_get_node_info_for_ref()
5580 context->binder_context_mgr_node->proc != proc) { in binder_ioctl_get_node_info_for_ref()
5586 node = binder_get_node_from_ref(proc, handle, true, NULL); in binder_ioctl_get_node_info_for_ref()
5599 static int binder_ioctl_get_node_debug_info(struct binder_proc *proc, in binder_ioctl_get_node_debug_info() argument
5607 binder_inner_proc_lock(proc); in binder_ioctl_get_node_debug_info()
5608 for (n = rb_first(&proc->nodes); n != NULL; n = rb_next(n)) { in binder_ioctl_get_node_debug_info()
5619 binder_inner_proc_unlock(proc); in binder_ioctl_get_node_debug_info()
5624 static bool binder_txns_pending_ilocked(struct binder_proc *proc) in binder_txns_pending_ilocked() argument
5629 if (proc->outstanding_txns > 0) in binder_txns_pending_ilocked()
5632 for (n = rb_first(&proc->threads); n; n = rb_next(n)) { in binder_txns_pending_ilocked()
5640 static void binder_add_freeze_work(struct binder_proc *proc, bool is_frozen) in binder_add_freeze_work() argument
5646 binder_inner_proc_lock(proc); in binder_add_freeze_work()
5647 for (n = rb_first(&proc->nodes); n; n = rb_next(n)) { in binder_add_freeze_work()
5652 binder_inner_proc_unlock(proc); in binder_add_freeze_work()
5663 binder_inner_proc_lock(ref->proc); in binder_add_freeze_work()
5665 binder_inner_proc_unlock(ref->proc); in binder_add_freeze_work()
5671 binder_enqueue_work_ilocked(&ref->freeze->work, &ref->proc->todo); in binder_add_freeze_work()
5672 binder_wakeup_proc_ilocked(ref->proc); in binder_add_freeze_work()
5678 binder_inner_proc_unlock(ref->proc); in binder_add_freeze_work()
5682 binder_inner_proc_lock(proc); in binder_add_freeze_work()
5683 if (proc->is_dead) in binder_add_freeze_work()
5686 binder_inner_proc_unlock(proc); in binder_add_freeze_work()
5777 binder_inner_proc_lock(thread->proc); in binder_ioctl_get_extended_error()
5780 binder_inner_proc_unlock(thread->proc); in binder_ioctl_get_extended_error()
5791 struct binder_proc *proc = filp->private_data; in binder_ioctl() local
5801 thread = binder_get_thread(proc); in binder_ioctl()
5821 binder_inner_proc_lock(proc); in binder_ioctl()
5822 proc->max_threads = max_threads; in binder_ioctl()
5823 binder_inner_proc_unlock(proc); in binder_ioctl()
5845 proc->pid, thread->pid); in binder_ioctl()
5846 binder_thread_release(proc, thread); in binder_ioctl()
5867 ret = binder_ioctl_get_node_info_for_ref(proc, &info); in binder_ioctl()
5886 ret = binder_ioctl_get_node_debug_info(proc, &info); in binder_ioctl()
5980 binder_inner_proc_lock(proc); in binder_ioctl()
5981 proc->oneway_spam_detection_enabled = (bool)enable; in binder_ioctl()
5982 binder_inner_proc_unlock(proc); in binder_ioctl()
6000 pr_info("%d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret); in binder_ioctl()
6008 struct binder_proc *proc = vma->vm_private_data; in binder_vma_open() local
6012 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_open()
6019 struct binder_proc *proc = vma->vm_private_data; in binder_vma_close() local
6023 proc->pid, vma->vm_start, vma->vm_end, in binder_vma_close()
6026 binder_alloc_vma_close(&proc->alloc); in binder_vma_close()
6043 struct binder_proc *proc = filp->private_data; in binder_mmap() local
6045 if (!same_thread_group(proc->tsk, current)) in binder_mmap()
6050 __func__, proc->pid, vma->vm_start, vma->vm_end, in binder_mmap()
6056 proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", -EPERM); in binder_mmap()
6062 vma->vm_private_data = proc; in binder_mmap()
6064 return binder_alloc_mmap_handler(&proc->alloc, vma); in binder_mmap()
6069 struct binder_proc *proc, *itr; in binder_open() local
6078 proc = kzalloc_obj(*proc); in binder_open()
6079 if (proc == NULL) in binder_open()
6082 dbitmap_init(&proc->dmap); in binder_open()
6083 spin_lock_init(&proc->inner_lock); in binder_open()
6084 spin_lock_init(&proc->outer_lock); in binder_open()
6085 proc->tsk = get_task_struct(current->group_leader); in binder_open()
6086 proc->pid = current->tgid; in binder_open()
6087 proc->cred = get_cred(filp->f_cred); in binder_open()
6088 INIT_LIST_HEAD(&proc->todo); in binder_open()
6089 init_waitqueue_head(&proc->freeze_wait); in binder_open()
6090 proc->default_priority = task_nice(current); in binder_open()
6101 proc->context = &binder_dev->context; in binder_open()
6102 binder_alloc_init(&proc->alloc); in binder_open()
6105 INIT_LIST_HEAD(&proc->delivered_death); in binder_open()
6106 INIT_LIST_HEAD(&proc->delivered_freeze); in binder_open()
6107 INIT_LIST_HEAD(&proc->waiting_threads); in binder_open()
6108 filp->private_data = proc; in binder_open()
6112 if (itr->pid == proc->pid) { in binder_open()
6117 hlist_add_head(&proc->proc_node, &binder_procs); in binder_open()
6123 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
6125 * proc debug entries are shared between contexts. in binder_open()
6130 proc->debugfs_entry = debugfs_create_file(strbuf, 0444, in binder_open()
6132 (void *)(unsigned long)proc->pid, in binder_open()
6140 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); in binder_open()
6148 strbuf, &proc_fops, (void *)(unsigned long)proc->pid); in binder_open()
6150 proc->binderfs_entry = binderfs_entry; in binder_open()
6165 struct binder_proc *proc = filp->private_data; in binder_flush() local
6167 binder_defer_work(proc, BINDER_DEFERRED_FLUSH); in binder_flush()
6172 static void binder_deferred_flush(struct binder_proc *proc) in binder_deferred_flush() argument
6177 binder_inner_proc_lock(proc); in binder_deferred_flush()
6178 for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { in binder_deferred_flush()
6187 binder_inner_proc_unlock(proc); in binder_deferred_flush()
6190 "binder_flush: %d woke %d threads\n", proc->pid, in binder_deferred_flush()
6196 struct binder_proc *proc = filp->private_data; in binder_release() local
6198 debugfs_remove(proc->debugfs_entry); in binder_release()
6200 if (proc->binderfs_entry) { in binder_release()
6201 simple_recursive_removal(proc->binderfs_entry, NULL); in binder_release()
6202 proc->binderfs_entry = NULL; in binder_release()
6205 binder_defer_work(proc, BINDER_DEFERRED_RELEASE); in binder_release()
6214 struct binder_proc *proc = node->proc; in binder_node_release() local
6216 binder_release_work(proc, &node->async_todo); in binder_node_release()
6219 binder_inner_proc_lock(proc); in binder_node_release()
6226 binder_inner_proc_unlock(proc); in binder_node_release()
6233 node->proc = NULL; in binder_node_release()
6236 binder_inner_proc_unlock(proc); in binder_node_release()
6250 binder_inner_proc_lock(ref->proc); in binder_node_release()
6252 binder_inner_proc_unlock(ref->proc); in binder_node_release()
6261 &ref->proc->todo); in binder_node_release()
6262 binder_wakeup_proc_ilocked(ref->proc); in binder_node_release()
6263 binder_inner_proc_unlock(ref->proc); in binder_node_release()
6275 static void binder_deferred_release(struct binder_proc *proc) in binder_deferred_release() argument
6277 struct binder_context *context = proc->context; in binder_deferred_release()
6282 hlist_del(&proc->proc_node); in binder_deferred_release()
6287 context->binder_context_mgr_node->proc == proc) { in binder_deferred_release()
6290 __func__, proc->pid); in binder_deferred_release()
6294 binder_inner_proc_lock(proc); in binder_deferred_release()
6296 * Make sure proc stays alive after we in binder_deferred_release()
6299 proc->tmp_ref++; in binder_deferred_release()
6301 proc->is_dead = true; in binder_deferred_release()
6302 proc->is_frozen = false; in binder_deferred_release()
6303 proc->sync_recv = false; in binder_deferred_release()
6304 proc->async_recv = false; in binder_deferred_release()
6307 while ((n = rb_first(&proc->threads))) { in binder_deferred_release()
6311 binder_inner_proc_unlock(proc); in binder_deferred_release()
6313 active_transactions += binder_thread_release(proc, thread); in binder_deferred_release()
6314 binder_inner_proc_lock(proc); in binder_deferred_release()
6319 while ((n = rb_first(&proc->nodes))) { in binder_deferred_release()
6330 rb_erase(&node->rb_node, &proc->nodes); in binder_deferred_release()
6331 binder_inner_proc_unlock(proc); in binder_deferred_release()
6333 binder_inner_proc_lock(proc); in binder_deferred_release()
6335 binder_inner_proc_unlock(proc); in binder_deferred_release()
6338 binder_proc_lock(proc); in binder_deferred_release()
6339 while ((n = rb_first(&proc->refs_by_desc))) { in binder_deferred_release()
6345 binder_proc_unlock(proc); in binder_deferred_release()
6347 binder_proc_lock(proc); in binder_deferred_release()
6349 binder_proc_unlock(proc); in binder_deferred_release()
6351 binder_release_work(proc, &proc->todo); in binder_deferred_release()
6352 binder_release_work(proc, &proc->delivered_death); in binder_deferred_release()
6353 binder_release_work(proc, &proc->delivered_freeze); in binder_deferred_release()
6357 __func__, proc->pid, threads, nodes, incoming_refs, in binder_deferred_release()
6360 binder_proc_dec_tmpref(proc); in binder_deferred_release()
6365 struct binder_proc *proc; in binder_deferred_func() local
6372 proc = hlist_entry(binder_deferred_list.first, in binder_deferred_func()
6374 hlist_del_init(&proc->deferred_work_node); in binder_deferred_func()
6375 defer = proc->deferred_work; in binder_deferred_func()
6376 proc->deferred_work = 0; in binder_deferred_func()
6378 proc = NULL; in binder_deferred_func()
6384 binder_deferred_flush(proc); in binder_deferred_func()
6387 binder_deferred_release(proc); /* frees proc */ in binder_deferred_func()
6388 } while (proc); in binder_deferred_func()
6393 binder_defer_work(struct binder_proc *proc, enum binder_deferred_state defer) in binder_defer_work() argument
6396 proc->deferred_work |= defer; in binder_defer_work()
6397 if (hlist_unhashed(&proc->deferred_work_node)) { in binder_defer_work()
6398 hlist_add_head(&proc->deferred_work_node, in binder_defer_work()
6405 struct binder_proc *proc, in print_binder_transaction_ilocked() argument
6426 if (proc != to_proc) { in print_binder_transaction_ilocked()
6429 * correct proc inner lock for this node in print_binder_transaction_ilocked()
6443 buffer->user_data - proc->alloc.vm_start); in print_binder_transaction_ilocked()
6447 struct binder_proc *proc, in print_binder_work_ilocked() argument
6459 m, proc, transaction_prefix, t); in print_binder_work_ilocked()
6521 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6525 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6529 print_binder_transaction_ilocked(m, thread->proc, in print_binder_thread_ilocked()
6535 print_binder_work_ilocked(m, thread->proc, " ", in print_binder_thread_ilocked()
6564 seq_puts(m, " proc"); in print_binder_node_nilocked()
6566 seq_printf(m, " %d", ref->proc->pid); in print_binder_node_nilocked()
6569 if (node->proc) { in print_binder_node_nilocked()
6571 print_binder_work_ilocked(m, node->proc, " ", in print_binder_node_nilocked()
6583 ref->node->proc ? "" : "dead ", in print_binder_ref_olocked()
6592 * @proc: struct binder_proc we hold the inner_proc_lock to (if any)
6598 * binder_node while iterating through @proc->nodes or the dead nodes list.
6599 * Caller must hold either @proc->inner_lock (for live nodes) or
6606 print_next_binder_node_ilocked(struct seq_file *m, struct binder_proc *proc, in print_next_binder_node_ilocked() argument
6616 * Live nodes need to drop the inner proc lock and dead nodes need to in print_next_binder_node_ilocked()
6619 if (proc) in print_next_binder_node_ilocked()
6620 binder_inner_proc_unlock(proc); in print_next_binder_node_ilocked()
6628 if (proc) in print_next_binder_node_ilocked()
6629 binder_inner_proc_lock(proc); in print_next_binder_node_ilocked()
6635 static void print_binder_proc(struct seq_file *m, struct binder_proc *proc, in print_binder_proc() argument
6644 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc()
6645 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc()
6648 binder_inner_proc_lock(proc); in print_binder_proc()
6649 for (n = rb_first(&proc->threads); n; n = rb_next(n)) in print_binder_proc()
6653 for (n = rb_first(&proc->nodes); n; n = rb_next(n)) { in print_binder_proc()
6659 last_node = print_next_binder_node_ilocked(m, proc, node, in print_binder_proc()
6663 binder_inner_proc_unlock(proc); in print_binder_proc()
6668 binder_proc_lock(proc); in print_binder_proc()
6669 for (n = rb_first(&proc->refs_by_desc); n; n = rb_next(n)) in print_binder_proc()
6673 binder_proc_unlock(proc); in print_binder_proc()
6675 binder_alloc_print_allocated(m, &proc->alloc); in print_binder_proc()
6676 binder_inner_proc_lock(proc); in print_binder_proc()
6677 list_for_each_entry(w, &proc->todo, entry) in print_binder_proc()
6678 print_binder_work_ilocked(m, proc, " ", in print_binder_proc()
6681 list_for_each_entry(w, &proc->delivered_death, entry) { in print_binder_proc()
6685 list_for_each_entry(w, &proc->delivered_freeze, entry) { in print_binder_proc()
6689 binder_inner_proc_unlock(proc); in print_binder_proc()
6746 "proc",
6799 struct binder_proc *proc) in print_binder_proc_stats() argument
6806 binder_alloc_get_free_async_space(&proc->alloc); in print_binder_proc_stats()
6808 seq_printf(m, "proc %d\n", proc->pid); in print_binder_proc_stats()
6809 seq_printf(m, "context %s\n", proc->context->name); in print_binder_proc_stats()
6812 binder_inner_proc_lock(proc); in print_binder_proc_stats()
6813 for (n = rb_first(&proc->threads); n; n = rb_next(n)) in print_binder_proc_stats()
6816 list_for_each_entry(thread, &proc->waiting_threads, waiting_thread_node) in print_binder_proc_stats()
6822 " free async space %zd\n", proc->requested_threads, in print_binder_proc_stats()
6823 proc->requested_threads_started, proc->max_threads, in print_binder_proc_stats()
6827 for (n = rb_first(&proc->nodes); n; n = rb_next(n)) in print_binder_proc_stats()
6829 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
6834 binder_proc_lock(proc); in print_binder_proc_stats()
6835 for (n = rb_first(&proc->refs_by_desc); n; n = rb_next(n)) { in print_binder_proc_stats()
6842 binder_proc_unlock(proc); in print_binder_proc_stats()
6845 count = binder_alloc_get_allocated_count(&proc->alloc); in print_binder_proc_stats()
6848 binder_alloc_print_pages(m, &proc->alloc); in print_binder_proc_stats()
6851 binder_inner_proc_lock(proc); in print_binder_proc_stats()
6852 list_for_each_entry(w, &proc->todo, entry) { in print_binder_proc_stats()
6856 binder_inner_proc_unlock(proc); in print_binder_proc_stats()
6859 print_binder_stats(m, " ", &proc->stats); in print_binder_proc_stats()
6864 struct binder_proc *proc; in print_binder_state() local
6882 hlist_for_each_entry(proc, &binder_procs, proc_node) in print_binder_state()
6883 print_binder_proc(m, proc, true, hash_ptrs); in print_binder_state()
6889 struct binder_proc *proc; in print_binder_transactions() local
6893 hlist_for_each_entry(proc, &binder_procs, proc_node) in print_binder_transactions()
6894 print_binder_proc(m, proc, false, hash_ptrs); in print_binder_transactions()
6912 struct binder_proc *proc; in stats_show() local
6919 hlist_for_each_entry(proc, &binder_procs, proc_node) in stats_show()
6920 print_binder_proc_stats(m, proc); in stats_show()
6946 seq_puts(m, "binder proc state:\n"); in proc_show()
7131 binder_debugfs_dir_entry_proc = debugfs_create_dir("proc", in binder_init()