Skip to content

Commit 4483b60

Browse files
Helium-Studioonettboots
authored andcommitted
binder: Fix 5.10 binder compilation on 4.14
* Taken from YumeMichi/kernel_xiaomi_pipa@6b161e4 and cyberknight777/dragonheart_kernel_oneplus_sm8150@fc245aa Signed-off-by: Helium-Studio <67852324+Helium-Studio@users.noreply.github.com> Signed-off-by: onettboots <blackcocopet@gmail.com>
1 parent 9e82666 commit 4483b60

4 files changed

Lines changed: 120 additions & 193 deletions

File tree

drivers/android/binder.c

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@
7575
#include <linux/syscalls.h>
7676
#include <linux/task_work.h>
7777
#include <linux/sizes.h>
78-
#include <linux/android_vendor.h>
7978

8079
#include <uapi/linux/sched/types.h>
8180
#include <uapi/linux/android/binder.h>
82-
#include "binder_alloc.h"
81+
#include <uapi/linux/eventpoll.h>
82+
83+
#include <asm/cacheflush.h>
84+
8385
#include "binder_internal.h"
8486
#include "binder_trace.h"
85-
#include <trace/hooks/binder.h>
8687

8788
static HLIST_HEAD(binder_deferred_list);
8889
static DEFINE_MUTEX(binder_deferred_lock);
@@ -845,7 +846,6 @@ static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc,
845846
thread = rb_entry(n, struct binder_thread, rb_node);
846847
if (thread->looper & BINDER_LOOPER_STATE_POLL &&
847848
binder_available_for_proc_work_ilocked(thread)) {
848-
trace_android_vh_binder_wakeup_ilocked(thread->task, sync, proc);
849849
if (sync)
850850
wake_up_interruptible_sync(&thread->wait);
851851
else
@@ -905,7 +905,6 @@ static void binder_wakeup_thread_ilocked(struct binder_proc *proc,
905905
assert_spin_locked(&proc->inner_lock);
906906

907907
if (thread) {
908-
trace_android_vh_binder_wakeup_ilocked(thread->task, sync, proc);
909908
if (sync)
910909
wake_up_interruptible_sync(&thread->wait);
911910
else
@@ -1053,7 +1052,6 @@ static void binder_transaction_priority(struct task_struct *task,
10531052
.sched_policy = node->sched_policy,
10541053
.prio = node->min_priority,
10551054
};
1056-
bool skip = false;
10571055

10581056
if (t->set_priority_called)
10591057
return;
@@ -1062,10 +1060,6 @@ static void binder_transaction_priority(struct task_struct *task,
10621060
t->saved_priority.sched_policy = task->policy;
10631061
t->saved_priority.prio = task->normal_prio;
10641062

1065-
trace_android_vh_binder_priority_skip(task, &skip);
1066-
if (skip)
1067-
return;
1068-
10691063
if (!node->inherit_rt && is_rt_policy(desired.sched_policy)) {
10701064
desired.prio = NICE_TO_PRIO(0);
10711065
desired.sched_policy = SCHED_NORMAL;
@@ -1104,7 +1098,6 @@ static void binder_transaction_priority(struct task_struct *task,
11041098
spin_unlock(&thread->prio_lock);
11051099

11061100
binder_set_priority(thread, &desired);
1107-
trace_android_vh_binder_set_priority(t, task);
11081101
}
11091102

11101103
static struct binder_node *binder_get_node_ilocked(struct binder_proc *proc,
@@ -1548,7 +1541,6 @@ static struct binder_ref *binder_get_ref_for_node_olocked(
15481541
"%d new ref %d desc %d for node %d\n",
15491542
proc->pid, new_ref->data.debug_id, new_ref->data.desc,
15501543
node->debug_id);
1551-
trace_android_vh_binder_new_ref(proc->tsk, new_ref->data.desc, new_ref->node->debug_id);
15521544
binder_node_unlock(node);
15531545
return new_ref;
15541546
}
@@ -1716,7 +1708,6 @@ static struct binder_node *binder_get_node_from_ref(
17161708
*/
17171709
static void binder_free_ref(struct binder_ref *ref)
17181710
{
1719-
trace_android_vh_binder_del_ref(ref->proc ? ref->proc->tsk : 0, ref->data.desc);
17201711
if (ref->node)
17211712
binder_free_node(ref->node);
17221713
kfree(ref->death);
@@ -2319,10 +2310,10 @@ static void binder_deferred_fd_close(int fd)
23192310
if (!twcb)
23202311
return;
23212312
init_task_work(&twcb->twork, binder_do_fd_close);
2322-
close_fd_get_file(fd, &twcb->file);
2313+
__close_fd_get_file(fd, &twcb->file);
23232314
if (twcb->file) {
23242315
filp_close(twcb->file, current->files);
2325-
task_work_add(current, &twcb->twork, TWA_RESUME);
2316+
task_work_add(current, &twcb->twork, true);
23262317
} else {
23272318
kfree(twcb);
23282319
}
@@ -3122,9 +3113,6 @@ static int binder_proc_transaction(struct binder_transaction *t,
31223113
if (!thread && !pending_async)
31233114
thread = binder_select_thread_ilocked(proc);
31243115

3125-
trace_android_vh_binder_proc_transaction(current, proc->tsk,
3126-
thread ? thread->task : 0, node->debug_id, t->code, pending_async);
3127-
31283116
if (thread) {
31293117
binder_transaction_priority(thread->task, t, node_prio,
31303118
node->inherit_rt);
@@ -3301,7 +3289,6 @@ static void binder_transaction(struct binder_proc *proc,
33013289
target_proc = target_thread->proc;
33023290
atomic_inc(&target_proc->tmp_ref);
33033291
binder_inner_proc_unlock(target_thread->proc);
3304-
trace_android_vh_binder_reply(target_proc, proc, thread, tr);
33053292
} else {
33063293
if (tr->target.handle) {
33073294
struct binder_ref *ref;
@@ -3360,7 +3347,6 @@ static void binder_transaction(struct binder_proc *proc,
33603347
return_error_line = __LINE__;
33613348
goto err_invalid_target_handle;
33623349
}
3363-
trace_android_vh_binder_trans(target_proc, proc, thread, tr);
33643350
if (security_binder_transaction(proc->cred,
33653351
target_proc->cred) < 0) {
33663352
return_error = BR_FAILED_REPLY;
@@ -3418,7 +3404,6 @@ static void binder_transaction(struct binder_proc *proc,
34183404
}
34193405
binder_stats_created(BINDER_STAT_TRANSACTION);
34203406
spin_lock_init(&t->lock);
3421-
trace_android_vh_binder_transaction_init(t);
34223407

34233408
tcomplete = kzalloc(sizeof(*tcomplete), GFP_KERNEL);
34243409
if (tcomplete == NULL) {
@@ -3849,7 +3834,6 @@ static void binder_transaction(struct binder_proc *proc,
38493834
target_proc->outstanding_txns++;
38503835
binder_inner_proc_unlock(target_proc);
38513836
wake_up_interruptible_sync(&target_thread->wait);
3852-
trace_android_vh_binder_restore_priority(in_reply_to, current);
38533837
binder_restore_priority(thread, &in_reply_to->saved_priority);
38543838
binder_free_transaction(in_reply_to);
38553839
} else if (!(t->flags & TF_ONE_WAY)) {
@@ -3963,7 +3947,6 @@ static void binder_transaction(struct binder_proc *proc,
39633947

39643948
BUG_ON(thread->return_error.cmd != BR_OK);
39653949
if (in_reply_to) {
3966-
trace_android_vh_binder_restore_priority(in_reply_to, current);
39673950
binder_restore_priority(thread, &in_reply_to->saved_priority);
39683951
thread->return_error.cmd = BR_TRANSACTION_COMPLETE;
39693952
binder_enqueue_thread_work(thread, &thread->return_error.work);
@@ -4545,7 +4528,6 @@ static int binder_wait_for_work(struct binder_thread *thread,
45454528
if (do_proc_work)
45464529
list_add(&thread->waiting_thread_node,
45474530
&proc->waiting_threads);
4548-
trace_android_vh_binder_wait_for_work(do_proc_work, thread, proc);
45494531
binder_inner_proc_unlock(proc);
45504532
schedule();
45514533
binder_inner_proc_lock(proc);
@@ -4598,7 +4580,6 @@ static int binder_thread_read(struct binder_proc *proc,
45984580
wait_event_interruptible(binder_user_error_wait,
45994581
binder_stop_on_user_error < 2);
46004582
}
4601-
trace_android_vh_binder_restore_priority(NULL, current);
46024583
binder_restore_priority(thread, &proc->default_priority);
46034584
}
46044585

@@ -4846,7 +4827,6 @@ static int binder_thread_read(struct binder_proc *proc,
48464827
trd->sender_pid =
48474828
task_tgid_nr_ns(sender,
48484829
task_active_pid_ns(current));
4849-
trace_android_vh_sync_txn_recvd(thread->task, t_from->task);
48504830
} else {
48514831
trd->sender_pid = 0;
48524832
}
@@ -5171,7 +5151,7 @@ static int binder_thread_release(struct binder_proc *proc,
51715151
return active_transactions;
51725152
}
51735153

5174-
static __poll_t binder_poll(struct file *filp,
5154+
static unsigned int binder_poll(struct file *filp,
51755155
struct poll_table_struct *wait)
51765156
{
51775157
struct binder_proc *proc = filp->private_data;
@@ -5713,7 +5693,7 @@ static void binder_vma_close(struct vm_area_struct *vma)
57135693
binder_defer_work(proc, BINDER_DEFERRED_PUT_FILES);
57145694
}
57155695

5716-
static vm_fault_t binder_vm_fault(struct vm_fault *vmf)
5696+
static int binder_vm_fault(struct vm_fault *vmf)
57175697
{
57185698
return VM_FAULT_SIGBUS;
57195699
}
@@ -5822,7 +5802,7 @@ static int binder_open(struct inode *nodp, struct file *filp)
58225802
mutex_lock(&binder_procs_lock);
58235803
hlist_add_head(&proc->proc_node, &binder_procs);
58245804
mutex_unlock(&binder_procs_lock);
5825-
trace_android_vh_binder_preset(&binder_procs, &binder_procs_lock);
5805+
58265806
if (binder_debugfs_dir_entry_proc && !existing_pid) {
58275807
char strbuf[11];
58285808

@@ -6137,7 +6117,6 @@ static void print_binder_transaction_ilocked(struct seq_file *m,
61376117
struct binder_buffer *buffer = t->buffer;
61386118

61396119
spin_lock(&t->lock);
6140-
trace_android_vh_binder_print_transaction_info(m, proc, prefix, t);
61416120
to_proc = t->to_proc;
61426121
seq_printf(m,
61436122
"%s %d: %pK from %d:%d to %d:%d code %x flags %x pri %d:%d r%d",

drivers/android/binder_alloc.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <linux/sizes.h>
3535
#include "binder_internal.h"
3636
#include "binder_trace.h"
37-
#include <trace/hooks/binder.h>
3837

3938
struct list_lru binder_freelist;
4039

@@ -241,7 +240,7 @@ static int binder_install_single_page(struct binder_alloc *alloc,
241240
* Protected with mmap_sem in write mode as multiple tasks
242241
* might race to install the same page.
243242
*/
244-
mmap_write_lock(alloc->vma_vm_mm);
243+
down_read(&alloc->vma_vm_mm->mmap_sem);
245244
if (binder_get_installed_page(lru_page))
246245
goto out;
247246

@@ -271,7 +270,7 @@ static int binder_install_single_page(struct binder_alloc *alloc,
271270
/* Mark page installation complete and safe to use */
272271
binder_set_installed_page(lru_page, page);
273272
out:
274-
mmap_write_unlock(alloc->vma_vm_mm);
273+
up_read(&alloc->vma_vm_mm->mmap_sem);
275274
mmput_async(alloc->vma_vm_mm);
276275
return ret;
277276
}
@@ -471,8 +470,6 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
471470
unsigned long curr_last_page;
472471
size_t buffer_size;
473472

474-
trace_android_vh_binder_alloc_new_buf_locked(size, alloc, is_async);
475-
476473
if (is_async && alloc->free_async_space < size) {
477474
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
478475
"%d: binder_alloc_buf size %zd failed, no async space left\n",
@@ -1094,8 +1091,8 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
10941091

10951092
if (!mmget_not_zero(mm))
10961093
goto err_mmget;
1097-
if (!mmap_read_trylock(mm))
1098-
goto err_mmap_read_lock_failed;
1094+
if (!down_read_trylock(&mm->mmap_sem))
1095+
goto err_down_read_mmap_sem_failed;
10991096
if (!binder_alloc_trylock(alloc))
11001097
goto err_get_alloc_lock_failed;
11011098
if (!page->page_ptr)
@@ -1127,7 +1124,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
11271124
trace_binder_unmap_user_end(alloc, index);
11281125
}
11291126

1130-
mmap_read_unlock(mm);
1127+
up_read(&mm->mmap_sem);
11311128
mmput_async(mm);
11321129
__free_page(page_to_free);
11331130

@@ -1138,8 +1135,8 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
11381135
err_page_already_freed:
11391136
binder_alloc_unlock(alloc);
11401137
err_get_alloc_lock_failed:
1141-
mmap_read_unlock(mm);
1142-
err_mmap_read_lock_failed:
1138+
up_read(&mm->mmap_sem);
1139+
err_down_read_mmap_sem_failed:
11431140
mmput_async(mm);
11441141
err_mmget:
11451142
return LRU_SKIP;

drivers/android/binder_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,6 @@ struct binder_transaction {
629629
* during thread teardown
630630
*/
631631
spinlock_t lock;
632-
ANDROID_VENDOR_DATA(1);
633-
ANDROID_OEM_DATA_ARRAY(1, 2);
634632
};
635633

636634
/**

0 commit comments

Comments
 (0)