amdgpu_fence.c 17 KB

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