diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_ring.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ring.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index 6579eb4c1f28..e50513a62735 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c | |||
@@ -34,6 +34,36 @@ | |||
34 | 34 | ||
35 | int radeon_debugfs_ib_init(struct radeon_device *rdev); | 35 | int radeon_debugfs_ib_init(struct radeon_device *rdev); |
36 | 36 | ||
37 | void radeon_ib_bogus_cleanup(struct radeon_device *rdev) | ||
38 | { | ||
39 | struct radeon_ib *ib, *n; | ||
40 | |||
41 | list_for_each_entry_safe(ib, n, &rdev->ib_pool.bogus_ib, list) { | ||
42 | list_del(&ib->list); | ||
43 | vfree(ib->ptr); | ||
44 | kfree(ib); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | void radeon_ib_bogus_add(struct radeon_device *rdev, struct radeon_ib *ib) | ||
49 | { | ||
50 | struct radeon_ib *bib; | ||
51 | |||
52 | bib = kmalloc(sizeof(*bib), GFP_KERNEL); | ||
53 | if (bib == NULL) | ||
54 | return; | ||
55 | bib->ptr = vmalloc(ib->length_dw * 4); | ||
56 | if (bib->ptr == NULL) { | ||
57 | kfree(bib); | ||
58 | return; | ||
59 | } | ||
60 | memcpy(bib->ptr, ib->ptr, ib->length_dw * 4); | ||
61 | bib->length_dw = ib->length_dw; | ||
62 | mutex_lock(&rdev->ib_pool.mutex); | ||
63 | list_add_tail(&bib->list, &rdev->ib_pool.bogus_ib); | ||
64 | mutex_unlock(&rdev->ib_pool.mutex); | ||
65 | } | ||
66 | |||
37 | /* | 67 | /* |
38 | * IB. | 68 | * IB. |
39 | */ | 69 | */ |
@@ -142,6 +172,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev) | |||
142 | 172 | ||
143 | if (rdev->ib_pool.robj) | 173 | if (rdev->ib_pool.robj) |
144 | return 0; | 174 | return 0; |
175 | INIT_LIST_HEAD(&rdev->ib_pool.bogus_ib); | ||
145 | /* Allocate 1M object buffer */ | 176 | /* Allocate 1M object buffer */ |
146 | r = radeon_bo_create(rdev, NULL, RADEON_IB_POOL_SIZE*64*1024, | 177 | r = radeon_bo_create(rdev, NULL, RADEON_IB_POOL_SIZE*64*1024, |
147 | true, RADEON_GEM_DOMAIN_GTT, | 178 | true, RADEON_GEM_DOMAIN_GTT, |
@@ -192,6 +223,8 @@ void radeon_ib_pool_fini(struct radeon_device *rdev) | |||
192 | return; | 223 | return; |
193 | } | 224 | } |
194 | mutex_lock(&rdev->ib_pool.mutex); | 225 | mutex_lock(&rdev->ib_pool.mutex); |
226 | radeon_ib_bogus_cleanup(rdev); | ||
227 | |||
195 | if (rdev->ib_pool.robj) { | 228 | if (rdev->ib_pool.robj) { |
196 | r = radeon_bo_reserve(rdev->ib_pool.robj, false); | 229 | r = radeon_bo_reserve(rdev->ib_pool.robj, false); |
197 | if (likely(r == 0)) { | 230 | if (likely(r == 0)) { |
@@ -349,15 +382,49 @@ static int radeon_debugfs_ib_info(struct seq_file *m, void *data) | |||
349 | return 0; | 382 | return 0; |
350 | } | 383 | } |
351 | 384 | ||
385 | static int radeon_debugfs_ib_bogus_info(struct seq_file *m, void *data) | ||
386 | { | ||
387 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
388 | struct radeon_device *rdev = node->info_ent->data; | ||
389 | struct radeon_ib *ib; | ||
390 | unsigned i; | ||
391 | |||
392 | mutex_lock(&rdev->ib_pool.mutex); | ||
393 | if (list_empty(&rdev->ib_pool.bogus_ib)) { | ||
394 | mutex_unlock(&rdev->ib_pool.mutex); | ||
395 | seq_printf(m, "no bogus IB recorded\n"); | ||
396 | return 0; | ||
397 | } | ||
398 | ib = list_first_entry(&rdev->ib_pool.bogus_ib, struct radeon_ib, list); | ||
399 | list_del_init(&ib->list); | ||
400 | mutex_unlock(&rdev->ib_pool.mutex); | ||
401 | seq_printf(m, "IB size %05u dwords\n", ib->length_dw); | ||
402 | for (i = 0; i < ib->length_dw; i++) { | ||
403 | seq_printf(m, "[%05u]=0x%08X\n", i, ib->ptr[i]); | ||
404 | } | ||
405 | vfree(ib->ptr); | ||
406 | kfree(ib); | ||
407 | return 0; | ||
408 | } | ||
409 | |||
352 | static struct drm_info_list radeon_debugfs_ib_list[RADEON_IB_POOL_SIZE]; | 410 | static struct drm_info_list radeon_debugfs_ib_list[RADEON_IB_POOL_SIZE]; |
353 | static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32]; | 411 | static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32]; |
412 | |||
413 | static struct drm_info_list radeon_debugfs_ib_bogus_info_list[] = { | ||
414 | {"radeon_ib_bogus", radeon_debugfs_ib_bogus_info, 0, NULL}, | ||
415 | }; | ||
354 | #endif | 416 | #endif |
355 | 417 | ||
356 | int radeon_debugfs_ib_init(struct radeon_device *rdev) | 418 | int radeon_debugfs_ib_init(struct radeon_device *rdev) |
357 | { | 419 | { |
358 | #if defined(CONFIG_DEBUG_FS) | 420 | #if defined(CONFIG_DEBUG_FS) |
359 | unsigned i; | 421 | unsigned i; |
422 | int r; | ||
360 | 423 | ||
424 | radeon_debugfs_ib_bogus_info_list[0].data = rdev; | ||
425 | r = radeon_debugfs_add_files(rdev, radeon_debugfs_ib_bogus_info_list, 1); | ||
426 | if (r) | ||
427 | return r; | ||
361 | for (i = 0; i < RADEON_IB_POOL_SIZE; i++) { | 428 | for (i = 0; i < RADEON_IB_POOL_SIZE; i++) { |
362 | sprintf(radeon_debugfs_ib_names[i], "radeon_ib_%04u", i); | 429 | sprintf(radeon_debugfs_ib_names[i], "radeon_ib_%04u", i); |
363 | radeon_debugfs_ib_list[i].name = radeon_debugfs_ib_names[i]; | 430 | radeon_debugfs_ib_list[i].name = radeon_debugfs_ib_names[i]; |