xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/debug/backend/mali_kbase_debug_ktrace_defs_csf.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2020-2022 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_DEFS_CSF_H_
23 #define _KBASE_DEBUG_KTRACE_DEFS_CSF_H_
24 
25 #if KBASE_KTRACE_TARGET_RBUF
26 /**
27  * DOC: KTrace version history, CSF variant
28  *
29  * 1.0:
30  * First version, with version information in the header.
31  *
32  * 1.1:
33  * kctx field is no longer a pointer, and is now an ID of the format %d_%u as
34  * used by kctx directories in mali debugfs entries: (tgid creating the kctx),
35  * (unique kctx id)
36  *
37  * ftrace backend now outputs kctx field (as %d_%u format).
38  *
39  * Add fields group, slot, prio, csi into backend-specific part.
40  *
41  * 1.2:
42  * There is a new class of KCPU traces; with this, a new KCPU column in the
43  * ringbuffer RBUF (mali_trace) between csi and info_val, which is empty
44  * for non-kcpu related traces, and usually displays the KCPU Queue ID and
45  * an extra information value. ftrace also displays these KCPU traces.
46  *
47  * 1.3:
48  * Add a lot of extra new traces. Tweak some existing scheduler related traces
49  * to contain extra information information/happen at slightly different times.
50  * SCHEDULER_PROTM_EXIT now has group information
51  */
52 #define KBASE_KTRACE_VERSION_MAJOR 1
53 #define KBASE_KTRACE_VERSION_MINOR 3
54 
55 /* indicates if the trace message has valid queue-group related info. */
56 #define KBASE_KTRACE_FLAG_CSF_GROUP     (((kbase_ktrace_flag_t)1) << 0)
57 
58 /* indicates if the trace message has valid queue related info. */
59 #define KBASE_KTRACE_FLAG_CSF_QUEUE     (((kbase_ktrace_flag_t)1) << 1)
60 
61 /* indicates if the trace message has valid KCPU-queue related info. */
62 #define KBASE_KTRACE_FLAG_CSF_KCPU     (((kbase_ktrace_flag_t)1) << 2)
63 
64 /* Collect all the flags together for debug checking */
65 #define KBASE_KTRACE_FLAG_BACKEND_ALL \
66 		(KBASE_KTRACE_FLAG_CSF_GROUP | KBASE_KTRACE_FLAG_CSF_QUEUE | \
67 		 KBASE_KTRACE_FLAG_CSF_KCPU)
68 
69 /**
70  * union kbase_ktrace_backend - backend specific part of a trace message
71  * @kcpu:           kcpu union member
72  * @kcpu.code:      Identifies the event, refer to enum kbase_ktrace_code.
73  * @kcpu.flags:     indicates information about the trace message itself. Used
74  *                  during dumping of the message.
75  * @kcpu.id:        ID of the KCPU queue.
76  * @kcpu.extra_info_val: value specific to the type of KCPU event being traced.
77  *                  Refer to the KPU specific code in enum kbase_ktrace_code in
78  *                  mali_kbase_debug_ktrace_codes_csf.h
79  * @gpu:            gpu union member
80  * @gpu.code:       Identifies the event, refer to enum kbase_ktrace_code.
81  * @gpu.flags:      indicates information about the trace message itself. Used
82  *                  during dumping of the message.
83  * @gpu.group_handle: Handle identifying the associated queue group. Only valid
84  *                  when @flags contains KBASE_KTRACE_FLAG_CSF_GROUP.
85  * @gpu.csg_nr:     Number/index of the associated queue group's CS group to
86  *                  which it is mapped, or negative if none associated. Only
87  *                  valid when @flags contains KBASE_KTRACE_FLAG_CSF_GROUP.
88  * @gpu.slot_prio:  The priority of the slot for the associated group, if it
89  *                  was scheduled. Hence, only valid when @csg_nr >=0 and
90  *                  @flags contains KBASE_KTRACE_FLAG_CSF_GROUP.
91  * @gpu.csi_index:  ID of the associated queue's CS HW interface.
92  *                  Only valid when @flags contains KBASE_KTRACE_FLAG_CSF_QUEUE.
93  */
94 
95 union kbase_ktrace_backend {
96 	/* Place 64 and 32-bit members together */
97 	/* Pack smaller members together */
98 	struct {
99 		kbase_ktrace_code_t code;
100 		kbase_ktrace_flag_t flags;
101 		u8 id;
102 		u64 extra_info_val;
103 	} kcpu;
104 
105 	struct {
106 		kbase_ktrace_code_t code;
107 		kbase_ktrace_flag_t flags;
108 		u8 group_handle;
109 		s8 csg_nr;
110 		u8 slot_prio;
111 		s8 csi_index;
112 	} gpu;
113 };
114 
115 #endif /* KBASE_KTRACE_TARGET_RBUF */
116 #endif /* _KBASE_DEBUG_KTRACE_DEFS_CSF_H_ */
117