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

drm: Use ktime_mono_to_real()

Convert the monotonic timestamp with ktime_mono_to_real() in
drm_calc_vbltimestamp_from_scanoutpos().

In get_drm_timestamp we can call either ktime_get() or
ktime_get_real() depending on drm_timestamp_monotonic. No point in
having two calls into the core for CLOCK_REALTIME.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>

authored by

Thomas Gleixner and committed by
John Stultz
d2cb58c8 5cac2f4d

+3 -13
+3 -13
drivers/gpu/drm/drm_irq.c
··· 542 542 const struct drm_crtc *refcrtc, 543 543 const struct drm_display_mode *mode) 544 544 { 545 - ktime_t stime, etime, mono_time_offset; 546 545 struct timeval tv_etime; 546 + ktime_t stime, etime; 547 547 int vbl_status; 548 548 int vpos, hpos, i; 549 549 int framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns; ··· 588 588 vbl_status = dev->driver->get_scanout_position(dev, crtc, flags, &vpos, 589 589 &hpos, &stime, &etime); 590 590 591 - /* 592 - * Get correction for CLOCK_MONOTONIC -> CLOCK_REALTIME if 593 - * CLOCK_REALTIME is requested. 594 - */ 595 - if (!drm_timestamp_monotonic) 596 - mono_time_offset = ktime_get_monotonic_offset(); 597 - 598 591 /* Return as no-op if scanout query unsupported or failed. */ 599 592 if (!(vbl_status & DRM_SCANOUTPOS_VALID)) { 600 593 DRM_DEBUG("crtc %d : scanoutpos query failed [%d].\n", ··· 626 633 delta_ns = vpos * linedur_ns + hpos * pixeldur_ns; 627 634 628 635 if (!drm_timestamp_monotonic) 629 - etime = ktime_sub(etime, mono_time_offset); 636 + etime = ktime_mono_to_real(etime); 630 637 631 638 /* save this only for debugging purposes */ 632 639 tv_etime = ktime_to_timeval(etime); ··· 657 664 { 658 665 ktime_t now; 659 666 660 - now = ktime_get(); 661 - if (!drm_timestamp_monotonic) 662 - now = ktime_sub(now, ktime_get_monotonic_offset()); 663 - 667 + now = drm_timestamp_monotonic ? ktime_get() : ktime_get_real(); 664 668 return ktime_to_timeval(now); 665 669 } 666 670