summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'driver/gator_trace_gpu.c')
-rw-r--r--driver/gator_trace_gpu.c142
1 files changed, 43 insertions, 99 deletions
diff --git a/driver/gator_trace_gpu.c b/driver/gator_trace_gpu.c
index a8b9e7d..6afa548 100644
--- a/driver/gator_trace_gpu.c
+++ b/driver/gator_trace_gpu.c
@@ -44,19 +44,21 @@ enum {
44 NUMBER_OF_GPU_UNITS 44 NUMBER_OF_GPU_UNITS
45}; 45};
46 46
47#define MALI_4xx (0x0b07)
48#define MALI_T6xx (0x0056)
49
47#if defined(MALI_SUPPORT) 50#if defined(MALI_SUPPORT)
48 51
49struct mali_activity { 52struct mali_gpu_job {
50 int core;
51 int key;
52 int count; 53 int count;
53 int last_activity; 54 int last_tgid;
54 int last_pid; 55 int last_pid;
56 int last_job_id;
55}; 57};
56 58
57#define NUMBER_OF_GPU_CORES 16 59#define NUMBER_OF_GPU_CORES 16
58static struct mali_activity mali_activities[NUMBER_OF_GPU_UNITS*NUMBER_OF_GPU_CORES]; 60static struct mali_gpu_job mali_gpu_jobs[NUMBER_OF_GPU_UNITS][NUMBER_OF_GPU_CORES];
59static DEFINE_SPINLOCK(mali_activities_lock); 61static DEFINE_SPINLOCK(mali_gpu_jobs_lock);
60 62
61/* Only one event should be running on a unit and core at a time (ie, a start 63/* Only one event should be running on a unit and core at a time (ie, a start
62 * event can only be followed by a stop and vice versa), but because the kernel 64 * event can only be followed by a stop and vice versa), but because the kernel
@@ -64,95 +66,52 @@ static DEFINE_SPINLOCK(mali_activities_lock);
64 * start1, start2, stop1, stop2. Change it back into start1, stop1, start2, 66 * start1, start2, stop1, stop2. Change it back into start1, stop1, start2,
65 * stop2 by queueing up start2 and releasing it when stop1 is received. 67 * stop2 by queueing up start2 and releasing it when stop1 is received.
66 */ 68 */
67 69static void mali_gpu_enqueue(int unit, int core, int tgid, int pid, int job_id)
68static int mali_activity_index(int core, int key)
69{
70 int i;
71
72 for (i = 0; i < ARRAY_SIZE(mali_activities); ++i) {
73 if ((mali_activities[i].core == core) && (mali_activities[i].key == key)) {
74 break;
75 }
76 if ((mali_activities[i].core == 0) && (mali_activities[i].key == 0)) {
77 mali_activities[i].core = core;
78 mali_activities[i].key = key;
79 break;
80 }
81 }
82 BUG_ON(i >= ARRAY_SIZE(mali_activities));
83
84 return i;
85}
86
87static void mali_activity_enqueue(int core, int key, int activity, int pid)
88{ 70{
89 int i;
90 int count; 71 int count;
91 72
92 spin_lock(&mali_activities_lock); 73 spin_lock(&mali_gpu_jobs_lock);
93 i = mali_activity_index(core, key); 74 count = mali_gpu_jobs[unit][core].count;
94
95 count = mali_activities[i].count;
96 BUG_ON(count < 0); 75 BUG_ON(count < 0);
97 ++mali_activities[i].count; 76 ++mali_gpu_jobs[unit][core].count;
98 if (count) { 77 if (count) {
99 mali_activities[i].last_activity = activity; 78 mali_gpu_jobs[unit][core].last_tgid = tgid;
100 mali_activities[i].last_pid = pid; 79 mali_gpu_jobs[unit][core].last_pid = pid;
80 mali_gpu_jobs[unit][core].last_job_id = job_id;
101 } 81 }
102 spin_unlock(&mali_activities_lock); 82 spin_unlock(&mali_gpu_jobs_lock);
103 83
104 if (!count) { 84 if (!count) {
105 gator_marshal_activity_switch(core, key, activity, pid); 85 marshal_sched_gpu_start(unit, core, tgid, pid/*, job_id*/);
106 } 86 }
107} 87}
108 88
109static void mali_activity_stop(int core, int key) 89static void mali_gpu_stop(int unit, int core)
110{ 90{
111 int i;
112 int count; 91 int count;
113 int last_activity = 0; 92 int last_tgid = 0;
114 int last_pid = 0; 93 int last_pid = 0;
94 //int last_job_id = 0;
115 95
116 spin_lock(&mali_activities_lock); 96 spin_lock(&mali_gpu_jobs_lock);
117 i = mali_activity_index(core, key); 97 if (mali_gpu_jobs[unit][core].count == 0) {
118 98 spin_unlock(&mali_gpu_jobs_lock);
119 if (mali_activities[i].count == 0) {
120 spin_unlock(&mali_activities_lock);
121 return; 99 return;
122 } 100 }
123 --mali_activities[i].count; 101 --mali_gpu_jobs[unit][core].count;
124 count = mali_activities[i].count; 102 count = mali_gpu_jobs[unit][core].count;
125 if (count) { 103 if (count) {
126 last_activity = mali_activities[i].last_activity; 104 last_tgid = mali_gpu_jobs[unit][core].last_tgid;
127 last_pid = mali_activities[i].last_pid; 105 last_pid = mali_gpu_jobs[unit][core].last_pid;
106 //last_job_id = mali_gpu_jobs[unit][core].last_job_id;
128 } 107 }
129 spin_unlock(&mali_activities_lock); 108 spin_unlock(&mali_gpu_jobs_lock);
130 109
131 gator_marshal_activity_switch(core, key, 0, 0); 110 marshal_sched_gpu_stop(unit, core);
132 if (count) { 111 if (count) {
133 gator_marshal_activity_switch(core, key, last_activity, last_pid); 112 marshal_sched_gpu_start(unit, core, last_tgid, last_pid/*, last_job_id*/);
134 } 113 }
135} 114}
136
137void mali_activity_clear(mali_counter mali_activity[], size_t mali_activity_size)
138{
139 int activity;
140 int cores;
141 int core;
142
143 for (activity = 0; activity < mali_activity_size; ++activity) {
144 cores = mali_activity[activity].cores;
145 if (cores < 0) {
146 cores = 1;
147 }
148 for (core = 0; core < cores; ++core) {
149 if (mali_activity[activity].enabled) {
150 gator_marshal_activity_switch(core, mali_activity[activity].key, 0, 0);
151 }
152 }
153 }
154}
155
156#endif 115#endif
157 116
158#if defined(MALI_SUPPORT) && (MALI_SUPPORT != MALI_T6xx) 117#if defined(MALI_SUPPORT) && (MALI_SUPPORT != MALI_T6xx)
@@ -183,8 +142,6 @@ enum {
183 EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE = 1, 142 EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE = 1,
184}; 143};
185 144
186mali_counter mali_activity[2];
187
188GATOR_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)) 145GATOR_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))
189{ 146{
190 unsigned int component, state; 147 unsigned int component, state;
@@ -197,26 +154,18 @@ GATOR_DEFINE_PROBE(mali_timeline_event, TP_PROTO(unsigned int event_id, unsigned
197 case EVENT_TYPE_START: 154 case EVENT_TYPE_START:
198 if (component == EVENT_CHANNEL_VP0) { 155 if (component == EVENT_CHANNEL_VP0) {
199 /* tgid = d0; pid = d1; */ 156 /* tgid = d0; pid = d1; */
200 if (mali_activity[1].enabled) { 157 mali_gpu_enqueue(GPU_UNIT_VP, 0, d0, d1, 0);
201 mali_activity_enqueue(0, mali_activity[1].key, 1, d1);
202 }
203 } else if (component >= EVENT_CHANNEL_FP0 && component <= EVENT_CHANNEL_FP7) { 158 } else if (component >= EVENT_CHANNEL_FP0 && component <= EVENT_CHANNEL_FP7) {
204 /* tgid = d0; pid = d1; */ 159 /* tgid = d0; pid = d1; */
205 if (mali_activity[0].enabled) { 160 mali_gpu_enqueue(GPU_UNIT_FP, component - EVENT_CHANNEL_FP0, d0, d1, 0);
206 mali_activity_enqueue(component - EVENT_CHANNEL_FP0, mali_activity[0].key, 1, d1);
207 }
208 } 161 }
209 break; 162 break;
210 163
211 case EVENT_TYPE_STOP: 164 case EVENT_TYPE_STOP:
212 if (component == EVENT_CHANNEL_VP0) { 165 if (component == EVENT_CHANNEL_VP0) {
213 if (mali_activity[1].enabled) { 166 mali_gpu_stop(GPU_UNIT_VP, 0);
214 mali_activity_stop(0, mali_activity[1].key);
215 }
216 } else if (component >= EVENT_CHANNEL_FP0 && component <= EVENT_CHANNEL_FP7) { 167 } else if (component >= EVENT_CHANNEL_FP0 && component <= EVENT_CHANNEL_FP7) {
217 if (mali_activity[0].enabled) { 168 mali_gpu_stop(GPU_UNIT_FP, component - EVENT_CHANNEL_FP0);
218 mali_activity_stop(component - EVENT_CHANNEL_FP0, mali_activity[0].key);
219 }
220 } 169 }
221 break; 170 break;
222 171
@@ -237,9 +186,6 @@ GATOR_DEFINE_PROBE(mali_timeline_event, TP_PROTO(unsigned int event_id, unsigned
237#endif 186#endif
238 187
239#if defined(MALI_SUPPORT) && (MALI_SUPPORT == MALI_T6xx) 188#if defined(MALI_SUPPORT) && (MALI_SUPPORT == MALI_T6xx)
240
241mali_counter mali_activity[3];
242
243#if defined(MALI_JOB_SLOTS_EVENT_CHANGED) 189#if defined(MALI_JOB_SLOTS_EVENT_CHANGED)
244GATOR_DEFINE_PROBE(mali_job_slots_event, TP_PROTO(unsigned int event_id, unsigned int tgid, unsigned int pid, unsigned char job_id)) 190GATOR_DEFINE_PROBE(mali_job_slots_event, TP_PROTO(unsigned int event_id, unsigned int tgid, unsigned int pid, unsigned char job_id))
245#else 191#else
@@ -271,16 +217,16 @@ GATOR_DEFINE_PROBE(mali_job_slots_event, TP_PROTO(unsigned int event_id, unsigne
271 if (unit != GPU_UNIT_NONE) { 217 if (unit != GPU_UNIT_NONE) {
272 switch (state) { 218 switch (state) {
273 case EVENT_TYPE_START: 219 case EVENT_TYPE_START:
274 if (mali_activity[component].enabled) { 220 mali_gpu_enqueue(unit, 0, tgid, (pid != 0 ? pid : tgid), job_id);
275 mali_activity_enqueue(0, mali_activity[component].key, 1, (pid != 0 ? pid : tgid));
276 }
277 break; 221 break;
278 case EVENT_TYPE_STOP: 222 case EVENT_TYPE_STOP:
279 default: // Some jobs can be soft-stopped, so ensure that this terminates the activity trace. 223 mali_gpu_stop(unit, 0);
280 if (mali_activity[component].enabled) {
281 mali_activity_stop(0, mali_activity[component].key);
282 }
283 break; 224 break;
225 default:
226 /*
227 * Some jobs can be soft-stopped, so ensure that this terminates the activity trace.
228 */
229 mali_gpu_stop(unit, 0);
284 } 230 }
285 } 231 }
286} 232}
@@ -294,19 +240,17 @@ static int gator_trace_gpu_start(void)
294 */ 240 */
295 241
296#if defined(MALI_SUPPORT) 242#if defined(MALI_SUPPORT)
297 memset(&mali_activities, 0, sizeof(mali_activities)); 243 memset(&mali_gpu_jobs, 0, sizeof(mali_gpu_jobs));
298#endif 244#endif
299 mali_timeline_trace_registered = mali_job_slots_trace_registered = 0; 245 mali_timeline_trace_registered = mali_job_slots_trace_registered = 0;
300 246
301#if defined(MALI_SUPPORT) && (MALI_SUPPORT != MALI_T6xx) 247#if defined(MALI_SUPPORT) && (MALI_SUPPORT != MALI_T6xx)
302 mali_activity_clear(mali_activity, ARRAY_SIZE(mali_activity));
303 if (!GATOR_REGISTER_TRACE(mali_timeline_event)) { 248 if (!GATOR_REGISTER_TRACE(mali_timeline_event)) {
304 mali_timeline_trace_registered = 1; 249 mali_timeline_trace_registered = 1;
305 } 250 }
306#endif 251#endif
307 252
308#if defined(MALI_SUPPORT) && (MALI_SUPPORT == MALI_T6xx) 253#if defined(MALI_SUPPORT) && (MALI_SUPPORT == MALI_T6xx)
309 mali_activity_clear(mali_activity, ARRAY_SIZE(mali_activity));
310 if (!GATOR_REGISTER_TRACE(mali_job_slots_event)) { 254 if (!GATOR_REGISTER_TRACE(mali_job_slots_event)) {
311 mali_job_slots_trace_registered = 1; 255 mali_job_slots_trace_registered = 1;
312 } 256 }