v3d carried an exact copy of i915's nsecs_to_jiffies_timeout(). Now
that the conversion lives in "drm_timeout.c", drop the copy and use it.

The core helper also returns 0 for a zero timeout. i915 has that check in
to_wait_timeout(), but v3d only ever copied the conversion, so
DRM_IOCTL_V3D_WAIT_BO with timeout_ns == 0 was turned into a one jiffy
wait and could block for a tick before reporting -ETIME. It now returns
without waiting.

Signed-off-by: Maíra Canal <[email protected]>
---
 drivers/gpu/drm/v3d/v3d_bo.c  |  3 ++-
 drivers/gpu/drm/v3d/v3d_drv.h | 10 ----------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
index a847d2f0ccf5..919bdff1036e 100644
--- a/drivers/gpu/drm/v3d/v3d_bo.c
+++ b/drivers/gpu/drm/v3d/v3d_bo.c
@@ -19,6 +19,7 @@
 #include <linux/vmalloc.h>
 
 #include <drm/drm_print.h>
+#include <drm/drm_utils.h>
 
 #include "v3d_drv.h"
 #include "uapi/drm/v3d_drm.h"
@@ -281,7 +282,7 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
        ktime_t start = ktime_get();
        u64 delta_ns;
        unsigned long timeout_jiffies =
-               nsecs_to_jiffies_timeout(args->timeout_ns);
+               drm_timeout_rel_to_jiffies(args->timeout_ns);
 
        if (args->pad != 0)
                return -EINVAL;
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index 8c46ed09f5c4..595c61a955e8 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -578,16 +578,6 @@ struct v3d_submit_ext {
                                                   (Wmax))
 #define wait_for(COND, MS)             _wait_for((COND), (MS) * 1000, 10, 1000)
 
-static inline unsigned long nsecs_to_jiffies_timeout(const u64 n)
-{
-       /* nsecs_to_jiffies64() does not guard against overflow */
-       if ((NSEC_PER_SEC % HZ) != 0 &&
-           div_u64(n, NSEC_PER_SEC) >= MAX_JIFFY_OFFSET / HZ)
-               return MAX_JIFFY_OFFSET;
-
-       return min_t(u64, MAX_JIFFY_OFFSET, nsecs_to_jiffies64(n) + 1);
-}
-
 /* v3d_bo.c */
 struct drm_gem_object *v3d_create_object(struct drm_device *dev, size_t size);
 void v3d_free_object(struct drm_gem_object *gem_obj);

-- 
2.55.0

Reply via email to