drm/vkms: Avoid extra discount in the timestamp value
PATCH 1/1 drm/vkms: Avoid extra discount in the timestamp value
After the commit def35e7c5926 ("drm/vkms: Bugfix extra vblank frame") some of the crc tests (IGT) start to fail in the vkms with the following error:
[drm:drm_crtc_add_crc_entry [drm]] *ERROR* Overflow of CRC buffer,
userspace reads too slow.
[drm] failed to queue vkms_crc_work_handle
...
The commit def35e7c5926 ("drm/vkms: Bugfix extra vblank frame") added an operation for decrement the timestamp value returned by get_vblank_timestamp() which solved the problems related to kms_flip tests. However, each call to get_vblank_timestamp() reduces the timestamp even when it is not required. Such decrement generates a negative number in the following calculation within drm_update_vblank_count():
u64 diff_ns = ktime_to_ns(ktime_sub(t_vblank, vblank->time));
Next, the DIV_ROUND_CLOSEST_ULL macro is invoked using the diff_ns value, which generates an undefined result. Therefore, the returned frame is incorrect, which assign a huge number to the variable frame_end. In this case, causing the loop (vkms_crc_work_handle()) below to take a long time:
frame_end = drm_crtc_accurate_vblank_count(crtc); while (frame_start <= frame_end)
drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
This commit fixes this issue by adding a check that validates whether the current vblank timestamp is still the same, thus avoiding excessive timestamp decrement of the timestamp value.
--- drivers/gpu/drm/vkms/vkms_crtc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/vkms/vkms_crtc.c +4 -0
@@ -74,9 +74,13 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, {struct vkms_device *vkmsdev =drm_device_to_vkms_device (dev);struct vkms_output *output = &vkmsdev->output; +struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; *vblank_time = output->vblank_hrtimer.node.expires; +if (*vblank_time == vblank->time) +return true; +if (!in_vblank_irq) *vblank_time -= output->period_ns;
Signature · 1 line
2.21.0