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

Michel Dänzer michel at daenzer.net
Wed May 27 00:17:05 PDT 2015


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.


> 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.


> Maybe rename it to vblank_counter_mask or similar while at it to
> prevent further confusion?

I'm just fixing an off-by-one bug here; I invite you or anyone else to
be my guest for anything more. :)


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the dri-devel mailing list