From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 6/9] drm: Avoid random vblank counter jumps if the hardware counter has been reset Date: Mon, 26 May 2014 15:28:21 +0200 Message-ID: <20140526132821.GM14357@phenom.ffwll.local> References: <1401104792-26560-1-git-send-email-ville.syrjala@linux.intel.com> <1401104792-26560-7-git-send-email-ville.syrjala@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by gabe.freedesktop.org (Postfix) with ESMTP id 129FB6E4EA for ; Mon, 26 May 2014 06:28:26 -0700 (PDT) Received: by mail-wi0-f180.google.com with SMTP id hi2so4405315wib.13 for ; Mon, 26 May 2014 06:28:25 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1401104792-26560-7-git-send-email-ville.syrjala@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: ville.syrjala@linux.intel.com Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Mon, May 26, 2014 at 02:46:29PM +0300, ville.syrjala@linux.intel.com wro= te: > From: Ville Syrj=E4l=E4 > = > When drm_vblank_on() is called the hardware vblank counter may have > been reset, so we can't trust that the old values sampled prior to > drm_vblank_off() have anything to do with the new values. > = > So update the .last count in drm_vblank_on() to make the first > drm_vblank_enable() consider that as the reference point. This > will correct the user space visible counter to account for the > time between drm_vblank_on() and the first drm_vblank_enable() > calls. > = > For extra safety subtract one from the .last count in drm_vblank_on() > to make sure that user space will never see the same counter value > before and after modeset. > = > Signed-off-by: Ville Syrj=E4l=E4 Reviewed-by: Daniel Vetter > --- > drivers/gpu/drm/drm_irq.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > = > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c > index bb64f0f..54cb85d 100644 > --- a/drivers/gpu/drm/drm_irq.c > +++ b/drivers/gpu/drm/drm_irq.c > @@ -1095,6 +1095,18 @@ void drm_vblank_on(struct drm_device *dev, int crt= c) > atomic_dec(&dev->vblank[crtc].refcount); > dev->vblank[crtc].inmodeset =3D 0; > } > + > + /* > + * sample the current counter to avoid random jumps > + * when drm_vblank_enable() applies the diff > + * > + * -1 to make sure user will never see the same > + * vblank counter value before and after a modeset > + */ > + dev->vblank[crtc].last =3D > + (dev->driver->get_vblank_counter(dev, crtc) - 1) & > + dev->max_vblank_count; > + > /* re-enable interrupts if there's are users left */ > if (atomic_read(&dev->vblank[crtc].refcount) !=3D 0) > WARN_ON(drm_vblank_enable(dev, crtc)); > -- = > 1.8.5.5 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch