xref: /openbsd/sys/dev/pci/drm/include/linux/sched.h (revision 53e1df33)
1 /*	$OpenBSD: sched.h,v 1.5 2023/03/21 09:44:35 jsg Exp $	*/
2 /*
3  * Copyright (c) 2013, 2014, 2015 Mark Kettenis
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _LINUX_SCHED_H
19 #define _LINUX_SCHED_H
20 
21 #include <sys/param.h>
22 #include <sys/systm.h>
23 #include <sys/kernel.h>
24 #include <sys/stdint.h>
25 #include <sys/mutex.h>
26 #include <linux/hrtimer.h>
27 #include <linux/sem.h>
28 
29 #define TASK_NORMAL		1
30 #define TASK_UNINTERRUPTIBLE	0
31 #define TASK_INTERRUPTIBLE	PCATCH
32 #define TASK_RUNNING		-1
33 
34 #define MAX_SCHEDULE_TIMEOUT	(INT32_MAX)
35 
36 #define TASK_COMM_LEN		(MAXCOMLEN + 1)
37 
38 #define cond_resched()		sched_pause(yield)
39 #define drm_need_resched() \
40     (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD)
41 
42 static inline int
cond_resched_lock(struct mutex * mtxp)43 cond_resched_lock(struct mutex *mtxp)
44 {
45 	if (drm_need_resched() == 0)
46 		return 0;
47 
48 	mtx_leave(mtxp);
49 	cond_resched();
50 	mtx_enter(mtxp);
51 
52 	return 1;
53 }
54 
55 void set_current_state(int);
56 void __set_current_state(int);
57 void schedule(void);
58 long schedule_timeout(long);
59 long schedule_timeout_uninterruptible(long);
60 
61 #define io_schedule_timeout(x)	schedule_timeout(x)
62 
63 struct proc;
64 int wake_up_process(struct proc *p);
65 
66 #endif
67