radeon_ring.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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. u32 rptr;
  281. if (rdev->wb.enabled)
  282. rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]);
  283. else
  284. rptr = RREG32(ring->rptr_reg);
  285. ring->rptr = (rptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift;
  286. /* This works because ring_size is a power of 2 */
  287. ring->ring_free_dw = (ring->rptr + (ring->ring_size / 4));
  288. ring->ring_free_dw -= ring->wptr;
  289. ring->ring_free_dw &= ring->ptr_mask;
  290. if (!ring->ring_free_dw) {
  291. ring->ring_free_dw = ring->ring_size / 4;
  292. }
  293. }
  294. int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw)
  295. {
  296. int r;
  297. /* Align requested size with padding so unlock_commit can
  298. * pad safely */
  299. ndw = (ndw + ring->align_mask) & ~ring->align_mask;
  300. while (ndw > (ring->ring_free_dw - 1)) {
  301. radeon_ring_free_size(rdev, ring);
  302. if (ndw < ring->ring_free_dw) {
  303. break;
  304. }
  305. r = radeon_fence_wait_next(rdev, radeon_ring_index(rdev, ring));
  306. if (r)
  307. return r;
  308. }
  309. ring->count_dw = ndw;
  310. ring->wptr_old = ring->wptr;
  311. return 0;
  312. }
  313. int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ndw)
  314. {
  315. int r;
  316. mutex_lock(&ring->mutex);
  317. r = radeon_ring_alloc(rdev, ring, ndw);
  318. if (r) {
  319. mutex_unlock(&ring->mutex);
  320. return r;
  321. }
  322. return 0;
  323. }
  324. void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *ring)
  325. {
  326. unsigned count_dw_pad;
  327. unsigned i;
  328. /* We pad to match fetch size */
  329. count_dw_pad = (ring->align_mask + 1) -
  330. (ring->wptr & ring->align_mask);
  331. for (i = 0; i < count_dw_pad; i++) {
  332. radeon_ring_write(ring, ring->nop);
  333. }
  334. DRM_MEMORYBARRIER();
  335. WREG32(ring->wptr_reg, (ring->wptr << ring->ptr_reg_shift) & ring->ptr_reg_mask);
  336. (void)RREG32(ring->wptr_reg);
  337. }
  338. void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *ring)
  339. {
  340. radeon_ring_commit(rdev, ring);
  341. mutex_unlock(&ring->mutex);
  342. }
  343. void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *ring)
  344. {
  345. ring->wptr = ring->wptr_old;
  346. mutex_unlock(&ring->mutex);
  347. }
  348. int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ring_size,
  349. unsigned rptr_offs, unsigned rptr_reg, unsigned wptr_reg,
  350. u32 ptr_reg_shift, u32 ptr_reg_mask, u32 nop)
  351. {
  352. int r;
  353. ring->ring_size = ring_size;
  354. ring->rptr_offs = rptr_offs;
  355. ring->rptr_reg = rptr_reg;
  356. ring->wptr_reg = wptr_reg;
  357. ring->ptr_reg_shift = ptr_reg_shift;
  358. ring->ptr_reg_mask = ptr_reg_mask;
  359. ring->nop = nop;
  360. /* Allocate ring buffer */
  361. if (ring->ring_obj == NULL) {
  362. r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true,
  363. RADEON_GEM_DOMAIN_GTT,
  364. &ring->ring_obj);
  365. if (r) {
  366. dev_err(rdev->dev, "(%d) ring create failed\n", r);
  367. return r;
  368. }
  369. r = radeon_bo_reserve(ring->ring_obj, false);
  370. if (unlikely(r != 0))
  371. return r;
  372. r = radeon_bo_pin(ring->ring_obj, RADEON_GEM_DOMAIN_GTT,
  373. &ring->gpu_addr);
  374. if (r) {
  375. radeon_bo_unreserve(ring->ring_obj);
  376. dev_err(rdev->dev, "(%d) ring pin failed\n", r);
  377. return r;
  378. }
  379. r = radeon_bo_kmap(ring->ring_obj,
  380. (void **)&ring->ring);
  381. radeon_bo_unreserve(ring->ring_obj);
  382. if (r) {
  383. dev_err(rdev->dev, "(%d) ring map failed\n", r);
  384. return r;
  385. }
  386. }
  387. ring->ptr_mask = (ring->ring_size / 4) - 1;
  388. ring->ring_free_dw = ring->ring_size / 4;
  389. return 0;
  390. }
  391. void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *ring)
  392. {
  393. int r;
  394. struct radeon_bo *ring_obj;
  395. mutex_lock(&ring->mutex);
  396. ring_obj = ring->ring_obj;
  397. ring->ring = NULL;
  398. ring->ring_obj = NULL;
  399. mutex_unlock(&ring->mutex);
  400. if (ring_obj) {
  401. r = radeon_bo_reserve(ring_obj, false);
  402. if (likely(r == 0)) {
  403. radeon_bo_kunmap(ring_obj);
  404. radeon_bo_unpin(ring_obj);
  405. radeon_bo_unreserve(ring_obj);
  406. }
  407. radeon_bo_unref(&ring_obj);
  408. }
  409. }
  410. /*
  411. * Debugfs info
  412. */
  413. #if defined(CONFIG_DEBUG_FS)
  414. static int radeon_debugfs_ring_info(struct seq_file *m, void *data)
  415. {
  416. struct drm_info_node *node = (struct drm_info_node *) m->private;
  417. struct drm_device *dev = node->minor->dev;
  418. struct radeon_device *rdev = dev->dev_private;
  419. int ridx = *(int*)node->info_ent->data;
  420. struct radeon_ring *ring = &rdev->ring[ridx];
  421. unsigned count, i, j;
  422. radeon_ring_free_size(rdev, ring);
  423. count = (ring->ring_size / 4) - ring->ring_free_dw;
  424. seq_printf(m, "wptr(0x%04x): 0x%08x\n", ring->wptr_reg, RREG32(ring->wptr_reg));
  425. seq_printf(m, "rptr(0x%04x): 0x%08x\n", ring->rptr_reg, RREG32(ring->rptr_reg));
  426. seq_printf(m, "driver's copy of the wptr: 0x%08x\n", ring->wptr);
  427. seq_printf(m, "driver's copy of the rptr: 0x%08x\n", ring->rptr);
  428. seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);
  429. seq_printf(m, "%u dwords in ring\n", count);
  430. i = ring->rptr;
  431. for (j = 0; j <= count; j++) {
  432. seq_printf(m, "r[%04d]=0x%08x\n", i, ring->ring[i]);
  433. i = (i + 1) & ring->ptr_mask;
  434. }
  435. return 0;
  436. }
  437. static int radeon_ring_type_gfx_index = RADEON_RING_TYPE_GFX_INDEX;
  438. static int cayman_ring_type_cp1_index = CAYMAN_RING_TYPE_CP1_INDEX;
  439. static int cayman_ring_type_cp2_index = CAYMAN_RING_TYPE_CP2_INDEX;
  440. static struct drm_info_list radeon_debugfs_ring_info_list[] = {
  441. {"radeon_ring_gfx", radeon_debugfs_ring_info, 0, &radeon_ring_type_gfx_index},
  442. {"radeon_ring_cp1", radeon_debugfs_ring_info, 0, &cayman_ring_type_cp1_index},
  443. {"radeon_ring_cp2", radeon_debugfs_ring_info, 0, &cayman_ring_type_cp2_index},
  444. };
  445. static int radeon_debugfs_ib_info(struct seq_file *m, void *data)
  446. {
  447. struct drm_info_node *node = (struct drm_info_node *) m->private;
  448. struct radeon_ib *ib = node->info_ent->data;
  449. unsigned i;
  450. if (ib == NULL) {
  451. return 0;
  452. }
  453. seq_printf(m, "IB %04u\n", ib->idx);
  454. seq_printf(m, "IB fence %p\n", ib->fence);
  455. seq_printf(m, "IB size %05u dwords\n", ib->length_dw);
  456. for (i = 0; i < ib->length_dw; i++) {
  457. seq_printf(m, "[%05u]=0x%08X\n", i, ib->ptr[i]);
  458. }
  459. return 0;
  460. }
  461. static int radeon_debugfs_ib_bogus_info(struct seq_file *m, void *data)
  462. {
  463. struct drm_info_node *node = (struct drm_info_node *) m->private;
  464. struct radeon_device *rdev = node->info_ent->data;
  465. struct radeon_ib *ib;
  466. unsigned i;
  467. mutex_lock(&rdev->ib_pool.mutex);
  468. if (list_empty(&rdev->ib_pool.bogus_ib)) {
  469. mutex_unlock(&rdev->ib_pool.mutex);
  470. seq_printf(m, "no bogus IB recorded\n");
  471. return 0;
  472. }
  473. ib = list_first_entry(&rdev->ib_pool.bogus_ib, struct radeon_ib, list);
  474. list_del_init(&ib->list);
  475. mutex_unlock(&rdev->ib_pool.mutex);
  476. seq_printf(m, "IB size %05u dwords\n", ib->length_dw);
  477. for (i = 0; i < ib->length_dw; i++) {
  478. seq_printf(m, "[%05u]=0x%08X\n", i, ib->ptr[i]);
  479. }
  480. vfree(ib->ptr);
  481. kfree(ib);
  482. return 0;
  483. }
  484. static struct drm_info_list radeon_debugfs_ib_list[RADEON_IB_POOL_SIZE];
  485. static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32];
  486. static struct drm_info_list radeon_debugfs_ib_bogus_info_list[] = {
  487. {"radeon_ib_bogus", radeon_debugfs_ib_bogus_info, 0, NULL},
  488. };
  489. #endif
  490. int radeon_debugfs_ring_init(struct radeon_device *rdev)
  491. {
  492. #if defined(CONFIG_DEBUG_FS)
  493. return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list,
  494. ARRAY_SIZE(radeon_debugfs_ring_info_list));
  495. #else
  496. return 0;
  497. #endif
  498. }
  499. int radeon_debugfs_ib_init(struct radeon_device *rdev)
  500. {
  501. #if defined(CONFIG_DEBUG_FS)
  502. unsigned i;
  503. int r;
  504. radeon_debugfs_ib_bogus_info_list[0].data = rdev;
  505. r = radeon_debugfs_add_files(rdev, radeon_debugfs_ib_bogus_info_list, 1);
  506. if (r)
  507. return r;
  508. for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
  509. sprintf(radeon_debugfs_ib_names[i], "radeon_ib_%04u", i);
  510. radeon_debugfs_ib_list[i].name = radeon_debugfs_ib_names[i];
  511. radeon_debugfs_ib_list[i].show = &radeon_debugfs_ib_info;
  512. radeon_debugfs_ib_list[i].driver_features = 0;
  513. radeon_debugfs_ib_list[i].data = &rdev->ib_pool.ibs[i];
  514. }
  515. return radeon_debugfs_add_files(rdev, radeon_debugfs_ib_list,
  516. RADEON_IB_POOL_SIZE);
  517. #else
  518. return 0;
  519. #endif
  520. }