From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Roper Subject: Re: [PATCH 2/4] drm: Only update final vblank count when precise ts is available Date: Thu, 11 Sep 2014 07:09:43 -0700 Message-ID: <20140911140943.GA26680@intel.com> References: <1410363371-11282-1-git-send-email-daniel.vetter@ffwll.ch> <1410363371-11282-2-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id E55726E113 for ; Thu, 11 Sep 2014 07:08:25 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1410363371-11282-2-git-send-email-daniel.vetter@ffwll.ch> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Daniel Vetter Cc: Daniel Vetter , DRI Development List-Id: dri-devel@lists.freedesktop.org On Wed, Sep 10, 2014 at 05:36:09PM +0200, Daniel Vetter wrote: > Drivers without a hardware vblank counter simply can't account for the > vblanks that happened while the vblank interrupt was off. To check > this grab a vblank timestamp and if the result is dubious follow the > normal save-and-disable logic. > = > Drivers should prevent this by setting vblank_disable_allowed =3D false, > but since running vblank interrupts constantly is not good for power > consumption most drivers lie. Testing for precise vblank timestamps is > the next best thing we can check for. > = > Suggested-by: Mario Kleiner > Cc: Mario Kleiner > Cc: Matt Roper > Cc: Ville Syrj=E4l=E4 > Signed-off-by: Daniel Vetter Reviewed-by: Matt Roper > --- > drivers/gpu/drm/drm_irq.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > = > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c > index 6eb015020af2..922721ead29a 100644 > --- a/drivers/gpu/drm/drm_irq.c > +++ b/drivers/gpu/drm/drm_irq.c > @@ -163,8 +163,15 @@ static void vblank_disable_and_save(struct drm_devic= e *dev, int crtc) > * has been ticking all along until this time. This makes the > * count account for the entire time between drm_vblank_on() and > * drm_vblank_off(). > + * > + * But only do this if precise vblank timestamps are available. > + * Otherwise we might read a totally bogus timestamp since drivers > + * lacking precise timestamp support rely upon sampling the system clock > + * at vblank interrupt time. Which obviously won't work out well if the > + * vblank interrupt is disabled. > */ > - if (!vblank->enabled) { > + if (!vblank->enabled && > + drm_get_last_vbltimestamp(dev, crtc, &tvblank, 0) > 0) { > drm_update_vblank_count(dev, crtc); > spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags); > return; > -- = > 1.9.3 > = -- = Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795