xref: /linux/drivers/gpu/drm/xe/xe_guc_log.h (revision 24168c5e6dfbdd5b414f048f47f75d64533296ca)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #ifndef _XE_GUC_LOG_H_
7 #define _XE_GUC_LOG_H_
8 
9 #include "xe_guc_log_types.h"
10 
11 struct drm_printer;
12 
13 #if IS_ENABLED(CONFIG_DRM_XE_LARGE_GUC_BUFFER)
14 #define CRASH_BUFFER_SIZE       SZ_1M
15 #define DEBUG_BUFFER_SIZE       SZ_8M
16 #define CAPTURE_BUFFER_SIZE     SZ_2M
17 #else
18 #define CRASH_BUFFER_SIZE	SZ_8K
19 #define DEBUG_BUFFER_SIZE	SZ_64K
20 #define CAPTURE_BUFFER_SIZE	SZ_16K
21 #endif
22 /*
23  * While we're using plain log level in i915, GuC controls are much more...
24  * "elaborate"? We have a couple of bits for verbosity, separate bit for actual
25  * log enabling, and separate bit for default logging - which "conveniently"
26  * ignores the enable bit.
27  */
28 #define GUC_LOG_LEVEL_DISABLED		0
29 #define GUC_LOG_LEVEL_NON_VERBOSE	1
30 #define GUC_LOG_LEVEL_IS_ENABLED(x)	((x) > GUC_LOG_LEVEL_DISABLED)
31 #define GUC_LOG_LEVEL_IS_VERBOSE(x)	((x) > GUC_LOG_LEVEL_NON_VERBOSE)
32 #define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({		\
33 	typeof(x) _x = (x);				\
34 	GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0;	\
35 })
36 #define GUC_VERBOSITY_TO_LOG_LEVEL(x)	((x) + 2)
37 #define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)
38 
39 int xe_guc_log_init(struct xe_guc_log *log);
40 void xe_guc_log_print(struct xe_guc_log *log, struct drm_printer *p);
41 
42 static inline u32
43 xe_guc_log_get_level(struct xe_guc_log *log)
44 {
45 	return log->level;
46 }
47 
48 #endif
49