radeon_ring.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #include <linux/seq_file.h>
  29. #include <linux/slab.h>
  30. #include "drmP.h"
  31. #include "radeon_drm.h"
  32. #include "radeon_reg.h"
  33. #include "radeon.h"
  34. #include "atom.h"
  35. int radeon_debugfs_ib_init(struct radeon_device *rdev);
  36. int radeon_debugfs_ring_init(struct radeon_device *rdev);
  37. u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
  38. {
  39. struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx];
  40. u32 pg_idx, pg_offset;
  41. u32 idx_value = 0;
  42. int new_page;
  43. pg_idx = (idx * 4) / PAGE_SIZE;
  44. pg_offset = (idx * 4) % PAGE_SIZE;
  45. if (ibc->kpage_idx[0] == pg_idx)
  46. return ibc->kpage[0][pg_offset/4];
  47. if (ibc->kpage_idx[1] == pg_idx)
  48. return ibc->kpage[1][pg_offset/4];
  49. new_page = radeon_cs_update_pages(p, pg_idx);
  50. if (new_page < 0) {
  51. p->parser_error = new_page;
  52. return 0;
  53. }
  54. idx_value = ibc->kpage[new_page][pg_offset/4];
  55. return idx_value;
  56. }
  57. void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
  58. {
  59. #if DRM_DEBUG_CODE
  60. if (ring->count_dw <= 0) {
  61. DRM_ERROR("radeon: writting more dword to ring than expected !\n");
  62. }
  63. #endif
  64. ring->ring[ring->wptr++] = v;
  65. ring->wptr &= ring->ptr_mask;
  66. ring->count_dw--;
  67. ring->ring_free_dw--;
  68. }
  69. void radeon_ib_bogus_cleanup(struct radeon_device *rdev)
  70. {
  71. struct radeon_ib *ib, *n;
  72. list_for_each_entry_safe(ib, n, &rdev->ib_pool.bogus_ib, list) {
  73. list_del(&ib->list);
  74. vfree(ib->ptr);
  75. kfree(ib);
  76. }
  77. }
  78. void radeon_ib_bogus_add(struct radeon_device *rdev, struct radeon_ib *ib)
  79. {
  80. struct radeon_ib *bib;
  81. bib = kmalloc(sizeof(*bib), GFP_KERNEL);
  82. if (bib == NULL)
  83. return;
  84. bib->ptr = vmalloc(ib->length_dw * 4);
  85. if (bib->ptr == NULL) {
  86. kfree(bib);
  87. return;
  88. }
  89. memcpy(bib->ptr, ib->ptr, ib->length_dw * 4);
  90. bib->length_dw = ib->length_dw;
  91. mutex_lock(&rdev->ib_pool.mutex);
  92. list_add_tail(&bib->list, &rdev->ib_pool.bogus_ib);
  93. mutex_unlock(&rdev->ib_pool.mutex);
  94. }
  95. /*
  96. * IB.
  97. */
  98. int radeon_ib_get(struct radeon_device *rdev, int ring, struct radeon_ib **ib)
  99. {
  100. struct radeon_fence *fence;
  101. struct radeon_ib *nib;
  102. int r = 0, i, c;
  103. *ib = NULL;
  104. r = radeon_fence_create(rdev, &fence, ring);
  105. if (r) {
  106. dev_err(rdev->dev, "failed to create fence for new IB\n");
  107. return r;
  108. }
  109. mutex_lock(&rdev->ib_pool.mutex);
  110. for (i = rdev->ib_pool.head_id, c = 0, nib = NULL; c < RADEON_IB_POOL_SIZE; c++, i++) {
  111. i &= (RADEON_IB_POOL_SIZE - 1);
  112. if (rdev->ib_pool.ibs[i].free) {
  113. nib = &rdev->ib_pool.ibs[i];
  114. break;
  115. }
  116. }
  117. if (nib == NULL) {
  118. /* This should never happen, it means we allocated all
  119. * IB and haven't scheduled one yet, return EBUSY to
  120. * userspace hoping that on ioctl recall we get better
  121. * luck
  122. */
  123. dev_err(rdev->dev, "no free indirect buffer !\n");
  124. mutex_unlock(&rdev->ib_pool.mutex);
  125. radeon_fence_unref(&fence);
  126. return -EBUSY;
  127. }
  128. rdev->ib_pool.head_id = (nib->idx + 1) & (RADEON_IB_POOL_SIZE - 1);
  129. nib->free = false;
  130. if (nib->fence) {
  131. mutex_unlock(&rdev->ib_pool.mutex);
  132. r = radeon_fence_wait(nib->fence, false);
  133. if (r) {
  134. dev_err(rdev->dev, "error waiting fence of IB(%u:0x%016lX:%u)\n",
  135. nib->idx, (unsigned long)nib->gpu_addr, nib->length_dw);
  136. mutex_lock(&rdev->ib_pool.mutex);
  137. nib->free = true;
  138. mutex_unlock(&rdev->ib_pool.mutex);
  139. radeon_fence_unref(&fence);
  140. return r;
  141. }
  142. mutex_lock(&rdev->ib_pool.mutex);
  143. }
  144. radeon_fence_unref(&nib->fence);
  145. nib->fence = fence;
  146. nib->length_dw = 0;
  147. mutex_unlock(&rdev->ib_pool.mutex);
  148. *ib = nib;
  149. return 0;
  150. }
  151. void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib)
  152. {
  153. struct radeon_ib *tmp = *ib;
  154. *ib = NULL;
  155. if (tmp == NULL) {
  156. return;
  157. }
  158. if (!tmp->fence->emitted)
  159. radeon_fence_unref(&tmp->fence);
  160. mutex_lock(&rdev->ib_pool.mutex);
  161. tmp->free = true;
  162. mutex_unlock(&rdev->ib_pool.mutex);
  163. }
  164. int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
  165. {
  166. struct radeon_ring *ring = &rdev->ring[ib->fence->ring];
  167. int r = 0;
  168. if (!ib->length_dw || !ring->ready) {
  169. /* TODO: Nothings in the ib we should report. */
  170. DRM_ERROR("radeon: couldn't schedule IB(%u).\n", ib->idx);
  171. return -EINVAL;
  172. }
  173. /* 64 dwords should be enough for fence too */
  174. r = radeon_ring_lock(rdev, ring, 64);
  175. if (r) {
  176. DRM_ERROR("radeon: scheduling IB failed (%d).\n", r);
  177. return r;
  178. }
  179. radeon_ring_ib_execute(rdev, ib->fence->ring, ib);
  180. radeon_fence_emit(rdev, ib->fence);
  181. mutex_lock(&rdev->ib_pool.mutex);
  182. /* once scheduled IB is considered free and protected by the fence */
  183. ib->free = true;
  184. mutex_unlock(&rdev->ib_pool.mutex);
  185. radeon_ring_unlock_commit(rdev, ring);
  186. return 0;
  187. }
  188. int radeon_ib_pool_init(struct radeon_device *rdev)
  189. {
  190. void *ptr;
  191. uint64_t gpu_addr;
  192. int i;
  193. int r = 0;
  194. if (rdev->ib_pool.robj)
  195. return 0;
  196. INIT_LIST_HEAD(&rdev->ib_pool.bogus_ib);
  197. /* Allocate 1M object buffer */
  198. r = radeon_bo_create(rdev, RADEON_IB_POOL_SIZE*64*1024,
  199. PAGE_SIZE, true, RADEON_GEM_DOMAIN_GTT,
  200. &rdev->ib_pool.robj);
  201. if (r) {
  202. DRM_ERROR("radeon: failed to ib pool (%d).\n", r);
  203. return r;
  204. }
  205. r = radeon_bo_reserve(rdev->ib_pool.robj, false);
  206. if (unlikely(r != 0))
  207. return r;
  208. r = radeon_bo_pin(rdev->ib_pool.robj, RADEON_GEM_DOMAIN_GTT, &gpu_addr);
  209. if (r) {
  210. radeon_bo_unreserve(rdev->ib_pool.robj);
  211. DRM_ERROR("radeon: failed to pin ib pool (%d).\n", r);
  212. return r;
  213. }
  214. r = radeon_bo_kmap(rdev->ib_pool.robj, &ptr);
  215. radeon_bo_unreserve(rdev->ib_pool.robj);
  216. if (r) {
  217. DRM_ERROR("radeon: failed to map ib pool (%d).\n", r);
  218. return r;
  219. }
  220. for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
  221. unsigned offset;
  222. offset = i * 64 * 1024;
  223. rdev->ib_pool.ibs[i].gpu_addr = gpu_addr + offset;
  224. rdev->ib_pool.ibs[i].ptr = ptr + offset;
  225. rdev->ib_pool.ibs[i].idx = i;
  226. rdev->ib_pool.ibs[i].length_dw = 0;
  227. rdev->ib_pool.ibs[i].free = true;
  228. }
  229. rdev->ib_pool.head_id = 0;
  230. rdev->ib_pool.ready = true;
  231. DRM_INFO("radeon: ib pool ready.\n");
  232. if (radeon_debugfs_ib_init(rdev)) {
  233. DRM_ERROR("Failed to register debugfs file for IB !\n");
  234. }
  235. if (radeon_debugfs_ring_init(rdev)) {
  236. DRM_ERROR("Failed to register debugfs file for rings !\n");
  237. }
  238. return r;
  239. }
  240. void radeon_ib_pool_fini(struct radeon_device *rdev)
  241. {
  242. int r;
  243. struct radeon_bo *robj;
  244. if (!rdev->ib_pool.ready) {
  245. return;
  246. }
  247. mutex_lock(&rdev->ib_pool.mutex);
  248. radeon_ib_bogus_cleanup(rdev);
  249. robj = rdev->ib_pool.robj;
  250. rdev->ib_pool.robj = NULL;
  251. mutex_unlock(&rdev->ib_pool.mutex);
  252. if (robj) {
  253. r = radeon_bo_reserve(robj, false);
  254. if (likely(r == 0)) {
  255. radeon_bo_kunmap(robj);
  256. radeon_bo_unpin(robj);
  257. radeon_bo_unreserve(robj);
  258. }
  259. radeon_bo_unref(&robj);
  260. }
  261. }
  262. /*
  263. * Ring.
  264. */
  265. int radeon_ring_index(struct radeon_device *rdev, struct radeon_ring *ring)
  266. {
  267. /* r1xx-r5xx only has CP ring */
  268. if (rdev->family < CHIP_R600)
  269. return RADEON_RING_TYPE_GFX_INDEX;
  270. if (rdev->family >= CHIP_CAYMAN) {
  271. if (ring == &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX])
  272. return CAYMAN_RING_TYPE_CP1_INDEX;
  273. else if (ring == &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX])
  274. return CAYMAN_RING_TYPE_CP2_INDEX;
  275. }
  276. return RADEON_RING_TYPE_GFX_INDEX;
  277. }
  278. void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *ring)
  279. {
  280. if (rdev->wb.enabled)
  281. ring->rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]);
  282. else
  283. ring->rptr = RREG32(ring->rptr_reg);
  284. /* This works because ring_size is a power of 2 */
  285. ring->ring_free_dw = (ring->rptr + (ring->ring_size / 4));
  286. ring->ring_free_dw -= ring->wptr;
  287. ring->ring_free_dw &= ring->ptr_mask;
  288. if (!ring->ring_free_dw) {
  289. ring->ring_free_dw = ring->ring_size / 4;
  290. }
  291. }
  292. int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw)
  293. {
  294. int r;
  295. /* Align requested size with padding so unlock_commit can
  296. * pad safely */
  297. ndw = (ndw + ring->align_mask) & ~ring->align_mask;
  298. while (ndw > (ring->ring_free_dw - 1)) {
  299. radeon_ring_free_size(rdev, ring);
  300. if (ndw < ring->ring_free_dw) {
  301. break;
  302. }
  303. r = radeon_fence_wait_next(rdev, radeon_ring_index(rdev, ring));
  304. if (r)
  305. return r;
  306. }
  307. ring->count_dw = ndw;
  308. ring->wptr_old = ring->wptr;
  309. return 0;
  310. }
  311. int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw)
  312. {
  313. int r;
  314. mutex_lock(&ring->mutex);
  315. r = radeon_ring_alloc(rdev, ring, ndw);
  316. if (r) {
  317. mutex_unlock(&ring->mutex);
  318. return r;
  319. }
  320. return 0;
  321. }
  322. void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *ring)
  323. {
  324. unsigned count_dw_pad;
  325. unsigned i;
  326. /* We pad to match fetch size */
  327. count_dw_pad = (ring->align_mask + 1) -
  328. (ring->wptr & ring->align_mask);
  329. for (i = 0; i < count_dw_pad; i++) {
  330. radeon_ring_write(ring, 2 << 30);
  331. }
  332. DRM_MEMORYBARRIER();
  333. WREG32(ring->wptr_reg, ring->wptr);
  334. (void)RREG32(ring->wptr_reg);
  335. }
  336. void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *ring)
  337. {
  338. radeon_ring_commit(rdev, ring);
  339. mutex_unlock(&ring->mutex);
  340. }
  341. void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *ring)
  342. {
  343. ring->wptr = ring->wptr_old;
  344. mutex_unlock(&ring->mutex);
  345. }
  346. int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ring_size,
  347. unsigned rptr_offs, unsigned rptr_reg, unsigned wptr_reg)
  348. {
  349. int r;
  350. ring->ring_size = ring_size;
  351. ring->rptr_offs = rptr_offs;
  352. ring->rptr_reg = rptr_reg;
  353. ring->wptr_reg = wptr_reg;
  354. /* Allocate ring buffer */
  355. if (ring->ring_obj == NULL) {
  356. r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true,
  357. RADEON_GEM_DOMAIN_GTT,
  358. &ring->ring_obj);
  359. if (r) {
  360. dev_err(rdev->dev, "(%d) ring create failed\n", r);
  361. return r;
  362. }
  363. r = radeon_bo_reserve(ring->ring_obj, false);
  364. if (unlikely(r != 0))
  365. return r;
  366. r = radeon_bo_pin(ring->ring_obj, RADEON_GEM_DOMAIN_GTT,
  367. &ring->gpu_addr);
  368. if (r) {
  369. radeon_bo_unreserve(ring->ring_obj);
  370. dev_err(rdev->dev, "(%d) ring pin failed\n", r);
  371. return r;
  372. }
  373. r = radeon_bo_kmap(ring->ring_obj,
  374. (void **)&ring->ring);
  375. radeon_bo_unreserve(ring->ring_obj);
  376. if (r) {
  377. dev_err(rdev->dev, "(%d) ring map failed\n", r);
  378. return r;
  379. }
  380. }
  381. ring->ptr_mask = (ring->ring_size / 4) - 1;
  382. ring->ring_free_dw = ring->ring_size / 4;
  383. return 0;
  384. }
  385. void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *ring)
  386. {
  387. int r;
  388. struct radeon_bo *ring_obj;
  389. mutex_lock(&ring->mutex);
  390. ring_obj = ring->ring_obj;
  391. ring->ring = NULL;
  392. ring->ring_obj = NULL;
  393. mutex_unlock(&ring->mutex);
  394. if (ring_obj) {
  395. r = radeon_bo_reserve(ring_obj, false);
  396. if (likely(r == 0)) {
  397. radeon_bo_kunmap(ring_obj);
  398. radeon_bo_unpin(ring_obj);
  399. radeon_bo_unreserve(ring_obj);
  400. }
  401. radeon_bo_unref(&ring_obj);
  402. }
  403. }
  404. /*
  405. * Debugfs info
  406. */
  407. #if defined(CONFIG_DEBUG_FS)
  408. static int radeon_debugfs_ring_info(struct seq_file *m, void *data)
  409. {
  410. struct drm_info_node *node = (struct drm_info_node *) m->private;
  411. struct drm_device *dev = node->minor->dev;
  412. struct radeon_device *rdev = dev->dev_private;
  413. int ridx = *(int*)node->info_ent->data;
  414. struct radeon_ring *ring = &rdev->ring[ridx];
  415. unsigned count, i, j;
  416. radeon_ring_free_size(rdev, ring);
  417. count = (ring->ring_size / 4) - ring->ring_free_dw;
  418. seq_printf(m, "wptr(0x%04x): 0x%08x\n", ring->wptr_reg, RREG32(ring->wptr_reg));
  419. seq_printf(m, "rptr(0x%04x): 0x%08x\n", ring->rptr_reg, RREG32(ring->rptr_reg));
  420. seq_printf(m, "driver's copy of the wptr: 0x%08x\n", ring->wptr);
  421. seq_printf(m, "driver's copy of the rptr: 0x%08x\n", ring->rptr);
  422. seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);
  423. seq_printf(m, "%u dwords in ring\n", count);
  424. i = ring->rptr;
  425. for (j = 0; j <= count; j++) {
  426. seq_printf(m, "r[%04d]=0x%08x\n", i, ring->ring[i]);
  427. i = (i + 1) & ring->ptr_mask;
  428. }
  429. return 0;
  430. }
  431. static int radeon_ring_type_gfx_index = RADEON_RING_TYPE_GFX_INDEX;
  432. static int cayman_ring_type_cp1_index = CAYMAN_RING_TYPE_CP1_INDEX;
  433. static int cayman_ring_type_cp2_index = CAYMAN_RING_TYPE_CP2_INDEX;
  434. static struct drm_info_list radeon_debugfs_ring_info_list[] = {
  435. {"radeon_ring_gfx", radeon_debugfs_ring_info, 0, &radeon_ring_type_gfx_index},
  436. {"radeon_ring_cp1", radeon_debugfs_ring_info, 0, &cayman_ring_type_cp1_index},
  437. {"radeon_ring_cp2", radeon_debugfs_ring_info, 0, &cayman_ring_type_cp2_index},
  438. };
  439. static int radeon_debugfs_ib_info(struct seq_file *m, void *data)
  440. {
  441. struct drm_info_node *node = (struct drm_info_node *) m->private;
  442. struct radeon_ib *ib = node->info_ent->data;
  443. unsigned i;
  444. if (ib == NULL) {
  445. return 0;
  446. }
  447. seq_printf(m, "IB %04u\n", ib->idx);
  448. seq_printf(m, "IB fence %p\n", ib->fence);
  449. seq_printf(m, "IB size %05u dwords\n", ib->length_dw);
  450. for (i = 0; i < ib->length_dw; i++) {
  451. seq_printf(m, "[%05u]=0x%08X\n", i, ib->ptr[i]);
  452. }
  453. return 0;
  454. }
  455. static int radeon_debugfs_ib_bogus_info(struct seq_file *m, void *data)
  456. {
  457. struct drm_info_node *node = (struct drm_info_node *) m->private;
  458. struct radeon_device *rdev = node->info_ent->data;
  459. struct radeon_ib *ib;
  460. unsigned i;
  461. mutex_lock(&rdev->ib_pool.mutex);
  462. if (list_empty(&rdev->ib_pool.bogus_ib)) {
  463. mutex_unlock(&rdev->ib_pool.mutex);
  464. seq_printf(m, "no bogus IB recorded\n");
  465. return 0;
  466. }
  467. ib = list_first_entry(&rdev->ib_pool.bogus_ib, struct radeon_ib, list);
  468. list_del_init(&ib->list);
  469. mutex_unlock(&rdev->ib_pool.mutex);
  470. seq_printf(m, "IB size %05u dwords\n", ib->length_dw);
  471. for (i = 0; i < ib->length_dw; i++) {
  472. seq_printf(m, "[%05u]=0x%08X\n", i, ib->ptr[i]);
  473. }
  474. vfree(ib->ptr);
  475. kfree(ib);
  476. return 0;
  477. }
  478. static struct drm_info_list radeon_debugfs_ib_list[RADEON_IB_POOL_SIZE];
  479. static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32];
  480. static struct drm_info_list radeon_debugfs_ib_bogus_info_list[] = {
  481. {"radeon_ib_bogus", radeon_debugfs_ib_bogus_info, 0, NULL},
  482. };
  483. #endif
  484. int radeon_debugfs_ring_init(struct radeon_device *rdev)
  485. {
  486. #if defined(CONFIG_DEBUG_FS)
  487. return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list,
  488. ARRAY_SIZE(radeon_debugfs_ring_info_list));
  489. #else
  490. return 0;
  491. #endif
  492. }
  493. int radeon_debugfs_ib_init(struct radeon_device *rdev)
  494. {
  495. #if defined(CONFIG_DEBUG_FS)
  496. unsigned i;
  497. int r;
  498. radeon_debugfs_ib_bogus_info_list[0].data = rdev;
  499. r = radeon_debugfs_add_files(rdev, radeon_debugfs_ib_bogus_info_list, 1);
  500. if (r)
  501. return r;
  502. for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
  503. sprintf(radeon_debugfs_ib_names[i], "radeon_ib_%04u", i);
  504. radeon_debugfs_ib_list[i].name = radeon_debugfs_ib_names[i];
  505. radeon_debugfs_ib_list[i].show = &radeon_debugfs_ib_info;
  506. radeon_debugfs_ib_list[i].driver_features = 0;
  507. radeon_debugfs_ib_list[i].data = &rdev->ib_pool.ibs[i];
  508. }
  509. return radeon_debugfs_add_files(rdev, radeon_debugfs_ib_list,
  510. RADEON_IB_POOL_SIZE);
  511. #else
  512. return 0;
  513. #endif
  514. }