drm: rcar-du: track dma-buf fences
Subsystems (3)
PATCH 1/1 drm: rcar-du: track dma-buf fences
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.
--- 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(+)
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2 -0
@@ -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,
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +20 -0
@@ -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:
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hello Emre,
Thank you for the patch.
Quoted 21 lines · On Tuesday, 3 April 2018 12:14:33 EEST Emre Ucan wrote:
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 <[email protected]>--- 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(+)(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_kms.cindex 0329b35..f3da3d1 100644
drivers/gpu/drm/rcar-du/rcar_du_kms.c static void rcar_du_atomic_commit_tail(struct · line 259
Quoted 5 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2
-0@@ -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); +
The commit_tail() function in drm_atomic_helper.c, which calls our atomic_commit_tail() implementation, already calls drm_atomic_helper_wait_for_fences(). Why is there a need to duplicate the call here ?
Quoted 29 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0/* Apply the atomic update. */ drm_atomic_helper_commit_modeset_disables (dev, old_state); drm_atomic_helper_commit_planes(dev, old_state,(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.cindex 2c260c3..482e23c 100644drivers/gpu/drm/rcar-du/rcar_du_vsp.c +5
-0@@ -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)
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct · line 220
Quoted 10 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +10
-0+{ +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);
Unless I'm mistaken this is used for implicit fencing only. What is your use case, wouldn't it be better for userspace to use explicit fencing as that is the fence model that has been selected for display ?
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 222
Quoted 2 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0+ } +}
This looks very similar to drm_gem_fb_prepare_fb(), couldn't you use that function instead ?
Quoted 12 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0static 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:
Signature · 10 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 65 lines · Laurent Pinchart
Hello Emre,
Thank you for the patch.
Quoted 21 lines · On Tuesday, 3 April 2018 12:14:33 EEST Emre Ucan wrote:
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 <[email protected]>--- 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(+)(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_kms.cindex 0329b35..f3da3d1 100644drivers/gpu/drm/rcar-du/rcar_du_kms.c static void rcar_du_atomic_commit_tail(struct · line 259
Quoted 5 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2
-0@@ -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); +The
commit_tail()function indrm_atomic_helper.c, which calls ouratomic_commit_tail()implementation, already callsdrm_atomic_helper_wait_for_fences(). Why is there a need to duplicate the call here ?Quoted 28 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0/* Apply the atomic update. */ drm_atomic_helper_commit_modeset_disables (dev, old_state); drm_atomic_helper_commit_planes(dev, old_state,(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.cindex 2c260c3..482e23c 100644drivers/gpu/drm/rcar-du/rcar_du_vsp.c +4
-0@@ -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); }
Quoted 15 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 220
Quoted 11 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +11
-0+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);Unless I'm mistaken this is used for implicit fencing only. What is your use case, wouldn't it be better for userspace to use explicit fencing as that is the fence model that has been selected for display ?
Implicit fencing is very much still a thing on most X and wayland setups. There's a push to eventually make everything explicit, but it'll take a while I think.
-Daniel
Quoted 31 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 222
Quoted 3 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0+ } +}This looks very similar to
drm_gem_fb_prepare_fb(), couldn't you use that function instead ?drivers/gpu/drm/rcar-du/rcar_du_vsp.c static int rcar_du_vsp_plane_prepare_fb(struct drm_plane · line 262
Quoted 12 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0static 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:--
Regards,Laurent Pinchart
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hello Laurent
Thank you for your review.
Quoted 36 lines
-----Original Message-----
From: Laurent Pinchart [mailto:[email protected]]
Sent: Dienstag, 3. April 2018 20:53
To: Ucan, Emre (ADITG/ESB)
Cc: [email protected]
Subject: Re: [PATCH] drm: rcar-du: track dma-buf fencesHello Emre,
Thank you for the patch.
Quoted 24 lines · On Tuesday, 3 April 2018 12:14:33 EEST Emre Ucan wrote:
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 <[email protected]>--- 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(+)(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_kms.cindex 0329b35..f3da3d1 100644drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0@@ -255,6 +255,8 @@ static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) {struct drm_device *dev = old_state->dev;
Quoted 8 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) · line 259
Quoted 2 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2
-0+drm_atomic_helper_wait_for_fences (dev, old_state, false); +The
commit_tail()function indrm_atomic_helper.c, which calls ouratomic_commit_tail()implementation, already callsdrm_atomic_helper_wait_for_fences(). Why is there a need to duplicate the call
here ?
You are right. I will remove it in second version.
Quoted 31 lines
Quoted 26 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0/* Apply the atomic update. */ drm_atomic_helper_commit_modeset_disables (dev, old_state); drm_atomic_helper_commit_planes(dev, old_state,(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.cindex 2c260c3..482e23c 100644drivers/gpu/drm/rcar-du/rcar_du_vsp.c +4
-0@@ -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> drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct · line 210
Quoted 4 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +1
-0@@ -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)
Quoted 14 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 220
Quoted 10 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +10
-0+{ +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);Unless I'm mistaken this is used for implicit fencing only. What is your use case, wouldn't it be better for userspace to use explicit fencing as that is the fence model that has been selected for display ?
We are using Weston on Renesas R-Car H3 SoC. I am using GPU rendered client buffers directly as scanout buffer for the display. Weston is not using explicit fencing.
Quoted 6 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 222
Quoted 3 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0+ } +}This looks very similar to
drm_gem_fb_prepare_fb(), couldn't you use that function instead ?
Description of drm_gem_fb_prepare_fb() function states that it can be used as the &drm_plane_helper_funcs.prepare_fb hook. But we have our own hook function which is called rcar_du_vsp_plane_prepare_fb(). Therefore, I was not sure if it is correct to use drm_gem_fb_prepare_fb() inside our hook function.
I will use it in the second version nevertheless.
Quoted 13 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static int rcar_du_vsp_plane_prepare_fb(struct
Quoted 5 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0
-0static 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_planeQuoted 7 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0*plane, } } +rcar_du_vsp_set_fence_for_plane (state); +return 0 ;
Quoted 8 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static int rcar_du_vsp_plane_prepare_fb(struct · line 262
Quoted 1 line
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0
-0fail:--
Regards,Laurent Pinchart
Best Regards,
Emre Ucan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 49 lines · Emre (ADITG/ESB)
Hello Laurent
Thank you for your review.
Quoted 36 lines
-----Original Message-----
From: Laurent Pinchart [mailto:[email protected]]
Sent: Dienstag, 3. April 2018 20:53
To: Ucan, Emre (ADITG/ESB)
Cc: [email protected]
Subject: Re: [PATCH] drm: rcar-du: track dma-buf fencesHello Emre,
Thank you for the patch.
Quoted 24 lines · On Tuesday, 3 April 2018 12:14:33 EEST Emre Ucan wrote:
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 <[email protected]>--- 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(+)(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_kms.cindex 0329b35..f3da3d1 100644drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0@@ -255,6 +255,8 @@ static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) {struct drm_device *dev = old_state->dev;Quoted 8 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) · line 259
Quoted 2 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2
-0+drm_atomic_helper_wait_for_fences (dev, old_state, false); +The
commit_tail()function indrm_atomic_helper.c, which calls ouratomic_commit_tail()implementation, already callsdrm_atomic_helper_wait_for_fences(). Why is there a need to duplicate the call
here ?
Quoted 1 line
You are right. I will remove it in second version.
You can use it in your own hook. Patch to update the kerneldoc to clarify that would be great.
-Daniel
Quoted 95 lines
Quoted 32 lines
Quoted 27 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0/* Apply the atomic update. */ drm_atomic_helper_commit_modeset_disables (dev, old_state); drm_atomic_helper_commit_planes(dev, old_state,(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.cindex 2c260c3..482e23c 100644drivers/gpu/drm/rcar-du/rcar_du_vsp.c +4
-0@@ -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> drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct · line 210
Quoted 4 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +1
-0@@ -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)
Quoted 14 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 220
Quoted 10 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +10
-0+{ +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);Unless I'm mistaken this is used for implicit fencing only. What is your use case, wouldn't it be better for userspace to use explicit fencing as that is the fence model that has been selected for display ?
We are using Weston on Renesas R-Car H3 SoC. I am using GPU rendered client buffers directly as scanout buffer for the display. Weston is not using explicit fencing.
Quoted 6 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 222
Quoted 3 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0+ } +}This looks very similar to
drm_gem_fb_prepare_fb(), couldn't you use that function instead ?Description of
drm_gem_fb_prepare_fb()function states that it can be used as the &drm_plane_helper_funcs.prepare_fb hook. But we have our own hook function which is calledrcar_du_vsp_plane_prepare_fb(). Therefore, I was not sure if it is correct to usedrm_gem_fb_prepare_fb()inside our hook function.I will use it in the second version nevertheless.
Quoted 13 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static int rcar_du_vsp_plane_prepare_fb(struct
Quoted 5 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0
-0static 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_planeQuoted 7 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0*plane, } } +rcar_du_vsp_set_fence_for_plane (state); +return 0 ;Quoted 8 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static int rcar_du_vsp_plane_prepare_fb(struct · line 262
Quoted 1 line
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0
-0fail:--
Regards,Laurent Pinchart
Best Regards,
Emre Ucan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hello Laurent,
Thank you for your review.
Actually I sent this email yesterday. But I don't see it in mailing list archives because of some reason.
Quoted 36 lines
-----Original Message-----
From: Laurent Pinchart [mailto:[email protected]]
Sent: Dienstag, 3. April 2018 20:53
To: Ucan, Emre (ADITG/ESB)
Cc: [email protected]
Subject: Re: [PATCH] drm: rcar-du: track dma-buf fencesHello Emre,
Thank you for the patch.
Quoted 24 lines · On Tuesday, 3 April 2018 12:14:33 EEST Emre Ucan wrote:
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 <[email protected]>--- 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(+)(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_kms.cindex 0329b35..f3da3d1 100644drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0@@ -255,6 +255,8 @@ static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) {struct drm_device *dev = old_state->dev;
Quoted 8 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state) · line 259
Quoted 2 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +2
-0+drm_atomic_helper_wait_for_fences (dev, old_state, false); +The
commit_tail()function indrm_atomic_helper.c, which calls ouratomic_commit_tail()implementation, already callsdrm_atomic_helper_wait_for_fences(). Why is there a need to duplicate the call
here ?
You are right. I will remove it in second version.
Quoted 31 lines
Quoted 26 lines
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0
-0/* Apply the atomic update. */ drm_atomic_helper_commit_modeset_disables (dev, old_state); drm_atomic_helper_commit_planes(dev, old_state,(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.cindex 2c260c3..482e23c 100644drivers/gpu/drm/rcar-du/rcar_du_vsp.c +4
-0@@ -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> drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct · line 210
Quoted 4 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +1
-0@@ -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)
Quoted 14 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 220
Quoted 10 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +10
-0+{ +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);Unless I'm mistaken this is used for implicit fencing only. What is your use case, wouldn't it be better for userspace to use explicit fencing as that is the fence model that has been selected for display ?
We are using Weston on Renesas R-Car H3 SoC. I am using GPU rendered client buffers directly as scanout buffer for the display. Weston is not using explicit fencing.
Quoted 6 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 222
Quoted 3 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0+ } +}This looks very similar to
drm_gem_fb_prepare_fb(), couldn't you use that function instead ?
Description of drm_gem_fb_prepare_fb() function states that it can be used as the &drm_plane_helper_funcs.prepare_fb hook. But we have our own hook function which is called rcar_du_vsp_plane_prepare_fb(). Therefore, I was not sure if it is correct to use drm_gem_fb_prepare_fb() inside our hook function.
I will use it in the second version nevertheless.
Quoted 13 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static int rcar_du_vsp_plane_prepare_fb(struct
Quoted 5 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0
-0static 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_planeQuoted 7 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +2
-0*plane, } } +rcar_du_vsp_set_fence_for_plane (state); +return 0 ;
Quoted 8 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c static int rcar_du_vsp_plane_prepare_fb(struct · line 262
Quoted 1 line
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0
-0fail:--
Regards,Laurent Pinchart
Best Regards,
Emre Ucan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel