The scanout position and vblank boundaries were decoded with a 13 bit mask, but the hardware reports wider values. With VRR, the vertical blank can be extended beyond 8191 lines, so the position gets truncated. This results in wrong vblank timestamps. Decode both values as 16 bit fields. No hardware generation uses the upper bits for anything else. Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)") Suggested-by: Michel Dänzer Cc: stable@vger.kernel.org Signed-off-by: Erhan Bilgili --- v2: Decode both values as 16 bit fields (Michel). Point Fixes at the commit which introduced the 13 bit mask (Michel). drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 0a8dd7241750..9ceb2921ccec 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -1784,15 +1784,15 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev, /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */ /* Decode into vertical and horizontal scanout position. */ - *vpos = position & 0x1fff; - *hpos = (position >> 16) & 0x1fff; + *vpos = lower_16_bits(position); + *hpos = upper_16_bits(position); /* Valid vblank area boundaries from gpu retrieved? */ if (vbl > 0) { /* Yes: Decode. */ ret |= DRM_SCANOUTPOS_ACCURATE; - vbl_start = vbl & 0x1fff; - vbl_end = (vbl >> 16) & 0x1fff; + vbl_start = lower_16_bits(vbl); + vbl_end = upper_16_bits(vbl); } else { /* No: Fake something reasonable which gives at least ok results. */ vbl_start = mode->crtc_vdisplay; -- 2.56.0