xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/debug/mali_kbase_debug_ktrace_internal.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2020-2021 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 #ifndef _KBASE_DEBUG_KTRACE_INTERNAL_H_
23 #define _KBASE_DEBUG_KTRACE_INTERNAL_H_
24 
25 #if KBASE_KTRACE_TARGET_RBUF
26 
27 #define KTRACE_DUMP_MESSAGE_SIZE 256
28 
29 /**
30  * kbasep_ktrace_backend_format_header - format the backend part of the header
31  * @buffer:    buffer to write to
32  * @sz:        size of @buffer in bytes
33  * @written:   pointer to storage for updating bytes written so far to @buffer
34  *
35  * The backend must format only the non-common backend specific parts of the
36  * header. It must format them as though they were standalone. The caller will
37  * handle adding any delimiters around this.
38  */
39 void kbasep_ktrace_backend_format_header(char *buffer, int sz, s32 *written);
40 
41 /**
42  * kbasep_ktrace_backend_format_msg - format the backend part of the message
43  * @trace_msg: ktrace message
44  * @buffer:    buffer to write to
45  * @sz:        size of @buffer in bytes
46  * @written:   pointer to storage for updating bytes written so far to @buffer
47  *
48  * The backend must format only the non-common backend specific parts of the
49  * message. It must format them as though they were standalone. The caller will
50  * handle adding any delimiters around this.
51  *
52  * A caller may have the flags member of @trace_msg with
53  * %KBASE_KTRACE_FLAG_BACKEND clear. The backend must handle that setting
54  * appropriately.
55  */
56 void kbasep_ktrace_backend_format_msg(struct kbase_ktrace_msg *trace_msg,
57 		char *buffer, int sz, s32 *written);
58 
59 
60 /**
61  * kbasep_ktrace_reserve - internal function to reserve space for a ktrace
62  *                         message
63  * @ktrace: kbase device's ktrace
64  *
65  * This may also empty the oldest entry in the ringbuffer to make space.
66  *
67  * Return: ktrace message
68  */
69 struct kbase_ktrace_msg *kbasep_ktrace_reserve(struct kbase_ktrace *ktrace);
70 
71 /**
72  * kbasep_ktrace_msg_init - internal function to initialize just the common
73  *                          part of a ktrace message
74  * @ktrace:    kbase device's ktrace
75  * @trace_msg: ktrace message to initialize
76  * @code:      ktrace code
77  * @kctx:      kbase context, or NULL if no context
78  * @flags:     flags about the message
79  * @info_val:  generic information about @code to add to the trace
80  *
81  * The common part includes the mandatory parts of the backend part
82  */
83 void kbasep_ktrace_msg_init(struct kbase_ktrace *ktrace,
84 		struct kbase_ktrace_msg *trace_msg, enum kbase_ktrace_code code,
85 		struct kbase_context *kctx, kbase_ktrace_flag_t flags,
86 		u64 info_val);
87 
88 #endif /* KBASE_KTRACE_TARGET_RBUF */
89 
90 #endif /* _KBASE_DEBUG_KTRACE_INTERNAL_H_ */
91