Am 15.09.26 um 21:42 schrieb Maíra Canal:
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]>
i915 and the new helper return 0 if the given time is 0. It looks like
v3d always returned 1 in this case. Assuming that v3d can handle the
slightly different semantics:
Reviewed-by: Thomas Zimmermann <[email protected]>
Best regards
Thomas
---
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..db95a2fac5d0 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_timeout.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 79ef20c89ff2..78de9fd69e0b 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);
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)