Merge tag 'x86_seves_for_v5.10_rc3' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / dc / os_types.h
1 /*
2  * Copyright 2012-16 Advanced Micro Devices, Inc.
3  * Copyright 2019 Raptor Engineering, LLC
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * Authors: AMD
24  *
25  */
26
27 #ifndef _OS_TYPES_H_
28 #define _OS_TYPES_H_
29
30 #include <linux/kgdb.h>
31 #include <linux/kref.h>
32 #include <linux/types.h>
33 #include <linux/slab.h>
34
35 #include <asm/byteorder.h>
36
37 #include <drm/drm_print.h>
38
39 #include "cgs_common.h"
40
41 #if defined(__BIG_ENDIAN) && !defined(BIGENDIAN_CPU)
42 #define BIGENDIAN_CPU
43 #elif defined(__LITTLE_ENDIAN) && !defined(LITTLEENDIAN_CPU)
44 #define LITTLEENDIAN_CPU
45 #endif
46
47 #undef FRAME_SIZE
48
49 #define dm_output_to_console(fmt, ...) DRM_DEBUG_KMS(fmt, ##__VA_ARGS__)
50
51 #define dm_error(fmt, ...) DRM_ERROR(fmt, ##__VA_ARGS__)
52
53 #if defined(CONFIG_DRM_AMD_DC_DCN)
54 #if defined(CONFIG_X86)
55 #include <asm/fpu/api.h>
56 #define DC_FP_START() kernel_fpu_begin()
57 #define DC_FP_END() kernel_fpu_end()
58 #elif defined(CONFIG_ARM64)
59 #include <asm/neon.h>
60 #define DC_FP_START() kernel_neon_begin()
61 #define DC_FP_END() kernel_neon_end()
62 #elif defined(CONFIG_PPC64)
63 #include <asm/switch_to.h>
64 #include <asm/cputable.h>
65 #define DC_FP_START() { \
66         if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
67                 preempt_disable(); \
68                 enable_kernel_vsx(); \
69         } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
70                 preempt_disable(); \
71                 enable_kernel_altivec(); \
72         } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
73                 preempt_disable(); \
74                 enable_kernel_fp(); \
75         } \
76 }
77 #define DC_FP_END() { \
78         if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
79                 disable_kernel_vsx(); \
80                 preempt_enable(); \
81         } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
82                 disable_kernel_altivec(); \
83                 preempt_enable(); \
84         } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
85                 disable_kernel_fp(); \
86                 preempt_enable(); \
87         } \
88 }
89 #endif
90 #endif
91
92 /*
93  *
94  * general debug capabilities
95  *
96  */
97 #ifdef CONFIG_DEBUG_KERNEL_DC
98 #define dc_breakpoint()         kgdb_breakpoint()
99 #else
100 #define dc_breakpoint()         do {} while (0)
101 #endif
102
103 #define ASSERT_CRITICAL(expr) do {              \
104                 if (WARN_ON(!(expr)))           \
105                         dc_breakpoint();        \
106         } while (0)
107
108 #define ASSERT(expr) do {                       \
109                 if (WARN_ON_ONCE(!(expr)))      \
110                         dc_breakpoint();        \
111         } while (0)
112
113 #define BREAK_TO_DEBUGGER() \
114         do { \
115                 DRM_DEBUG_DRIVER("%s():%d\n", __func__, __LINE__); \
116                 dc_breakpoint(); \
117         } while (0)
118
119 #define DC_ERR(...)  do { \
120         dm_error(__VA_ARGS__); \
121         BREAK_TO_DEBUGGER(); \
122 } while (0)
123
124 #endif /* _OS_TYPES_H_ */