Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337149
b: refs/heads/master
c: 73327b4
h: refs/heads/master
i:
  337147: 4a4b559
v: v3
  • Loading branch information
Peter Senna Tschudin authored and Jonathan Cameron committed Oct 19, 2012
1 parent 6655757 commit 0ce683f
Show file tree
Hide file tree
Showing 196 changed files with 3,105 additions and 3,478 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9385f21b293d6bd37078154bc9d4f193c106176b
refs/heads/master: 73327b4c80713da3a854fb04ef7e9739fe006709
2 changes: 0 additions & 2 deletions trunk/drivers/staging/android/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ccflags-y += -I$(src) # needed for trace events

obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o
obj-$(CONFIG_ASHMEM) += ashmem.o
obj-$(CONFIG_ANDROID_LOGGER) += logger.o
Expand Down
95 changes: 20 additions & 75 deletions trunk/drivers/staging/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
#include <linux/slab.h>

#include "binder.h"
#include "binder_trace.h"

static DEFINE_MUTEX(binder_main_lock);
static DEFINE_MUTEX(binder_lock);
static DEFINE_MUTEX(binder_deferred_lock);
static DEFINE_MUTEX(binder_mmap_lock);

Expand Down Expand Up @@ -412,19 +411,6 @@ static long task_close_fd(struct binder_proc *proc, unsigned int fd)
return retval;
}

static inline void binder_lock(const char *tag)
{
trace_binder_lock(tag);
mutex_lock(&binder_main_lock);
trace_binder_locked(tag);
}

static inline void binder_unlock(const char *tag)
{
trace_binder_unlock(tag);
mutex_unlock(&binder_main_lock);
}

static void binder_set_nice(long nice)
{
long min_nice;
Expand Down Expand Up @@ -551,8 +537,6 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
if (end <= start)
return 0;

trace_binder_update_page_range(proc, allocate, start, end);

if (vma)
mm = NULL;
else
Expand Down Expand Up @@ -1477,9 +1461,6 @@ static void binder_transaction(struct binder_proc *proc,
t->code = tr->code;
t->flags = tr->flags;
t->priority = task_nice(current);

trace_binder_transaction(reply, t, target_node);

t->buffer = binder_alloc_buf(target_proc, tr->data_size,
tr->offsets_size, !reply && (t->flags & TF_ONE_WAY));
if (t->buffer == NULL) {
Expand All @@ -1490,7 +1471,6 @@ static void binder_transaction(struct binder_proc *proc,
t->buffer->debug_id = t->debug_id;
t->buffer->transaction = t;
t->buffer->target_node = target_node;
trace_binder_transaction_alloc_buf(t->buffer);
if (target_node)
binder_inc_node(target_node, 1, 0, NULL);

Expand Down Expand Up @@ -1563,7 +1543,6 @@ static void binder_transaction(struct binder_proc *proc,
binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE,
&thread->todo);

trace_binder_transaction_node_to_ref(t, node, ref);
binder_debug(BINDER_DEBUG_TRANSACTION,
" node %d u%p -> ref %d desc %d\n",
node->debug_id, node->ptr, ref->debug_id,
Expand All @@ -1588,7 +1567,6 @@ static void binder_transaction(struct binder_proc *proc,
fp->binder = ref->node->ptr;
fp->cookie = ref->node->cookie;
binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL);
trace_binder_transaction_ref_to_node(t, ref);
binder_debug(BINDER_DEBUG_TRANSACTION,
" ref %d desc %d -> node %d u%p\n",
ref->debug_id, ref->desc, ref->node->debug_id,
Expand All @@ -1602,8 +1580,6 @@ static void binder_transaction(struct binder_proc *proc,
}
fp->handle = new_ref->desc;
binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL);
trace_binder_transaction_ref_to_ref(t, ref,
new_ref);
binder_debug(BINDER_DEBUG_TRANSACTION,
" ref %d desc %d -> ref %d desc %d (node %d)\n",
ref->debug_id, ref->desc, new_ref->debug_id,
Expand Down Expand Up @@ -1643,7 +1619,6 @@ static void binder_transaction(struct binder_proc *proc,
goto err_get_unused_fd_failed;
}
task_fd_install(target_proc, target_fd, file);
trace_binder_transaction_fd(t, fp->handle, target_fd);
binder_debug(BINDER_DEBUG_TRANSACTION,
" fd %ld -> %d\n", fp->handle, target_fd);
/* TODO: fput? */
Expand Down Expand Up @@ -1692,7 +1667,6 @@ static void binder_transaction(struct binder_proc *proc,
err_bad_object_type:
err_bad_offset:
err_copy_data_failed:
trace_binder_transaction_failed_buffer_release(t->buffer);
binder_transaction_buffer_release(target_proc, t->buffer, offp);
t->buffer->transaction = NULL;
binder_free_buf(target_proc, t->buffer);
Expand Down Expand Up @@ -1738,7 +1712,6 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
if (get_user(cmd, (uint32_t __user *)ptr))
return -EFAULT;
ptr += sizeof(uint32_t);
trace_binder_command(cmd);
if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.bc)) {
binder_stats.bc[_IOC_NR(cmd)]++;
proc->stats.bc[_IOC_NR(cmd)]++;
Expand Down Expand Up @@ -1908,7 +1881,6 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
else
list_move_tail(buffer->target_node->async_todo.next, &thread->todo);
}
trace_binder_transaction_buffer_release(buffer);
binder_transaction_buffer_release(proc, buffer, NULL);
binder_free_buf(proc, buffer);
break;
Expand Down Expand Up @@ -2117,7 +2089,6 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
void binder_stat_br(struct binder_proc *proc, struct binder_thread *thread,
uint32_t cmd)
{
trace_binder_return(cmd);
if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) {
binder_stats.br[_IOC_NR(cmd)]++;
proc->stats.br[_IOC_NR(cmd)]++;
Expand Down Expand Up @@ -2164,15 +2135,13 @@ static int binder_thread_read(struct binder_proc *proc,
if (put_user(thread->return_error2, (uint32_t __user *)ptr))
return -EFAULT;
ptr += sizeof(uint32_t);
binder_stat_br(proc, thread, thread->return_error2);
if (ptr == end)
goto done;
thread->return_error2 = BR_OK;
}
if (put_user(thread->return_error, (uint32_t __user *)ptr))
return -EFAULT;
ptr += sizeof(uint32_t);
binder_stat_br(proc, thread, thread->return_error);
thread->return_error = BR_OK;
goto done;
}
Expand All @@ -2181,12 +2150,7 @@ static int binder_thread_read(struct binder_proc *proc,
thread->looper |= BINDER_LOOPER_STATE_WAITING;
if (wait_for_proc_work)
proc->ready_threads++;

binder_unlock(__func__);

trace_binder_wait_for_work(wait_for_proc_work,
!!thread->transaction_stack,
!list_empty(&thread->todo));
mutex_unlock(&binder_lock);
if (wait_for_proc_work) {
if (!(thread->looper & (BINDER_LOOPER_STATE_REGISTERED |
BINDER_LOOPER_STATE_ENTERED))) {
Expand All @@ -2210,9 +2174,7 @@ static int binder_thread_read(struct binder_proc *proc,
} else
ret = wait_event_interruptible(thread->wait, binder_has_thread_work(thread));
}

binder_lock(__func__);

mutex_lock(&binder_lock);
if (wait_for_proc_work)
proc->ready_threads--;
thread->looper &= ~BINDER_LOOPER_STATE_WAITING;
Expand Down Expand Up @@ -2335,7 +2297,6 @@ static int binder_thread_read(struct binder_proc *proc,
if (put_user(death->cookie, (void * __user *)ptr))
return -EFAULT;
ptr += sizeof(void *);
binder_stat_br(proc, thread, cmd);
binder_debug(BINDER_DEBUG_DEATH_NOTIFICATION,
"binder: %d:%d %s %p\n",
proc->pid, thread->pid,
Expand Down Expand Up @@ -2403,7 +2364,6 @@ static int binder_thread_read(struct binder_proc *proc,
return -EFAULT;
ptr += sizeof(tr);

trace_binder_transaction_received(t);
binder_stat_br(proc, thread, cmd);
binder_debug(BINDER_DEBUG_TRANSACTION,
"binder: %d:%d %s %d %d:%d, cmd %d"
Expand Down Expand Up @@ -2444,7 +2404,6 @@ static int binder_thread_read(struct binder_proc *proc,
proc->pid, thread->pid);
if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer))
return -EFAULT;
binder_stat_br(proc, thread, BR_SPAWN_LOOPER);
}
return 0;
}
Expand Down Expand Up @@ -2557,14 +2516,12 @@ static unsigned int binder_poll(struct file *filp,
struct binder_thread *thread = NULL;
int wait_for_proc_work;

binder_lock(__func__);

mutex_lock(&binder_lock);
thread = binder_get_thread(proc);

wait_for_proc_work = thread->transaction_stack == NULL &&
list_empty(&thread->todo) && thread->return_error == BR_OK;

binder_unlock(__func__);
mutex_unlock(&binder_lock);

if (wait_for_proc_work) {
if (binder_has_proc_work(proc, thread))
Expand Down Expand Up @@ -2592,13 +2549,11 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

/*pr_info("binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/

trace_binder_ioctl(cmd, arg);

ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
if (ret)
goto err_unlocked;
return ret;

binder_lock(__func__);
mutex_lock(&binder_lock);
thread = binder_get_thread(proc);
if (thread == NULL) {
ret = -ENOMEM;
Expand All @@ -2623,7 +2578,6 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

if (bwr.write_size > 0) {
ret = binder_thread_write(proc, thread, (void __user *)bwr.write_buffer, bwr.write_size, &bwr.write_consumed);
trace_binder_write_done(ret);
if (ret < 0) {
bwr.read_consumed = 0;
if (copy_to_user(ubuf, &bwr, sizeof(bwr)))
Expand All @@ -2633,7 +2587,6 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
if (bwr.read_size > 0) {
ret = binder_thread_read(proc, thread, (void __user *)bwr.read_buffer, bwr.read_size, &bwr.read_consumed, filp->f_flags & O_NONBLOCK);
trace_binder_read_done(ret);
if (!list_empty(&proc->todo))
wake_up_interruptible(&proc->wait);
if (ret < 0) {
Expand Down Expand Up @@ -2709,12 +2662,10 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
err:
if (thread)
thread->looper &= ~BINDER_LOOPER_STATE_NEED_RETURN;
binder_unlock(__func__);
mutex_unlock(&binder_lock);
wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
if (ret && ret != -ERESTARTSYS)
pr_info("binder: %d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret);
err_unlocked:
trace_binder_ioctl_done(ret);
return ret;
}

Expand Down Expand Up @@ -2860,16 +2811,13 @@ static int binder_open(struct inode *nodp, struct file *filp)
INIT_LIST_HEAD(&proc->todo);
init_waitqueue_head(&proc->wait);
proc->default_priority = task_nice(current);

binder_lock(__func__);

mutex_lock(&binder_lock);
binder_stats_created(BINDER_STAT_PROC);
hlist_add_head(&proc->proc_node, &binder_procs);
proc->pid = current->group_leader->pid;
INIT_LIST_HEAD(&proc->delivered_death);
filp->private_data = proc;

binder_unlock(__func__);
mutex_unlock(&binder_lock);

if (binder_debugfs_dir_entry_proc) {
char strbuf[11];
Expand Down Expand Up @@ -3049,7 +2997,7 @@ static void binder_deferred_func(struct work_struct *work)

int defer;
do {
binder_lock(__func__);
mutex_lock(&binder_lock);
mutex_lock(&binder_deferred_lock);
if (!hlist_empty(&binder_deferred_list)) {
proc = hlist_entry(binder_deferred_list.first,
Expand All @@ -3076,7 +3024,7 @@ static void binder_deferred_func(struct work_struct *work)
if (defer & BINDER_DEFERRED_RELEASE)
binder_deferred_release(proc); /* frees proc */

binder_unlock(__func__);
mutex_unlock(&binder_lock);
if (files)
put_files_struct(files);
} while (proc);
Expand Down Expand Up @@ -3417,7 +3365,7 @@ static int binder_state_show(struct seq_file *m, void *unused)
int do_lock = !binder_debug_no_lock;

if (do_lock)
binder_lock(__func__);
mutex_lock(&binder_lock);

seq_puts(m, "binder state:\n");

Expand All @@ -3429,7 +3377,7 @@ static int binder_state_show(struct seq_file *m, void *unused)
hlist_for_each_entry(proc, pos, &binder_procs, proc_node)
print_binder_proc(m, proc, 1);
if (do_lock)
binder_unlock(__func__);
mutex_unlock(&binder_lock);
return 0;
}

Expand All @@ -3440,7 +3388,7 @@ static int binder_stats_show(struct seq_file *m, void *unused)
int do_lock = !binder_debug_no_lock;

if (do_lock)
binder_lock(__func__);
mutex_lock(&binder_lock);

seq_puts(m, "binder stats:\n");

Expand All @@ -3449,7 +3397,7 @@ static int binder_stats_show(struct seq_file *m, void *unused)
hlist_for_each_entry(proc, pos, &binder_procs, proc_node)
print_binder_proc_stats(m, proc);
if (do_lock)
binder_unlock(__func__);
mutex_unlock(&binder_lock);
return 0;
}

Expand All @@ -3460,13 +3408,13 @@ static int binder_transactions_show(struct seq_file *m, void *unused)
int do_lock = !binder_debug_no_lock;

if (do_lock)
binder_lock(__func__);
mutex_lock(&binder_lock);

seq_puts(m, "binder transactions:\n");
hlist_for_each_entry(proc, pos, &binder_procs, proc_node)
print_binder_proc(m, proc, 0);
if (do_lock)
binder_unlock(__func__);
mutex_unlock(&binder_lock);
return 0;
}

Expand All @@ -3476,11 +3424,11 @@ static int binder_proc_show(struct seq_file *m, void *unused)
int do_lock = !binder_debug_no_lock;

if (do_lock)
binder_lock(__func__);
mutex_lock(&binder_lock);
seq_puts(m, "binder proc state:\n");
print_binder_proc(m, proc, 1);
if (do_lock)
binder_unlock(__func__);
mutex_unlock(&binder_lock);
return 0;
}

Expand Down Expand Up @@ -3575,7 +3523,4 @@ static int __init binder_init(void)

device_initcall(binder_init);

#define CREATE_TRACE_POINTS
#include "binder_trace.h"

MODULE_LICENSE("GPL v2");
Loading

0 comments on commit 0ce683f

Please sign in to comment.