amdgpu_fence.c 17 KB

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