amdgpu_fence.c 17 KB

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