The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=e9f21e4f28ce8cf8ca890b86f8c791473976396f
commit e9f21e4f28ce8cf8ca890b86f8c791473976396f Author: Jean-Sébastien Pédron <[email protected]> AuthorDate: 2026-06-12 16:00:56 +0000 Commit: Jean-Sébastien Pédron <[email protected]> CommitDate: 2026-07-09 18:33:56 +0000 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 --- sys/compat/linuxkpi/common/include/linux/delay.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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
