amdgpu_fence.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * Copyright 2009 Jerome Glisse.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sub license, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  16. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  17. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  19. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. *
  21. * The above copyright notice and this permission notice (including the
  22. * next paragraph) shall be included in all copies or substantial portions
  23. * of the Software.
  24. *
  25. */
  26. /*
  27. * Authors:
  28. * Jerome Glisse <glisse@freedesktop.org>
  29. * Dave Airlie
  30. */
  31. #include <linux/seq_file.h>
  32. #include <linux/atomic.h>
  33. #include <linux/wait.h>
  34. #include <linux/kref.h>
  35. #include <linux/slab.h>
  36. #include <linux/firmware.h>
  37. #include <drm/drmP.h>
  38. #include "amdgpu.h"
  39. #include "amdgpu_trace.h"
  40. /*
  41. * Fences
  42. * Fences mark an event in the GPUs pipeline and are used
  43. * for GPU/CPU synchronization. When the fence is written,
  44. * it is expected that all buffers associated with that fence
  45. * are no longer in use by the associated ring on the GPU and
  46. * that the the relevant GPU caches have been flushed.
  47. */
  48. struct amdgpu_fence {
  49. struct fence base;
  50. /* RB, DMA, etc. */
  51. struct amdgpu_ring *ring;
  52. };
  53. static struct kmem_cache *amdgpu_fence_slab;
  54. int amdgpu_fence_slab_init(void)
  55. {
  56. amdgpu_fence_slab = kmem_cache_create(
  57. "amdgpu_fence", sizeof(struct amdgpu_fence), 0,
  58. SLAB_HWCACHE_ALIGN, NULL);
  59. if (!amdgpu_fence_slab)
  60. return -ENOMEM;
  61. return 0;
  62. }
  63. void amdgpu_fence_slab_fini(void)
  64. {
  65. kmem_cache_destroy(amdgpu_fence_slab);
  66. }
  67. /*
  68. * Cast helper
  69. */
  70. static const struct fence_ops amdgpu_fence_ops;
  71. static inline struct amdgpu_fence *to_amdgpu_fence(struct fence *f)
  72. {
  73. struct amdgpu_fence *__f = container_of(f, struct amdgpu_fence, base);
  74. if (__f->base.ops == &amdgpu_fence_ops)
  75. return __f;
  76. return NULL;
  77. }
  78. /**
  79. * amdgpu_fence_write - write a fence value
  80. *
  81. * @ring: ring the fence is associated with
  82. * @seq: sequence number to write
  83. *
  84. * Writes a fence value to memory (all asics).
  85. */
  86. static void amdgpu_fence_write(struct amdgpu_ring *ring, u32 seq)
  87. {
  88. struct amdgpu_fence_driver *drv = &ring->fence_drv;
  89. if (drv->cpu_addr)
  90. *drv->cpu_addr = cpu_to_le32(seq);
  91. }
  92. /**
  93. * amdgpu_fence_read - read a fence value
  94. *
  95. * @ring: ring the fence is associated with
  96. *
  97. * Reads a fence value from memory (all asics).
  98. * Returns the value of the fence read from memory.
  99. */
  100. static u32 amdgpu_fence_read(struct amdgpu_ring *ring)
  101. {
  102. struct amdgpu_fence_driver *drv = &ring->fence_drv;
  103. u32 seq = 0;
  104. if (drv->cpu_addr)
  105. seq = le32_to_cpu(*drv->cpu_addr);
  106. else
  107. seq = atomic_read(&drv->last_seq);
  108. return seq;
  109. }
  110. /**
  111. * amdgpu_fence_emit - emit a fence on the requested ring
  112. *
  113. * @ring: ring the fence is associated with
  114. * @f: resulting fence object
  115. *
  116. * Emits a fence command on the requested ring (all asics).
  117. * Returns 0 on success, -ENOMEM on failure.
  118. */
  119. int amdgpu_fence_emit(struct amdgpu_ring *ring, struct fence **f)
  120. {
  121. struct amdgpu_device *adev = ring->adev;
  122. struct amdgpu_fence *fence;
  123. struct fence *old, **ptr;
  124. uint32_t seq;
  125. fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_KERNEL);
  126. if (fence == NULL)
  127. return -ENOMEM;
  128. seq = ++ring->fence_drv.sync_seq;
  129. fence->ring = ring;
  130. fence_init(&fence->base, &amdgpu_fence_ops,
  131. &ring->fence_drv.lock,
  132. adev->fence_context + ring->idx,
  133. seq);
  134. amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
  135. seq, AMDGPU_FENCE_FLAG_INT);
  136. ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask];
  137. /* This function can't be called concurrently anyway, otherwise
  138. * emitting the fence would mess up the hardware ring buffer.
  139. */
  140. old = rcu_dereference_protected(*ptr, 1);
  141. if (old && !fence_is_signaled(old)) {
  142. DRM_INFO("rcu slot is busy\n");
  143. fence_wait(old, false);
  144. }
  145. rcu_assign_pointer(*ptr, fence_get(&fence->base));
  146. *f = &fence->base;
  147. return 0;
  148. }
  149. /**
  150. * amdgpu_fence_schedule_fallback - schedule fallback check
  151. *
  152. * @ring: pointer to struct amdgpu_ring
  153. *
  154. * Start a timer as fallback to our interrupts.
  155. */
  156. static void amdgpu_fence_schedule_fallback(struct amdgpu_ring *ring)
  157. {
  158. mod_timer(&ring->fence_drv.fallback_timer,
  159. jiffies + AMDGPU_FENCE_JIFFIES_TIMEOUT);
  160. }
  161. /**
  162. * amdgpu_fence_process - check for fence activity
  163. *
  164. * @ring: pointer to struct amdgpu_ring
  165. *
  166. * Checks the current fence value and calculates the last
  167. * signalled fence value. Wakes the fence queue if the
  168. * sequence number has increased.
  169. */
  170. void amdgpu_fence_process(struct amdgpu_ring *ring)
  171. {
  172. struct amdgpu_fence_driver *drv = &ring->fence_drv;
  173. uint32_t seq, last_seq;
  174. int r;
  175. do {
  176. last_seq = atomic_read(&ring->fence_drv.last_seq);
  177. seq = amdgpu_fence_read(ring);
  178. } while (atomic_cmpxchg(&drv->last_seq, last_seq, seq) != last_seq);
  179. if (seq != ring->fence_drv.sync_seq)
  180. amdgpu_fence_schedule_fallback(ring);
  181. while (last_seq != seq) {
  182. struct fence *fence, **ptr;
  183. ptr = &drv->fences[++last_seq & drv->num_fences_mask];
  184. /* There is always exactly one thread signaling this fence slot */
  185. fence = rcu_dereference_protected(*ptr, 1);
  186. RCU_INIT_POINTER(*ptr, NULL);
  187. BUG_ON(!fence);
  188. r = fence_signal(fence);
  189. if (!r)
  190. FENCE_TRACE(fence, "signaled from irq context\n");
  191. else
  192. BUG();
  193. fence_put(fence);
  194. }
  195. }
  196. /**
  197. * amdgpu_fence_fallback - fallback for hardware interrupts
  198. *
  199. * @work: delayed work item
  200. *
  201. * Checks for fence activity.
  202. */
  203. static void amdgpu_fence_fallback(unsigned long arg)
  204. {
  205. struct amdgpu_ring *ring = (void *)arg;
  206. amdgpu_fence_process(ring);
  207. }
  208. /**
  209. * amdgpu_fence_wait_empty - wait for all fences to signal
  210. *
  211. * @adev: amdgpu device pointer
  212. * @ring: ring index the fence is associated with
  213. *
  214. * Wait for all fences on the requested ring to signal (all asics).
  215. * Returns 0 if the fences have passed, error for all other cases.
  216. */
  217. int amdgpu_fence_wait_empty(struct amdgpu_ring *ring)
  218. {
  219. uint64_t seq = ACCESS_ONCE(ring->fence_drv.sync_seq);
  220. struct fence *fence, **ptr;
  221. int r;
  222. if (!seq)
  223. return 0;
  224. ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask];
  225. rcu_read_lock();
  226. fence = rcu_dereference(*ptr);
  227. if (!fence || !fence_get_rcu(fence)) {
  228. rcu_read_unlock();
  229. return 0;
  230. }
  231. rcu_read_unlock();
  232. r = fence_wait(fence, false);
  233. fence_put(fence);
  234. return r;
  235. }
  236. /**
  237. * amdgpu_fence_count_emitted - get the count of emitted fences
  238. *
  239. * @ring: ring the fence is associated with
  240. *
  241. * Get the number of fences emitted on the requested ring (all asics).
  242. * Returns the number of emitted fences on the ring. Used by the
  243. * dynpm code to ring track activity.
  244. */
  245. unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring)
  246. {
  247. uint64_t emitted;
  248. /* We are not protected by ring lock when reading the last sequence
  249. * but it's ok to report slightly wrong fence count here.
  250. */
  251. amdgpu_fence_process(ring);
  252. emitted = 0x100000000ull;
  253. emitted -= atomic_read(&ring->fence_drv.last_seq);
  254. emitted += ACCESS_ONCE(ring->fence_drv.sync_seq);
  255. return lower_32_bits(emitted);
  256. }
  257. /**
  258. * amdgpu_fence_driver_start_ring - make the fence driver
  259. * ready for use on the requested ring.
  260. *
  261. * @ring: ring to start the fence driver on
  262. * @irq_src: interrupt source to use for this ring
  263. * @irq_type: interrupt type to use for this ring
  264. *
  265. * Make the fence driver ready for processing (all asics).
  266. * Not all asics have all rings, so each asic will only
  267. * start the fence driver on the rings it has.
  268. * Returns 0 for success, errors for failure.
  269. */
  270. int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
  271. struct amdgpu_irq_src *irq_src,
  272. unsigned irq_type)
  273. {
  274. struct amdgpu_device *adev = ring->adev;
  275. uint64_t index;
  276. if (ring != &adev->uvd.ring) {
  277. ring->fence_drv.cpu_addr = &adev->wb.wb[ring->fence_offs];
  278. ring->fence_drv.gpu_addr = adev->wb.gpu_addr + (ring->fence_offs * 4);
  279. } else {
  280. /* put fence directly behind firmware */
  281. index = ALIGN(adev->uvd.fw->size, 8);
  282. ring->fence_drv.cpu_addr = adev->uvd.cpu_addr + index;
  283. ring->fence_drv.gpu_addr = adev->uvd.gpu_addr + index;
  284. }
  285. amdgpu_fence_write(ring, atomic_read(&ring->fence_drv.last_seq));
  286. amdgpu_irq_get(adev, irq_src, irq_type);
  287. ring->fence_drv.irq_src = irq_src;
  288. ring->fence_drv.irq_type = irq_type;
  289. ring->fence_drv.initialized = true;
  290. dev_info(adev->dev, "fence driver on ring %d use gpu addr 0x%016llx, "
  291. "cpu addr 0x%p\n", ring->idx,
  292. ring->fence_drv.gpu_addr, ring->fence_drv.cpu_addr);
  293. return 0;
  294. }
  295. /**
  296. * amdgpu_fence_driver_init_ring - init the fence driver
  297. * for the requested ring.
  298. *
  299. * @ring: ring to init the fence driver on
  300. * @num_hw_submission: number of entries on the hardware queue
  301. *
  302. * Init the fence driver for the requested ring (all asics).
  303. * Helper function for amdgpu_fence_driver_init().
  304. */
  305. int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
  306. unsigned num_hw_submission)
  307. {
  308. long timeout;
  309. int r;
  310. /* Check that num_hw_submission is a power of two */
  311. if ((num_hw_submission & (num_hw_submission - 1)) != 0)
  312. return -EINVAL;
  313. ring->fence_drv.cpu_addr = NULL;
  314. ring->fence_drv.gpu_addr = 0;
  315. ring->fence_drv.sync_seq = 0;
  316. atomic_set(&ring->fence_drv.last_seq, 0);
  317. ring->fence_drv.initialized = false;
  318. setup_timer(&ring->fence_drv.fallback_timer, amdgpu_fence_fallback,
  319. (unsigned long)ring);
  320. ring->fence_drv.num_fences_mask = num_hw_submission * 2 - 1;
  321. spin_lock_init(&ring->fence_drv.lock);
  322. ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *),
  323. GFP_KERNEL);
  324. if (!ring->fence_drv.fences)
  325. return -ENOMEM;
  326. timeout = msecs_to_jiffies(amdgpu_lockup_timeout);
  327. if (timeout == 0) {
  328. /*
  329. * FIXME:
  330. * Delayed workqueue cannot use it directly,
  331. * so the scheduler will not use delayed workqueue if
  332. * MAX_SCHEDULE_TIMEOUT is set.
  333. * Currently keep it simple and silly.
  334. */
  335. timeout = MAX_SCHEDULE_TIMEOUT;
  336. }
  337. r = amd_sched_init(&ring->sched, &amdgpu_sched_ops,
  338. num_hw_submission,
  339. timeout, ring->name);
  340. if (r) {
  341. DRM_ERROR("Failed to create scheduler on ring %s.\n",
  342. ring->name);
  343. return r;
  344. }
  345. return 0;
  346. }
  347. /**
  348. * amdgpu_fence_driver_init - init the fence driver
  349. * for all possible rings.
  350. *
  351. * @adev: amdgpu device pointer
  352. *
  353. * Init the fence driver for all possible rings (all asics).
  354. * Not all asics have all rings, so each asic will only
  355. * start the fence driver on the rings it has using
  356. * amdgpu_fence_driver_start_ring().
  357. * Returns 0 for success.
  358. */
  359. int amdgpu_fence_driver_init(struct amdgpu_device *adev)
  360. {
  361. if (amdgpu_debugfs_fence_init(adev))
  362. dev_err(adev->dev, "fence debugfs file creation failed\n");
  363. return 0;
  364. }
  365. /**
  366. * amdgpu_fence_driver_fini - tear down the fence driver
  367. * for all possible rings.
  368. *
  369. * @adev: amdgpu device pointer
  370. *
  371. * Tear down the fence driver for all possible rings (all asics).
  372. */
  373. void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
  374. {
  375. unsigned i, j;
  376. int r;
  377. for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
  378. struct amdgpu_ring *ring = adev->rings[i];
  379. if (!ring || !ring->fence_drv.initialized)
  380. continue;
  381. r = amdgpu_fence_wait_empty(ring);
  382. if (r) {
  383. /* no need to trigger GPU reset as we are unloading */
  384. amdgpu_fence_driver_force_completion(adev);
  385. }
  386. amdgpu_irq_put(adev, ring->fence_drv.irq_src,
  387. ring->fence_drv.irq_type);
  388. amd_sched_fini(&ring->sched);
  389. del_timer_sync(&ring->fence_drv.fallback_timer);
  390. for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
  391. fence_put(ring->fence_drv.fences[j]);
  392. kfree(ring->fence_drv.fences);
  393. ring->fence_drv.initialized = false;
  394. }
  395. }
  396. /**
  397. * amdgpu_fence_driver_suspend - suspend the fence driver
  398. * for all possible rings.
  399. *
  400. * @adev: amdgpu device pointer
  401. *
  402. * Suspend the fence driver for all possible rings (all asics).
  403. */
  404. void amdgpu_fence_driver_suspend(struct amdgpu_device *adev)
  405. {
  406. int i, r;
  407. for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
  408. struct amdgpu_ring *ring = adev->rings[i];
  409. if (!ring || !ring->fence_drv.initialized)
  410. continue;
  411. /* wait for gpu to finish processing current batch */
  412. r = amdgpu_fence_wait_empty(ring);
  413. if (r) {
  414. /* delay GPU reset to resume */
  415. amdgpu_fence_driver_force_completion(adev);
  416. }
  417. /* disable the interrupt */
  418. amdgpu_irq_put(adev, ring->fence_drv.irq_src,
  419. ring->fence_drv.irq_type);
  420. }
  421. }
  422. /**
  423. * amdgpu_fence_driver_resume - resume the fence driver
  424. * for all possible rings.
  425. *
  426. * @adev: amdgpu device pointer
  427. *
  428. * Resume the fence driver for all possible rings (all asics).
  429. * Not all asics have all rings, so each asic will only
  430. * start the fence driver on the rings it has using
  431. * amdgpu_fence_driver_start_ring().
  432. * Returns 0 for success.
  433. */
  434. void amdgpu_fence_driver_resume(struct amdgpu_device *adev)
  435. {
  436. int i;
  437. for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
  438. struct amdgpu_ring *ring = adev->rings[i];
  439. if (!ring || !ring->fence_drv.initialized)
  440. continue;
  441. /* enable the interrupt */
  442. amdgpu_irq_get(adev, ring->fence_drv.irq_src,
  443. ring->fence_drv.irq_type);
  444. }
  445. }
  446. /**
  447. * amdgpu_fence_driver_force_completion - force all fence waiter to complete
  448. *
  449. * @adev: amdgpu device pointer
  450. *
  451. * In case of GPU reset failure make sure no process keep waiting on fence
  452. * that will never complete.
  453. */
  454. void amdgpu_fence_driver_force_completion(struct amdgpu_device *adev)
  455. {
  456. int i;
  457. for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
  458. struct amdgpu_ring *ring = adev->rings[i];
  459. if (!ring || !ring->fence_drv.initialized)
  460. continue;
  461. amdgpu_fence_write(ring, ring->fence_drv.sync_seq);
  462. }
  463. }
  464. /*
  465. * Common fence implementation
  466. */
  467. static const char *amdgpu_fence_get_driver_name(struct fence *fence)
  468. {
  469. return "amdgpu";
  470. }
  471. static const char *amdgpu_fence_get_timeline_name(struct fence *f)
  472. {
  473. struct amdgpu_fence *fence = to_amdgpu_fence(f);
  474. return (const char *)fence->ring->name;
  475. }
  476. /**
  477. * amdgpu_fence_enable_signaling - enable signalling on fence
  478. * @fence: fence
  479. *
  480. * This function is called with fence_queue lock held, and adds a callback
  481. * to fence_queue that checks if this fence is signaled, and if so it
  482. * signals the fence and removes itself.
  483. */
  484. static bool amdgpu_fence_enable_signaling(struct fence *f)
  485. {
  486. struct amdgpu_fence *fence = to_amdgpu_fence(f);
  487. struct amdgpu_ring *ring = fence->ring;
  488. if (!timer_pending(&ring->fence_drv.fallback_timer))
  489. amdgpu_fence_schedule_fallback(ring);
  490. FENCE_TRACE(&fence->base, "armed on ring %i!\n", ring->idx);
  491. return true;
  492. }
  493. /**
  494. * amdgpu_fence_free - free up the fence memory
  495. *
  496. * @rcu: RCU callback head
  497. *
  498. * Free up the fence memory after the RCU grace period.
  499. */
  500. static void amdgpu_fence_free(struct rcu_head *rcu)
  501. {
  502. struct fence *f = container_of(rcu, struct fence, rcu);
  503. struct amdgpu_fence *fence = to_amdgpu_fence(f);
  504. kmem_cache_free(amdgpu_fence_slab, fence);
  505. }
  506. /**
  507. * amdgpu_fence_release - callback that fence can be freed
  508. *
  509. * @fence: fence
  510. *
  511. * This function is called when the reference count becomes zero.
  512. * It just RCU schedules freeing up the fence.
  513. */
  514. static void amdgpu_fence_release(struct fence *f)
  515. {
  516. call_rcu(&f->rcu, amdgpu_fence_free);
  517. }
  518. static const struct fence_ops amdgpu_fence_ops = {
  519. .get_driver_name = amdgpu_fence_get_driver_name,
  520. .get_timeline_name = amdgpu_fence_get_timeline_name,
  521. .enable_signaling = amdgpu_fence_enable_signaling,
  522. .wait = fence_default_wait,
  523. .release = amdgpu_fence_release,
  524. };
  525. /*
  526. * Fence debugfs
  527. */
  528. #if defined(CONFIG_DEBUG_FS)
  529. static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
  530. {
  531. struct drm_info_node *node = (struct drm_info_node *)m->private;
  532. struct drm_device *dev = node->minor->dev;
  533. struct amdgpu_device *adev = dev->dev_private;
  534. int i;
  535. for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
  536. struct amdgpu_ring *ring = adev->rings[i];
  537. if (!ring || !ring->fence_drv.initialized)
  538. continue;
  539. amdgpu_fence_process(ring);
  540. seq_printf(m, "--- ring %d (%s) ---\n", i, ring->name);
  541. seq_printf(m, "Last signaled fence 0x%08x\n",
  542. atomic_read(&ring->fence_drv.last_seq));
  543. seq_printf(m, "Last emitted 0x%08x\n",
  544. ring->fence_drv.sync_seq);
  545. }
  546. return 0;
  547. }
  548. /**
  549. * amdgpu_debugfs_gpu_reset - manually trigger a gpu reset
  550. *
  551. * Manually trigger a gpu reset at the next fence wait.
  552. */
  553. static int amdgpu_debugfs_gpu_reset(struct seq_file *m, void *data)
  554. {
  555. struct drm_info_node *node = (struct drm_info_node *) m->private;
  556. struct drm_device *dev = node->minor->dev;
  557. struct amdgpu_device *adev = dev->dev_private;
  558. seq_printf(m, "gpu reset\n");
  559. amdgpu_gpu_reset(adev);
  560. return 0;
  561. }
  562. static const struct drm_info_list amdgpu_debugfs_fence_list[] = {
  563. {"amdgpu_fence_info", &amdgpu_debugfs_fence_info, 0, NULL},
  564. {"amdgpu_gpu_reset", &amdgpu_debugfs_gpu_reset, 0, NULL}
  565. };
  566. #endif
  567. int amdgpu_debugfs_fence_init(struct amdgpu_device *adev)
  568. {
  569. #if defined(CONFIG_DEBUG_FS)
  570. return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_fence_list, 2);
  571. #else
  572. return 0;
  573. #endif
  574. }