[PATCH] drm/vblank: Fix flip event vblank count

Andrzej Hajda a.hajda at samsung.com
Wed Oct 18 07:07:47 UTC 2017


Hi Ville,

On 10.10.2017 15:33, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> On machines where the vblank interrupt fires some time after the start
> of vblank (or we just manage to race with the vblank interrupt handler)
> we will currently stuff a stale vblank counter value into the flip event,
> and thus we'll prematurely complete the flip.
>
> Switch over to drm_crtc_accurate_vblank_count() to make sure we have an
> up to date counter value, crucially also remember to add the +1 so that
> the delayed vblank interrupt won't complete the flip prematurely.
>
> Cc: stable at vger.kernel.org
> Cc: Daniel Vetter <daniel at ffwll.ch>
> Suggested-by: Daniel Vetter <daniel at ffwll.ch>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  drivers/gpu/drm/drm_vblank.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 70f2b9593edc..f14e6c92e332 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -869,7 +869,7 @@ void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
>  	assert_spin_locked(&dev->event_lock);
>  
>  	e->pipe = pipe;
> -	e->event.sequence = drm_vblank_count(dev, pipe);
> +	e->event.sequence = drm_crtc_accurate_vblank_count(crtc) + 1;

With this patch drm_crtc_arm_vblank_event calls
drm_crtc_accurate_vblank_count, which requires get_vblank_timestamp
callback, otherwise it issue WARN every time it is called.
On the other side most of the users of drm_crtc_arm_vblank_event do not
implement this callback. As a result one can observe multiple WARNs.
It was observed on Exynos platform but grep shows it can affect many
other platforms:

$ git grep -l drm_crtc_arm_vblank_event drivers/gpu/drm/
drivers/gpu/drm/arm/hdlcd_crtc.c
drivers/gpu/drm/arm/malidp_drv.c
drivers/gpu/drm/drm_vblank.c
drivers/gpu/drm/exynos/exynos_drm_crtc.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
drivers/gpu/drm/i915/intel_sprite.c
drivers/gpu/drm/imx/ipuv3-crtc.c
drivers/gpu/drm/mxsfb/mxsfb_crtc.c
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/pl111/pl111_display.c
drivers/gpu/drm/sti/sti_crtc.c
drivers/gpu/drm/stm/ltdc.c
drivers/gpu/drm/sun4i/sun4i_crtc.c
drivers/gpu/drm/tve200/tve200_display.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
drivers/gpu/drm/zte/zx_vou.c

$ git grep -l get_vblank_timestamp drivers/gpu/drm/
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/drm_vblank.c
drivers/gpu/drm/i915/i915_irq.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/vc4/vc4_drv.c

Regards
Andrzej

>  	e->event.crtc_id = crtc->base.id;
>  	list_add_tail(&e->base.link, &dev->vblank_event_list);
>  }




More information about the dri-devel mailing list