xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/mali400/mali/include/linux/mali/mali_utgard_profiling_gator_api.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2013, 2015-2017 ARM Limited. All rights reserved.
3  *
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  *
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10 
11 #ifndef __MALI_UTGARD_PROFILING_GATOR_API_H__
12 #define __MALI_UTGARD_PROFILING_GATOR_API_H__
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define MALI_PROFILING_API_VERSION 4
19 
20 #define MAX_NUM_L2_CACHE_CORES 3
21 #define MAX_NUM_FP_CORES 8
22 #define MAX_NUM_VP_CORES 1
23 
24 #define _MALI_SPCIAL_COUNTER_DESCRIPTIONS \
25 	{                                           \
26 		"Filmstrip_cnt0",                 \
27 		"Frequency",       \
28 		"Voltage",       \
29 		"vertex",     \
30 		"fragment",         \
31 		"Total_alloc_pages",        \
32 	};
33 
34 #define _MALI_MEM_COUTNER_DESCRIPTIONS \
35 	{                                           \
36 		"untyped_memory",                 \
37 		"vertex_index_buffer",       \
38 		"texture_buffer",       \
39 		"varying_buffer",     \
40 		"render_target",         \
41 		"pbuffer_buffer",        \
42 		"plbu_heap",            \
43 		"pointer_array_buffer",             \
44 		"slave_tilelist",          \
45 		"untyped_gp_cmdlist",     \
46 		"polygon_cmdlist",               \
47 		"texture_descriptor",               \
48 		"render_state_word",               \
49 		"shader",               \
50 		"stream_buffer",               \
51 		"fragment_stack",               \
52 		"uniform",               \
53 		"untyped_frame_pool",               \
54 		"untyped_surface",               \
55 	};
56 
57 /** The list of events supported by the Mali DDK. */
58 typedef enum {
59 	/* Vertex processor activity */
60 	ACTIVITY_VP_0 = 0,
61 
62 	/* Fragment processor activity */
63 	ACTIVITY_FP_0,
64 	ACTIVITY_FP_1,
65 	ACTIVITY_FP_2,
66 	ACTIVITY_FP_3,
67 	ACTIVITY_FP_4,
68 	ACTIVITY_FP_5,
69 	ACTIVITY_FP_6,
70 	ACTIVITY_FP_7,
71 
72 	/* L2 cache counters */
73 	COUNTER_L2_0_C0,
74 	COUNTER_L2_0_C1,
75 	COUNTER_L2_1_C0,
76 	COUNTER_L2_1_C1,
77 	COUNTER_L2_2_C0,
78 	COUNTER_L2_2_C1,
79 
80 	/* Vertex processor counters */
81 	COUNTER_VP_0_C0,
82 	COUNTER_VP_0_C1,
83 
84 	/* Fragment processor counters */
85 	COUNTER_FP_0_C0,
86 	COUNTER_FP_0_C1,
87 	COUNTER_FP_1_C0,
88 	COUNTER_FP_1_C1,
89 	COUNTER_FP_2_C0,
90 	COUNTER_FP_2_C1,
91 	COUNTER_FP_3_C0,
92 	COUNTER_FP_3_C1,
93 	COUNTER_FP_4_C0,
94 	COUNTER_FP_4_C1,
95 	COUNTER_FP_5_C0,
96 	COUNTER_FP_5_C1,
97 	COUNTER_FP_6_C0,
98 	COUNTER_FP_6_C1,
99 	COUNTER_FP_7_C0,
100 	COUNTER_FP_7_C1,
101 
102 	/*
103 	 * If more hardware counters are added, the _mali_osk_hw_counter_table
104 	 * below should also be updated.
105 	 */
106 
107 	/* EGL software counters */
108 	COUNTER_EGL_BLIT_TIME,
109 
110 	/* GLES software counters */
111 	COUNTER_GLES_DRAW_ELEMENTS_CALLS,
112 	COUNTER_GLES_DRAW_ELEMENTS_NUM_INDICES,
113 	COUNTER_GLES_DRAW_ELEMENTS_NUM_TRANSFORMED,
114 	COUNTER_GLES_DRAW_ARRAYS_CALLS,
115 	COUNTER_GLES_DRAW_ARRAYS_NUM_TRANSFORMED,
116 	COUNTER_GLES_DRAW_POINTS,
117 	COUNTER_GLES_DRAW_LINES,
118 	COUNTER_GLES_DRAW_LINE_LOOP,
119 	COUNTER_GLES_DRAW_LINE_STRIP,
120 	COUNTER_GLES_DRAW_TRIANGLES,
121 	COUNTER_GLES_DRAW_TRIANGLE_STRIP,
122 	COUNTER_GLES_DRAW_TRIANGLE_FAN,
123 	COUNTER_GLES_NON_VBO_DATA_COPY_TIME,
124 	COUNTER_GLES_UNIFORM_BYTES_COPIED_TO_MALI,
125 	COUNTER_GLES_UPLOAD_TEXTURE_TIME,
126 	COUNTER_GLES_UPLOAD_VBO_TIME,
127 	COUNTER_GLES_NUM_FLUSHES,
128 	COUNTER_GLES_NUM_VSHADERS_GENERATED,
129 	COUNTER_GLES_NUM_FSHADERS_GENERATED,
130 	COUNTER_GLES_VSHADER_GEN_TIME,
131 	COUNTER_GLES_FSHADER_GEN_TIME,
132 	COUNTER_GLES_INPUT_TRIANGLES,
133 	COUNTER_GLES_VXCACHE_HIT,
134 	COUNTER_GLES_VXCACHE_MISS,
135 	COUNTER_GLES_VXCACHE_COLLISION,
136 	COUNTER_GLES_CULLED_TRIANGLES,
137 	COUNTER_GLES_CULLED_LINES,
138 	COUNTER_GLES_BACKFACE_TRIANGLES,
139 	COUNTER_GLES_GBCLIP_TRIANGLES,
140 	COUNTER_GLES_GBCLIP_LINES,
141 	COUNTER_GLES_TRIANGLES_DRAWN,
142 	COUNTER_GLES_DRAWCALL_TIME,
143 	COUNTER_GLES_TRIANGLES_COUNT,
144 	COUNTER_GLES_INDEPENDENT_TRIANGLES_COUNT,
145 	COUNTER_GLES_STRIP_TRIANGLES_COUNT,
146 	COUNTER_GLES_FAN_TRIANGLES_COUNT,
147 	COUNTER_GLES_LINES_COUNT,
148 	COUNTER_GLES_INDEPENDENT_LINES_COUNT,
149 	COUNTER_GLES_STRIP_LINES_COUNT,
150 	COUNTER_GLES_LOOP_LINES_COUNT,
151 
152 	/* Special counter */
153 
154 	/* Framebuffer capture pseudo-counter */
155 	COUNTER_FILMSTRIP,
156 	COUNTER_FREQUENCY,
157 	COUNTER_VOLTAGE,
158 	COUNTER_VP_ACTIVITY,
159 	COUNTER_FP_ACTIVITY,
160 	COUNTER_TOTAL_ALLOC_PAGES,
161 
162 	/* Memory usage counter */
163 	COUNTER_MEM_UNTYPED,
164 	COUNTER_MEM_VB_IB,
165 	COUNTER_MEM_TEXTURE,
166 	COUNTER_MEM_VARYING,
167 	COUNTER_MEM_RT,
168 	COUNTER_MEM_PBUFFER,
169 	/* memory usages for gp command */
170 	COUNTER_MEM_PLBU_HEAP,
171 	COUNTER_MEM_POINTER_ARRAY,
172 	COUNTER_MEM_SLAVE_TILELIST,
173 	COUNTER_MEM_UNTYPE_GP_CMDLIST,
174 	/* memory usages for polygon list command */
175 	COUNTER_MEM_POLYGON_CMDLIST,
176 	/* memory usages for pp command */
177 	COUNTER_MEM_TD,
178 	COUNTER_MEM_RSW,
179 	/* other memory usages */
180 	COUNTER_MEM_SHADER,
181 	COUNTER_MEM_STREAMS,
182 	COUNTER_MEM_FRAGMENT_STACK,
183 	COUNTER_MEM_UNIFORM,
184 	/* Special mem usage, which is used for mem pool allocation */
185 	COUNTER_MEM_UNTYPE_MEM_POOL,
186 	COUNTER_MEM_UNTYPE_SURFACE,
187 
188 	NUMBER_OF_EVENTS
189 } _mali_osk_counter_id;
190 
191 #define FIRST_ACTIVITY_EVENT    ACTIVITY_VP_0
192 #define LAST_ACTIVITY_EVENT     ACTIVITY_FP_7
193 
194 #define FIRST_HW_COUNTER        COUNTER_L2_0_C0
195 #define LAST_HW_COUNTER         COUNTER_FP_7_C1
196 
197 #define FIRST_SW_COUNTER        COUNTER_EGL_BLIT_TIME
198 #define LAST_SW_COUNTER         COUNTER_GLES_LOOP_LINES_COUNT
199 
200 #define FIRST_SPECIAL_COUNTER   COUNTER_FILMSTRIP
201 #define LAST_SPECIAL_COUNTER    COUNTER_TOTAL_ALLOC_PAGES
202 
203 #define FIRST_MEM_COUNTER               COUNTER_MEM_UNTYPED
204 #define LAST_MEM_COUNTER                COUNTER_MEM_UNTYPE_SURFACE
205 
206 #define MALI_PROFILING_MEM_COUNTERS_NUM (LAST_MEM_COUNTER - FIRST_MEM_COUNTER + 1)
207 #define MALI_PROFILING_SPECIAL_COUNTERS_NUM     (LAST_SPECIAL_COUNTER - FIRST_SPECIAL_COUNTER + 1)
208 #define MALI_PROFILING_SW_COUNTERS_NUM  (LAST_SW_COUNTER - FIRST_SW_COUNTER + 1)
209 
210 /**
211  * Define the stream header type for porfiling stream.
212  */
213 #define  STREAM_HEADER_FRAMEBUFFER 0x05         /* The stream packet header type for framebuffer dumping. */
214 #define STREAM_HEADER_COUNTER_VALUE  0x09       /* The stream packet header type for hw/sw/memory counter sampling. */
215 #define STREAM_HEADER_CORE_ACTIVITY 0x0a                /* The stream packet header type for activity counter sampling. */
216 #define STREAM_HEADER_SIZE      5
217 
218 /**
219  * Define the packet header type of profiling control packet.
220  */
221 #define PACKET_HEADER_ERROR            0x80             /* The response packet header type if error. */
222 #define PACKET_HEADER_ACK              0x81             /* The response packet header type if OK. */
223 #define PACKET_HEADER_COUNTERS_REQUEST 0x82             /* The control packet header type to request counter information from ddk. */
224 #define PACKET_HEADER_COUNTERS_ACK         0x83         /* The response packet header type to send out counter information. */
225 #define PACKET_HEADER_COUNTERS_ENABLE  0x84             /* The control packet header type to enable counters. */
226 #define PACKET_HEADER_START_CAPTURE_VALUE            0x85               /* The control packet header type to start capture values. */
227 
228 #define PACKET_HEADER_SIZE      5
229 
230 /**
231  * Structure to pass performance counter data of a Mali core
232  */
233 typedef struct _mali_profiling_core_counters {
234 	u32 source0;
235 	u32 value0;
236 	u32 source1;
237 	u32 value1;
238 } _mali_profiling_core_counters;
239 
240 /**
241  * Structure to pass performance counter data of Mali L2 cache cores
242  */
243 typedef struct _mali_profiling_l2_counter_values {
244 	struct _mali_profiling_core_counters cores[MAX_NUM_L2_CACHE_CORES];
245 } _mali_profiling_l2_counter_values;
246 
247 /**
248  * Structure to pass data defining Mali instance in use:
249  *
250  * mali_product_id - Mali product id
251  * mali_version_major - Mali version major number
252  * mali_version_minor - Mali version minor number
253  * num_of_l2_cores - number of L2 cache cores
254  * num_of_fp_cores - number of fragment processor cores
255  * num_of_vp_cores - number of vertex processor cores
256  */
257 typedef struct _mali_profiling_mali_version {
258 	u32 mali_product_id;
259 	u32 mali_version_major;
260 	u32 mali_version_minor;
261 	u32 num_of_l2_cores;
262 	u32 num_of_fp_cores;
263 	u32 num_of_vp_cores;
264 } _mali_profiling_mali_version;
265 
266 /**
267  * Structure to define the mali profiling counter struct.
268  */
269 typedef struct mali_profiling_counter {
270 	char counter_name[40];
271 	u32 counter_id;
272 	u32 counter_event;
273 	u32 prev_counter_value;
274 	u32 current_counter_value;
275 	u32 key;
276 	int enabled;
277 } mali_profiling_counter;
278 
279 /*
280  * List of possible actions to be controlled by Streamline.
281  * The following numbers are used by gator to control the frame buffer dumping and s/w counter reporting.
282  * We cannot use the enums in mali_uk_types.h because they are unknown inside gator.
283  */
284 #define FBDUMP_CONTROL_ENABLE (1)
285 #define FBDUMP_CONTROL_RATE (2)
286 #define SW_COUNTER_ENABLE (3)
287 #define FBDUMP_CONTROL_RESIZE_FACTOR (4)
288 #define MEM_COUNTER_ENABLE (5)
289 #define ANNOTATE_PROFILING_ENABLE (6)
290 
291 void _mali_profiling_control(u32 action, u32 value);
292 
293 u32 _mali_profiling_get_l2_counters(_mali_profiling_l2_counter_values *values);
294 
295 int _mali_profiling_set_event(u32 counter_id, s32 event_id);
296 
297 u32 _mali_profiling_get_api_version(void);
298 
299 void _mali_profiling_get_mali_version(struct _mali_profiling_mali_version *values);
300 
301 #ifdef __cplusplus
302 }
303 #endif
304 
305 #endif /* __MALI_UTGARD_PROFILING_GATOR_API_H__ */
306