dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: "Michel Dänzer" <michel@daenzer.net>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm: Fix off-by-one in vblank hardware counter wraparound handling
Date: Wed, 27 May 2015 10:42:38 +0300	[thread overview]
Message-ID: <20150527074238.GI18908@intel.com> (raw)
In-Reply-To: <20150526114811.GL12971@phenom.ffwll.local>

On Tue, May 26, 2015 at 01:48:11PM +0200, Daniel Vetter wrote:
> On Tue, May 26, 2015 at 05:53:38PM +0900, Michel Dänzer wrote:
> > From: Michel Dänzer <michel.daenzer@amd.com>
> > 
> > dev->max_vblank_count contains the largest value that can be represented
> > by the hardware counter. When the hardware counter wraps around, we have
> > to add that value + 1 to get the same value as if the hardware counter
> > didn't wrap around.
> > 
> > Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> 
> Well there's two users of this really, one wants the max (this one here)
> and the other a mask. And all the drivers use it as a mask. Maybe rename
> it to vblank_counter_mask or similar while at it to prevent further
> confusion?

Well, really it's just 'value % (max + 1)'. Just happens to work with &
since it's POT-1.

> -Daniel
> 
> > ---
> >  drivers/gpu/drm/drm_irq.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> > index c8a3447..f9634da 100644
> > --- a/drivers/gpu/drm/drm_irq.c
> > +++ b/drivers/gpu/drm/drm_irq.c
> > @@ -100,7 +100,7 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc)
> >  	/*
> >  	 * Interrupts were disabled prior to this call, so deal with counter
> >  	 * wrap if needed.
> > -	 * NOTE!  It's possible we lost a full dev->max_vblank_count events
> > +	 * NOTE!  It's possible we lost a full dev->max_vblank_count + 1 events
> >  	 * here if the register is small or we had vblank interrupts off for
> >  	 * a long time.
> >  	 *
> > @@ -117,7 +117,7 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc)
> >  	/* Deal with counter wrap */
> >  	diff = cur_vblank - vblank->last;
> >  	if (cur_vblank < vblank->last) {
> > -		diff += dev->max_vblank_count;
> > +		diff += dev->max_vblank_count + 1;
> >  
> >  		DRM_DEBUG("last_vblank[%d]=0x%x, cur_vblank=0x%x => diff=0x%x\n",
> >  			  crtc, vblank->last, cur_vblank, diff);
> > -- 
> > 2.1.4
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2015-05-27  7:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26  8:53 [PATCH 1/2] drm: Fix off-by-one in vblank hardware counter wraparound handling Michel Dänzer
2015-05-26  8:53 ` [PATCH 2/2] drm/radeon: Fix max_vblank_count value for current display engines Michel Dänzer
2015-05-28  4:17   ` Alex Deucher
2015-05-26  8:57 ` [PATCH 1/2] drm: Fix off-by-one in vblank hardware counter wraparound handling Christian König
2015-05-26 11:48 ` Daniel Vetter
2015-05-27  7:17   ` Michel Dänzer
2015-05-27 11:03     ` Daniel Vetter
2015-05-27  7:42   ` Ville Syrjälä [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150527074238.GI18908@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=michel@daenzer.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).