diff mbox

[DPU,04/11] drm/msm: Move implicit sync fence handling to prepare_fb

Message ID 20180228191906.185417-5-seanpaul@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Paul Feb. 28, 2018, 7:18 p.m. UTC
This is another piece that can be moved out of atomic to facilitate using
the atomic helpers.

Change-Id: I6dc3c4e5df508942bbc378c73a44e46e511b8469
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c |  8 ++++++++
 drivers/gpu/drm/msm/msm_atomic.c          | 13 -------------
 2 files changed, 8 insertions(+), 13 deletions(-)

Comments

Jeykumar Sankaran March 3, 2018, 12:20 a.m. UTC | #1
On 2018-02-28 11:18, Sean Paul wrote:
> This is another piece that can be moved out of atomic to facilitate 
> using
> the atomic helpers.
> 
> Change-Id: I6dc3c4e5df508942bbc378c73a44e46e511b8469
> Signed-off-by: Sean Paul <seanpaul@chromium.org>

Reviewed-by: Jeykumar Sankaran <jsanka@codeaurora.org>

> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c |  8 ++++++++
>  drivers/gpu/drm/msm/msm_atomic.c          | 13 -------------
>  2 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> index 834dcc0bfefd..29e72b39fd72 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> @@ -2720,6 +2720,8 @@ static int dpu_plane_prepare_fb(struct drm_plane
> *plane,
>  	struct dpu_plane_rot_state *new_rstate;
>  	struct dpu_hw_fmt_layout layout;
>  	struct msm_gem_address_space *aspace;
> +	struct msm_gem_object *msm_obj;
> +	struct dma_fence *fence;
>  	int ret;
> 
>  	if (!new_state->fb)
> @@ -2761,6 +2763,12 @@ static int dpu_plane_prepare_fb(struct drm_plane
> *plane,
>  		return ret;
>  	}
> 
> +	/* To support implicit sync, set a fence on the plane if
> appropriate */
> +	msm_obj = to_msm_bo(msm_framebuffer_bo(fb, 0));
> +	fence = reservation_object_get_excl_rcu(msm_obj->resv);
> +	if (fence)
> +		drm_atomic_set_fence_for_plane(new_state, fence);
> +
>  	return 0;
>  }
> 
> diff --git a/drivers/gpu/drm/msm/msm_atomic.c
> b/drivers/gpu/drm/msm/msm_atomic.c
> index eb2ccda5da0f..3a18bd3dc215 100644
> --- a/drivers/gpu/drm/msm/msm_atomic.c
> +++ b/drivers/gpu/drm/msm/msm_atomic.c
> @@ -282,19 +282,6 @@ int msm_atomic_commit(struct drm_device *dev,
>  	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
>  		c->crtc_mask |= drm_crtc_mask(crtc);
> 
> -	/*
> -	 * Figure out what fence to wait for:
> -	 */
> -	for_each_oldnew_plane_in_state(state, plane, old_plane_state,
> new_plane_state, i) {
> -		if ((new_plane_state->fb != old_plane_state->fb) &&
> new_plane_state->fb) {
> -			struct drm_gem_object *obj =
> msm_framebuffer_bo(new_plane_state->fb, 0);
> -			struct msm_gem_object *msm_obj = to_msm_bo(obj);
> -			struct dma_fence *fence =
> reservation_object_get_excl_rcu(msm_obj->resv);
> -
> -			drm_atomic_set_fence_for_plane(new_plane_state,
> fence);
> -		}
> -	}
> -
>  	/*
>  	 * Wait for pending updates on any of the same crtc's and then
>  	 * mark our set of crtc's as busy:
diff mbox

Patch

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index 834dcc0bfefd..29e72b39fd72 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -2720,6 +2720,8 @@  static int dpu_plane_prepare_fb(struct drm_plane *plane,
 	struct dpu_plane_rot_state *new_rstate;
 	struct dpu_hw_fmt_layout layout;
 	struct msm_gem_address_space *aspace;
+	struct msm_gem_object *msm_obj;
+	struct dma_fence *fence;
 	int ret;
 
 	if (!new_state->fb)
@@ -2761,6 +2763,12 @@  static int dpu_plane_prepare_fb(struct drm_plane *plane,
 		return ret;
 	}
 
+	/* To support implicit sync, set a fence on the plane if appropriate */
+	msm_obj = to_msm_bo(msm_framebuffer_bo(fb, 0));
+	fence = reservation_object_get_excl_rcu(msm_obj->resv);
+	if (fence)
+		drm_atomic_set_fence_for_plane(new_state, fence);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index eb2ccda5da0f..3a18bd3dc215 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -282,19 +282,6 @@  int msm_atomic_commit(struct drm_device *dev,
 	for_each_new_crtc_in_state(state, crtc, crtc_state, i)
 		c->crtc_mask |= drm_crtc_mask(crtc);
 
-	/*
-	 * Figure out what fence to wait for:
-	 */
-	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
-		if ((new_plane_state->fb != old_plane_state->fb) && new_plane_state->fb) {
-			struct drm_gem_object *obj = msm_framebuffer_bo(new_plane_state->fb, 0);
-			struct msm_gem_object *msm_obj = to_msm_bo(obj);
-			struct dma_fence *fence = reservation_object_get_excl_rcu(msm_obj->resv);
-
-			drm_atomic_set_fence_for_plane(new_plane_state, fence);
-		}
-	}
-
 	/*
 	 * Wait for pending updates on any of the same crtc's and then
 	 * mark our set of crtc's as busy: