brcm2708: update linux 4.4 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0094-drm-vc4-Use-job_lock-to-protect-seqno_cb_list.patch
1 From cfa018eec8227589076e45fd65f654e525349ff5 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Mon, 19 Oct 2015 08:32:24 -0700
4 Subject: [PATCH] drm/vc4: Use job_lock to protect seqno_cb_list.
5
6 We're (mostly) not supposed to be using struct_mutex in drivers these
7 days.
8
9 Signed-off-by: Eric Anholt <eric@anholt.net>
10 ---
11 drivers/gpu/drm/vc4/vc4_gem.c | 8 +++++---
12 1 file changed, 5 insertions(+), 3 deletions(-)
13
14 --- a/drivers/gpu/drm/vc4/vc4_gem.c
15 +++ b/drivers/gpu/drm/vc4/vc4_gem.c
16 @@ -474,7 +474,6 @@ vc4_job_handle_completed(struct vc4_dev
17 vc4_complete_exec(exec);
18 spin_lock_irqsave(&vc4->job_lock, irqflags);
19 }
20 - spin_unlock_irqrestore(&vc4->job_lock, irqflags);
21
22 list_for_each_entry_safe(cb, cb_temp, &vc4->seqno_cb_list, work.entry) {
23 if (cb->seqno <= vc4->finished_seqno) {
24 @@ -482,6 +481,8 @@ vc4_job_handle_completed(struct vc4_dev
25 schedule_work(&cb->work);
26 }
27 }
28 +
29 + spin_unlock_irqrestore(&vc4->job_lock, irqflags);
30 }
31
32 static void vc4_seqno_cb_work(struct work_struct *work)
33 @@ -496,18 +497,19 @@ int vc4_queue_seqno_cb(struct drm_device
34 {
35 struct vc4_dev *vc4 = to_vc4_dev(dev);
36 int ret = 0;
37 + unsigned long irqflags;
38
39 cb->func = func;
40 INIT_WORK(&cb->work, vc4_seqno_cb_work);
41
42 - mutex_lock(&dev->struct_mutex);
43 + spin_lock_irqsave(&vc4->job_lock, irqflags);
44 if (seqno > vc4->finished_seqno) {
45 cb->seqno = seqno;
46 list_add_tail(&cb->work.entry, &vc4->seqno_cb_list);
47 } else {
48 schedule_work(&cb->work);
49 }
50 - mutex_unlock(&dev->struct_mutex);
51 + spin_unlock_irqrestore(&vc4->job_lock, irqflags);
52
53 return ret;
54 }