Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 Jul 2026 18:34:21 +0000
From:      Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron <dumbbell@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e9f21e4f28ce - main - linuxkpi: Add `usleep_range_state()`
Message-ID:  <6a4fe9ad.452a8.66cd3c35@gitrepo.freebsd.org>

index | next in thread | raw e-mail

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 <dumbbell@FreeBSD.org>
AuthorDate: 2026-06-12 16:00:56 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
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


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a4fe9ad.452a8.66cd3c35>