blob: 0840aba77e617acd95abde8b4e5a67a4afaf5d27 [file] [log] [blame]
Shrenuj Bansala419c792016-10-20 14:05:11 -07001/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include "kgsl.h"
14#include "kgsl_sharedmem.h"
15#include "kgsl_snapshot.h"
16
17#include "adreno.h"
18#include "adreno_pm4types.h"
19#include "a3xx_reg.h"
20#include "adreno_cp_parser.h"
21#include "adreno_snapshot.h"
22#include "adreno_a5xx.h"
23
24#define VPC_MEMORY_BANKS 4
25
26/* Maintain a list of the objects we see during parsing */
27
28#define SNAPSHOT_OBJ_BUFSIZE 64
29
Shrenuj Bansala419c792016-10-20 14:05:11 -070030/* Used to print error message if an IB has too many objects in it */
31static int ib_max_objs;
32
33struct snapshot_rb_params {
34 struct kgsl_snapshot *snapshot;
35 struct adreno_ringbuffer *rb;
36};
37
38/* Keep track of how many bytes are frozen after a snapshot and tell the user */
39static size_t snapshot_frozen_objsize;
40
41static struct kgsl_snapshot_object objbuf[SNAPSHOT_OBJ_BUFSIZE];
42
43/* Pointer to the next open entry in the object list */
44static unsigned int objbufptr;
45
46static inline int adreno_rb_ctxtswitch(struct adreno_device *adreno_dev,
47 unsigned int *cmd)
48{
49 return cmd[0] == cp_packet(adreno_dev, CP_NOP, 1) &&
50 cmd[1] == KGSL_CONTEXT_TO_MEM_IDENTIFIER;
51}
52
53/* Push a new buffer object onto the list */
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +053054void kgsl_snapshot_push_object(struct kgsl_process_private *process,
Shrenuj Bansala419c792016-10-20 14:05:11 -070055 uint64_t gpuaddr, uint64_t dwords)
56{
57 int index;
58 struct kgsl_mem_entry *entry;
59
60 if (process == NULL)
61 return;
62
63 /*
64 * Sometimes IBs can be reused in the same dump. Because we parse from
65 * oldest to newest, if we come across an IB that has already been used,
66 * assume that it has been reused and update the list with the newest
67 * size.
68 */
69
70 for (index = 0; index < objbufptr; index++) {
71 if (objbuf[index].gpuaddr == gpuaddr &&
72 objbuf[index].entry->priv == process) {
73
74 objbuf[index].size = max_t(uint64_t,
75 objbuf[index].size,
76 dwords << 2);
77 return;
78 }
79 }
80
81 if (objbufptr == SNAPSHOT_OBJ_BUFSIZE) {
82 KGSL_CORE_ERR("snapshot: too many snapshot objects\n");
83 return;
84 }
85
86 entry = kgsl_sharedmem_find(process, gpuaddr);
87 if (entry == NULL) {
88 KGSL_CORE_ERR("snapshot: Can't find entry for 0x%016llX\n",
89 gpuaddr);
90 return;
91 }
92
93 if (!kgsl_gpuaddr_in_memdesc(&entry->memdesc, gpuaddr, dwords << 2)) {
94 KGSL_CORE_ERR("snapshot: Mem entry 0x%016llX is too small\n",
95 gpuaddr);
96 kgsl_mem_entry_put(entry);
97 return;
98 }
99
100 /* Put it on the list of things to parse */
Shrenuj Bansala419c792016-10-20 14:05:11 -0700101 objbuf[objbufptr].gpuaddr = gpuaddr;
102 objbuf[objbufptr].size = dwords << 2;
103 objbuf[objbufptr++].entry = entry;
104}
105
106/*
107 * Returns index of the specified object is already on the list of buffers
108 * to be dumped
109 */
110
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530111static int find_object(uint64_t gpuaddr, struct kgsl_process_private *process)
Shrenuj Bansala419c792016-10-20 14:05:11 -0700112{
113 int index;
114
115 for (index = 0; index < objbufptr; index++) {
116 if (objbuf[index].gpuaddr == gpuaddr &&
117 objbuf[index].entry->priv == process)
118 return index;
119 }
120 return -ENOENT;
121}
122
123/*
124 * snapshot_freeze_obj_list() - Take a list of ib objects and freeze their
125 * memory for snapshot
126 * @snapshot: The snapshot data.
127 * @process: The process to which the IB belongs
128 * @ib_obj_list: List of the IB objects
Shrenuj Bansala419c792016-10-20 14:05:11 -0700129 *
130 * Returns 0 on success else error code
131 */
132static int snapshot_freeze_obj_list(struct kgsl_snapshot *snapshot,
133 struct kgsl_process_private *process,
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530134 struct adreno_ib_object_list *ib_obj_list)
Shrenuj Bansala419c792016-10-20 14:05:11 -0700135{
136 int ret = 0;
137 struct adreno_ib_object *ib_objs;
138 int i;
139
140 for (i = 0; i < ib_obj_list->num_objs; i++) {
141 int temp_ret;
142 int index;
143 int freeze = 1;
144
145 ib_objs = &(ib_obj_list->obj_list[i]);
146 /* Make sure this object is not going to be saved statically */
147 for (index = 0; index < objbufptr; index++) {
148 if ((objbuf[index].gpuaddr <= ib_objs->gpuaddr) &&
149 ((objbuf[index].gpuaddr +
150 (objbuf[index].size)) >=
151 (ib_objs->gpuaddr + ib_objs->size)) &&
152 (objbuf[index].entry->priv == process)) {
153 freeze = 0;
154 break;
155 }
156 }
157
158 if (freeze) {
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530159 temp_ret = kgsl_snapshot_get_object(snapshot,
160 process, ib_objs->gpuaddr,
161 ib_objs->size,
162 ib_objs->snapshot_obj_type);
163 if (temp_ret < 0) {
164 if (ret >= 0)
165 ret = temp_ret;
Shrenuj Bansala419c792016-10-20 14:05:11 -0700166 } else {
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530167 snapshot_frozen_objsize += temp_ret;
Shrenuj Bansala419c792016-10-20 14:05:11 -0700168 }
169 }
170 }
171 return ret;
172}
173
174/*
175 * We want to store the last executed IB1 and IB2 in the static region to ensure
176 * that we get at least some information out of the snapshot even if we can't
177 * access the dynamic data from the sysfs file. Push all other IBs on the
178 * dynamic list
179 */
180static inline void parse_ib(struct kgsl_device *device,
181 struct kgsl_snapshot *snapshot,
182 struct kgsl_process_private *process,
183 uint64_t gpuaddr, uint64_t dwords)
184{
185 struct adreno_ib_object_list *ib_obj_list;
186
187 /*
188 * Check the IB address - if it is either the last executed IB1
189 * then push it into the static blob otherwise put it in the dynamic
190 * list
191 */
192 if (gpuaddr == snapshot->ib1base) {
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530193 kgsl_snapshot_push_object(process, gpuaddr, dwords);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700194 return;
195 }
196
197 if (kgsl_snapshot_have_object(snapshot, process,
198 gpuaddr, dwords << 2))
199 return;
200
201 if (-E2BIG == adreno_ib_create_object_list(device, process,
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530202 gpuaddr, dwords, snapshot->ib2base,
203 &ib_obj_list))
Shrenuj Bansala419c792016-10-20 14:05:11 -0700204 ib_max_objs = 1;
205
206 if (ib_obj_list)
207 kgsl_snapshot_add_ib_obj_list(snapshot, ib_obj_list);
208
209}
210
211static inline bool iommu_is_setstate_addr(struct kgsl_device *device,
212 uint64_t gpuaddr, uint64_t size)
213{
214 struct kgsl_iommu *iommu = KGSL_IOMMU_PRIV(device);
215
216 if (kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_IOMMU)
217 return false;
218
219 return kgsl_gpuaddr_in_memdesc(&iommu->setstate, gpuaddr,
220 size);
221}
222
223static void dump_all_ibs(struct kgsl_device *device,
224 struct adreno_ringbuffer *rb,
225 struct kgsl_snapshot *snapshot)
226{
227 int index = 0;
228 unsigned int *rbptr;
229 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
230
231 rbptr = rb->buffer_desc.hostptr;
232
233 for (index = 0; index < KGSL_RB_DWORDS;) {
234
235 if (adreno_cmd_is_ib(adreno_dev, rbptr[index])) {
236 uint64_t ibaddr;
237 uint64_t ibsize;
238
239 if (ADRENO_LEGACY_PM4(adreno_dev)) {
240 ibaddr = rbptr[index + 1];
241 ibsize = rbptr[index + 2];
242 index += 3;
243 } else {
244 ibaddr = rbptr[index + 2];
245 ibaddr = ibaddr << 32 | rbptr[index + 1];
246 ibsize = rbptr[index + 3];
247 index += 4;
248 }
249
250 /* Don't parse known global IBs */
251 if (iommu_is_setstate_addr(device, ibaddr, ibsize))
252 continue;
253
254 if (kgsl_gpuaddr_in_memdesc(&adreno_dev->pwron_fixup,
255 ibaddr, ibsize))
256 continue;
257
258 parse_ib(device, snapshot, snapshot->process, ibaddr,
259 ibsize);
260 } else
261 index = index + 1;
262 }
263}
264
265/**
266 * snapshot_rb_ibs() - Dump rb data and capture the IB's in the RB as well
267 * @device: Pointer to a KGSL device
268 * @rb: The RB to dump
269 * @data: Pointer to memory where the RB data is to be dumped
270 * @snapshot: Pointer to information about the current snapshot being taken
271 */
272static void snapshot_rb_ibs(struct kgsl_device *device,
273 struct adreno_ringbuffer *rb,
274 struct kgsl_snapshot *snapshot)
275{
276 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
277 unsigned int rptr, *rbptr;
278 int index, i;
279 int parse_ibs = 0, ib_parse_start;
280
281 /* Get the current read pointers for the RB */
282 adreno_readreg(adreno_dev, ADRENO_REG_CP_RB_RPTR, &rptr);
283
284 /*
285 * Figure out the window of ringbuffer data to dump. First we need to
286 * find where the last processed IB ws submitted. Start walking back
287 * from the rptr
288 */
289
290 index = rptr;
291 rbptr = rb->buffer_desc.hostptr;
292
293 do {
294 index--;
295
296 if (index < 0) {
297 if (ADRENO_LEGACY_PM4(adreno_dev))
298 index = KGSL_RB_DWORDS - 3;
299 else
300 index = KGSL_RB_DWORDS - 4;
301
302 /* We wrapped without finding what we wanted */
303 if (index < rb->wptr) {
304 index = rb->wptr;
305 break;
306 }
307 }
308
309 if (adreno_cmd_is_ib(adreno_dev, rbptr[index])) {
310 if (ADRENO_LEGACY_PM4(adreno_dev)) {
311 if (rbptr[index + 1] == snapshot->ib1base)
312 break;
313 } else {
314 uint64_t ibaddr;
315
316 ibaddr = rbptr[index + 2];
317 ibaddr = ibaddr << 32 | rbptr[index + 1];
318 if (ibaddr == snapshot->ib1base)
319 break;
320 }
321 }
322 } while (index != rb->wptr);
323
324 /*
325 * If the ib1 was not found, for example, if ib1base was restored
326 * incorrectly after preemption, then simply dump the entire
327 * ringbuffer along with all the IBs in the ringbuffer.
328 */
329
330 if (index == rb->wptr) {
331 dump_all_ibs(device, rb, snapshot);
332 return;
333 }
334
335 /*
336 * index points at the last submitted IB. We can only trust that the
337 * memory between the context switch and the hanging IB is valid, so
338 * the next step is to find the context switch before the submission
339 */
340
341 while (index != rb->wptr) {
342 index--;
343
344 if (index < 0) {
345 index = KGSL_RB_DWORDS - 2;
346
347 /*
348 * Wrapped without finding the context switch. This is
349 * harmless - we should still have enough data to dump a
350 * valid state
351 */
352
353 if (index < rb->wptr) {
354 index = rb->wptr;
355 break;
356 }
357 }
358
359 /* Break if the current packet is a context switch identifier */
360 if ((rbptr[index] == cp_packet(adreno_dev, CP_NOP, 1)) &&
361 (rbptr[index + 1] == KGSL_CONTEXT_TO_MEM_IDENTIFIER))
362 break;
363 }
364
365 /*
366 * Index represents the start of the window of interest. We will try
367 * to dump all buffers between here and the rptr
368 */
369
370 ib_parse_start = index;
371
372 /*
373 * Loop through the RB, looking for indirect buffers and MMU pagetable
374 * changes
375 */
376
377 index = rb->wptr;
378 for (i = 0; i < KGSL_RB_DWORDS; i++) {
379 /*
380 * Only parse IBs between the start and the rptr or the next
381 * context switch, whichever comes first
382 */
383
384 if (parse_ibs == 0 && index == ib_parse_start)
385 parse_ibs = 1;
386 else if (index == rptr || adreno_rb_ctxtswitch(adreno_dev,
387 &rbptr[index]))
388 parse_ibs = 0;
389
390 if (parse_ibs && adreno_cmd_is_ib(adreno_dev, rbptr[index])) {
391 uint64_t ibaddr;
392 uint64_t ibsize;
393
394 if (ADRENO_LEGACY_PM4(adreno_dev)) {
395 ibaddr = rbptr[index + 1];
396 ibsize = rbptr[index + 2];
397 } else {
398 ibaddr = rbptr[index + 2];
399 ibaddr = ibaddr << 32 | rbptr[index + 1];
400 ibsize = rbptr[index + 3];
401 }
402
403 /* Don't parse known global IBs */
404 if (iommu_is_setstate_addr(device, ibaddr, ibsize))
405 continue;
406
407 if (kgsl_gpuaddr_in_memdesc(&adreno_dev->pwron_fixup,
408 ibaddr, ibsize))
409 continue;
410
411 parse_ib(device, snapshot, snapshot->process,
412 ibaddr, ibsize);
413 }
414
415 index = (index + 1) % KGSL_RB_DWORDS;
416 }
417
418}
419
420/* Snapshot the ringbuffer memory */
421static size_t snapshot_rb(struct kgsl_device *device, u8 *buf,
422 size_t remain, void *priv)
423{
424 struct kgsl_snapshot_rb_v2 *header = (struct kgsl_snapshot_rb_v2 *)buf;
425 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
426 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
427 struct snapshot_rb_params *snap_rb_params = priv;
428 struct kgsl_snapshot *snapshot = snap_rb_params->snapshot;
429 struct adreno_ringbuffer *rb = snap_rb_params->rb;
430
431 /*
432 * Dump the entire ringbuffer - the parser can choose how much of it to
433 * process
434 */
435
436 if (remain < KGSL_RB_SIZE + sizeof(*header)) {
437 KGSL_CORE_ERR("snapshot: Not enough memory for the rb section");
438 return 0;
439 }
440
441 /* Write the sub-header for the section */
442 header->start = 0;
443 header->end = KGSL_RB_DWORDS;
444 header->wptr = rb->wptr;
445 header->rptr = adreno_get_rptr(rb);
446 header->rbsize = KGSL_RB_DWORDS;
447 header->count = KGSL_RB_DWORDS;
448 adreno_rb_readtimestamp(adreno_dev, rb, KGSL_TIMESTAMP_QUEUED,
449 &header->timestamp_queued);
450 adreno_rb_readtimestamp(adreno_dev, rb, KGSL_TIMESTAMP_RETIRED,
451 &header->timestamp_retired);
452 header->gpuaddr = rb->buffer_desc.gpuaddr;
453 header->id = rb->id;
454
455 if (rb == adreno_dev->cur_rb)
456 snapshot_rb_ibs(device, rb, snapshot);
457
458 /* Just copy the ringbuffer, there are no active IBs */
459 memcpy(data, rb->buffer_desc.hostptr, KGSL_RB_SIZE);
460
461 /* Return the size of the section */
462 return KGSL_RB_SIZE + sizeof(*header);
463}
464
465static int _count_mem_entries(int id, void *ptr, void *data)
466{
467 int *count = data;
468 *count = *count + 1;
469 return 0;
470}
471
472struct mem_entry {
473 uint64_t gpuaddr;
474 uint64_t size;
475 unsigned int type;
476} __packed;
477
478static int _save_mem_entries(int id, void *ptr, void *data)
479{
480 struct kgsl_mem_entry *entry = ptr;
481 struct mem_entry *m = (struct mem_entry *) data;
482 unsigned int index = id - 1;
483
484 m[index].gpuaddr = entry->memdesc.gpuaddr;
485 m[index].size = entry->memdesc.size;
486 m[index].type = kgsl_memdesc_get_memtype(&entry->memdesc);
487
488 return 0;
489}
490
491static size_t snapshot_capture_mem_list(struct kgsl_device *device,
492 u8 *buf, size_t remain, void *priv)
493{
494 struct kgsl_snapshot_mem_list_v2 *header =
495 (struct kgsl_snapshot_mem_list_v2 *)buf;
496 int num_mem = 0;
497 int ret = 0;
498 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
499 struct kgsl_process_private *process = priv;
500
501 /* we need a process to search! */
502 if (process == NULL)
503 return 0;
504
505 spin_lock(&process->mem_lock);
506
507 /* We need to know the number of memory objects that the process has */
508 idr_for_each(&process->mem_idr, _count_mem_entries, &num_mem);
509
510 if (num_mem == 0)
511 goto out;
512
513 if (remain < ((num_mem * sizeof(struct mem_entry)) + sizeof(*header))) {
514 KGSL_CORE_ERR("snapshot: Not enough memory for the mem list");
515 goto out;
516 }
517
518 header->num_entries = num_mem;
519 header->ptbase = kgsl_mmu_pagetable_get_ttbr0(process->pagetable);
520
521 /*
522 * Walk through the memory list and store the
523 * tuples(gpuaddr, size, memtype) in snapshot
524 */
525 idr_for_each(&process->mem_idr, _save_mem_entries, data);
526
527 ret = sizeof(*header) + (num_mem * sizeof(struct mem_entry));
528out:
529 spin_unlock(&process->mem_lock);
530 return ret;
531}
532
533struct snapshot_ib_meta {
534 struct kgsl_snapshot *snapshot;
535 struct kgsl_snapshot_object *obj;
536 uint64_t ib1base;
537 uint64_t ib1size;
538 uint64_t ib2base;
539 uint64_t ib2size;
540};
541
542void kgsl_snapshot_add_active_ib_obj_list(struct kgsl_device *device,
543 struct kgsl_snapshot *snapshot)
544{
545 struct adreno_ib_object_list *ib_obj_list;
546 int index = -ENOENT;
547
548 if (!snapshot->ib1dumped)
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530549 index = find_object(snapshot->ib1base, snapshot->process);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700550
551 /* only do this for IB1 because the IB2's are part of IB1 objects */
552 if ((index != -ENOENT) &&
553 (snapshot->ib1base == objbuf[index].gpuaddr)) {
554 if (-E2BIG == adreno_ib_create_object_list(device,
555 objbuf[index].entry->priv,
556 objbuf[index].gpuaddr,
557 objbuf[index].size >> 2,
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530558 snapshot->ib2base,
Shrenuj Bansala419c792016-10-20 14:05:11 -0700559 &ib_obj_list))
560 ib_max_objs = 1;
561 if (ib_obj_list) {
562 /* freeze the IB objects in the IB */
563 snapshot_freeze_obj_list(snapshot,
564 objbuf[index].entry->priv,
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530565 ib_obj_list);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700566 adreno_ib_destroy_obj_list(ib_obj_list);
567 }
568 } else {
569 /* Get the IB2 index from parsed object */
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530570 index = find_object(snapshot->ib2base, snapshot->process);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700571
572 if (index != -ENOENT)
573 parse_ib(device, snapshot, snapshot->process,
574 snapshot->ib2base, objbuf[index].size >> 2);
575 }
576}
577
578/*
579 * active_ib_is_parsed() - Checks if active ib is already parsed
580 * @gpuaddr: Active IB base address at the time of fault
581 * @size: Active IB size
582 * @process: The process to which the IB belongs
583 *
584 * Function returns true if the active is already is parsed
585 * else false
586 */
587static bool active_ib_is_parsed(uint64_t gpuaddr, uint64_t size,
588 struct kgsl_process_private *process)
589{
590 int index;
591 /* go through the static list for gpuaddr is in list or not */
592 for (index = 0; index < objbufptr; index++) {
593 if ((objbuf[index].gpuaddr <= gpuaddr) &&
594 ((objbuf[index].gpuaddr +
595 (objbuf[index].size)) >=
596 (gpuaddr + size)) &&
597 (objbuf[index].entry->priv == process))
598 return true;
599 }
600 return false;
601}
602/* Snapshot the memory for an indirect buffer */
603static size_t snapshot_ib(struct kgsl_device *device, u8 *buf,
604 size_t remain, void *priv)
605{
606 struct kgsl_snapshot_ib_v2 *header = (struct kgsl_snapshot_ib_v2 *)buf;
607 struct snapshot_ib_meta *meta = priv;
608 unsigned int *src;
609 unsigned int *dst = (unsigned int *)(buf + sizeof(*header));
610 struct adreno_ib_object_list *ib_obj_list;
611 struct kgsl_snapshot *snapshot;
612 struct kgsl_snapshot_object *obj;
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530613 struct kgsl_memdesc *memdesc;
Shrenuj Bansala419c792016-10-20 14:05:11 -0700614
615 if (meta == NULL || meta->snapshot == NULL || meta->obj == NULL) {
616 KGSL_CORE_ERR("snapshot: bad metadata");
617 return 0;
618 }
619 snapshot = meta->snapshot;
620 obj = meta->obj;
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530621 memdesc = &obj->entry->memdesc;
622
623 /* If size is zero get it from the medesc size */
624 if (!obj->size)
625 obj->size = (memdesc->size - (obj->gpuaddr - memdesc->gpuaddr));
Shrenuj Bansala419c792016-10-20 14:05:11 -0700626
627 if (remain < (obj->size + sizeof(*header))) {
628 KGSL_CORE_ERR("snapshot: Not enough memory for the ib\n");
629 return 0;
630 }
631
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530632 src = kgsl_gpuaddr_to_vaddr(memdesc, obj->gpuaddr);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700633 if (src == NULL) {
634 KGSL_DRV_ERR(device,
635 "snapshot: Unable to map GPU memory object 0x%016llX into the kernel\n",
636 obj->gpuaddr);
637 return 0;
638 }
639
640 /* only do this for IB1 because the IB2's are part of IB1 objects */
641 if (meta->ib1base == obj->gpuaddr) {
642
643 snapshot->ib1dumped = active_ib_is_parsed(obj->gpuaddr,
644 obj->size, obj->entry->priv);
645 if (-E2BIG == adreno_ib_create_object_list(device,
646 obj->entry->priv,
647 obj->gpuaddr, obj->size >> 2,
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530648 snapshot->ib2base,
Shrenuj Bansala419c792016-10-20 14:05:11 -0700649 &ib_obj_list))
650 ib_max_objs = 1;
651 if (ib_obj_list) {
652 /* freeze the IB objects in the IB */
653 snapshot_freeze_obj_list(snapshot,
654 obj->entry->priv,
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530655 ib_obj_list);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700656 adreno_ib_destroy_obj_list(ib_obj_list);
657 }
658 }
659
660
661 if (meta->ib2base == obj->gpuaddr)
662 snapshot->ib2dumped = active_ib_is_parsed(obj->gpuaddr,
663 obj->size, obj->entry->priv);
664
665 /* Write the sub-header for the section */
666 header->gpuaddr = obj->gpuaddr;
667 header->ptbase =
668 kgsl_mmu_pagetable_get_ttbr0(obj->entry->priv->pagetable);
669 header->size = obj->size >> 2;
670
671 /* Write the contents of the ib */
672 memcpy((void *)dst, (void *)src, (size_t) obj->size);
673 /* Write the contents of the ib */
674
675 return obj->size + sizeof(*header);
676}
677
678/* Dump another item on the current pending list */
679static void dump_object(struct kgsl_device *device, int obj,
680 struct kgsl_snapshot *snapshot)
681{
682 struct snapshot_ib_meta meta;
683
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530684 meta.snapshot = snapshot;
685 meta.obj = &objbuf[obj];
686 meta.ib1base = snapshot->ib1base;
687 meta.ib1size = snapshot->ib1size;
688 meta.ib2base = snapshot->ib2base;
689 meta.ib2size = snapshot->ib2size;
Shrenuj Bansala419c792016-10-20 14:05:11 -0700690
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530691 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_IB_V2,
Shrenuj Bansala419c792016-10-20 14:05:11 -0700692 snapshot, snapshot_ib, &meta);
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530693 if (objbuf[obj].entry) {
694 kgsl_memdesc_unmap(&(objbuf[obj].entry->memdesc));
695 kgsl_mem_entry_put(objbuf[obj].entry);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700696 }
697}
698
699/* setup_fault process - Find kgsl_process_private struct that caused the fault
700 *
701 * Find the faulting process based what the dispatcher thinks happened and
702 * what the hardware is using for the current pagetable. The process struct
703 * will be used to look up GPU addresses that are encountered while parsing
704 * the GPU state.
705 */
706static void setup_fault_process(struct kgsl_device *device,
707 struct kgsl_snapshot *snapshot,
708 struct kgsl_process_private *process)
709{
710 u64 hw_ptbase, proc_ptbase;
711
712 if (process != NULL && !kgsl_process_private_get(process))
713 process = NULL;
714
715 /* Get the physical address of the MMU pagetable */
716 hw_ptbase = kgsl_mmu_get_current_ttbr0(&device->mmu);
717
718 /* if we have an input process, make sure the ptbases match */
719 if (process) {
720 proc_ptbase = kgsl_mmu_pagetable_get_ttbr0(process->pagetable);
721 /* agreement! No need to check further */
722 if (hw_ptbase == proc_ptbase)
723 goto done;
724
725 kgsl_process_private_put(process);
726 process = NULL;
727 KGSL_CORE_ERR("snapshot: ptbase mismatch hw %llx sw %llx\n",
728 hw_ptbase, proc_ptbase);
729 }
730
731 /* try to find the right pagetable by walking the process list */
732 if (kgsl_mmu_is_perprocess(&device->mmu)) {
733 struct kgsl_process_private *tmp;
734
735 mutex_lock(&kgsl_driver.process_mutex);
736 list_for_each_entry(tmp, &kgsl_driver.process_list, list) {
737 u64 pt_ttbr0;
738
739 pt_ttbr0 = kgsl_mmu_pagetable_get_ttbr0(tmp->pagetable);
740 if ((pt_ttbr0 == hw_ptbase)
741 && kgsl_process_private_get(tmp)) {
742 process = tmp;
743 break;
744 }
745 }
746 mutex_unlock(&kgsl_driver.process_mutex);
747 }
748done:
749 snapshot->process = process;
750}
751
752/* Snapshot a global memory buffer */
753static size_t snapshot_global(struct kgsl_device *device, u8 *buf,
754 size_t remain, void *priv)
755{
756 struct kgsl_memdesc *memdesc = priv;
757
758 struct kgsl_snapshot_gpu_object_v2 *header =
759 (struct kgsl_snapshot_gpu_object_v2 *)buf;
760
761 u8 *ptr = buf + sizeof(*header);
762
763 if (memdesc->size == 0)
764 return 0;
765
766 if (remain < (memdesc->size + sizeof(*header))) {
767 KGSL_CORE_ERR("snapshot: Not enough memory for the memdesc\n");
768 return 0;
769 }
770
771 if (memdesc->hostptr == NULL) {
772 KGSL_CORE_ERR(
773 "snapshot: no kernel mapping for global object 0x%016llX\n",
774 memdesc->gpuaddr);
775 return 0;
776 }
777
778 header->size = memdesc->size >> 2;
779 header->gpuaddr = memdesc->gpuaddr;
780 header->ptbase = MMU_DEFAULT_TTBR0(device);
781 header->type = SNAPSHOT_GPU_OBJECT_GLOBAL;
782
783 memcpy(ptr, memdesc->hostptr, memdesc->size);
784
785 return memdesc->size + sizeof(*header);
786}
787
788/* Snapshot IOMMU specific buffers */
789static void adreno_snapshot_iommu(struct kgsl_device *device,
790 struct kgsl_snapshot *snapshot)
791{
792 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
793 struct kgsl_iommu *iommu = KGSL_IOMMU_PRIV(device);
794
795 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2,
796 snapshot, snapshot_global, &iommu->setstate);
797
798 if (ADRENO_FEATURE(adreno_dev, ADRENO_PREEMPTION))
799 kgsl_snapshot_add_section(device,
800 KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2,
801 snapshot, snapshot_global, &iommu->smmu_info);
802}
803
804static void adreno_snapshot_ringbuffer(struct kgsl_device *device,
805 struct kgsl_snapshot *snapshot, struct adreno_ringbuffer *rb)
806{
807 struct snapshot_rb_params params = {
808 .snapshot = snapshot,
809 .rb = rb,
810 };
811
812 if (rb == NULL)
813 return;
814
815 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_RB_V2, snapshot,
816 snapshot_rb, &params);
817}
818
819/* adreno_snapshot - Snapshot the Adreno GPU state
820 * @device - KGSL device to snapshot
821 * @snapshot - Pointer to the snapshot instance
822 * @context - context that caused the fault, if known by the driver
823 * This is a hook function called by kgsl_snapshot to snapshot the
824 * Adreno specific information for the GPU snapshot. In turn, this function
825 * calls the GPU specific snapshot function to get core specific information.
826 */
827void adreno_snapshot(struct kgsl_device *device, struct kgsl_snapshot *snapshot,
828 struct kgsl_context *context)
829{
830 unsigned int i;
831 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
832 struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
833
834 ib_max_objs = 0;
835 /* Reset the list of objects */
836 objbufptr = 0;
837
838 snapshot_frozen_objsize = 0;
839
840 setup_fault_process(device, snapshot,
841 context ? context->proc_priv : NULL);
842
Shrenuj Bansald197bf62017-04-07 11:00:09 -0700843 /* Add GPU specific sections - registers mainly, but other stuff too */
844 if (gpudev->snapshot)
845 gpudev->snapshot(adreno_dev, snapshot);
846
847 /* Dumping these buffers is useless if the GX is not on */
848 if (gpudev->gx_is_on)
849 if (!gpudev->gx_is_on(adreno_dev))
850 return;
851
Shrenuj Bansala419c792016-10-20 14:05:11 -0700852 adreno_readreg64(adreno_dev, ADRENO_REG_CP_IB1_BASE,
853 ADRENO_REG_CP_IB1_BASE_HI, &snapshot->ib1base);
854 adreno_readreg(adreno_dev, ADRENO_REG_CP_IB1_BUFSZ, &snapshot->ib1size);
855 adreno_readreg64(adreno_dev, ADRENO_REG_CP_IB2_BASE,
856 ADRENO_REG_CP_IB2_BASE_HI, &snapshot->ib2base);
857 adreno_readreg(adreno_dev, ADRENO_REG_CP_IB2_BUFSZ, &snapshot->ib2size);
858
859 snapshot->ib1dumped = false;
860 snapshot->ib2dumped = false;
861
862 adreno_snapshot_ringbuffer(device, snapshot, adreno_dev->cur_rb);
863
864 /* Dump the prev ringbuffer */
865 if (adreno_dev->prev_rb != adreno_dev->cur_rb)
866 adreno_snapshot_ringbuffer(device, snapshot,
867 adreno_dev->prev_rb);
868
869 if ((adreno_dev->next_rb != adreno_dev->prev_rb) &&
870 (adreno_dev->next_rb != adreno_dev->cur_rb))
871 adreno_snapshot_ringbuffer(device, snapshot,
872 adreno_dev->next_rb);
873
Shrenuj Bansala419c792016-10-20 14:05:11 -0700874 /* Dump selected global buffers */
875 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2,
876 snapshot, snapshot_global, &device->memstore);
877
878 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2,
879 snapshot, snapshot_global,
880 &adreno_dev->pwron_fixup);
881
882 if (kgsl_mmu_get_mmutype(device) == KGSL_MMU_TYPE_IOMMU)
883 adreno_snapshot_iommu(device, snapshot);
884
885 /*
886 * Add a section that lists (gpuaddr, size, memtype) tuples of the
887 * hanging process
888 */
889 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MEMLIST_V2,
890 snapshot, snapshot_capture_mem_list, snapshot->process);
891 /*
892 * Make sure that the last IB1 that was being executed is dumped.
893 * Since this was the last IB1 that was processed, we should have
894 * already added it to the list during the ringbuffer parse but we
895 * want to be double plus sure.
896 * The problem is that IB size from the register is the unprocessed size
897 * of the buffer not the original size, so if we didn't catch this
898 * buffer being directly used in the RB, then we might not be able to
899 * dump the whole thing. Print a warning message so we can try to
900 * figure how often this really happens.
901 */
902
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530903 if (-ENOENT == find_object(snapshot->ib1base, snapshot->process) &&
904 snapshot->ib1size) {
905 kgsl_snapshot_push_object(snapshot->process, snapshot->ib1base,
906 snapshot->ib1size);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700907 KGSL_CORE_ERR(
908 "CP_IB1_BASE not found in the ringbuffer.Dumping %x dwords of the buffer.\n",
909 snapshot->ib1size);
910 }
911
912 /*
913 * Add the last parsed IB2 to the list. The IB2 should be found as we
914 * parse the objects below, but we try to add it to the list first, so
915 * it too can be parsed. Don't print an error message in this case - if
916 * the IB2 is found during parsing, the list will be updated with the
917 * correct size.
918 */
919
Hareesh Gundu9c6b1fa2017-01-06 15:37:09 +0530920 if (-ENOENT == find_object(snapshot->ib2base, snapshot->process)) {
921 kgsl_snapshot_push_object(snapshot->process, snapshot->ib2base,
922 snapshot->ib2size);
Shrenuj Bansala419c792016-10-20 14:05:11 -0700923 }
924
925 /*
926 * Go through the list of found objects and dump each one. As the IBs
927 * are parsed, more objects might be found, and objbufptr will increase
928 */
929 for (i = 0; i < objbufptr; i++)
930 dump_object(device, i, snapshot);
931
932 /*
933 * Incase snapshot static blob is running out of memory, Add Active IB1
934 * and IB2 entries to obj_list so that active ib's can be dumped to
935 * snapshot dynamic blob.
936 */
937 if (!snapshot->ib1dumped || !snapshot->ib2dumped)
938 kgsl_snapshot_add_active_ib_obj_list(device, snapshot);
939
940 if (ib_max_objs)
941 KGSL_CORE_ERR("Max objects found in IB\n");
942 if (snapshot_frozen_objsize)
943 KGSL_CORE_ERR("GPU snapshot froze %zdKb of GPU buffers\n",
944 snapshot_frozen_objsize / 1024);
945
946}
947
948/*
949 * adreno_snapshot_cp_roq - Dump CP merciu data in snapshot
950 * @device: Device being snapshotted
951 * @remain: Bytes remaining in snapshot memory
952 * @priv: Size of merciu data in Dwords
953 */
954size_t adreno_snapshot_cp_merciu(struct kgsl_device *device, u8 *buf,
955 size_t remain, void *priv)
956{
957 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
958 struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf;
959 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
960 int i, size = *((int *)priv);
961
962 /* The MERCIU data is two dwords per entry */
963 size = size << 1;
964
965 if (remain < DEBUG_SECTION_SZ(size)) {
966 SNAPSHOT_ERR_NOMEM(device, "CP MERCIU DEBUG");
967 return 0;
968 }
969
970 header->type = SNAPSHOT_DEBUG_CP_MERCIU;
971 header->size = size;
972
973 adreno_writereg(adreno_dev, ADRENO_REG_CP_MERCIU_ADDR, 0x0);
974
975 for (i = 0; i < size; i++) {
976 adreno_readreg(adreno_dev, ADRENO_REG_CP_MERCIU_DATA,
977 &data[(i * 2)]);
978 adreno_readreg(adreno_dev, ADRENO_REG_CP_MERCIU_DATA2,
979 &data[(i * 2) + 1]);
980 }
981
982 return DEBUG_SECTION_SZ(size);
983}
984
985/*
986 * adreno_snapshot_cp_roq - Dump ROQ data in snapshot
987 * @device: Device being snapshotted
988 * @remain: Bytes remaining in snapshot memory
989 * @priv: Size of ROQ data in Dwords
990 */
991size_t adreno_snapshot_cp_roq(struct kgsl_device *device, u8 *buf,
992 size_t remain, void *priv)
993{
994 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
995 struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf;
996 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
997 int i, size = *((int *)priv);
998
999 if (remain < DEBUG_SECTION_SZ(size)) {
1000 SNAPSHOT_ERR_NOMEM(device, "CP ROQ DEBUG");
1001 return 0;
1002 }
1003
1004 header->type = SNAPSHOT_DEBUG_CP_ROQ;
1005 header->size = size;
1006
1007 adreno_writereg(adreno_dev, ADRENO_REG_CP_ROQ_ADDR, 0x0);
1008 for (i = 0; i < size; i++)
1009 adreno_readreg(adreno_dev, ADRENO_REG_CP_ROQ_DATA, &data[i]);
1010
1011 return DEBUG_SECTION_SZ(size);
1012}
1013
1014/*
1015 * adreno_snapshot_cp_pm4_ram() - Dump PM4 data in snapshot
1016 * @device: Device being snapshotted
1017 * @buf: Snapshot memory
1018 * @remain: Number of bytes left in snapshot memory
1019 * @priv: Unused
1020 */
1021size_t adreno_snapshot_cp_pm4_ram(struct kgsl_device *device, u8 *buf,
1022 size_t remain, void *priv)
1023{
1024 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1025 struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf;
1026 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1027 int i;
Shrenuj Bansalacf1ef42016-06-01 11:11:27 -07001028 struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_PM4);
1029 size_t size = fw->size - 1;
Shrenuj Bansala419c792016-10-20 14:05:11 -07001030
1031 if (remain < DEBUG_SECTION_SZ(size)) {
1032 SNAPSHOT_ERR_NOMEM(device, "CP PM4 RAM DEBUG");
1033 return 0;
1034 }
1035
1036 header->type = SNAPSHOT_DEBUG_CP_PM4_RAM;
1037 header->size = size;
1038
1039 /*
1040 * Read the firmware from the GPU rather than use our cache in order to
1041 * try to catch mis-programming or corruption in the hardware. We do
1042 * use the cached version of the size, however, instead of trying to
1043 * maintain always changing hardcoded constants
1044 */
1045
1046 adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_RAM_RADDR, 0x0);
1047 for (i = 0; i < size; i++)
1048 adreno_readreg(adreno_dev, ADRENO_REG_CP_ME_RAM_DATA, &data[i]);
1049
1050 return DEBUG_SECTION_SZ(size);
1051}
1052
1053/*
1054 * adreno_snapshot_cp_pfp_ram() - Dump the PFP data on snapshot
1055 * @device: Device being snapshotted
1056 * @buf: Snapshot memory
1057 * @remain: Amount of butes left in snapshot memory
1058 * @priv: Unused
1059 */
1060size_t adreno_snapshot_cp_pfp_ram(struct kgsl_device *device, u8 *buf,
1061 size_t remain, void *priv)
1062{
1063 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1064 struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf;
1065 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
Shrenuj Bansalacf1ef42016-06-01 11:11:27 -07001066 int i;
1067 struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_PFP);
1068 int size = fw->size - 1;
Shrenuj Bansala419c792016-10-20 14:05:11 -07001069
1070 if (remain < DEBUG_SECTION_SZ(size)) {
1071 SNAPSHOT_ERR_NOMEM(device, "CP PFP RAM DEBUG");
1072 return 0;
1073 }
1074
1075 header->type = SNAPSHOT_DEBUG_CP_PFP_RAM;
1076 header->size = size;
1077
1078 /*
1079 * Read the firmware from the GPU rather than use our cache in order to
1080 * try to catch mis-programming or corruption in the hardware. We do
1081 * use the cached version of the size, however, instead of trying to
1082 * maintain always changing hardcoded constants
1083 */
1084 adreno_writereg(adreno_dev, ADRENO_REG_CP_PFP_UCODE_ADDR, 0x0);
1085 for (i = 0; i < size; i++)
1086 adreno_readreg(adreno_dev, ADRENO_REG_CP_PFP_UCODE_DATA,
1087 &data[i]);
1088
1089 return DEBUG_SECTION_SZ(size);
1090}
1091
1092/*
1093 * adreno_snapshot_vpc_memory() - Save VPC data in snapshot
1094 * @device: Device being snapshotted
1095 * @buf: Snapshot memory
1096 * @remain: Number of bytes left in snapshot memory
1097 * @priv: Private data for VPC if any
1098 */
1099size_t adreno_snapshot_vpc_memory(struct kgsl_device *device, u8 *buf,
1100 size_t remain, void *priv)
1101{
1102 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1103 struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf;
1104 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1105 int vpc_mem_size = *((int *)priv);
1106 size_t size = VPC_MEMORY_BANKS * vpc_mem_size;
1107 int bank, addr, i = 0;
1108
1109 if (remain < DEBUG_SECTION_SZ(size)) {
1110 SNAPSHOT_ERR_NOMEM(device, "VPC MEMORY");
1111 return 0;
1112 }
1113
1114 header->type = SNAPSHOT_DEBUG_VPC_MEMORY;
1115 header->size = size;
1116
1117 for (bank = 0; bank < VPC_MEMORY_BANKS; bank++) {
1118 for (addr = 0; addr < vpc_mem_size; addr++) {
1119 unsigned int val = bank | (addr << 4);
1120
1121 adreno_writereg(adreno_dev,
1122 ADRENO_REG_VPC_DEBUG_RAM_SEL, val);
1123 adreno_readreg(adreno_dev,
1124 ADRENO_REG_VPC_DEBUG_RAM_READ, &data[i++]);
1125 }
1126 }
1127
1128 return DEBUG_SECTION_SZ(size);
1129}
1130
1131/*
1132 * adreno_snapshot_cp_meq() - Save CP MEQ data in snapshot
1133 * @device: Device being snapshotted
1134 * @buf: Snapshot memory
1135 * @remain: Number of bytes left in snapshot memory
1136 * @priv: Contains the size of MEQ data
1137 */
1138size_t adreno_snapshot_cp_meq(struct kgsl_device *device, u8 *buf,
1139 size_t remain, void *priv)
1140{
1141 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1142 struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf;
1143 unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1144 int i;
1145 int cp_meq_sz = *((int *)priv);
1146
1147 if (remain < DEBUG_SECTION_SZ(cp_meq_sz)) {
1148 SNAPSHOT_ERR_NOMEM(device, "CP MEQ DEBUG");
1149 return 0;
1150 }
1151
1152 header->type = SNAPSHOT_DEBUG_CP_MEQ;
1153 header->size = cp_meq_sz;
1154
1155 adreno_writereg(adreno_dev, ADRENO_REG_CP_MEQ_ADDR, 0x0);
1156 for (i = 0; i < cp_meq_sz; i++)
1157 adreno_readreg(adreno_dev, ADRENO_REG_CP_MEQ_DATA, &data[i]);
1158
1159 return DEBUG_SECTION_SZ(cp_meq_sz);
1160}
1161
1162static const struct adreno_vbif_snapshot_registers *vbif_registers(
1163 struct adreno_device *adreno_dev,
1164 const struct adreno_vbif_snapshot_registers *list,
1165 unsigned int count)
1166{
1167 unsigned int version;
1168 unsigned int i;
1169
1170 adreno_readreg(adreno_dev, ADRENO_REG_VBIF_VERSION, &version);
1171
1172 for (i = 0; i < count; i++) {
1173 if ((list[i].version & list[i].mask) ==
1174 (version & list[i].mask))
1175 return &list[i];
1176 }
1177
1178 KGSL_CORE_ERR(
1179 "snapshot: Registers for VBIF version %X register were not dumped\n",
1180 version);
1181
1182 return NULL;
1183}
1184
1185void adreno_snapshot_registers(struct kgsl_device *device,
1186 struct kgsl_snapshot *snapshot,
1187 const unsigned int *regs, unsigned int count)
1188{
1189 struct kgsl_snapshot_registers r;
1190
1191 r.regs = regs;
1192 r.count = count;
1193
1194 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS, snapshot,
1195 kgsl_snapshot_dump_registers, &r);
1196}
1197
1198void adreno_snapshot_vbif_registers(struct kgsl_device *device,
1199 struct kgsl_snapshot *snapshot,
1200 const struct adreno_vbif_snapshot_registers *list,
1201 unsigned int count)
1202{
1203 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1204 struct kgsl_snapshot_registers regs;
1205 const struct adreno_vbif_snapshot_registers *vbif;
1206
1207 vbif = vbif_registers(adreno_dev, list, count);
1208
1209 if (vbif != NULL) {
1210 regs.regs = vbif->registers;
1211 regs.count = vbif->count;
1212
1213 kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
1214 snapshot, kgsl_snapshot_dump_registers, &regs);
1215 }
1216}