summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'driver/gator_trace_gpu.c')
-rw-r--r--driver/gator_trace_gpu.c152
1 files changed, 119 insertions, 33 deletions
diff --git a/driver/gator_trace_gpu.c b/driver/gator_trace_gpu.c
index 921932c..d053987 100644
--- a/driver/gator_trace_gpu.c
+++ b/driver/gator_trace_gpu.c
@@ -18,11 +18,19 @@
18#endif 18#endif
19#include "gator_trace_gpu.h" 19#include "gator_trace_gpu.h"
20 20
21#define ACTIVITY_START 1 21/*
22#define ACTIVITY_STOP 2 22 * Taken from MALI_PROFILING_EVENT_TYPE_* items in Mali DDK.
23 */
24#define EVENT_TYPE_SINGLE 0
25#define EVENT_TYPE_START 1
26#define EVENT_TYPE_STOP 2
27#define EVENT_TYPE_SUSPEND 3
28#define EVENT_TYPE_RESUME 4
29
23 30
24/* Note whether tracepoints have been registered */ 31/* Note whether tracepoints have been registered */
25static int mali_trace_registered; 32static int mali_timeline_trace_registered;
33static int mali_job_slots_trace_registered;
26static int gpu_trace_registered; 34static int gpu_trace_registered;
27 35
28#define GPU_START 1 36#define GPU_START 1
@@ -32,42 +40,107 @@ static int gpu_trace_registered;
32#define GPU_UNIT_FP 2 40#define GPU_UNIT_FP 2
33#define GPU_UNIT_CL 3 41#define GPU_UNIT_CL 3
34 42
35#ifdef MALI_SUPPORT 43#define MALI_400 (0x0b07)
44#define MALI_T6xx (0x0056)
45
46#if defined(MALI_SUPPORT) && (MALI_SUPPORT != MALI_T6xx)
47#include "gator_events_mali_400.h"
36 48
37enum components { 49/*
38 COMPONENT_VP0 = 1, 50 * Taken from MALI_PROFILING_EVENT_CHANNEL_* in Mali DDK.
39 COMPONENT_FP0 = 5, 51 */
40 COMPONENT_FP1, 52enum {
41 COMPONENT_FP2, 53 EVENT_CHANNEL_SOFTWARE = 0,
42 COMPONENT_FP3, 54 EVENT_CHANNEL_VP0 = 1,
43 COMPONENT_FP4, 55 EVENT_CHANNEL_FP0 = 5,
44 COMPONENT_FP5, 56 EVENT_CHANNEL_FP1,
45 COMPONENT_FP6, 57 EVENT_CHANNEL_FP2,
46 COMPONENT_FP7, 58 EVENT_CHANNEL_FP3,
59 EVENT_CHANNEL_FP4,
60 EVENT_CHANNEL_FP5,
61 EVENT_CHANNEL_FP6,
62 EVENT_CHANNEL_FP7,
63 EVENT_CHANNEL_GPU = 21
64};
65
66/**
67 * These events are applicable when the type MALI_PROFILING_EVENT_TYPE_SINGLE is used from the GPU channel
68 */
69enum {
70 EVENT_REASON_SINGLE_GPU_NONE = 0,
71 EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE = 1,
47}; 72};
48 73
74
49GATOR_DEFINE_PROBE(mali_timeline_event, TP_PROTO(unsigned int event_id, unsigned int d0, unsigned int d1, unsigned int d2, unsigned int d3, unsigned int d4)) 75GATOR_DEFINE_PROBE(mali_timeline_event, TP_PROTO(unsigned int event_id, unsigned int d0, unsigned int d1, unsigned int d2, unsigned int d3, unsigned int d4))
50{ 76{
51 unsigned int component, state; 77 unsigned int component, state;
52 int tgid = 0, pid = 0;
53 78
54 // do as much work as possible before disabling interrupts 79 // do as much work as possible before disabling interrupts
55 component = (event_id >> 16) & 0xFF; // component is an 8-bit field 80 component = (event_id >> 16) & 0xFF; // component is an 8-bit field
56 state = (event_id >> 24) & 0xF; // state is a 4-bit field 81 state = (event_id >> 24) & 0xF; // state is a 4-bit field
57 82
58 if ((component == COMPONENT_VP0) || (component >= COMPONENT_FP0 && component <= COMPONENT_FP7)) { 83 switch (state) {
59 if (state == ACTIVITY_START || state == ACTIVITY_STOP) { 84 case EVENT_TYPE_START:
60 unsigned int type = (state == ACTIVITY_START) ? GPU_START : GPU_STOP; 85 if (component == EVENT_CHANNEL_VP0) {
61 unsigned int unit = (component < COMPONENT_FP0) ? GPU_UNIT_VP : GPU_UNIT_FP; 86 /* tgid = d0; pid = d1; */
62 unsigned int core = (component < COMPONENT_FP0) ? component - COMPONENT_VP0 : component - COMPONENT_FP0; 87 marshal_sched_gpu(GPU_START, GPU_UNIT_VP, 0, d0, d1);
63 if (state == ACTIVITY_START) { 88 } else if (component >= EVENT_CHANNEL_FP0 && component <= EVENT_CHANNEL_FP7) {
64 tgid = d0; 89 /* tgid = d0; pid = d1; */
65 pid = d1; 90 marshal_sched_gpu(GPU_START, GPU_UNIT_FP, component - EVENT_CHANNEL_FP0, d0, d1);
91 }
92 break;
93
94 case EVENT_TYPE_STOP:
95 if (component == EVENT_CHANNEL_VP0) {
96 marshal_sched_gpu(GPU_STOP, GPU_UNIT_VP, 0, 0, 0);
97 } else if (component >= EVENT_CHANNEL_FP0 && component <= EVENT_CHANNEL_FP7) {
98 marshal_sched_gpu(GPU_STOP, GPU_UNIT_FP, component - EVENT_CHANNEL_FP0, 0, 0);
99 }
100 break;
101
102 case EVENT_TYPE_SINGLE:
103 if (component == EVENT_CHANNEL_GPU) {
104 unsigned int reason = (event_id & 0xffff);
105
106 if(reason == EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE) {
107 gator_events_mali_log_dvfs_event(d0, d1);
66 } 108 }
109 }
110 break;
67 111
68 marshal_sched_gpu(type, unit, core, tgid, pid); 112 default:
69 } 113 break;
70 } 114 }
115}
116#endif
117
118#if defined(MALI_SUPPORT) && (MALI_SUPPORT == MALI_T6xx)
119GATOR_DEFINE_PROBE(mali_job_slots_event, TP_PROTO(unsigned int event_id, unsigned int tgid, unsigned int pid))
120{
121 unsigned int component, state, type, unit = 0;
122
123 component = (event_id >> 16) & 0xFF; // component is an 8-bit field
124 state = (event_id >> 24) & 0xF; // state is a 4-bit field
125 type = (state == EVENT_TYPE_START) ? GPU_START : GPU_STOP;
126
127 switch (component)
128 {
129 case 0:
130 unit = GPU_UNIT_FP;
131 break;
132 case 1:
133 unit = GPU_UNIT_VP;
134 break;
135 case 2:
136 unit = GPU_UNIT_CL;
137 break;
138 }
139
140 if (unit != 0)
141 {
142 marshal_sched_gpu(type, unit, 0, tgid, (pid != 0 ? pid : tgid));
143 }
71} 144}
72#endif 145#endif
73 146
@@ -88,15 +161,21 @@ int gator_trace_gpu_start(void)
88 * Absence of gpu trace points is not an error 161 * Absence of gpu trace points is not an error
89 */ 162 */
90 163
91 gpu_trace_registered = mali_trace_registered = 0; 164 gpu_trace_registered = mali_timeline_trace_registered = mali_job_slots_trace_registered = 0;
92 165
93#ifdef MALI_SUPPORT 166#if defined(MALI_SUPPORT) && (MALI_SUPPORT != MALI_T6xx)
94 if (!GATOR_REGISTER_TRACE(mali_timeline_event)) { 167 if (!GATOR_REGISTER_TRACE(mali_timeline_event)) {
95 mali_trace_registered = 1; 168 mali_timeline_trace_registered = 1;
96 } 169 }
97#endif 170#endif
98 171
99 if (!mali_trace_registered) { 172#if defined(MALI_SUPPORT) && (MALI_SUPPORT == MALI_T6xx)
173 if (!GATOR_REGISTER_TRACE(mali_job_slots_event)) {
174 mali_job_slots_trace_registered = 1;
175 }
176#endif
177
178 if (!mali_timeline_trace_registered) {
100 if (GATOR_REGISTER_TRACE(gpu_activity_start)) { 179 if (GATOR_REGISTER_TRACE(gpu_activity_start)) {
101 return 0; 180 return 0;
102 } 181 }
@@ -112,15 +191,22 @@ int gator_trace_gpu_start(void)
112 191
113void gator_trace_gpu_stop(void) 192void gator_trace_gpu_stop(void)
114{ 193{
115#ifdef MALI_SUPPORT 194#if defined(MALI_SUPPORT) && (MALI_SUPPORT != MALI_T6xx)
116 if (mali_trace_registered) { 195 if (mali_timeline_trace_registered) {
117 GATOR_UNREGISTER_TRACE(mali_timeline_event); 196 GATOR_UNREGISTER_TRACE(mali_timeline_event);
118 } 197 }
119#endif 198#endif
199
200#if defined(MALI_SUPPORT) && (MALI_SUPPORT == MALI_T6xx)
201 if (mali_job_slots_trace_registered) {
202 GATOR_UNREGISTER_TRACE(mali_job_slots_event);
203 }
204#endif
205
120 if (gpu_trace_registered) { 206 if (gpu_trace_registered) {
121 GATOR_UNREGISTER_TRACE(gpu_activity_stop); 207 GATOR_UNREGISTER_TRACE(gpu_activity_stop);
122 GATOR_UNREGISTER_TRACE(gpu_activity_start); 208 GATOR_UNREGISTER_TRACE(gpu_activity_start);
123 } 209 }
124 210
125 gpu_trace_registered = mali_trace_registered = 0; 211 gpu_trace_registered = mali_timeline_trace_registered = mali_job_slots_trace_registered = 0;
126} 212}