2 * Copyright 2012-16 Advanced Micro Devices, Inc.
3 * Copyright 2019 Raptor Engineering, LLC
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
30 #include <linux/kgdb.h>
31 #include <linux/kref.h>
32 #include <linux/types.h>
33 #include <linux/slab.h>
35 #include <asm/byteorder.h>
37 #include <drm/drm_print.h>
39 #include "cgs_common.h"
41 #if defined(__BIG_ENDIAN) && !defined(BIGENDIAN_CPU)
43 #elif defined(__LITTLE_ENDIAN) && !defined(LITTLEENDIAN_CPU)
44 #define LITTLEENDIAN_CPU
49 #define dm_output_to_console(fmt, ...) DRM_DEBUG_KMS(fmt, ##__VA_ARGS__)
51 #define dm_error(fmt, ...) DRM_ERROR(fmt, ##__VA_ARGS__)
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_PPC64)
59 #include <asm/switch_to.h>
60 #include <asm/cputable.h>
61 #define DC_FP_START() { \
62 if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
64 enable_kernel_vsx(); \
65 } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
67 enable_kernel_altivec(); \
68 } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
73 #define DC_FP_END() { \
74 if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
75 disable_kernel_vsx(); \
77 } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
78 disable_kernel_altivec(); \
80 } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
81 disable_kernel_fp(); \
90 * general debug capabilities
93 #if defined(CONFIG_HAVE_KGDB) || defined(CONFIG_KGDB)
94 #define ASSERT_CRITICAL(expr) do { \
95 if (WARN_ON(!(expr))) { \
100 #define ASSERT_CRITICAL(expr) do { \
101 if (WARN_ON(!(expr))) { \
107 #if defined(CONFIG_DEBUG_KERNEL_DC)
108 #define ASSERT(expr) ASSERT_CRITICAL(expr)
111 #define ASSERT(expr) WARN_ON_ONCE(!(expr))
114 #define BREAK_TO_DEBUGGER() ASSERT(0)
116 #define DC_ERR(...) do { \
117 dm_error(__VA_ARGS__); \
118 BREAK_TO_DEBUGGER(); \
121 #endif /* _OS_TYPES_H_ */