diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-10-11 11:20:13 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2017-10-12 18:34:50 -0400 |
commit | 25e1a79874eb3821d93310c908cc0a81b47af060 (patch) | |
tree | 3081b7fc5f68805e9ff376ad8cb6976c8fda1216 | |
parent | 67680d3c046450b3901aa4e5a9cf2f8fbd7ed9a2 (diff) |
drm: vblank: remove drm_timestamp_monotonic parameter
There is a risk of overflowing vblank timestamps in 2038 or 2106 if
someone sets the drm_timestamp_monotonic module parameter to zero.
I found no indication of anyone ever setting the parameter, or
complaining about the default being wrong, after it was introduced
as a way to handle backwards-compatibility with linux prior to
c61eef726a78 ("drm: add support for monotonic vblank timestamps"),
so it's probably safer to just remove the parameter completely
and only allowing the default behavior.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_internal.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_ioctl.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_vblank.c | 29 |
3 files changed, 7 insertions, 25 deletions
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index fbc3f308fa19..edd921adcf33 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h | |||
@@ -55,7 +55,6 @@ int drm_clients_info(struct seq_file *m, void* data); | |||
55 | int drm_gem_name_info(struct seq_file *m, void *data); | 55 | int drm_gem_name_info(struct seq_file *m, void *data); |
56 | 56 | ||
57 | /* drm_vblank.c */ | 57 | /* drm_vblank.c */ |
58 | extern unsigned int drm_timestamp_monotonic; | ||
59 | void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe); | 58 | void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe); |
60 | void drm_vblank_cleanup(struct drm_device *dev); | 59 | void drm_vblank_cleanup(struct drm_device *dev); |
61 | 60 | ||
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index a9ae6dd2d593..a78f03155466 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c | |||
@@ -235,7 +235,7 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ | |||
235 | /* Only some caps make sense with UMS/render-only drivers. */ | 235 | /* Only some caps make sense with UMS/render-only drivers. */ |
236 | switch (req->capability) { | 236 | switch (req->capability) { |
237 | case DRM_CAP_TIMESTAMP_MONOTONIC: | 237 | case DRM_CAP_TIMESTAMP_MONOTONIC: |
238 | req->value = drm_timestamp_monotonic; | 238 | req->value = 1; |
239 | return 0; | 239 | return 0; |
240 | case DRM_CAP_PRIME: | 240 | case DRM_CAP_PRIME: |
241 | req->value |= dev->driver->prime_fd_to_handle ? DRM_PRIME_CAP_IMPORT : 0; | 241 | req->value |= dev->driver->prime_fd_to_handle ? DRM_PRIME_CAP_IMPORT : 0; |
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index c605c3ad6b6e..810a93fc558b 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c | |||
@@ -82,20 +82,12 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, | |||
82 | 82 | ||
83 | static unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */ | 83 | static unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */ |
84 | 84 | ||
85 | /* | ||
86 | * Default to use monotonic timestamps for wait-for-vblank and page-flip | ||
87 | * complete events. | ||
88 | */ | ||
89 | unsigned int drm_timestamp_monotonic = 1; | ||
90 | |||
91 | static int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */ | 85 | static int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */ |
92 | 86 | ||
93 | module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600); | 87 | module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600); |
94 | module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600); | 88 | module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600); |
95 | module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600); | ||
96 | MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately)"); | 89 | MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately)"); |
97 | MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]"); | 90 | MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]"); |
98 | MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps"); | ||
99 | 91 | ||
100 | static void store_vblank(struct drm_device *dev, unsigned int pipe, | 92 | static void store_vblank(struct drm_device *dev, unsigned int pipe, |
101 | u32 vblank_count_inc, | 93 | u32 vblank_count_inc, |
@@ -672,9 +664,6 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, | |||
672 | delta_ns = div_s64(1000000LL * (vpos * mode->crtc_htotal + hpos), | 664 | delta_ns = div_s64(1000000LL * (vpos * mode->crtc_htotal + hpos), |
673 | mode->crtc_clock); | 665 | mode->crtc_clock); |
674 | 666 | ||
675 | if (!drm_timestamp_monotonic) | ||
676 | etime = ktime_mono_to_real(etime); | ||
677 | |||
678 | /* save this only for debugging purposes */ | 667 | /* save this only for debugging purposes */ |
679 | ts_etime = ktime_to_timespec64(etime); | 668 | ts_etime = ktime_to_timespec64(etime); |
680 | ts_vblank_time = ktime_to_timespec64(*vblank_time); | 669 | ts_vblank_time = ktime_to_timespec64(*vblank_time); |
@@ -694,11 +683,6 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, | |||
694 | } | 683 | } |
695 | EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos); | 684 | EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos); |
696 | 685 | ||
697 | static ktime_t get_drm_timestamp(void) | ||
698 | { | ||
699 | return drm_timestamp_monotonic ? ktime_get() : ktime_get_real(); | ||
700 | } | ||
701 | |||
702 | /** | 686 | /** |
703 | * drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent | 687 | * drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent |
704 | * vblank interval | 688 | * vblank interval |
@@ -738,7 +722,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, | |||
738 | * Return current monotonic/gettimeofday timestamp as best estimate. | 722 | * Return current monotonic/gettimeofday timestamp as best estimate. |
739 | */ | 723 | */ |
740 | if (!ret) | 724 | if (!ret) |
741 | *tvblank = get_drm_timestamp(); | 725 | *tvblank = ktime_get(); |
742 | 726 | ||
743 | return ret; | 727 | return ret; |
744 | } | 728 | } |
@@ -811,8 +795,8 @@ static void send_vblank_event(struct drm_device *dev, | |||
811 | e->event.sequence = seq; | 795 | e->event.sequence = seq; |
812 | /* | 796 | /* |
813 | * e->event is a user space structure, with hardcoded unsigned | 797 | * e->event is a user space structure, with hardcoded unsigned |
814 | * 32-bit seconds/microseconds. This will overflow in 2106 for | 798 | * 32-bit seconds/microseconds. This is safe as we always use |
815 | * drm_timestamp_monotonic==0, but not with drm_timestamp_monotonic==1 | 799 | * monotonic timestamps since linux-4.15 |
816 | */ | 800 | */ |
817 | e->event.tv_sec = tv.tv_sec; | 801 | e->event.tv_sec = tv.tv_sec; |
818 | e->event.tv_usec = tv.tv_nsec / 1000; | 802 | e->event.tv_usec = tv.tv_nsec / 1000; |
@@ -899,7 +883,7 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc, | |||
899 | } else { | 883 | } else { |
900 | seq = 0; | 884 | seq = 0; |
901 | 885 | ||
902 | now = get_drm_timestamp(); | 886 | now = ktime_get(); |
903 | } | 887 | } |
904 | e->pipe = pipe; | 888 | e->pipe = pipe; |
905 | e->event.crtc_id = crtc->base.id; | 889 | e->event.crtc_id = crtc->base.id; |
@@ -1408,9 +1392,8 @@ static void drm_wait_vblank_reply(struct drm_device *dev, unsigned int pipe, | |||
1408 | 1392 | ||
1409 | /* | 1393 | /* |
1410 | * drm_wait_vblank_reply is a UAPI structure that uses 'long' | 1394 | * drm_wait_vblank_reply is a UAPI structure that uses 'long' |
1411 | * to store the seconds. This will overflow in y2038 on 32-bit | 1395 | * to store the seconds. This is safe as we always use monotonic |
1412 | * architectures with drm_timestamp_monotonic==0, but not with | 1396 | * timestamps since linux-4.15. |
1413 | * drm_timestamp_monotonic==1 (the default). | ||
1414 | */ | 1397 | */ |
1415 | reply->sequence = drm_vblank_count_and_time(dev, pipe, &now); | 1398 | reply->sequence = drm_vblank_count_and_time(dev, pipe, &now); |
1416 | ts = ktime_to_timespec64(now); | 1399 | ts = ktime_to_timespec64(now); |