diff options
Diffstat (limited to 'driver/gator_events_mali_t6xx.c')
-rw-r--r-- | driver/gator_events_mali_t6xx.c | 716 |
1 files changed, 338 insertions, 378 deletions
diff --git a/driver/gator_events_mali_t6xx.c b/driver/gator_events_mali_t6xx.c index f8f868e..1b3a53d 100644 --- a/driver/gator_events_mali_t6xx.c +++ b/driver/gator_events_mali_t6xx.c | |||
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | #include "linux/mali_linux_trace.h" | 18 | #include "linux/mali_linux_trace.h" |
19 | 19 | ||
20 | |||
21 | #include "gator_events_mali_common.h" | 20 | #include "gator_events_mali_common.h" |
22 | 21 | ||
23 | /* | 22 | /* |
@@ -27,7 +26,6 @@ | |||
27 | #error MALI_SUPPORT set to an invalid device code: expecting MALI_T6xx | 26 | #error MALI_SUPPORT set to an invalid device code: expecting MALI_T6xx |
28 | #endif | 27 | #endif |
29 | 28 | ||
30 | |||
31 | /* Counters for Mali-T6xx: | 29 | /* Counters for Mali-T6xx: |
32 | * | 30 | * |
33 | * - Timeline events | 31 | * - Timeline events |
@@ -43,72 +41,66 @@ | |||
43 | */ | 41 | */ |
44 | 42 | ||
45 | /* Timeline (start/stop) activity */ | 43 | /* Timeline (start/stop) activity */ |
46 | static const char* timeline_event_names [] = | 44 | static const char *timeline_event_names[] = { |
47 | { | 45 | "PM_SHADER_0", |
48 | "PM_SHADER_0", | 46 | "PM_SHADER_1", |
49 | "PM_SHADER_1", | 47 | "PM_SHADER_2", |
50 | "PM_SHADER_2", | 48 | "PM_SHADER_3", |
51 | "PM_SHADER_3", | 49 | "PM_SHADER_4", |
52 | "PM_SHADER_4", | 50 | "PM_SHADER_5", |
53 | "PM_SHADER_5", | 51 | "PM_SHADER_6", |
54 | "PM_SHADER_6", | 52 | "PM_SHADER_7", |
55 | "PM_SHADER_7", | 53 | "PM_TILER_0", |
56 | "PM_TILER_0", | 54 | "PM_L2_0", |
57 | "PM_L2_0", | 55 | "PM_L2_1", |
58 | "PM_L2_1", | 56 | "MMU_AS_0", |
59 | "MMU_AS_0", | 57 | "MMU_AS_1", |
60 | "MMU_AS_1", | 58 | "MMU_AS_2", |
61 | "MMU_AS_2", | 59 | "MMU_AS_3" |
62 | "MMU_AS_3" | ||
63 | }; | 60 | }; |
64 | 61 | ||
65 | enum | 62 | enum { |
66 | { | 63 | PM_SHADER_0 = 0, |
67 | PM_SHADER_0 = 0, | 64 | PM_SHADER_1, |
68 | PM_SHADER_1, | 65 | PM_SHADER_2, |
69 | PM_SHADER_2, | 66 | PM_SHADER_3, |
70 | PM_SHADER_3, | 67 | PM_SHADER_4, |
71 | PM_SHADER_4, | 68 | PM_SHADER_5, |
72 | PM_SHADER_5, | 69 | PM_SHADER_6, |
73 | PM_SHADER_6, | 70 | PM_SHADER_7, |
74 | PM_SHADER_7, | 71 | PM_TILER_0, |
75 | PM_TILER_0, | 72 | PM_L2_0, |
76 | PM_L2_0, | 73 | PM_L2_1, |
77 | PM_L2_1, | 74 | MMU_AS_0, |
78 | MMU_AS_0, | 75 | MMU_AS_1, |
79 | MMU_AS_1, | 76 | MMU_AS_2, |
80 | MMU_AS_2, | 77 | MMU_AS_3 |
81 | MMU_AS_3 | ||
82 | }; | 78 | }; |
83 | /* The number of shader blocks in the enum above */ | 79 | /* The number of shader blocks in the enum above */ |
84 | #define NUM_PM_SHADER (8) | 80 | #define NUM_PM_SHADER (8) |
85 | 81 | ||
86 | /* Software Counters */ | 82 | /* Software Counters */ |
87 | static const char* software_counter_names [] = | 83 | static const char *software_counter_names[] = { |
88 | { | 84 | "MMU_PAGE_FAULT_0", |
89 | "MMU_PAGE_FAULT_0", | 85 | "MMU_PAGE_FAULT_1", |
90 | "MMU_PAGE_FAULT_1", | 86 | "MMU_PAGE_FAULT_2", |
91 | "MMU_PAGE_FAULT_2", | 87 | "MMU_PAGE_FAULT_3" |
92 | "MMU_PAGE_FAULT_3" | ||
93 | }; | 88 | }; |
94 | 89 | ||
95 | enum | 90 | enum { |
96 | { | 91 | MMU_PAGE_FAULT_0 = 0, |
97 | MMU_PAGE_FAULT_0 = 0, | 92 | MMU_PAGE_FAULT_1, |
98 | MMU_PAGE_FAULT_1, | 93 | MMU_PAGE_FAULT_2, |
99 | MMU_PAGE_FAULT_2, | 94 | MMU_PAGE_FAULT_3 |
100 | MMU_PAGE_FAULT_3 | ||
101 | }; | 95 | }; |
102 | 96 | ||
103 | /* Software Counters */ | 97 | /* Software Counters */ |
104 | static const char* accumulators_names [] = | 98 | static const char *accumulators_names[] = { |
105 | { | 99 | "TOTAL_ALLOC_PAGES" |
106 | "TOTAL_ALLOC_PAGES" | ||
107 | }; | 100 | }; |
108 | 101 | ||
109 | enum | 102 | enum { |
110 | { | 103 | TOTAL_ALLOC_PAGES = 0 |
111 | TOTAL_ALLOC_PAGES = 0 | ||
112 | }; | 104 | }; |
113 | 105 | ||
114 | #define FIRST_TIMELINE_EVENT (0) | 106 | #define FIRST_TIMELINE_EVENT (0) |
@@ -153,49 +145,46 @@ static struct timespec prev_timestamp; | |||
153 | */ | 145 | */ |
154 | static inline long get_duration_us(const struct timespec *start, const struct timespec *end) | 146 | static inline long get_duration_us(const struct timespec *start, const struct timespec *end) |
155 | { | 147 | { |
156 | long event_duration_us = (end->tv_nsec - start->tv_nsec)/1000; | 148 | long event_duration_us = (end->tv_nsec - start->tv_nsec) / 1000; |
157 | event_duration_us += (end->tv_sec - start->tv_sec) * 1000000; | 149 | event_duration_us += (end->tv_sec - start->tv_sec) * 1000000; |
158 | 150 | ||
159 | return event_duration_us; | 151 | return event_duration_us; |
160 | } | 152 | } |
161 | 153 | ||
162 | static void record_timeline_event(unsigned int timeline_index, unsigned int type) | 154 | static void record_timeline_event(unsigned int timeline_index, unsigned int type) |
163 | { | 155 | { |
164 | struct timespec event_timestamp; | 156 | struct timespec event_timestamp; |
165 | struct timespec *event_start = &timeline_event_starttime[timeline_index]; | 157 | struct timespec *event_start = &timeline_event_starttime[timeline_index]; |
166 | 158 | ||
167 | switch(type) | 159 | switch (type) { |
168 | { | 160 | case ACTIVITY_START: |
169 | case ACTIVITY_START: | 161 | /* Get the event time... */ |
170 | /* Get the event time... */ | 162 | getnstimeofday(&event_timestamp); |
171 | getnstimeofday(&event_timestamp); | 163 | |
172 | 164 | /* Remember the start time if the activity is not already started */ | |
173 | /* Remember the start time if the activity is not already started */ | 165 | if (event_start->tv_sec == 0) { |
174 | if(event_start->tv_sec == 0) | 166 | *event_start = event_timestamp; /* Structure copy */ |
175 | { | 167 | } |
176 | *event_start = event_timestamp; /* Structure copy */ | 168 | break; |
177 | } | 169 | |
178 | break; | 170 | case ACTIVITY_STOP: |
179 | 171 | /* if the counter was started... */ | |
180 | case ACTIVITY_STOP: | 172 | if (event_start->tv_sec != 0) { |
181 | /* if the counter was started... */ | 173 | /* Get the event time... */ |
182 | if(event_start->tv_sec != 0) | 174 | getnstimeofday(&event_timestamp); |
183 | { | 175 | |
184 | /* Get the event time... */ | 176 | /* Accumulate the duration in us */ |
185 | getnstimeofday(&event_timestamp); | 177 | timeline_data[timeline_index] += get_duration_us(event_start, &event_timestamp); |
186 | 178 | ||
187 | /* Accumulate the duration in us */ | 179 | /* Reset the start time to indicate the activity is stopped. */ |
188 | timeline_data[timeline_index] += get_duration_us(event_start, &event_timestamp); | 180 | event_start->tv_sec = 0; |
189 | 181 | } | |
190 | /* Reset the start time to indicate the activity is stopped. */ | 182 | break; |
191 | event_start->tv_sec = 0; | 183 | |
192 | } | 184 | default: |
193 | break; | 185 | /* Other activity events are ignored. */ |
194 | 186 | break; | |
195 | default: | 187 | } |
196 | /* Other activity events are ignored. */ | ||
197 | break; | ||
198 | } | ||
199 | } | 188 | } |
200 | 189 | ||
201 | /* | 190 | /* |
@@ -204,68 +193,62 @@ static void record_timeline_event(unsigned int timeline_index, unsigned int type | |||
204 | 193 | ||
205 | GATOR_DEFINE_PROBE(mali_pm_status, TP_PROTO(unsigned int event_id, unsigned long long value)) | 194 | GATOR_DEFINE_PROBE(mali_pm_status, TP_PROTO(unsigned int event_id, unsigned long long value)) |
206 | { | 195 | { |
207 | #define SHADER_PRESENT_LO 0x100 /* (RO) Shader core present bitmap, low word */ | 196 | #define SHADER_PRESENT_LO 0x100 /* (RO) Shader core present bitmap, low word */ |
208 | #define TILER_PRESENT_LO 0x110 /* (RO) Tiler core present bitmap, low word */ | 197 | #define TILER_PRESENT_LO 0x110 /* (RO) Tiler core present bitmap, low word */ |
209 | #define L2_PRESENT_LO 0x120 /* (RO) Level 2 cache present bitmap, low word */ | 198 | #define L2_PRESENT_LO 0x120 /* (RO) Level 2 cache present bitmap, low word */ |
210 | #define BIT_AT(value, pos) ((value >> pos) & 1) | 199 | #define BIT_AT(value, pos) ((value >> pos) & 1) |
211 | 200 | ||
212 | static unsigned long long previous_shader_bitmask = 0; | 201 | static unsigned long long previous_shader_bitmask = 0; |
213 | static unsigned long long previous_tiler_bitmask = 0; | 202 | static unsigned long long previous_tiler_bitmask = 0; |
214 | static unsigned long long previous_l2_bitmask = 0; | 203 | static unsigned long long previous_l2_bitmask = 0; |
215 | 204 | ||
216 | switch (event_id) | 205 | switch (event_id) { |
217 | { | 206 | case SHADER_PRESENT_LO: |
218 | case SHADER_PRESENT_LO: | 207 | { |
219 | { | 208 | unsigned long long changed_bitmask = previous_shader_bitmask ^ value; |
220 | unsigned long long changed_bitmask = previous_shader_bitmask ^ value; | 209 | int pos; |
221 | int pos; | 210 | |
222 | 211 | for (pos = 0; pos < NUM_PM_SHADER; ++pos) { | |
223 | for (pos = 0; pos < NUM_PM_SHADER; ++pos) | 212 | if (BIT_AT(changed_bitmask, pos)) { |
224 | { | 213 | record_timeline_event(PM_SHADER_0 + pos, BIT_AT(value, pos) ? ACTIVITY_START : ACTIVITY_STOP); |
225 | if (BIT_AT(changed_bitmask, pos)) | 214 | } |
226 | { | 215 | } |
227 | record_timeline_event(PM_SHADER_0 + pos, BIT_AT(value, pos) ? ACTIVITY_START : ACTIVITY_STOP); | 216 | |
228 | } | 217 | previous_shader_bitmask = value; |
229 | } | 218 | break; |
230 | 219 | } | |
231 | previous_shader_bitmask = value; | 220 | |
232 | break; | 221 | case TILER_PRESENT_LO: |
233 | } | 222 | { |
234 | 223 | unsigned long long changed = previous_tiler_bitmask ^ value; | |
235 | case TILER_PRESENT_LO: | 224 | |
236 | { | 225 | if (BIT_AT(changed, 0)) { |
237 | unsigned long long changed = previous_tiler_bitmask ^ value; | 226 | record_timeline_event(PM_TILER_0, BIT_AT(value, 0) ? ACTIVITY_START : ACTIVITY_STOP); |
238 | 227 | } | |
239 | if (BIT_AT(changed, 0)) | 228 | |
240 | { | 229 | previous_tiler_bitmask = value; |
241 | record_timeline_event(PM_TILER_0, BIT_AT(value, 0) ? ACTIVITY_START : ACTIVITY_STOP); | 230 | break; |
242 | } | 231 | } |
243 | 232 | ||
244 | previous_tiler_bitmask = value; | 233 | case L2_PRESENT_LO: |
245 | break; | 234 | { |
246 | } | 235 | unsigned long long changed = previous_l2_bitmask ^ value; |
247 | 236 | ||
248 | case L2_PRESENT_LO: | 237 | if (BIT_AT(changed, 0)) { |
249 | { | 238 | record_timeline_event(PM_L2_0, BIT_AT(value, 0) ? ACTIVITY_START : ACTIVITY_STOP); |
250 | unsigned long long changed = previous_l2_bitmask ^ value; | 239 | } |
251 | 240 | if (BIT_AT(changed, 4)) { | |
252 | if (BIT_AT(changed, 0)) | 241 | record_timeline_event(PM_L2_1, BIT_AT(value, 4) ? ACTIVITY_START : ACTIVITY_STOP); |
253 | { | 242 | } |
254 | record_timeline_event(PM_L2_0, BIT_AT(value, 0) ? ACTIVITY_START : ACTIVITY_STOP); | 243 | |
255 | } | 244 | previous_l2_bitmask = value; |
256 | if (BIT_AT(changed, 4)) | 245 | break; |
257 | { | 246 | } |
258 | record_timeline_event(PM_L2_1, BIT_AT(value, 4) ? ACTIVITY_START : ACTIVITY_STOP); | 247 | |
259 | } | 248 | default: |
260 | 249 | /* No other blocks are supported at present */ | |
261 | previous_l2_bitmask = value; | 250 | break; |
262 | break; | 251 | } |
263 | } | ||
264 | |||
265 | default: | ||
266 | /* No other blocks are supported at present */ | ||
267 | break; | ||
268 | } | ||
269 | 252 | ||
270 | #undef SHADER_PRESENT_LO | 253 | #undef SHADER_PRESENT_LO |
271 | #undef TILER_PRESENT_LO | 254 | #undef TILER_PRESENT_LO |
@@ -275,278 +258,255 @@ GATOR_DEFINE_PROBE(mali_pm_status, TP_PROTO(unsigned int event_id, unsigned long | |||
275 | 258 | ||
276 | GATOR_DEFINE_PROBE(mali_page_fault_insert_pages, TP_PROTO(int event_id, unsigned long value)) | 259 | GATOR_DEFINE_PROBE(mali_page_fault_insert_pages, TP_PROTO(int event_id, unsigned long value)) |
277 | { | 260 | { |
278 | /* We add to the previous since we may receive many tracepoints in one sample period */ | 261 | /* We add to the previous since we may receive many tracepoints in one sample period */ |
279 | sw_counter_data[MMU_PAGE_FAULT_0 + event_id] += value; | 262 | sw_counter_data[MMU_PAGE_FAULT_0 + event_id] += value; |
280 | } | 263 | } |
281 | 264 | ||
282 | GATOR_DEFINE_PROBE(mali_mmu_as_in_use, TP_PROTO(int event_id)) | 265 | GATOR_DEFINE_PROBE(mali_mmu_as_in_use, TP_PROTO(int event_id)) |
283 | { | 266 | { |
284 | record_timeline_event(MMU_AS_0 + event_id, ACTIVITY_START); | 267 | record_timeline_event(MMU_AS_0 + event_id, ACTIVITY_START); |
285 | } | 268 | } |
286 | 269 | ||
287 | GATOR_DEFINE_PROBE(mali_mmu_as_released, TP_PROTO(int event_id)) | 270 | GATOR_DEFINE_PROBE(mali_mmu_as_released, TP_PROTO(int event_id)) |
288 | { | 271 | { |
289 | record_timeline_event(MMU_AS_0 + event_id, ACTIVITY_STOP); | 272 | record_timeline_event(MMU_AS_0 + event_id, ACTIVITY_STOP); |
290 | } | 273 | } |
291 | 274 | ||
292 | GATOR_DEFINE_PROBE(mali_total_alloc_pages_change, TP_PROTO(long long int event_id)) | 275 | GATOR_DEFINE_PROBE(mali_total_alloc_pages_change, TP_PROTO(long long int event_id)) |
293 | { | 276 | { |
294 | accumulators_data[TOTAL_ALLOC_PAGES] = event_id; | 277 | accumulators_data[TOTAL_ALLOC_PAGES] = event_id; |
295 | } | 278 | } |
296 | 279 | ||
297 | static int create_files(struct super_block *sb, struct dentry *root) | 280 | static int create_files(struct super_block *sb, struct dentry *root) |
298 | { | 281 | { |
299 | int event; | 282 | int event; |
300 | /* | 283 | /* |
301 | * Create the filesystem for all events | 284 | * Create the filesystem for all events |
302 | */ | 285 | */ |
303 | int counter_index = 0; | 286 | int counter_index = 0; |
304 | const char* mali_name = gator_mali_get_mali_name(); | 287 | const char *mali_name = gator_mali_get_mali_name(); |
305 | 288 | ||
306 | for (event = FIRST_TIMELINE_EVENT; event < FIRST_TIMELINE_EVENT + NUMBER_OF_TIMELINE_EVENTS; event++) | 289 | for (event = FIRST_TIMELINE_EVENT; event < FIRST_TIMELINE_EVENT + NUMBER_OF_TIMELINE_EVENTS; event++) { |
307 | { | 290 | if (gator_mali_create_file_system(mali_name, timeline_event_names[counter_index], sb, root, &counters[event]) != 0) { |
308 | if (gator_mali_create_file_system(mali_name, timeline_event_names[counter_index], sb, root, &counters[event]) != 0) | 291 | return -1; |
309 | { | 292 | } |
310 | return -1; | 293 | counter_index++; |
311 | } | 294 | } |
312 | counter_index++; | 295 | counter_index = 0; |
313 | } | 296 | for (event = FIRST_SOFTWARE_COUNTER; event < FIRST_SOFTWARE_COUNTER + NUMBER_OF_SOFTWARE_COUNTERS; event++) { |
314 | counter_index = 0; | 297 | if (gator_mali_create_file_system(mali_name, software_counter_names[counter_index], sb, root, &counters[event]) != 0) { |
315 | for (event = FIRST_SOFTWARE_COUNTER; event < FIRST_SOFTWARE_COUNTER + NUMBER_OF_SOFTWARE_COUNTERS; event++) | 298 | return -1; |
316 | { | 299 | } |
317 | if (gator_mali_create_file_system(mali_name, software_counter_names[counter_index], sb, root, &counters[event]) != 0) | 300 | counter_index++; |
318 | { | 301 | } |
319 | return -1; | 302 | counter_index = 0; |
320 | } | 303 | for (event = FIRST_ACCUMULATOR; event < FIRST_ACCUMULATOR + NUMBER_OF_ACCUMULATORS; event++) { |
321 | counter_index++; | 304 | if (gator_mali_create_file_system(mali_name, accumulators_names[counter_index], sb, root, &counters[event]) != 0) { |
322 | } | 305 | return -1; |
323 | counter_index = 0; | 306 | } |
324 | for (event = FIRST_ACCUMULATOR; event < FIRST_ACCUMULATOR + NUMBER_OF_ACCUMULATORS; event++) | 307 | counter_index++; |
325 | { | 308 | } |
326 | if (gator_mali_create_file_system(mali_name, accumulators_names[counter_index], sb, root, &counters[event]) != 0) | 309 | |
327 | { | 310 | return 0; |
328 | return -1; | ||
329 | } | ||
330 | counter_index++; | ||
331 | } | ||
332 | |||
333 | return 0; | ||
334 | } | 311 | } |
335 | 312 | ||
336 | static int register_tracepoints(void) | 313 | static int register_tracepoints(void) |
337 | { | 314 | { |
338 | if (GATOR_REGISTER_TRACE(mali_pm_status)) | 315 | if (GATOR_REGISTER_TRACE(mali_pm_status)) { |
339 | { | 316 | pr_debug("gator: Mali-T6xx: mali_pm_status tracepoint failed to activate\n"); |
340 | pr_debug("gator: Mali-T6xx: mali_pm_status tracepoint failed to activate\n"); | 317 | return 0; |
341 | return 0; | 318 | } |
342 | } | 319 | |
343 | 320 | if (GATOR_REGISTER_TRACE(mali_page_fault_insert_pages)) { | |
344 | if (GATOR_REGISTER_TRACE(mali_page_fault_insert_pages)) | 321 | pr_debug("gator: Mali-T6xx: mali_page_fault_insert_pages tracepoint failed to activate\n"); |
345 | { | 322 | return 0; |
346 | pr_debug("gator: Mali-T6xx: mali_page_fault_insert_pages tracepoint failed to activate\n"); | 323 | } |
347 | return 0; | 324 | |
348 | } | 325 | if (GATOR_REGISTER_TRACE(mali_mmu_as_in_use)) { |
349 | 326 | pr_debug("gator: Mali-T6xx: mali_mmu_as_in_use tracepoint failed to activate\n"); | |
350 | if (GATOR_REGISTER_TRACE(mali_mmu_as_in_use)) | 327 | return 0; |
351 | { | 328 | } |
352 | pr_debug("gator: Mali-T6xx: mali_mmu_as_in_use tracepoint failed to activate\n"); | 329 | |
353 | return 0; | 330 | if (GATOR_REGISTER_TRACE(mali_mmu_as_released)) { |
354 | } | 331 | pr_debug("gator: Mali-T6xx: mali_mmu_as_released tracepoint failed to activate\n"); |
355 | 332 | return 0; | |
356 | if (GATOR_REGISTER_TRACE(mali_mmu_as_released)) | 333 | } |
357 | { | 334 | |
358 | pr_debug("gator: Mali-T6xx: mali_mmu_as_released tracepoint failed to activate\n"); | 335 | if (GATOR_REGISTER_TRACE(mali_total_alloc_pages_change)) { |
359 | return 0; | 336 | pr_debug("gator: Mali-T6xx: mali_total_alloc_pages_change tracepoint failed to activate\n"); |
360 | } | 337 | return 0; |
361 | 338 | } | |
362 | if (GATOR_REGISTER_TRACE(mali_total_alloc_pages_change)) | 339 | |
363 | { | 340 | pr_debug("gator: Mali-T6xx: start\n"); |
364 | pr_debug("gator: Mali-T6xx: mali_total_alloc_pages_change tracepoint failed to activate\n"); | 341 | pr_debug("gator: Mali-T6xx: mali_pm_status probe is at %p\n", &probe_mali_pm_status); |
365 | return 0; | 342 | pr_debug("gator: Mali-T6xx: mali_page_fault_insert_pages probe is at %p\n", &probe_mali_page_fault_insert_pages); |
366 | } | 343 | pr_debug("gator: Mali-T6xx: mali_mmu_as_in_use probe is at %p\n", &probe_mali_mmu_as_in_use); |
367 | 344 | pr_debug("gator: Mali-T6xx: mali_mmu_as_released probe is at %p\n", &probe_mali_mmu_as_released); | |
368 | pr_debug("gator: Mali-T6xx: start\n"); | 345 | pr_debug("gator: Mali-T6xx: mali_total_alloc_pages_change probe is at %p\n", &probe_mali_total_alloc_pages_change); |
369 | pr_debug("gator: Mali-T6xx: mali_pm_status probe is at %p\n", &probe_mali_pm_status); | 346 | |
370 | pr_debug("gator: Mali-T6xx: mali_page_fault_insert_pages probe is at %p\n", &probe_mali_page_fault_insert_pages); | 347 | return 1; |
371 | pr_debug("gator: Mali-T6xx: mali_mmu_as_in_use probe is at %p\n", &probe_mali_mmu_as_in_use); | ||
372 | pr_debug("gator: Mali-T6xx: mali_mmu_as_released probe is at %p\n", &probe_mali_mmu_as_released); | ||
373 | pr_debug("gator: Mali-T6xx: mali_total_alloc_pages_change probe is at %p\n", &probe_mali_total_alloc_pages_change); | ||
374 | |||
375 | return 1; | ||
376 | } | 348 | } |
377 | 349 | ||
378 | static int start(void) | 350 | static int start(void) |
379 | { | 351 | { |
380 | unsigned int cnt; | 352 | unsigned int cnt; |
381 | 353 | ||
382 | /* Clean all data for the next capture */ | 354 | /* Clean all data for the next capture */ |
383 | for (cnt = 0; cnt < NUMBER_OF_TIMELINE_EVENTS; cnt++) | 355 | for (cnt = 0; cnt < NUMBER_OF_TIMELINE_EVENTS; cnt++) { |
384 | { | 356 | timeline_event_starttime[cnt].tv_sec = timeline_event_starttime[cnt].tv_nsec = 0; |
385 | timeline_event_starttime[cnt].tv_sec = timeline_event_starttime[cnt].tv_nsec = 0; | 357 | timeline_data[cnt] = 0; |
386 | timeline_data[cnt] = 0; | 358 | } |
387 | } | 359 | |
388 | 360 | for (cnt = 0; cnt < NUMBER_OF_SOFTWARE_COUNTERS; cnt++) { | |
389 | for (cnt = 0; cnt < NUMBER_OF_SOFTWARE_COUNTERS; cnt++) | 361 | sw_counter_data[cnt] = 0; |
390 | { | 362 | } |
391 | sw_counter_data[cnt] = 0; | 363 | |
392 | } | 364 | for (cnt = 0; cnt < NUMBER_OF_ACCUMULATORS; cnt++) { |
393 | 365 | accumulators_data[cnt] = 0; | |
394 | for (cnt = 0; cnt < NUMBER_OF_ACCUMULATORS; cnt++) | 366 | } |
395 | { | 367 | |
396 | accumulators_data[cnt] = 0; | 368 | /* Register tracepoints */ |
397 | } | 369 | if (register_tracepoints() == 0) { |
398 | 370 | return -1; | |
399 | /* Register tracepoints */ | 371 | } |
400 | if (register_tracepoints() == 0) | 372 | |
401 | { | 373 | /* |
402 | return -1; | 374 | * Set the first timestamp for calculating the sample interval. The first interval could be quite long, |
403 | } | 375 | * since it will be the time between 'start' and the first 'read'. |
404 | 376 | * This means that timeline values will be divided by a big number for the first sample. | |
405 | /* | 377 | */ |
406 | * Set the first timestamp for calculating the sample interval. The first interval could be quite long, | 378 | getnstimeofday(&prev_timestamp); |
407 | * since it will be the time between 'start' and the first 'read'. | 379 | |
408 | * This means that timeline values will be divided by a big number for the first sample. | 380 | return 0; |
409 | */ | ||
410 | getnstimeofday(&prev_timestamp); | ||
411 | |||
412 | return 0; | ||
413 | } | 381 | } |
414 | 382 | ||
415 | static void stop(void) | 383 | static void stop(void) |
416 | { | 384 | { |
417 | pr_debug("gator: Mali-T6xx: stop\n"); | 385 | pr_debug("gator: Mali-T6xx: stop\n"); |
418 | 386 | ||
419 | /* | 387 | /* |
420 | * It is safe to unregister traces even if they were not successfully | 388 | * It is safe to unregister traces even if they were not successfully |
421 | * registered, so no need to check. | 389 | * registered, so no need to check. |
422 | */ | 390 | */ |
423 | GATOR_UNREGISTER_TRACE(mali_pm_status); | 391 | GATOR_UNREGISTER_TRACE(mali_pm_status); |
424 | pr_debug("gator: Mali-T6xx: mali_pm_status tracepoint deactivated\n"); | 392 | pr_debug("gator: Mali-T6xx: mali_pm_status tracepoint deactivated\n"); |
425 | 393 | ||
426 | GATOR_UNREGISTER_TRACE(mali_page_fault_insert_pages); | 394 | GATOR_UNREGISTER_TRACE(mali_page_fault_insert_pages); |
427 | pr_debug("gator: Mali-T6xx: mali_page_fault_insert_pages tracepoint deactivated\n"); | 395 | pr_debug("gator: Mali-T6xx: mali_page_fault_insert_pages tracepoint deactivated\n"); |
428 | 396 | ||
429 | GATOR_UNREGISTER_TRACE(mali_mmu_as_in_use); | 397 | GATOR_UNREGISTER_TRACE(mali_mmu_as_in_use); |
430 | pr_debug("gator: Mali-T6xx: mali_mmu_as_in_use tracepoint deactivated\n"); | 398 | pr_debug("gator: Mali-T6xx: mali_mmu_as_in_use tracepoint deactivated\n"); |
431 | 399 | ||
432 | GATOR_UNREGISTER_TRACE(mali_mmu_as_released); | 400 | GATOR_UNREGISTER_TRACE(mali_mmu_as_released); |
433 | pr_debug("gator: Mali-T6xx: mali_mmu_as_released tracepoint deactivated\n"); | 401 | pr_debug("gator: Mali-T6xx: mali_mmu_as_released tracepoint deactivated\n"); |
434 | 402 | ||
435 | GATOR_UNREGISTER_TRACE(mali_total_alloc_pages_change); | 403 | GATOR_UNREGISTER_TRACE(mali_total_alloc_pages_change); |
436 | pr_debug("gator: Mali-T6xx: mali_total_alloc_pages_change tracepoint deactivated\n"); | 404 | pr_debug("gator: Mali-T6xx: mali_total_alloc_pages_change tracepoint deactivated\n"); |
437 | } | 405 | } |
438 | 406 | ||
439 | static int read(int **buffer) | 407 | static int read(int **buffer) |
440 | { | 408 | { |
441 | int cnt; | 409 | int cnt; |
442 | int len = 0; | 410 | int len = 0; |
443 | long sample_interval_us = 0; | 411 | long sample_interval_us = 0; |
444 | struct timespec read_timestamp; | 412 | struct timespec read_timestamp; |
445 | 413 | ||
446 | if (smp_processor_id()!=0) | 414 | if (smp_processor_id() != 0) { |
447 | { | 415 | return 0; |
448 | return 0; | 416 | } |
449 | } | 417 | |
450 | 418 | /* Get the start of this sample period. */ | |
451 | /* Get the start of this sample period. */ | 419 | getnstimeofday(&read_timestamp); |
452 | getnstimeofday(&read_timestamp); | 420 | |
453 | 421 | /* | |
454 | /* | 422 | * Calculate the sample interval if the previous sample time is valid. |
455 | * Calculate the sample interval if the previous sample time is valid. | 423 | * We use tv_sec since it will not be 0. |
456 | * We use tv_sec since it will not be 0. | 424 | */ |
457 | */ | 425 | if (prev_timestamp.tv_sec != 0) { |
458 | if(prev_timestamp.tv_sec != 0) { | 426 | sample_interval_us = get_duration_us(&prev_timestamp, &read_timestamp); |
459 | sample_interval_us = get_duration_us(&prev_timestamp, &read_timestamp); | 427 | } |
460 | } | 428 | |
461 | 429 | /* Structure copy. Update the previous timestamp. */ | |
462 | /* Structure copy. Update the previous timestamp. */ | 430 | prev_timestamp = read_timestamp; |
463 | prev_timestamp = read_timestamp; | 431 | |
464 | 432 | /* | |
465 | /* | 433 | * Report the timeline counters (ACTIVITY_START/STOP) |
466 | * Report the timeline counters (ACTIVITY_START/STOP) | 434 | */ |
467 | */ | 435 | for (cnt = FIRST_TIMELINE_EVENT; cnt < (FIRST_TIMELINE_EVENT + NUMBER_OF_TIMELINE_EVENTS); cnt++) { |
468 | for (cnt = FIRST_TIMELINE_EVENT; cnt < (FIRST_TIMELINE_EVENT + NUMBER_OF_TIMELINE_EVENTS); cnt++) | 436 | mali_counter *counter = &counters[cnt]; |
469 | { | 437 | if (counter->enabled) { |
470 | mali_counter *counter = &counters[cnt]; | 438 | const int index = cnt - FIRST_TIMELINE_EVENT; |
471 | if (counter->enabled) | 439 | unsigned int value; |
472 | { | 440 | |
473 | const int index = cnt - FIRST_TIMELINE_EVENT; | 441 | /* If the activity is still running, reset its start time to the start of this sample period |
474 | unsigned int value; | 442 | * to correct the count. Add the time up to the end of the sample onto the count. */ |
475 | 443 | if (timeline_event_starttime[index].tv_sec != 0) { | |
476 | /* If the activity is still running, reset its start time to the start of this sample period | 444 | const long event_duration = get_duration_us(&timeline_event_starttime[index], &read_timestamp); |
477 | * to correct the count. Add the time up to the end of the sample onto the count. */ | 445 | timeline_data[index] += event_duration; |
478 | if(timeline_event_starttime[index].tv_sec != 0) { | 446 | timeline_event_starttime[index] = read_timestamp; /* Activity is still running. */ |
479 | const long event_duration = get_duration_us(&timeline_event_starttime[index], &read_timestamp); | 447 | } |
480 | timeline_data[index] += event_duration; | 448 | |
481 | timeline_event_starttime[index] = read_timestamp; /* Activity is still running. */ | 449 | if (sample_interval_us != 0) { |
482 | } | 450 | /* Convert the counter to a percent-of-sample value */ |
483 | 451 | value = (timeline_data[index] * 100) / sample_interval_us; | |
484 | if(sample_interval_us != 0) { | 452 | } else { |
485 | /* Convert the counter to a percent-of-sample value */ | 453 | pr_debug("gator: Mali-T6xx: setting value to zero\n"); |
486 | value = (timeline_data[index] * 100) / sample_interval_us; | 454 | value = 0; |
487 | } else { | 455 | } |
488 | pr_debug("gator: Mali-T6xx: setting value to zero\n"); | 456 | |
489 | value = 0; | 457 | /* Clear the counter value ready for the next sample. */ |
490 | } | 458 | timeline_data[index] = 0; |
491 | 459 | ||
492 | /* Clear the counter value ready for the next sample. */ | 460 | counter_dump[len++] = counter->key; |
493 | timeline_data[index] = 0; | 461 | counter_dump[len++] = value; |
494 | 462 | } | |
495 | counter_dump[len++] = counter->key; | 463 | } |
496 | counter_dump[len++] = value; | 464 | |
497 | } | 465 | /* Report the software counters */ |
498 | } | 466 | for (cnt = FIRST_SOFTWARE_COUNTER; cnt < (FIRST_SOFTWARE_COUNTER + NUMBER_OF_SOFTWARE_COUNTERS); cnt++) { |
499 | 467 | const mali_counter *counter = &counters[cnt]; | |
500 | /* Report the software counters */ | 468 | if (counter->enabled) { |
501 | for (cnt = FIRST_SOFTWARE_COUNTER; cnt < (FIRST_SOFTWARE_COUNTER + NUMBER_OF_SOFTWARE_COUNTERS); cnt++) | 469 | const int index = cnt - FIRST_SOFTWARE_COUNTER; |
502 | { | 470 | counter_dump[len++] = counter->key; |
503 | const mali_counter *counter = &counters[cnt]; | 471 | counter_dump[len++] = sw_counter_data[index]; |
504 | if (counter->enabled) | 472 | /* Set the value to zero for the next time */ |
505 | { | 473 | sw_counter_data[index] = 0; |
506 | const int index = cnt - FIRST_SOFTWARE_COUNTER; | 474 | } |
507 | counter_dump[len++] = counter->key; | 475 | } |
508 | counter_dump[len++] = sw_counter_data[index]; | 476 | |
509 | /* Set the value to zero for the next time */ | 477 | /* Report the accumulators */ |
510 | sw_counter_data[index] = 0; | 478 | for (cnt = FIRST_ACCUMULATOR; cnt < (FIRST_ACCUMULATOR + NUMBER_OF_ACCUMULATORS); cnt++) { |
511 | } | 479 | const mali_counter *counter = &counters[cnt]; |
512 | } | 480 | if (counter->enabled) { |
513 | 481 | const int index = cnt - FIRST_ACCUMULATOR; | |
514 | /* Report the accumulators */ | 482 | counter_dump[len++] = counter->key; |
515 | for (cnt = FIRST_ACCUMULATOR; cnt < (FIRST_ACCUMULATOR + NUMBER_OF_ACCUMULATORS); cnt++) | 483 | counter_dump[len++] = accumulators_data[index]; |
516 | { | 484 | /* Do not zero the accumulator */ |
517 | const mali_counter *counter = &counters[cnt]; | 485 | } |
518 | if (counter->enabled) | 486 | } |
519 | { | 487 | |
520 | const int index = cnt - FIRST_ACCUMULATOR; | 488 | /* Update the buffer */ |
521 | counter_dump[len++] = counter->key; | 489 | if (buffer) { |
522 | counter_dump[len++] = accumulators_data[index]; | 490 | *buffer = (int *)counter_dump; |
523 | /* Do not zero the accumulator */ | 491 | } |
524 | } | 492 | |
525 | } | 493 | return len; |
526 | |||
527 | /* Update the buffer */ | ||
528 | if (buffer) | ||
529 | { | ||
530 | *buffer = (int*) counter_dump; | ||
531 | } | ||
532 | |||
533 | return len; | ||
534 | } | 494 | } |
535 | 495 | ||
536 | static struct gator_interface gator_events_mali_t6xx_interface = { | 496 | static struct gator_interface gator_events_mali_t6xx_interface = { |
537 | .create_files = create_files, | 497 | .create_files = create_files, |
538 | .start = start, | 498 | .start = start, |
539 | .stop = stop, | 499 | .stop = stop, |
540 | .read = read | 500 | .read = read |
541 | }; | 501 | }; |
542 | 502 | ||
543 | extern int gator_events_mali_t6xx_init(void) | 503 | extern int gator_events_mali_t6xx_init(void) |
544 | { | 504 | { |
545 | pr_debug("gator: Mali-T6xx: sw_counters init\n"); | 505 | pr_debug("gator: Mali-T6xx: sw_counters init\n"); |
546 | 506 | ||
547 | gator_mali_initialise_counters(counters, NUMBER_OF_EVENTS); | 507 | gator_mali_initialise_counters(counters, NUMBER_OF_EVENTS); |
548 | 508 | ||
549 | return gator_events_install(&gator_events_mali_t6xx_interface); | 509 | return gator_events_install(&gator_events_mali_t6xx_interface); |
550 | } | 510 | } |
551 | 511 | ||
552 | gator_events_init(gator_events_mali_t6xx_init); | 512 | gator_events_init(gator_events_mali_t6xx_init); |