* [PATCH] drm/exynos/ipp: Replace struct timeval usage
@ 2015-06-01 3:13 Tina Ruchandani
2015-06-01 3:31 ` Baruch Siach
0 siblings, 1 reply; 4+ messages in thread
From: Tina Ruchandani @ 2015-06-01 3:13 UTC (permalink / raw)
To: linux-arm-kernel
'struct timeval' uses a 32-bit seconds representation which
will overflow in the year 2038 and beyond. This patch
replaces the use of struct timeval with struct timespec64
which uses a 64-bit seconds representation and is y2038 safe.
The patch is part of a larger effort to remove all 32-bit
timekeeping variables (timeval, time_t and timespec) from the
kernel.
---
drivers/gpu/drm/exynos/exynos_drm_ipp.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index b7f1cbc..7cd4a97 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -16,6 +16,7 @@
#include <linux/types.h>
#include <linux/clk.h>
#include <linux/pm_runtime.h>
+#include <linux/time64.h>
#include <drm/drmP.h>
#include <drm/exynos_drm.h>
@@ -1414,7 +1415,7 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
struct drm_exynos_ipp_queue_buf qbuf;
struct drm_exynos_ipp_send_event *e;
struct list_head *head;
- struct timeval now;
+ struct timespec64 now;
unsigned long flags;
u32 tbuf_id[EXYNOS_DRM_OPS_MAX] = {0, };
int ret, i;
@@ -1518,10 +1519,11 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
e = list_first_entry(&c_node->event_list,
struct drm_exynos_ipp_send_event, base.link);
- do_gettimeofday(&now);
- DRM_DEBUG_KMS("tv_sec[%ld]tv_usec[%ld]\n", now.tv_sec, now.tv_usec);
+ getnstimeofday64(&now);
+ DRM_DEBUG_KMS("tv_sec[%lld]tv_usec[%lld]\n", now.tv_sec, (now.tv_nsec /
+ NSEC_PER_SEC));
e->event.tv_sec = now.tv_sec;
- e->event.tv_usec = now.tv_usec;
+ e->event.tv_usec = now.tv_nsec / NSEC_PER_SEC;
e->event.prop_id = property->prop_id;
/* set buffer id about source destination */
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] drm/exynos/ipp: Replace struct timeval usage
@ 2015-06-01 3:39 Tina Ruchandani
2015-06-01 19:26 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Tina Ruchandani @ 2015-06-01 3:39 UTC (permalink / raw)
To: linux-arm-kernel
'struct timeval' uses a 32-bit seconds representation which
will overflow in the year 2038 and beyond. This patch
replaces the use of struct timeval with struct timespec64
which uses a 64-bit seconds representation and is y2038 safe.
The patch is part of a larger effort to remove all 32-bit
timekeeping variables (timeval, time_t and timespec) from the
kernel.
Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
drivers/gpu/drm/exynos/exynos_drm_ipp.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index b7f1cbc..7cd4a97 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -16,6 +16,7 @@
#include <linux/types.h>
#include <linux/clk.h>
#include <linux/pm_runtime.h>
+#include <linux/time64.h>
#include <drm/drmP.h>
#include <drm/exynos_drm.h>
@@ -1414,7 +1415,7 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
struct drm_exynos_ipp_queue_buf qbuf;
struct drm_exynos_ipp_send_event *e;
struct list_head *head;
- struct timeval now;
+ struct timespec64 now;
unsigned long flags;
u32 tbuf_id[EXYNOS_DRM_OPS_MAX] = {0, };
int ret, i;
@@ -1518,10 +1519,11 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
e = list_first_entry(&c_node->event_list,
struct drm_exynos_ipp_send_event, base.link);
- do_gettimeofday(&now);
- DRM_DEBUG_KMS("tv_sec[%ld]tv_usec[%ld]\n", now.tv_sec, now.tv_usec);
+ getnstimeofday64(&now);
+ DRM_DEBUG_KMS("tv_sec[%lld]tv_usec[%lld]\n", now.tv_sec, (now.tv_nsec /
+ NSEC_PER_SEC));
e->event.tv_sec = now.tv_sec;
- e->event.tv_usec = now.tv_usec;
+ e->event.tv_usec = now.tv_nsec / NSEC_PER_SEC;
e->event.prop_id = property->prop_id;
/* set buffer id about source destination */
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] drm/exynos/ipp: Replace struct timeval usage
2015-06-01 3:39 Tina Ruchandani
@ 2015-06-01 19:26 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2015-06-01 19:26 UTC (permalink / raw)
To: linux-arm-kernel
On Monday 01 June 2015 09:09:00 Tina Ruchandani wrote:
> @@ -1518,10 +1519,11 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
> e = list_first_entry(&c_node->event_list,
> struct drm_exynos_ipp_send_event, base.link);
>
> - do_gettimeofday(&now);
> - DRM_DEBUG_KMS("tv_sec[%ld]tv_usec[%ld]\n", now.tv_sec, now.tv_usec);
> + getnstimeofday64(&now);
> + DRM_DEBUG_KMS("tv_sec[%lld]tv_usec[%lld]\n", now.tv_sec, (now.tv_nsec /
> + NSEC_PER_SEC));
> e->event.tv_sec = now.tv_sec;
> - e->event.tv_usec = now.tv_usec;
> + e->event.tv_usec = now.tv_nsec / NSEC_PER_SEC;
> e->event.prop_id = property->prop_id;
>
Unfortunately, this has two important bugs:
* e->event.tv_sec is defined as a '__u32' variable and is used in a public
user space API, so the code is just as broken afterwards as it was before.
Fixing this will require adding new ioctl commands.
* You have a typo above: I assume you mean NSEC_PER_USEC instead of
NSEC_PER_SEC, the current code will always assign tv_usec to zero,
because now.tv_nsec is by definition smaller than NSEC_PER_SEC.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-01 19:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01 3:13 [PATCH] drm/exynos/ipp: Replace struct timeval usage Tina Ruchandani
2015-06-01 3:31 ` Baruch Siach
-- strict thread matches above, loose matches on Subject: below --
2015-06-01 3:39 Tina Ruchandani
2015-06-01 19:26 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox