[v3,14/24] drm/msm: dpu: Grab the modeset locks in frame_event

Submitted by Sean Paul on Nov. 30, 2018, 10 p.m.

Details

Message ID 20181130220011.39644-1-sean@poorly.run
State New
Headers show
Series "drm/msm: Various dpu locking and legacy cleanups" ( rev: 2 ) in DRI devel

Not browsing as part of any series.

Commit Message

Sean Paul Nov. 30, 2018, 10 p.m.
From: Sean Paul <seanpaul@chromium.org>

This patch wraps dpu_core_perf_crtc_release_bw() with modeset locks
since it digs into the state objects.

Changes in v2:
- None
Changes in v3:
- Use those nifty new DRM_MODESET_LOCK_ALL_* helpers (Daniel)

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 74ef384d9cd6a..03ddd281a354f 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -306,6 +306,19 @@  static void dpu_crtc_vblank_cb(void *data)
 	trace_dpu_crtc_vblank_cb(DRMID(crtc));
 }
 
+static void dpu_crtc_release_bw_unlocked(struct drm_crtc *crtc)
+{
+	int ret = 0;
+	struct drm_modeset_acquire_ctx ctx;
+
+	DRM_MODESET_LOCK_ALL_BEGIN(crtc->dev, ctx, 0, ret);
+	dpu_core_perf_crtc_release_bw(crtc);
+	DRM_MODESET_LOCK_ALL_END(ctx, ret);
+	if (ret)
+		DRM_ERROR("Failed to acquire modeset locks to release bw, %d\n",
+			  ret);
+}
+
 static void dpu_crtc_frame_event_work(struct kthread_work *work)
 {
 	struct dpu_crtc_frame_event *fevent = container_of(work,
@@ -335,7 +348,7 @@  static void dpu_crtc_frame_event_work(struct kthread_work *work)
 			/* release bandwidth and other resources */
 			trace_dpu_crtc_frame_event_done(DRMID(crtc),
 							fevent->event);
-			dpu_core_perf_crtc_release_bw(crtc);
+			dpu_crtc_release_bw_unlocked(crtc);
 		} else {
 			trace_dpu_crtc_frame_event_more_pending(DRMID(crtc),
 								fevent->event);

Comments

On 2018-11-30 14:00, Sean Paul wrote:
> From: Sean Paul <seanpaul@chromium.org>
> 
> This patch wraps dpu_core_perf_crtc_release_bw() with modeset locks
> since it digs into the state objects.
> 
> Changes in v2:
> - None
> Changes in v3:
> - Use those nifty new DRM_MODESET_LOCK_ALL_* helpers (Daniel)
> 
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
I see Daniel's comments are addressed. So ..
Reviewed-by: Jeykumar Sankaran <jsanka@codeaurora.org>

>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 74ef384d9cd6a..03ddd281a354f 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -306,6 +306,19 @@ static void dpu_crtc_vblank_cb(void *data)
>  	trace_dpu_crtc_vblank_cb(DRMID(crtc));
>  }
> 
> +static void dpu_crtc_release_bw_unlocked(struct drm_crtc *crtc)
> +{
> +	int ret = 0;
> +	struct drm_modeset_acquire_ctx ctx;
> +
> +	DRM_MODESET_LOCK_ALL_BEGIN(crtc->dev, ctx, 0, ret);
> +	dpu_core_perf_crtc_release_bw(crtc);
> +	DRM_MODESET_LOCK_ALL_END(ctx, ret);
> +	if (ret)
> +		DRM_ERROR("Failed to acquire modeset locks to release bw,
> %d\n",
> +			  ret);
> +}
> +
>  static void dpu_crtc_frame_event_work(struct kthread_work *work)
>  {
>  	struct dpu_crtc_frame_event *fevent = container_of(work,
> @@ -335,7 +348,7 @@ static void dpu_crtc_frame_event_work(struct
> kthread_work *work)
>  			/* release bandwidth and other resources */
>  			trace_dpu_crtc_frame_event_done(DRMID(crtc),
>  							fevent->event);
> -			dpu_core_perf_crtc_release_bw(crtc);
> +			dpu_crtc_release_bw_unlocked(crtc);
>  		} else {
> 
> trace_dpu_crtc_frame_event_more_pending(DRMID(crtc),
> 
> fevent->event);
On Fri, Nov 30, 2018 at 05:00:02PM -0500, Sean Paul wrote:
> From: Sean Paul <seanpaul@chromium.org>
> 
> This patch wraps dpu_core_perf_crtc_release_bw() with modeset locks
> since it digs into the state objects.
> 
> Changes in v2:
> - None
> Changes in v3:
> - Use those nifty new DRM_MODESET_LOCK_ALL_* helpers (Daniel)
> 
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 74ef384d9cd6a..03ddd281a354f 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -306,6 +306,19 @@ static void dpu_crtc_vblank_cb(void *data)
>  	trace_dpu_crtc_vblank_cb(DRMID(crtc));
>  }
>  
> +static void dpu_crtc_release_bw_unlocked(struct drm_crtc *crtc)
> +{
> +	int ret = 0;
> +	struct drm_modeset_acquire_ctx ctx;
> +
> +	DRM_MODESET_LOCK_ALL_BEGIN(crtc->dev, ctx, 0, ret);
> +	dpu_core_perf_crtc_release_bw(crtc);
> +	DRM_MODESET_LOCK_ALL_END(ctx, ret);

Sooooo pretty, and correct even :-)

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +	if (ret)
> +		DRM_ERROR("Failed to acquire modeset locks to release bw, %d\n",
> +			  ret);
> +}
> +
>  static void dpu_crtc_frame_event_work(struct kthread_work *work)
>  {
>  	struct dpu_crtc_frame_event *fevent = container_of(work,
> @@ -335,7 +348,7 @@ static void dpu_crtc_frame_event_work(struct kthread_work *work)
>  			/* release bandwidth and other resources */
>  			trace_dpu_crtc_frame_event_done(DRMID(crtc),
>  							fevent->event);
> -			dpu_core_perf_crtc_release_bw(crtc);
> +			dpu_crtc_release_bw_unlocked(crtc);
>  		} else {
>  			trace_dpu_crtc_frame_event_more_pending(DRMID(crtc),
>  								fevent->event);
> -- 
> Sean Paul, Software Engineer, Google / Chromium OS
>