]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/etnaviv: avoid deprecated timespec
authorArnd Bergmann <arnd@arndb.de>
Mon, 6 Nov 2017 12:28:52 +0000 (13:28 +0100)
committerArnd Bergmann <arnd@arndb.de>
Wed, 18 Dec 2019 17:07:32 +0000 (18:07 +0100)
struct timespec is being removed from the kernel because it often leads
to code that is not y2038-safe.

In the etnaviv driver, monotonic timestamps are used, which do not suffer
from overflow, but the usage of timespec here gets in the way of removing
the interface completely.

Pass down the user-supplied 64-bit value here rather than converting
it to an intermediate timespec to avoid the conversion.

The conversion is transparent for all regular CLOCK_MONOTONIC values,
but is a small change in behavior for excessively large values: the
existing code would treat e.g. tv_sec=0x100000000 the same as tv_sec=0
and not block, while the new code it would block for up to 2^31
seconds. The new behavior is more logical here, but if it causes problems,
the truncation can be put back.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/gpu/drm/etnaviv/etnaviv_drv.c
drivers/gpu/drm/etnaviv/etnaviv_drv.h
drivers/gpu/drm/etnaviv/etnaviv_gem.c
drivers/gpu/drm/etnaviv/etnaviv_gem.h
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.h

index 95d72dc0028005a24e5b88d18bc03854dbebba8b..3eb0f9223beac6842cc24c6f4ac2111a4605f0fe 100644 (file)
@@ -282,11 +282,6 @@ static int etnaviv_ioctl_gem_new(struct drm_device *dev, void *data,
                        args->flags, &args->handle);
 }
 
-#define TS(t) ((struct timespec){ \
-       .tv_sec = (t).tv_sec, \
-       .tv_nsec = (t).tv_nsec \
-})
-
 static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
                struct drm_file *file)
 {
@@ -304,7 +299,7 @@ static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
        if (!obj)
                return -ENOENT;
 
-       ret = etnaviv_gem_cpu_prep(obj, args->op, &TS(args->timeout));
+       ret = etnaviv_gem_cpu_prep(obj, args->op, &args->timeout);
 
        drm_gem_object_put_unlocked(obj);
 
@@ -357,7 +352,7 @@ static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data,
 {
        struct drm_etnaviv_wait_fence *args = data;
        struct etnaviv_drm_private *priv = dev->dev_private;
-       struct timespec *timeout = &TS(args->timeout);
+       struct drm_etnaviv_timespec *timeout = &args->timeout;
        struct etnaviv_gpu *gpu;
 
        if (args->flags & ~(ETNA_WAIT_NONBLOCK))
@@ -409,7 +404,7 @@ static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data,
 {
        struct etnaviv_drm_private *priv = dev->dev_private;
        struct drm_etnaviv_gem_wait *args = data;
-       struct timespec *timeout = &TS(args->timeout);
+       struct drm_etnaviv_timespec *timeout = &args->timeout;
        struct drm_gem_object *obj;
        struct etnaviv_gpu *gpu;
        int ret;
index 32cfa5a48d420ca8621b1dab201d6d69bef41cea..efc656efeb0fd1a844796ace71d8a8ce100a3780 100644 (file)
@@ -61,7 +61,7 @@ int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
 void etnaviv_gem_prime_unpin(struct drm_gem_object *obj);
 void *etnaviv_gem_vmap(struct drm_gem_object *obj);
 int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
-               struct timespec *timeout);
+               struct drm_etnaviv_timespec *timeout);
 int etnaviv_gem_cpu_fini(struct drm_gem_object *obj);
 void etnaviv_gem_free_object(struct drm_gem_object *obj);
 int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
@@ -107,11 +107,12 @@ static inline size_t size_vstruct(size_t nelem, size_t elem_size, size_t base)
  * between the specified timeout and the current CLOCK_MONOTONIC time.
  */
 static inline unsigned long etnaviv_timeout_to_jiffies(
-       const struct timespec *timeout)
+       const struct drm_etnaviv_timespec *timeout)
 {
-       struct timespec64 ts, to;
-
-       to = timespec_to_timespec64(*timeout);
+       struct timespec64 ts, to = {
+               .tv_sec = timeout->tv_sec,
+               .tv_nsec = timeout->tv_nsec,
+       };
 
        ktime_get_ts64(&ts);
 
index cb1faaac380a3f40aa4f82ee6a0b83ca2d6ff2f5..6adea180d62995717406da88f6bd3694be53d74a 100644 (file)
@@ -373,7 +373,7 @@ static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op)
 }
 
 int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
-               struct timespec *timeout)
+               struct drm_etnaviv_timespec *timeout)
 {
        struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
        struct drm_device *dev = obj->dev;
@@ -431,7 +431,7 @@ int etnaviv_gem_cpu_fini(struct drm_gem_object *obj)
 }
 
 int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
-       struct timespec *timeout)
+       struct drm_etnaviv_timespec *timeout)
 {
        struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
 
index d6270acce619acedc89c5b238c4b2b5c2738fcbe..6b68fe16041b2307a284ec2f78d54049e4c898be 100644 (file)
@@ -112,7 +112,7 @@ struct etnaviv_gem_submit {
 void etnaviv_submit_put(struct etnaviv_gem_submit * submit);
 
 int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
-       struct timespec *timeout);
+       struct drm_etnaviv_timespec *timeout);
 int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags,
        const struct etnaviv_gem_ops *ops, struct etnaviv_gem_object **res);
 void etnaviv_gem_obj_add(struct drm_device *dev, struct drm_gem_object *obj);
index d47d1a8e02198efbbd683e7b3e7a1e1f50412ba0..799ec20b267dc991f71571596acab277d7307d0c 100644 (file)
@@ -1132,7 +1132,7 @@ static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
  * Cmdstream submission/retirement:
  */
 int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
-       u32 id, struct timespec *timeout)
+       u32 id, struct drm_etnaviv_timespec *timeout)
 {
        struct dma_fence *fence;
        int ret;
@@ -1179,7 +1179,8 @@ int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
  * that lock in this function while waiting.
  */
 int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu,
-       struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout)
+       struct etnaviv_gem_object *etnaviv_obj,
+       struct drm_etnaviv_timespec *timeout)
 {
        unsigned long remaining;
        long ret;
index 8f9bd4edc96a539d2e5f3471d577f3447ab1e510..97bb48042b4d64ed85287c7dee87af05aa574099 100644 (file)
@@ -169,9 +169,10 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m);
 void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu);
 void etnaviv_gpu_retire(struct etnaviv_gpu *gpu);
 int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
-       u32 fence, struct timespec *timeout);
+       u32 fence, struct drm_etnaviv_timespec *timeout);
 int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu,
-       struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout);
+       struct etnaviv_gem_object *etnaviv_obj,
+       struct drm_etnaviv_timespec *timeout);
 struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit);
 int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu);
 void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu);