[PATCH 1/2] drm: Fix off-by-one in vblank hardware counter wraparound handling

Daniel Vetter daniel at ffwll.ch
Wed May 27 04:03:05 PDT 2015


On Wed, May 27, 2015 at 04:17:05PM +0900, Michel Dänzer wrote:
> On 26.05.2015 20:48, Daniel Vetter wrote:
> > On Tue, May 26, 2015 at 05:53:38PM +0900, Michel Dänzer wrote:
> >> From: Michel Dänzer <michel.daenzer at 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 at amd.com>
> > 
> > Well there's two users of this really, one wants the max (this one here)
> > and the other a mask.
> 
> Well, this one has been around much longer. :) Looks like drm_vblank_on
> added a (probably valid, see below) assumption without updating the
> field name to reflect that.

Yeah, might be clearer to open-code the (slower) divide just for clarity.
Anyway applied this patch to drm-misc.

> > And all the drivers use it as a mask.
> 
> How so? They just assign the value, which happens to work for both
> meanings above in all cases.

Yeah I had the usual confusion about where exactly we start counting here
;-) I was thinking of num_vblank_counts_before_wrap vs. mask.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list