* [PATCH] vmwgfx: use monotonic event timestamps
@ 2017-11-27 11:16 Arnd Bergmann
2017-12-13 20:56 ` Sinclair Yeh
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2017-11-27 11:16 UTC (permalink / raw)
To: VMware Graphics, Sinclair Yeh, Thomas Hellstrom, David Airlie
Cc: Arnd Bergmann, linux-kernel, dri-devel, Tomi Valkeinen,
Arvind Yadav, Joe Perches, Ravikant B Sharma, Deepak Singh Rawat
DRM_VMW_EVENT_FENCE_SIGNALED (struct drm_vmw_event_fence) and
DRM_EVENT_VBLANK (struct drm_event_vblank) pass timestamps in 32-bit
seconds/microseconds format.
As of commit c61eef726a78 ("drm: add support for monotonic vblank
timestamps"), other DRM drivers use monotonic times for drm_event_vblank,
but vmwgfx still uses CLOCK_REALTIME for both events, which suffers from
the y2038/y2106 overflow as well as time jumps.
For consistency, this changes vmwgfx to use ktime_get_ts64 as well,
which solves those problems and avoids the deprecated do_gettimeofday()
function.
This should be transparent to to user space, as long as it doesn't
compare the time against the result of gettimeofday().
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index d6b1c509ae01..55214d0da66e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -897,11 +897,12 @@ static void vmw_event_fence_action_seq_passed(struct vmw_fence_action *action)
spin_lock_irq(&dev->event_lock);
if (likely(eaction->tv_sec != NULL)) {
- struct timeval tv;
+ struct timespec64 ts;
- do_gettimeofday(&tv);
- *eaction->tv_sec = tv.tv_sec;
- *eaction->tv_usec = tv.tv_usec;
+ ktime_get_ts64(&ts);
+ /* monotonic time, so no y2038 overflow */
+ *eaction->tv_sec = ts.tv_sec;
+ *eaction->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
}
drm_send_event_locked(dev, eaction->event);
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vmwgfx: use monotonic event timestamps
2017-11-27 11:16 [PATCH] vmwgfx: use monotonic event timestamps Arnd Bergmann
@ 2017-12-13 20:56 ` Sinclair Yeh
2017-12-14 9:05 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Sinclair Yeh @ 2017-12-13 20:56 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Thomas Hellstrom, David Airlie, linux-kernel, dri-devel,
Tomi Valkeinen, VMware Graphics, Ravikant B Sharma, Joe Perches,
Arvind Yadav, Deepak Singh Rawat
This looks okay to me. Although we should change eaction->tv_* type
to 64-bit as well.
I'll roll this in to our next pull request.
thanks,
Sinclair
On Mon, Nov 27, 2017 at 12:16:19PM +0100, Arnd Bergmann wrote:
> DRM_VMW_EVENT_FENCE_SIGNALED (struct drm_vmw_event_fence) and
> DRM_EVENT_VBLANK (struct drm_event_vblank) pass timestamps in 32-bit
> seconds/microseconds format.
>
> As of commit c61eef726a78 ("drm: add support for monotonic vblank
> timestamps"), other DRM drivers use monotonic times for drm_event_vblank,
> but vmwgfx still uses CLOCK_REALTIME for both events, which suffers from
> the y2038/y2106 overflow as well as time jumps.
>
> For consistency, this changes vmwgfx to use ktime_get_ts64 as well,
> which solves those problems and avoids the deprecated do_gettimeofday()
> function.
>
> This should be transparent to to user space, as long as it doesn't
> compare the time against the result of gettimeofday().
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> index d6b1c509ae01..55214d0da66e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> @@ -897,11 +897,12 @@ static void vmw_event_fence_action_seq_passed(struct vmw_fence_action *action)
> spin_lock_irq(&dev->event_lock);
>
> if (likely(eaction->tv_sec != NULL)) {
> - struct timeval tv;
> + struct timespec64 ts;
>
> - do_gettimeofday(&tv);
> - *eaction->tv_sec = tv.tv_sec;
> - *eaction->tv_usec = tv.tv_usec;
> + ktime_get_ts64(&ts);
> + /* monotonic time, so no y2038 overflow */
> + *eaction->tv_sec = ts.tv_sec;
> + *eaction->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
> }
>
> drm_send_event_locked(dev, eaction->event);
> --
> 2.9.0
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vmwgfx: use monotonic event timestamps
2017-12-13 20:56 ` Sinclair Yeh
@ 2017-12-14 9:05 ` Arnd Bergmann
0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-12-14 9:05 UTC (permalink / raw)
To: Sinclair Yeh
Cc: Thomas Hellstrom, David Airlie, Linux Kernel Mailing List,
dri-devel, Tomi Valkeinen, VMware Graphics, Ravikant B Sharma,
Joe Perches, Arvind Yadav, Deepak Singh Rawat
On Wed, Dec 13, 2017 at 9:56 PM, Sinclair Yeh <syeh@vmware.com> wrote:
> This looks okay to me. Although we should change eaction->tv_* type
> to 64-bit as well.
I thought about it but it would add significant complication without real gain,
as the eaction->tv_* pointers point into uapi structures (drm_vmw_event_fence
and drm_event_vblank) that are defined as 32-bit times and cannot be
changed. Changing the temporary pointer to 64 bit would require adding
a temporary variable to point to and then doing the truncation in the
callers. With monotonic times, we know that 32-bit times are sufficient,
they are good for 136 years after boot (68 years when interpreted as
signed).
Arnd
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-14 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-27 11:16 [PATCH] vmwgfx: use monotonic event timestamps Arnd Bergmann
2017-12-13 20:56 ` Sinclair Yeh
2017-12-14 9:05 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).