xref: /dflybsd-src/sys/dev/drm/include/linux/smp.h (revision 1382b9d01ca490a8b6800a3693a80e3b35744ebe)
1111dab5bSFrançois Tigeot /*
24757df22SFrançois Tigeot  * Copyright (c) 2019-2020 François Tigeot <ftigeot@wolfpond.org>
3111dab5bSFrançois Tigeot  * All rights reserved.
4111dab5bSFrançois Tigeot  *
5111dab5bSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6111dab5bSFrançois Tigeot  * modification, are permitted provided that the following conditions
7111dab5bSFrançois Tigeot  * are met:
8111dab5bSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9111dab5bSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10111dab5bSFrançois Tigeot  *    disclaimer.
11111dab5bSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12111dab5bSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13111dab5bSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14111dab5bSFrançois Tigeot  *
15111dab5bSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16111dab5bSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17111dab5bSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18111dab5bSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19111dab5bSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20111dab5bSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21111dab5bSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22111dab5bSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23111dab5bSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24111dab5bSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25111dab5bSFrançois Tigeot  */
26111dab5bSFrançois Tigeot 
27111dab5bSFrançois Tigeot #ifndef _LINUX_SMP_H_
28111dab5bSFrançois Tigeot #define _LINUX_SMP_H_
29111dab5bSFrançois Tigeot 
30111dab5bSFrançois Tigeot #include <linux/errno.h>
31111dab5bSFrançois Tigeot #include <linux/types.h>
32111dab5bSFrançois Tigeot #include <linux/list.h>
33111dab5bSFrançois Tigeot #include <linux/cpumask.h>
34111dab5bSFrançois Tigeot #include <linux/init.h>
35*1382b9d0SFrançois Tigeot #include <linux/llist.h>
36111dab5bSFrançois Tigeot 
37111dab5bSFrançois Tigeot #include <linux/preempt.h>
384757df22SFrançois Tigeot #include <linux/kernel.h>
394757df22SFrançois Tigeot #include <linux/compiler.h>
404757df22SFrançois Tigeot #include <linux/thread_info.h>
41111dab5bSFrançois Tigeot 
smp_processor_id(void)42111dab5bSFrançois Tigeot static inline uint32_t smp_processor_id(void)
43111dab5bSFrançois Tigeot {
44111dab5bSFrançois Tigeot 	return mycpuid;
45111dab5bSFrançois Tigeot }
46111dab5bSFrançois Tigeot 
get_cpu(void)47111dab5bSFrançois Tigeot static inline uint32_t get_cpu(void)
48111dab5bSFrançois Tigeot {
49111dab5bSFrançois Tigeot 	preempt_disable();
50111dab5bSFrançois Tigeot 
51111dab5bSFrançois Tigeot 	/* Regular DragonFly kernel threads always run on the same CPU */
52111dab5bSFrançois Tigeot 	return 0;
53111dab5bSFrançois Tigeot }
54111dab5bSFrançois Tigeot 
55111dab5bSFrançois Tigeot #define put_cpu()	preempt_enable()
56111dab5bSFrançois Tigeot 
57111dab5bSFrançois Tigeot #endif	/* _LINUX_SMP_H_ */
58