brcm2708: update to latest patches from RPi Foundation
[openwrt/staging/dedeckeh.git] / target / linux / brcm2708 / patches-4.19 / 950-0491-drm-v3d-Clean-up-the-reservation-object-setup.patch
diff --git a/target/linux/brcm2708/patches-4.19/950-0491-drm-v3d-Clean-up-the-reservation-object-setup.patch b/target/linux/brcm2708/patches-4.19/950-0491-drm-v3d-Clean-up-the-reservation-object-setup.patch
new file mode 100644 (file)
index 0000000..94156e7
--- /dev/null
@@ -0,0 +1,102 @@
+From 5ca5bd799b4f4a065b969461fa7852415bfb8c6f Mon Sep 17 00:00:00 2001
+From: Eric Anholt <eric@anholt.net>
+Date: Thu, 8 Nov 2018 08:16:53 -0800
+Subject: [PATCH] drm/v3d: Clean up the reservation object setup.
+
+The extra to_v3d_bo() calls came from copying this from the vc4
+driver, which stored the cma gem object in the structs.
+
+v2: Fix an unused var warning
+
+Signed-off-by: Eric Anholt <eric@anholt.net>
+Link: https://patchwork.freedesktop.org/patch/msgid/20181108161654.19888-4-eric@anholt.net
+Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> (v1)
+(cherry picked from commit 8f1cd826641d677d0f7494253ecfc3335f0bcd4e)
+---
+ drivers/gpu/drm/v3d/v3d_gem.c | 33 +++++++++++----------------------
+ 1 file changed, 11 insertions(+), 22 deletions(-)
+
+--- a/drivers/gpu/drm/v3d/v3d_gem.c
++++ b/drivers/gpu/drm/v3d/v3d_gem.c
+@@ -210,14 +210,11 @@ static void
+ v3d_attach_object_fences(struct v3d_exec_info *exec)
+ {
+       struct dma_fence *out_fence = exec->render_done_fence;
+-      struct v3d_bo *bo;
+       int i;
+       for (i = 0; i < exec->bo_count; i++) {
+-              bo = to_v3d_bo(&exec->bo[i]->base);
+-
+               /* XXX: Use shared fences for read-only objects. */
+-              reservation_object_add_excl_fence(bo->resv, out_fence);
++              reservation_object_add_excl_fence(exec->bo[i]->resv, out_fence);
+       }
+ }
+@@ -228,11 +225,8 @@ v3d_unlock_bo_reservations(struct drm_de
+ {
+       int i;
+-      for (i = 0; i < exec->bo_count; i++) {
+-              struct v3d_bo *bo = to_v3d_bo(&exec->bo[i]->base);
+-
+-              ww_mutex_unlock(&bo->resv->lock);
+-      }
++      for (i = 0; i < exec->bo_count; i++)
++              ww_mutex_unlock(&exec->bo[i]->resv->lock);
+       ww_acquire_fini(acquire_ctx);
+ }
+@@ -251,13 +245,13 @@ v3d_lock_bo_reservations(struct drm_devi
+ {
+       int contended_lock = -1;
+       int i, ret;
+-      struct v3d_bo *bo;
+       ww_acquire_init(acquire_ctx, &reservation_ww_class);
+ retry:
+       if (contended_lock != -1) {
+-              bo = to_v3d_bo(&exec->bo[contended_lock]->base);
++              struct v3d_bo *bo = exec->bo[contended_lock];
++
+               ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
+                                                      acquire_ctx);
+               if (ret) {
+@@ -270,19 +264,16 @@ retry:
+               if (i == contended_lock)
+                       continue;
+-              bo = to_v3d_bo(&exec->bo[i]->base);
+-
+-              ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx);
++              ret = ww_mutex_lock_interruptible(&exec->bo[i]->resv->lock,
++                                                acquire_ctx);
+               if (ret) {
+                       int j;
+-                      for (j = 0; j < i; j++) {
+-                              bo = to_v3d_bo(&exec->bo[j]->base);
+-                              ww_mutex_unlock(&bo->resv->lock);
+-                      }
++                      for (j = 0; j < i; j++)
++                              ww_mutex_unlock(&exec->bo[j]->resv->lock);
+                       if (contended_lock != -1 && contended_lock >= i) {
+-                              bo = to_v3d_bo(&exec->bo[contended_lock]->base);
++                              struct v3d_bo *bo = exec->bo[contended_lock];
+                               ww_mutex_unlock(&bo->resv->lock);
+                       }
+@@ -303,9 +294,7 @@ retry:
+        * before we commit the CL to the hardware.
+        */
+       for (i = 0; i < exec->bo_count; i++) {
+-              bo = to_v3d_bo(&exec->bo[i]->base);
+-
+-              ret = reservation_object_reserve_shared(bo->resv);
++              ret = reservation_object_reserve_shared(exec->bo[i]->resv);
+               if (ret) {
+                       v3d_unlock_bo_reservations(dev, exec, acquire_ctx);
+                       return ret;