Files
Maíra Canal 421cf7ccfc drm: Add drm_timeout_rel_to_jiffies()
drm_timeout_abs_to_jiffies() covers the drivers whose wait UAPI takes an
absolute deadline, but there is no equivalent for the drivers that
express a wait as a duration. Drivers such as i915 and v3d convert the
value themselves.

Converting a nanosecond duration to jiffies needs some care.
nsecs_to_jiffies() returns unsigned long, so on 32-bit a large
userspace-supplied timeout overflows its range and is silently truncated.

i915 already handles both cases in a local helper, which v3d has a copy
of. Add the same conversion to the core, so that it is available to any
driver and both copies can be dropped.

Differently from drm_timeout_abs_to_jiffies(), the new function enforces
that a timeout in jiffies is a positive value and therefore, returns an
unsigned value.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patch.msgid.link/20260915-drm-timeout-helpers-v3-2-f2ae987d861f@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
2026-09-30 19:38:46 -03:00

18 lines
395 B
C

/* SPDX-License-Identifier: MIT */
/*
* Function prototypes for timeout conversion helpers for wait ioctls.
*
* Copyright 2017 Red Hat
* Copyright 2016 Advanced Micro Devices, Inc.
*/
#ifndef __DRM_TIMEOUT_H__
#define __DRM_TIMEOUT_H__
#include <linux/types.h>
signed long drm_timeout_abs_to_jiffies(s64 timeout_nsec);
unsigned long drm_timeout_rel_to_jiffies(u64 timeout_nsec);
#endif