| .. | .. |
|---|
| 16 | 16 | * 3. CPU clock rate changes. |
|---|
| 17 | 17 | * |
|---|
| 18 | 18 | * 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 |
|---|
| 20 | 20 | */ |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | #include <linux/kernel.h> |
|---|
| 23 | +#include <linux/sched.h> |
|---|
| 23 | 24 | |
|---|
| 24 | 25 | extern unsigned long loops_per_jiffy; |
|---|
| 25 | 26 | |
|---|
| .. | .. |
|---|
| 55 | 56 | |
|---|
| 56 | 57 | extern unsigned long lpj_fine; |
|---|
| 57 | 58 | void calibrate_delay(void); |
|---|
| 59 | +void __attribute__((weak)) calibration_delay_done(void); |
|---|
| 58 | 60 | void msleep(unsigned int msecs); |
|---|
| 59 | 61 | unsigned long msleep_interruptible(unsigned int msecs); |
|---|
| 62 | +void usleep_range_state(unsigned long min, unsigned long max, |
|---|
| 63 | + unsigned int state); |
|---|
| 60 | 64 | 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 | +} |
|---|
| 61 | 70 | |
|---|
| 62 | 71 | static inline void ssleep(unsigned int seconds) |
|---|
| 63 | 72 | { |
|---|
| 64 | 73 | msleep(seconds * 1000); |
|---|
| 65 | 74 | } |
|---|
| 66 | 75 | |
|---|
| 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 |
|---|
| 68 | 88 | extern void cpu_chill(void); |
|---|
| 69 | 89 | #else |
|---|
| 70 | 90 | # define cpu_chill() cpu_relax() |
|---|