[PATCH v3] drm: rcar-du: track dma-buf fences

2018-04-30 Thread Emre Ucan
We have to check dma-buf reservation objects of our framebuffers before
we use them. Otherwise, another driver might be writing on the same
buffer which we are using. This would cause visible tearing effects
on display.

We can use existing atomic helper functions to solve this problem.

v2 changes:
- Remove drm_atomic_helper_wait_for_fences() call in rcar_du_kms.c.
  The commit_tail() function in drm_atomic_helper.c, which calls our
  atomic_commit_tail() implementation, already calls it.
- Remove proposed rcar_du_vsp_set_fence_for_plane() function.
  Call drm_gem_fb_prepare_fb(), which calls
  drm_atomic_set_fence_for_plane().

v3 changes:
- Sort the added header file alphabetically.
- Check return value of drm_gem_fb_prepare_fb() and clean up in the case
  of error.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 2c260c3..73c7948 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -237,6 +238,10 @@ static int rcar_du_vsp_plane_prepare_fb(struct drm_plane 
*plane,
}
}
 
+   ret = drm_gem_fb_prepare_fb(plane, state);
+   if (ret)
+   goto fail;
+
return 0;
 
 fail:
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm: rcar-du: track dma-buf fences

2018-04-05 Thread Emre Ucan
We have to check dma-buf reservation objects
of our framebuffers before we use them.
Otherwise, another driver might be writing
on the same buffer which we are using.
This would cause visible tearing effects
on display.

We can use existing atomic helper functions
to solve this problem.

v2 changes:
- Remove drm_atomic_helper_wait_for_fences()
  call in rcar_du_kms.c. The commit_tail()
  function in drm_atomic_helper.c, which calls
  our atomic_commit_tail() implementation,
  already calls it.
- Remove proposed rcar_du_vsp_set_fence_for_plane()
  function. Call drm_gem_fb_prepare_fb(), which
  calls drm_atomic_set_fence_for_plane().

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 2c260c3..fbad616 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -237,7 +238,7 @@ static int rcar_du_vsp_plane_prepare_fb(struct drm_plane 
*plane,
}
}
 
-   return 0;
+   return drm_gem_fb_prepare_fb(plane, state);
 
 fail:
while (i--) {
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm: rcar-du: track dma-buf fences

2018-04-03 Thread Emre Ucan
We have to check dma-buf reservation objects
of our framebuffers before we use them.
Otherwise, another driver might be writing
on the same buffer which we are using.
This would cause visible tearing effects
on display.

We can use existing atomic helper functions
to solve this problem.

Signed-off-by: Emre Ucan <eu...@de.adit-jv.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c |  2 ++
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 20 
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 0329b35..f3da3d1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -255,6 +255,8 @@ static void rcar_du_atomic_commit_tail(struct 
drm_atomic_state *old_state)
 {
struct drm_device *dev = old_state->dev;
 
+   drm_atomic_helper_wait_for_fences(dev, old_state, false);
+
/* Apply the atomic update. */
drm_atomic_helper_commit_modeset_disables(dev, old_state);
drm_atomic_helper_commit_planes(dev, old_state,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 2c260c3..482e23c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -18,12 +18,16 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -203,6 +207,20 @@ static void rcar_du_vsp_plane_setup(struct 
rcar_du_vsp_plane *plane)
  plane->index, );
 }
 
+static void rcar_du_vsp_set_fence_for_plane(struct drm_plane_state *state)
+{
+   struct drm_gem_cma_object *gem;
+   struct dma_buf *dma_buf;
+   struct dma_fence *fence;
+
+   gem = drm_fb_cma_get_gem_obj(state->fb, 0);
+   dma_buf = gem->base.dma_buf;
+   if (dma_buf) {
+   fence = reservation_object_get_excl_rcu(dma_buf->resv);
+   drm_atomic_set_fence_for_plane(state, fence);
+   }
+}
+
 static int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *state)
 {
@@ -237,6 +255,8 @@ static int rcar_du_vsp_plane_prepare_fb(struct drm_plane 
*plane,
}
}
 
+   rcar_du_vsp_set_fence_for_plane(state);
+
return 0;
 
 fail:
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel