All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: rcar-du: track dma-buf fences
@ 2018-04-03  9:14 Emre Ucan
  2018-04-03 18:53 ` Laurent Pinchart
  0 siblings, 1 reply; 6+ messages in thread
From: Emre Ucan @ 2018-04-03  9:14 UTC (permalink / raw)
  To: dri-devel; +Cc: laurent.pinchart

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 <eucan@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 <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_plane_helper.h>
+#include <drm/drm_atomic.h>
 
 #include <linux/bitops.h>
 #include <linux/dma-mapping.h>
+#include <linux/dma-fence.h>
+#include <linux/dma-buf.h>
 #include <linux/of_platform.h>
 #include <linux/scatterlist.h>
 #include <linux/videodev2.h>
+#include <linux/reservation.h>
 
 #include <media/vsp1.h>
 
@@ -203,6 +207,20 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 			      plane->index, &cfg);
 }
 
+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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-05 10:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-03  9:14 [PATCH] drm: rcar-du: track dma-buf fences Emre Ucan
2018-04-03 18:53 ` Laurent Pinchart
2018-04-03 20:25   ` Daniel Vetter
2018-04-04 10:59   ` Ucan, Emre (ADITG/ESB)
2018-04-05 10:41     ` Daniel Vetter
2018-04-05  6:39   ` Ucan, Emre (ADITG/ESB)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.