Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/via: use monotonic time for VIA_WAIT_IRQ

The normal DRM vblank interrupt events started using monotonic times in
commit c61eef726a78 ("drm: add support for monotonic vblank timestamps"),
which is useful for a number of reasons, including the possible y2038
overflow.

The VIA_WAIT_IRQ ioctl uses the same drm_wait_vblank_reply as
DRM_IOCTL_WAIT_VBLANK, but still uses wall-clock time.

This converts it to using monotonic time as well, which is more
consistent, and avoids problems with the y2038 overflow as well
as synchronization issues when the real time skips.

I could not find the matching user space that calls the VIA_WAIT_IRQ
ioctl to verify that this is safe, but it very likely is. Please
either test or review the user space side before applying this.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171127111728.1710742-1-arnd@arndb.de

authored by

Arnd Bergmann and committed by
Daniel Vetter
44a2d564 298b6a81

+3 -3
+3 -3
drivers/gpu/drm/via/via_irq.c
··· 343 343 int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv) 344 344 { 345 345 drm_via_irqwait_t *irqwait = data; 346 - struct timeval now; 346 + struct timespec64 now; 347 347 int ret = 0; 348 348 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 349 349 drm_via_irq_t *cur_irq = dev_priv->via_irqs; ··· 377 377 378 378 ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence, 379 379 &irqwait->request.sequence); 380 - do_gettimeofday(&now); 380 + ktime_get_ts64(&now); 381 381 irqwait->reply.tval_sec = now.tv_sec; 382 - irqwait->reply.tval_usec = now.tv_usec; 382 + irqwait->reply.tval_usec = now.tv_nsec / NSEC_PER_USEC; 383 383 384 384 return ret; 385 385 }