mediatek: add v4.19 support
[openwrt/staging/wigyori.git] / target / linux / brcm2708 / patches-4.19 / 950-0569-drm-v3d-Clean-up-the-reservation-object-setup.patch
1 From cdc1e8a4116661a965c1021cd153a8a4fa8eee82 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Thu, 8 Nov 2018 08:16:53 -0800
4 Subject: [PATCH 569/703] drm/v3d: Clean up the reservation object setup.
5
6 The extra to_v3d_bo() calls came from copying this from the vc4
7 driver, which stored the cma gem object in the structs.
8
9 v2: Fix an unused var warning
10
11 Signed-off-by: Eric Anholt <eric@anholt.net>
12 Link: https://patchwork.freedesktop.org/patch/msgid/20181108161654.19888-4-eric@anholt.net
13 Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> (v1)
14 (cherry picked from commit 8f1cd826641d677d0f7494253ecfc3335f0bcd4e)
15 ---
16 drivers/gpu/drm/v3d/v3d_gem.c | 33 +++++++++++----------------------
17 1 file changed, 11 insertions(+), 22 deletions(-)
18
19 --- a/drivers/gpu/drm/v3d/v3d_gem.c
20 +++ b/drivers/gpu/drm/v3d/v3d_gem.c
21 @@ -210,14 +210,11 @@ static void
22 v3d_attach_object_fences(struct v3d_exec_info *exec)
23 {
24 struct dma_fence *out_fence = exec->render_done_fence;
25 - struct v3d_bo *bo;
26 int i;
27
28 for (i = 0; i < exec->bo_count; i++) {
29 - bo = to_v3d_bo(&exec->bo[i]->base);
30 -
31 /* XXX: Use shared fences for read-only objects. */
32 - reservation_object_add_excl_fence(bo->resv, out_fence);
33 + reservation_object_add_excl_fence(exec->bo[i]->resv, out_fence);
34 }
35 }
36
37 @@ -228,11 +225,8 @@ v3d_unlock_bo_reservations(struct drm_de
38 {
39 int i;
40
41 - for (i = 0; i < exec->bo_count; i++) {
42 - struct v3d_bo *bo = to_v3d_bo(&exec->bo[i]->base);
43 -
44 - ww_mutex_unlock(&bo->resv->lock);
45 - }
46 + for (i = 0; i < exec->bo_count; i++)
47 + ww_mutex_unlock(&exec->bo[i]->resv->lock);
48
49 ww_acquire_fini(acquire_ctx);
50 }
51 @@ -251,13 +245,13 @@ v3d_lock_bo_reservations(struct drm_devi
52 {
53 int contended_lock = -1;
54 int i, ret;
55 - struct v3d_bo *bo;
56
57 ww_acquire_init(acquire_ctx, &reservation_ww_class);
58
59 retry:
60 if (contended_lock != -1) {
61 - bo = to_v3d_bo(&exec->bo[contended_lock]->base);
62 + struct v3d_bo *bo = exec->bo[contended_lock];
63 +
64 ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
65 acquire_ctx);
66 if (ret) {
67 @@ -270,19 +264,16 @@ retry:
68 if (i == contended_lock)
69 continue;
70
71 - bo = to_v3d_bo(&exec->bo[i]->base);
72 -
73 - ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx);
74 + ret = ww_mutex_lock_interruptible(&exec->bo[i]->resv->lock,
75 + acquire_ctx);
76 if (ret) {
77 int j;
78
79 - for (j = 0; j < i; j++) {
80 - bo = to_v3d_bo(&exec->bo[j]->base);
81 - ww_mutex_unlock(&bo->resv->lock);
82 - }
83 + for (j = 0; j < i; j++)
84 + ww_mutex_unlock(&exec->bo[j]->resv->lock);
85
86 if (contended_lock != -1 && contended_lock >= i) {
87 - bo = to_v3d_bo(&exec->bo[contended_lock]->base);
88 + struct v3d_bo *bo = exec->bo[contended_lock];
89
90 ww_mutex_unlock(&bo->resv->lock);
91 }
92 @@ -303,9 +294,7 @@ retry:
93 * before we commit the CL to the hardware.
94 */
95 for (i = 0; i < exec->bo_count; i++) {
96 - bo = to_v3d_bo(&exec->bo[i]->base);
97 -
98 - ret = reservation_object_reserve_shared(bo->resv);
99 + ret = reservation_object_reserve_shared(exec->bo[i]->resv);
100 if (ret) {
101 v3d_unlock_bo_reservations(dev, exec, acquire_ctx);
102 return ret;