hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/delay.h
....@@ -16,10 +16,11 @@
1616 * 3. CPU clock rate changes.
1717 *
1818 * Please see this thread:
19
- * http://lists.openwall.net/linux-kernel/2011/01/09/56
19
+ * https://lists.openwall.net/linux-kernel/2011/01/09/56
2020 */
2121
2222 #include <linux/kernel.h>
23
+#include <linux/sched.h>
2324
2425 extern unsigned long loops_per_jiffy;
2526
....@@ -55,16 +56,35 @@
5556
5657 extern unsigned long lpj_fine;
5758 void calibrate_delay(void);
59
+void __attribute__((weak)) calibration_delay_done(void);
5860 void msleep(unsigned int msecs);
5961 unsigned long msleep_interruptible(unsigned int msecs);
62
+void usleep_range_state(unsigned long min, unsigned long max,
63
+ unsigned int state);
6064 void usleep_range(unsigned long min, unsigned long max);
65
+
66
+static inline void usleep_idle_range(unsigned long min, unsigned long max)
67
+{
68
+ usleep_range_state(min, max, TASK_IDLE);
69
+}
6170
6271 static inline void ssleep(unsigned int seconds)
6372 {
6473 msleep(seconds * 1000);
6574 }
6675
67
-#ifdef CONFIG_PREEMPT_RT_FULL
76
+/* see Documentation/timers/timers-howto.rst for the thresholds */
77
+static inline void fsleep(unsigned long usecs)
78
+{
79
+ if (usecs <= 10)
80
+ udelay(usecs);
81
+ else if (usecs <= 20000)
82
+ usleep_range(usecs, 2 * usecs);
83
+ else
84
+ msleep(DIV_ROUND_UP(usecs, 1000));
85
+}
86
+
87
+#ifdef CONFIG_PREEMPT_RT
6888 extern void cpu_chill(void);
6989 #else
7090 # define cpu_chill() cpu_relax()