From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com ([134.134.136.20]:7825 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751824AbdJRNu1 (ORCPT ); Wed, 18 Oct 2017 09:50:27 -0400 Date: Wed, 18 Oct 2017 16:50:19 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Andrzej Hajda Cc: dri-devel@lists.freedesktop.org, stable@vger.kernel.org, "Szyprowski, Marek" , Daniel Vetter Subject: Re: [PATCH] drm/vblank: Fix flip event vblank count Message-ID: <20171018135019.GJ10981@intel.com> References: <20171010133322.24029-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: On Wed, Oct 18, 2017 at 09:07:47AM +0200, Andrzej Hajda wrote: > Hi Ville, > > On 10.10.2017 15:33, Ville Syrjala wrote: > > From: Ville Syrj�l� > > > > 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@vger.kernel.org > > Cc: Daniel Vetter > > Suggested-by: Daniel Vetter > > Signed-off-by: Ville Syrj�l� > > --- > > 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. Argh! Maybe just remove the WARN then? > 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); > > } > -- Ville Syrj�l� Intel OTC