[Intel-gfx] [PATCH 2/6] drm/i915: Move drm_crtc_vblank_get out of disabled pre-emption area.

Daniel Vetter daniel at ffwll.ch
Thu Aug 4 08:52:34 UTC 2016


On Wed, Aug 03, 2016 at 02:33:35PM -0700, Rodrigo Vivi wrote:
> drm_crtc_vblank_get call the drm_vblank_prepare that will be used soon
> to control power saving states or anything else that needs a mutex
> before the vblank happens.
> 
> local_irq_disable disables kernel preemption so we won't be able
> to use mutex inside drm_crtc_vblank_get. For this reason we need
> to move the drm_crtc_vblank_get a little up before disabling the
> interruptions.
> 
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> ---
>  drivers/gpu/drm/i915/intel_sprite.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 0de935a..d8bc27c 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -94,14 +94,14 @@ void intel_pipe_update_start(struct intel_crtc *crtc)
>  	min = vblank_start - usecs_to_scanlines(adjusted_mode, 100);
>  	max = vblank_start - 1;
>  
> -	local_irq_disable();
> -
>  	if (min <= 0 || max <= 0)
>  		return;
>  
>  	if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))
>  		return;
>  
> +	local_irq_disable();
> +
>  	crtc->debug.min_vbl = min;
>  	crtc->debug.max_vbl = max;
>  	trace_i915_pipe_update_start(crtc);
> @@ -166,6 +166,8 @@ void intel_pipe_update_end(struct intel_crtc *crtc, struct intel_flip_work *work
>  
>  	trace_i915_pipe_update_end(crtc, end_vbl_count, scanline_end);
>  
> +	local_irq_enable();
> +
>  	/* We're still in the vblank-evade critical section, this can't race.
>  	 * Would be slightly nice to just grab the vblank count and arm the
>  	 * event outside of the critical section - the spinlock might spin for a
> @@ -180,8 +182,6 @@ void intel_pipe_update_end(struct intel_crtc *crtc, struct intel_flip_work *work
>  		crtc->base.state->event = NULL;
>  	}
>  
> -	local_irq_enable();

You can't do this. Pls reaad the comment right above why.

What we need here is a drm_crtc_vblank_get_noresume() or similar which
will fail very loudly if the vblank refcount is 0. _noresume since that
mirroros runtime PM, but it's a really bad name.
-Daniel


> -
>  	if (crtc->debug.start_vbl_count &&
>  	    crtc->debug.start_vbl_count != end_vbl_count) {
>  		DRM_ERROR("Atomic update failure on pipe %c (start=%u end=%u) time %lld us, min %d, max %d, scanline start %d, end %d\n",
> -- 
> 2.4.3
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list