brcm2708: update linux 4.4 patches to latest version
[openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0097-drm-vc4-Drop-struct_mutex-around-CL-validation.patch
1 From f1924e632d16f98eee1fe1be636249b8cee4ee6e Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Mon, 19 Oct 2015 08:44:35 -0700
4 Subject: [PATCH 097/170] drm/vc4: Drop struct_mutex around CL validation.
5
6 We were using it so that we could make sure that shader validation
7 state didn't change while we were validating, but now shader
8 validation state is immutable.  The bcl/rcl generation doesn't do any
9 other BO dereferencing, and seems to have no other global state
10 dependency not covered by job_lock / bo_lock.  We only need to hold
11 struct_mutex for object unreferencing.
12
13 Fixes a lock order reversal between mmap_sem and struct_mutex.
14
15 Signed-off-by: Eric Anholt <eric@anholt.net>
16 ---
17  drivers/gpu/drm/vc4/vc4_gem.c | 13 ++++++-------
18  1 file changed, 6 insertions(+), 7 deletions(-)
19
20 --- a/drivers/gpu/drm/vc4/vc4_gem.c
21 +++ b/drivers/gpu/drm/vc4/vc4_gem.c
22 @@ -439,10 +439,12 @@ fail:
23  }
24  
25  static void
26 -vc4_complete_exec(struct vc4_exec_info *exec)
27 +vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
28  {
29         unsigned i;
30  
31 +       /* Need the struct lock for drm_gem_object_unreference(). */
32 +       mutex_lock(&dev->struct_mutex);
33         if (exec->bo) {
34                 for (i = 0; i < exec->bo_count; i++)
35                         drm_gem_object_unreference(&exec->bo[i].bo->base);
36 @@ -455,6 +457,7 @@ vc4_complete_exec(struct vc4_exec_info *
37                 list_del(&bo->unref_head);
38                 drm_gem_object_unreference(&bo->base.base);
39         }
40 +       mutex_unlock(&dev->struct_mutex);
41  
42         kfree(exec);
43  }
44 @@ -473,7 +476,7 @@ vc4_job_handle_completed(struct vc4_dev
45                 list_del(&exec->head);
46  
47                 spin_unlock_irqrestore(&vc4->job_lock, irqflags);
48 -               vc4_complete_exec(exec);
49 +               vc4_complete_exec(vc4->dev, exec);
50                 spin_lock_irqsave(&vc4->job_lock, irqflags);
51         }
52  
53 @@ -525,12 +528,8 @@ vc4_job_done_work(struct work_struct *wo
54  {
55         struct vc4_dev *vc4 =
56                 container_of(work, struct vc4_dev, job_done_work);
57 -       struct drm_device *dev = vc4->dev;
58  
59 -       /* Need the struct lock for drm_gem_object_unreference(). */
60 -       mutex_lock(&dev->struct_mutex);
61         vc4_job_handle_completed(vc4);
62 -       mutex_unlock(&dev->struct_mutex);
63  }
64  
65  static int
66 @@ -639,7 +638,7 @@ vc4_submit_cl_ioctl(struct drm_device *d
67         return 0;
68  
69  fail:
70 -       vc4_complete_exec(exec);
71 +       vc4_complete_exec(vc4->dev, exec);
72  
73         return ret;
74  }