drm/ttm: convert to unified vma offset manager
[dragonfly.git] / sys / dev / drm / include / linux / sched.h
CommitLineData
39cfddd2 1/*
237ffc69 2 * Copyright (c) 2015-2019 François Tigeot <ftigeot@wolfpond.org>
8c49d0de
FT
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef _LINUX_SCHED_H_
28#define _LINUX_SCHED_H_
29
5915b712 30#include <linux/capability.h>
d6aa1cc5 31#include <linux/threads.h>
5915b712
FT
32#include <linux/kernel.h>
33#include <linux/types.h>
34#include <linux/jiffies.h>
eaf74c33 35#include <linux/rbtree.h>
d6aa1cc5 36#include <linux/cpumask.h>
5915b712 37#include <linux/errno.h>
d6aa1cc5 38#include <linux/mm_types.h>
237ffc69 39#include <linux/preempt.h>
5915b712
FT
40
41#include <asm/page.h>
42
43#include <linux/compiler.h>
44#include <linux/completion.h>
d6aa1cc5
FT
45#include <linux/pid.h>
46#include <linux/rcupdate.h>
5915b712
FT
47#include <linux/rculist.h>
48
49#include <linux/time.h>
50#include <linux/timer.h>
51#include <linux/hrtimer.h>
52#include <linux/gfp.h>
53
c6002f72
FT
54#include <asm/processor.h>
55
43cc53d1
FT
56#include <linux/spinlock.h>
57
8c49d0de
FT
58#include <sys/param.h>
59#include <sys/systm.h>
60#include <sys/proc.h>
61#include <sys/sched.h>
861f7f60 62#include <sys/signal2.h>
8c49d0de
FT
63
64#define TASK_RUNNING 0
65#define TASK_INTERRUPTIBLE 1
66#define TASK_UNINTERRUPTIBLE 2
67
68/*
69 * schedule_timeout - sleep until timeout
70 * @timeout: timeout value in jiffies
71 */
72static inline long
73schedule_timeout(signed long timeout)
74{
75 static int dummy;
76
77 if (timeout < 0) {
78 kprintf("schedule_timeout(): timeout cannot be negative\n");
79 return 0;
80 }
81
82 tsleep(&dummy, 0, "lstim", timeout);
83
84 return 0;
85}
86
bc8b8fed
FT
87#define TASK_COMM_LEN MAXCOMLEN
88
861f7f60
FT
89#define signal_pending(lp) CURSIG(lp)
90
282d6506
FT
91/*
92 * local_clock: fast time source, monotonic on the same cpu
93 */
94static inline uint64_t
95local_clock(void)
96{
97 struct timespec ts;
98
99 getnanouptime(&ts);
100 return (ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec;
101}
102
39cfddd2
FT
103#define MAX_SCHEDULE_TIMEOUT LONG_MAX
104
105static inline void
106yield(void)
107{
108 lwkt_yield();
109}
110
be7d0317
FT
111static inline int
112wake_up_process(struct proc *tsk) {
113 /* Among other things, this function is supposed to act as
114 * a barrier */
115 smp_wmb();
116
117 return 0;
118}
119
ce723fce
FT
120static inline int
121signal_pending_state(long state, struct lwp *lp)
122{
123 sigset_t pending_set;
124
125 if (!(state & TASK_INTERRUPTIBLE))
126 return 0;
127
128 pending_set = lwp_sigpend(lp);
129
130 return SIGISMEMBER(pending_set, SIGKILL);
131}
132
ff14819b
FT
133/* Explicit rescheduling in order to reduce latency */
134static inline int
135cond_resched(void)
136{
137 lwkt_yield();
138 return 0;
139}
140
c58e4e0a
FT
141static inline int
142send_sig(int sig, struct proc *p, int priv)
143{
144 ksignal(p, sig);
145 return 0;
146}
147
a34b4168
MD
148static inline void
149set_need_resched(void)
150{
151 /* do nothing for now */
152 /* used on ttm_bo_reserve failures */
153}
154
8c49d0de 155#endif /* _LINUX_SCHED_H_ */