aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>2026-06-12 16:00:56 +0000
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>2026-07-09 18:33:56 +0000
commite9f21e4f28ce8cf8ca890b86f8c791473976396f (patch)
tree240323097c1cfc812ef195dc0d5479d5e213100b
parent6d5f5f730a42eb49240bf1a21a65f4c5f7fd2843 (diff)
linuxkpi: Add `usleep_range_state()`
It takes a task state as its last argument. We enforce that this state is `TASK_UNINTERRUPTIBLE` for the time being because other states are not interpreted. Change `usleep_range()` to call `usleep_range_state()` with the state set to `TASK_UNINTERRUPTIBLE`, which is what Linux does too. The amdgpu DRM driver starte to use `usleep_range_state()` in Linux 6.13. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57579
-rw-r--r--sys/compat/linuxkpi/common/include/linux/delay.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/delay.h b/sys/compat/linuxkpi/common/include/linux/delay.h
index f19d1a759c26..7d29211bf110 100644
--- a/sys/compat/linuxkpi/common/include/linux/delay.h
+++ b/sys/compat/linuxkpi/common/include/linux/delay.h
@@ -30,7 +30,10 @@
#ifndef _LINUXKPI_LINUX_DELAY_H_
#define _LINUXKPI_LINUX_DELAY_H_
+#include <linux/math.h>
+#include <linux/sched.h>
#include <linux/jiffies.h>
+
#include <sys/systm.h>
static inline void
@@ -64,14 +67,23 @@ ndelay(unsigned long x)
}
static inline void
-usleep_range(unsigned long min, unsigned long max)
+usleep_range_state(unsigned long min, unsigned long max, unsigned int state)
{
+ KASSERT(state == TASK_UNINTERRUPTIBLE, ("%s: state=%d unsupported\n",
+ __func__, state));
+
/* guard against invalid values */
if (min == 0)
min = 1;
pause_sbt("lnxsleep", ustosbt(min), 0, C_HARDCLOCK);
}
+static inline void
+usleep_range(unsigned long min, unsigned long max)
+{
+ usleep_range_state(min, max, TASK_UNINTERRUPTIBLE);
+}
+
extern unsigned int linux_msleep_interruptible(unsigned int ms);
static inline void