2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
26 #include <linux/kthread.h>
27 #include <linux/pci.h>
28 #include <linux/uaccess.h>
29 #include <linux/pm_runtime.h>
30 #include <linux/poll.h>
31 #include <drm/drm_debugfs.h>
34 #include "amdgpu_pm.h"
35 #include "amdgpu_dm_debugfs.h"
36 #include "amdgpu_ras.h"
37 #include "amdgpu_rap.h"
38 #include "amdgpu_securedisplay.h"
39 #include "amdgpu_fw_attestation.h"
42 * amdgpu_debugfs_add_files - Add simple debugfs entries
44 * @adev: Device to attach debugfs entries to
45 * @files: Array of function callbacks that respond to reads
46 * @nfiles: Number of callbacks to register
49 int amdgpu_debugfs_add_files(struct amdgpu_device *adev,
50 const struct drm_info_list *files,
55 for (i = 0; i < adev->debugfs_count; i++) {
56 if (adev->debugfs[i].files == files) {
57 /* Already registered */
62 i = adev->debugfs_count + 1;
63 if (i > AMDGPU_DEBUGFS_MAX_COMPONENTS) {
64 DRM_ERROR("Reached maximum number of debugfs components.\n");
65 DRM_ERROR("Report so we increase "
66 "AMDGPU_DEBUGFS_MAX_COMPONENTS.\n");
69 adev->debugfs[adev->debugfs_count].files = files;
70 adev->debugfs[adev->debugfs_count].num_files = nfiles;
71 adev->debugfs_count = i;
72 #if defined(CONFIG_DEBUG_FS)
73 drm_debugfs_create_files(files, nfiles,
74 adev_to_drm(adev)->primary->debugfs_root,
75 adev_to_drm(adev)->primary);
80 int amdgpu_debugfs_wait_dump(struct amdgpu_device *adev)
82 #if defined(CONFIG_DEBUG_FS)
83 unsigned long timeout = 600 * HZ;
86 wake_up_interruptible(&adev->autodump.gpu_hang);
88 ret = wait_for_completion_interruptible_timeout(&adev->autodump.dumping, timeout);
90 pr_err("autodump: timeout, move on to gpu recovery\n");
97 #if defined(CONFIG_DEBUG_FS)
99 static int amdgpu_debugfs_autodump_open(struct inode *inode, struct file *file)
101 struct amdgpu_device *adev = inode->i_private;
104 file->private_data = adev;
106 ret = down_read_killable(&adev->reset_sem);
110 if (adev->autodump.dumping.done) {
111 reinit_completion(&adev->autodump.dumping);
117 up_read(&adev->reset_sem);
122 static int amdgpu_debugfs_autodump_release(struct inode *inode, struct file *file)
124 struct amdgpu_device *adev = file->private_data;
126 complete_all(&adev->autodump.dumping);
130 static unsigned int amdgpu_debugfs_autodump_poll(struct file *file, struct poll_table_struct *poll_table)
132 struct amdgpu_device *adev = file->private_data;
134 poll_wait(file, &adev->autodump.gpu_hang, poll_table);
136 if (amdgpu_in_reset(adev))
137 return POLLIN | POLLRDNORM | POLLWRNORM;
142 static const struct file_operations autodump_debug_fops = {
143 .owner = THIS_MODULE,
144 .open = amdgpu_debugfs_autodump_open,
145 .poll = amdgpu_debugfs_autodump_poll,
146 .release = amdgpu_debugfs_autodump_release,
149 static void amdgpu_debugfs_autodump_init(struct amdgpu_device *adev)
151 init_completion(&adev->autodump.dumping);
152 complete_all(&adev->autodump.dumping);
153 init_waitqueue_head(&adev->autodump.gpu_hang);
155 debugfs_create_file("amdgpu_autodump", 0600,
156 adev_to_drm(adev)->primary->debugfs_root,
157 adev, &autodump_debug_fops);
161 * amdgpu_debugfs_process_reg_op - Handle MMIO register reads/writes
163 * @read: True if reading
164 * @f: open file handle
165 * @buf: User buffer to write/read to
166 * @size: Number of bytes to write/read
167 * @pos: Offset to seek to
169 * This debugfs entry has special meaning on the offset being sought.
170 * Various bits have different meanings:
172 * Bit 62: Indicates a GRBM bank switch is needed
173 * Bit 61: Indicates a SRBM bank switch is needed (implies bit 62 is
175 * Bits 24..33: The SE or ME selector if needed
176 * Bits 34..43: The SH (or SA) or PIPE selector if needed
177 * Bits 44..53: The INSTANCE (or CU/WGP) or QUEUE selector if needed
179 * Bit 23: Indicates that the PM power gating lock should be held
180 * This is necessary to read registers that might be
181 * unreliable during a power gating transistion.
183 * The lower bits are the BYTE offset of the register to read. This
184 * allows reading multiple registers in a single call and having
185 * the returned size reflect that.
187 static int amdgpu_debugfs_process_reg_op(bool read, struct file *f,
188 char __user *buf, size_t size, loff_t *pos)
190 struct amdgpu_device *adev = file_inode(f)->i_private;
193 bool pm_pg_lock, use_bank, use_ring;
194 unsigned instance_bank, sh_bank, se_bank, me, pipe, queue, vmid;
196 pm_pg_lock = use_bank = use_ring = false;
197 instance_bank = sh_bank = se_bank = me = pipe = queue = vmid = 0;
199 if (size & 0x3 || *pos & 0x3 ||
200 ((*pos & (1ULL << 62)) && (*pos & (1ULL << 61))))
203 /* are we reading registers for which a PG lock is necessary? */
204 pm_pg_lock = (*pos >> 23) & 1;
206 if (*pos & (1ULL << 62)) {
207 se_bank = (*pos & GENMASK_ULL(33, 24)) >> 24;
208 sh_bank = (*pos & GENMASK_ULL(43, 34)) >> 34;
209 instance_bank = (*pos & GENMASK_ULL(53, 44)) >> 44;
211 if (se_bank == 0x3FF)
212 se_bank = 0xFFFFFFFF;
213 if (sh_bank == 0x3FF)
214 sh_bank = 0xFFFFFFFF;
215 if (instance_bank == 0x3FF)
216 instance_bank = 0xFFFFFFFF;
218 } else if (*pos & (1ULL << 61)) {
220 me = (*pos & GENMASK_ULL(33, 24)) >> 24;
221 pipe = (*pos & GENMASK_ULL(43, 34)) >> 34;
222 queue = (*pos & GENMASK_ULL(53, 44)) >> 44;
223 vmid = (*pos & GENMASK_ULL(58, 54)) >> 54;
227 use_bank = use_ring = false;
230 *pos &= (1UL << 22) - 1;
232 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
234 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
238 r = amdgpu_virt_enable_access_debugfs(adev);
240 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
245 if ((sh_bank != 0xFFFFFFFF && sh_bank >= adev->gfx.config.max_sh_per_se) ||
246 (se_bank != 0xFFFFFFFF && se_bank >= adev->gfx.config.max_shader_engines)) {
247 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
248 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
249 amdgpu_virt_disable_access_debugfs(adev);
252 mutex_lock(&adev->grbm_idx_mutex);
253 amdgpu_gfx_select_se_sh(adev, se_bank,
254 sh_bank, instance_bank);
255 } else if (use_ring) {
256 mutex_lock(&adev->srbm_mutex);
257 amdgpu_gfx_select_me_pipe_q(adev, me, pipe, queue, vmid);
261 mutex_lock(&adev->pm.mutex);
267 value = RREG32(*pos >> 2);
268 r = put_user(value, (uint32_t *)buf);
270 r = get_user(value, (uint32_t *)buf);
272 amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, value);
287 amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
288 mutex_unlock(&adev->grbm_idx_mutex);
289 } else if (use_ring) {
290 amdgpu_gfx_select_me_pipe_q(adev, 0, 0, 0, 0);
291 mutex_unlock(&adev->srbm_mutex);
295 mutex_unlock(&adev->pm.mutex);
297 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
298 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
300 amdgpu_virt_disable_access_debugfs(adev);
305 * amdgpu_debugfs_regs_read - Callback for reading MMIO registers
307 static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
308 size_t size, loff_t *pos)
310 return amdgpu_debugfs_process_reg_op(true, f, buf, size, pos);
314 * amdgpu_debugfs_regs_write - Callback for writing MMIO registers
316 static ssize_t amdgpu_debugfs_regs_write(struct file *f, const char __user *buf,
317 size_t size, loff_t *pos)
319 return amdgpu_debugfs_process_reg_op(false, f, (char __user *)buf, size, pos);
324 * amdgpu_debugfs_regs_pcie_read - Read from a PCIE register
326 * @f: open file handle
327 * @buf: User buffer to store read data in
328 * @size: Number of bytes to read
329 * @pos: Offset to seek to
331 * The lower bits are the BYTE offset of the register to read. This
332 * allows reading multiple registers in a single call and having
333 * the returned size reflect that.
335 static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf,
336 size_t size, loff_t *pos)
338 struct amdgpu_device *adev = file_inode(f)->i_private;
342 if (size & 0x3 || *pos & 0x3)
345 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
347 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
351 r = amdgpu_virt_enable_access_debugfs(adev);
353 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
360 value = RREG32_PCIE(*pos);
361 r = put_user(value, (uint32_t *)buf);
363 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
364 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
365 amdgpu_virt_disable_access_debugfs(adev);
375 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
376 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
378 amdgpu_virt_disable_access_debugfs(adev);
383 * amdgpu_debugfs_regs_pcie_write - Write to a PCIE register
385 * @f: open file handle
386 * @buf: User buffer to write data from
387 * @size: Number of bytes to write
388 * @pos: Offset to seek to
390 * The lower bits are the BYTE offset of the register to write. This
391 * allows writing multiple registers in a single call and having
392 * the returned size reflect that.
394 static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user *buf,
395 size_t size, loff_t *pos)
397 struct amdgpu_device *adev = file_inode(f)->i_private;
401 if (size & 0x3 || *pos & 0x3)
404 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
406 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
410 r = amdgpu_virt_enable_access_debugfs(adev);
412 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
419 r = get_user(value, (uint32_t *)buf);
421 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
422 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
423 amdgpu_virt_disable_access_debugfs(adev);
427 WREG32_PCIE(*pos, value);
435 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
436 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
438 amdgpu_virt_disable_access_debugfs(adev);
443 * amdgpu_debugfs_regs_didt_read - Read from a DIDT register
445 * @f: open file handle
446 * @buf: User buffer to store read data in
447 * @size: Number of bytes to read
448 * @pos: Offset to seek to
450 * The lower bits are the BYTE offset of the register to read. This
451 * allows reading multiple registers in a single call and having
452 * the returned size reflect that.
454 static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf,
455 size_t size, loff_t *pos)
457 struct amdgpu_device *adev = file_inode(f)->i_private;
461 if (size & 0x3 || *pos & 0x3)
464 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
466 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
470 r = amdgpu_virt_enable_access_debugfs(adev);
472 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
479 value = RREG32_DIDT(*pos >> 2);
480 r = put_user(value, (uint32_t *)buf);
482 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
483 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
484 amdgpu_virt_disable_access_debugfs(adev);
494 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
495 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
497 amdgpu_virt_disable_access_debugfs(adev);
502 * amdgpu_debugfs_regs_didt_write - Write to a DIDT register
504 * @f: open file handle
505 * @buf: User buffer to write data from
506 * @size: Number of bytes to write
507 * @pos: Offset to seek to
509 * The lower bits are the BYTE offset of the register to write. This
510 * allows writing multiple registers in a single call and having
511 * the returned size reflect that.
513 static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user *buf,
514 size_t size, loff_t *pos)
516 struct amdgpu_device *adev = file_inode(f)->i_private;
520 if (size & 0x3 || *pos & 0x3)
523 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
525 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
529 r = amdgpu_virt_enable_access_debugfs(adev);
531 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
538 r = get_user(value, (uint32_t *)buf);
540 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
541 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
542 amdgpu_virt_disable_access_debugfs(adev);
546 WREG32_DIDT(*pos >> 2, value);
554 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
555 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
557 amdgpu_virt_disable_access_debugfs(adev);
562 * amdgpu_debugfs_regs_smc_read - Read from a SMC register
564 * @f: open file handle
565 * @buf: User buffer to store read data in
566 * @size: Number of bytes to read
567 * @pos: Offset to seek to
569 * The lower bits are the BYTE offset of the register to read. This
570 * allows reading multiple registers in a single call and having
571 * the returned size reflect that.
573 static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf,
574 size_t size, loff_t *pos)
576 struct amdgpu_device *adev = file_inode(f)->i_private;
580 if (size & 0x3 || *pos & 0x3)
583 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
585 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
589 r = amdgpu_virt_enable_access_debugfs(adev);
591 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
598 value = RREG32_SMC(*pos);
599 r = put_user(value, (uint32_t *)buf);
601 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
602 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
603 amdgpu_virt_disable_access_debugfs(adev);
613 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
614 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
616 amdgpu_virt_disable_access_debugfs(adev);
621 * amdgpu_debugfs_regs_smc_write - Write to a SMC register
623 * @f: open file handle
624 * @buf: User buffer to write data from
625 * @size: Number of bytes to write
626 * @pos: Offset to seek to
628 * The lower bits are the BYTE offset of the register to write. This
629 * allows writing multiple registers in a single call and having
630 * the returned size reflect that.
632 static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *buf,
633 size_t size, loff_t *pos)
635 struct amdgpu_device *adev = file_inode(f)->i_private;
639 if (size & 0x3 || *pos & 0x3)
642 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
644 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
648 r = amdgpu_virt_enable_access_debugfs(adev);
650 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
657 r = get_user(value, (uint32_t *)buf);
659 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
660 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
661 amdgpu_virt_disable_access_debugfs(adev);
665 WREG32_SMC(*pos, value);
673 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
674 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
676 amdgpu_virt_disable_access_debugfs(adev);
681 * amdgpu_debugfs_gca_config_read - Read from gfx config data
683 * @f: open file handle
684 * @buf: User buffer to store read data in
685 * @size: Number of bytes to read
686 * @pos: Offset to seek to
688 * This file is used to access configuration data in a somewhat
689 * stable fashion. The format is a series of DWORDs with the first
690 * indicating which revision it is. New content is appended to the
691 * end so that older software can still read the data.
694 static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
695 size_t size, loff_t *pos)
697 struct amdgpu_device *adev = file_inode(f)->i_private;
700 uint32_t *config, no_regs = 0;
702 if (size & 0x3 || *pos & 0x3)
705 config = kmalloc_array(256, sizeof(*config), GFP_KERNEL);
709 /* version, increment each time something is added */
710 config[no_regs++] = 3;
711 config[no_regs++] = adev->gfx.config.max_shader_engines;
712 config[no_regs++] = adev->gfx.config.max_tile_pipes;
713 config[no_regs++] = adev->gfx.config.max_cu_per_sh;
714 config[no_regs++] = adev->gfx.config.max_sh_per_se;
715 config[no_regs++] = adev->gfx.config.max_backends_per_se;
716 config[no_regs++] = adev->gfx.config.max_texture_channel_caches;
717 config[no_regs++] = adev->gfx.config.max_gprs;
718 config[no_regs++] = adev->gfx.config.max_gs_threads;
719 config[no_regs++] = adev->gfx.config.max_hw_contexts;
720 config[no_regs++] = adev->gfx.config.sc_prim_fifo_size_frontend;
721 config[no_regs++] = adev->gfx.config.sc_prim_fifo_size_backend;
722 config[no_regs++] = adev->gfx.config.sc_hiz_tile_fifo_size;
723 config[no_regs++] = adev->gfx.config.sc_earlyz_tile_fifo_size;
724 config[no_regs++] = adev->gfx.config.num_tile_pipes;
725 config[no_regs++] = adev->gfx.config.backend_enable_mask;
726 config[no_regs++] = adev->gfx.config.mem_max_burst_length_bytes;
727 config[no_regs++] = adev->gfx.config.mem_row_size_in_kb;
728 config[no_regs++] = adev->gfx.config.shader_engine_tile_size;
729 config[no_regs++] = adev->gfx.config.num_gpus;
730 config[no_regs++] = adev->gfx.config.multi_gpu_tile_size;
731 config[no_regs++] = adev->gfx.config.mc_arb_ramcfg;
732 config[no_regs++] = adev->gfx.config.gb_addr_config;
733 config[no_regs++] = adev->gfx.config.num_rbs;
736 config[no_regs++] = adev->rev_id;
737 config[no_regs++] = adev->pg_flags;
738 config[no_regs++] = adev->cg_flags;
741 config[no_regs++] = adev->family;
742 config[no_regs++] = adev->external_rev_id;
745 config[no_regs++] = adev->pdev->device;
746 config[no_regs++] = adev->pdev->revision;
747 config[no_regs++] = adev->pdev->subsystem_device;
748 config[no_regs++] = adev->pdev->subsystem_vendor;
750 while (size && (*pos < no_regs * 4)) {
753 value = config[*pos >> 2];
754 r = put_user(value, (uint32_t *)buf);
771 * amdgpu_debugfs_sensor_read - Read from the powerplay sensors
773 * @f: open file handle
774 * @buf: User buffer to store read data in
775 * @size: Number of bytes to read
776 * @pos: Offset to seek to
778 * The offset is treated as the BYTE address of one of the sensors
779 * enumerated in amd/include/kgd_pp_interface.h under the
780 * 'amd_pp_sensors' enumeration. For instance to read the UVD VCLK
781 * you would use the offset 3 * 4 = 12.
783 static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf,
784 size_t size, loff_t *pos)
786 struct amdgpu_device *adev = file_inode(f)->i_private;
787 int idx, x, outsize, r, valuesize;
790 if (size & 3 || *pos & 0x3)
793 if (!adev->pm.dpm_enabled)
796 /* convert offset to sensor number */
799 valuesize = sizeof(values);
801 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
803 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
807 r = amdgpu_virt_enable_access_debugfs(adev);
809 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
813 r = amdgpu_dpm_read_sensor(adev, idx, &values[0], &valuesize);
815 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
816 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
819 amdgpu_virt_disable_access_debugfs(adev);
823 if (size > valuesize) {
824 amdgpu_virt_disable_access_debugfs(adev);
832 r = put_user(values[x++], (int32_t *)buf);
839 amdgpu_virt_disable_access_debugfs(adev);
840 return !r ? outsize : r;
843 /** amdgpu_debugfs_wave_read - Read WAVE STATUS data
845 * @f: open file handle
846 * @buf: User buffer to store read data in
847 * @size: Number of bytes to read
848 * @pos: Offset to seek to
850 * The offset being sought changes which wave that the status data
851 * will be returned for. The bits are used as follows:
853 * Bits 0..6: Byte offset into data
854 * Bits 7..14: SE selector
855 * Bits 15..22: SH/SA selector
856 * Bits 23..30: CU/{WGP+SIMD} selector
857 * Bits 31..36: WAVE ID selector
858 * Bits 37..44: SIMD ID selector
860 * The returned data begins with one DWORD of version information
861 * Followed by WAVE STATUS registers relevant to the GFX IP version
862 * being used. See gfx_v8_0_read_wave_data() for an example output.
864 static ssize_t amdgpu_debugfs_wave_read(struct file *f, char __user *buf,
865 size_t size, loff_t *pos)
867 struct amdgpu_device *adev = f->f_inode->i_private;
870 uint32_t offset, se, sh, cu, wave, simd, data[32];
872 if (size & 3 || *pos & 3)
876 offset = (*pos & GENMASK_ULL(6, 0));
877 se = (*pos & GENMASK_ULL(14, 7)) >> 7;
878 sh = (*pos & GENMASK_ULL(22, 15)) >> 15;
879 cu = (*pos & GENMASK_ULL(30, 23)) >> 23;
880 wave = (*pos & GENMASK_ULL(36, 31)) >> 31;
881 simd = (*pos & GENMASK_ULL(44, 37)) >> 37;
883 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
885 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
889 r = amdgpu_virt_enable_access_debugfs(adev);
891 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
895 /* switch to the specific se/sh/cu */
896 mutex_lock(&adev->grbm_idx_mutex);
897 amdgpu_gfx_select_se_sh(adev, se, sh, cu);
900 if (adev->gfx.funcs->read_wave_data)
901 adev->gfx.funcs->read_wave_data(adev, simd, wave, data, &x);
903 amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
904 mutex_unlock(&adev->grbm_idx_mutex);
906 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
907 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
910 amdgpu_virt_disable_access_debugfs(adev);
914 while (size && (offset < x * 4)) {
917 value = data[offset >> 2];
918 r = put_user(value, (uint32_t *)buf);
920 amdgpu_virt_disable_access_debugfs(adev);
930 amdgpu_virt_disable_access_debugfs(adev);
934 /** amdgpu_debugfs_gpr_read - Read wave gprs
936 * @f: open file handle
937 * @buf: User buffer to store read data in
938 * @size: Number of bytes to read
939 * @pos: Offset to seek to
941 * The offset being sought changes which wave that the status data
942 * will be returned for. The bits are used as follows:
944 * Bits 0..11: Byte offset into data
945 * Bits 12..19: SE selector
946 * Bits 20..27: SH/SA selector
947 * Bits 28..35: CU/{WGP+SIMD} selector
948 * Bits 36..43: WAVE ID selector
949 * Bits 37..44: SIMD ID selector
950 * Bits 52..59: Thread selector
951 * Bits 60..61: Bank selector (VGPR=0,SGPR=1)
953 * The return data comes from the SGPR or VGPR register bank for
954 * the selected operational unit.
956 static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
957 size_t size, loff_t *pos)
959 struct amdgpu_device *adev = f->f_inode->i_private;
962 uint32_t offset, se, sh, cu, wave, simd, thread, bank, *data;
964 if (size > 4096 || size & 3 || *pos & 3)
968 offset = (*pos & GENMASK_ULL(11, 0)) >> 2;
969 se = (*pos & GENMASK_ULL(19, 12)) >> 12;
970 sh = (*pos & GENMASK_ULL(27, 20)) >> 20;
971 cu = (*pos & GENMASK_ULL(35, 28)) >> 28;
972 wave = (*pos & GENMASK_ULL(43, 36)) >> 36;
973 simd = (*pos & GENMASK_ULL(51, 44)) >> 44;
974 thread = (*pos & GENMASK_ULL(59, 52)) >> 52;
975 bank = (*pos & GENMASK_ULL(61, 60)) >> 60;
977 data = kcalloc(1024, sizeof(*data), GFP_KERNEL);
981 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
985 r = amdgpu_virt_enable_access_debugfs(adev);
989 /* switch to the specific se/sh/cu */
990 mutex_lock(&adev->grbm_idx_mutex);
991 amdgpu_gfx_select_se_sh(adev, se, sh, cu);
994 if (adev->gfx.funcs->read_wave_vgprs)
995 adev->gfx.funcs->read_wave_vgprs(adev, simd, wave, thread, offset, size>>2, data);
997 if (adev->gfx.funcs->read_wave_sgprs)
998 adev->gfx.funcs->read_wave_sgprs(adev, simd, wave, offset, size>>2, data);
1001 amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
1002 mutex_unlock(&adev->grbm_idx_mutex);
1004 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
1005 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1010 value = data[result >> 2];
1011 r = put_user(value, (uint32_t *)buf);
1013 amdgpu_virt_disable_access_debugfs(adev);
1023 amdgpu_virt_disable_access_debugfs(adev);
1027 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1033 * amdgpu_debugfs_regs_gfxoff_write - Enable/disable GFXOFF
1035 * @f: open file handle
1036 * @buf: User buffer to write data from
1037 * @size: Number of bytes to write
1038 * @pos: Offset to seek to
1040 * Write a 32-bit zero to disable or a 32-bit non-zero to enable
1042 static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *buf,
1043 size_t size, loff_t *pos)
1045 struct amdgpu_device *adev = file_inode(f)->i_private;
1049 if (size & 0x3 || *pos & 0x3)
1052 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
1054 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1061 r = get_user(value, (uint32_t *)buf);
1063 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
1064 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1068 amdgpu_gfx_off_ctrl(adev, value ? true : false);
1076 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
1077 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1084 * amdgpu_debugfs_regs_gfxoff_status - read gfxoff status
1086 * @f: open file handle
1087 * @buf: User buffer to store read data in
1088 * @size: Number of bytes to read
1089 * @pos: Offset to seek to
1091 static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,
1092 size_t size, loff_t *pos)
1094 struct amdgpu_device *adev = file_inode(f)->i_private;
1098 if (size & 0x3 || *pos & 0x3)
1101 r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
1108 r = amdgpu_get_gfx_off_status(adev, &value);
1110 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
1111 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1115 r = put_user(value, (uint32_t *)buf);
1117 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
1118 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1128 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
1129 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1134 static const struct file_operations amdgpu_debugfs_regs_fops = {
1135 .owner = THIS_MODULE,
1136 .read = amdgpu_debugfs_regs_read,
1137 .write = amdgpu_debugfs_regs_write,
1138 .llseek = default_llseek
1140 static const struct file_operations amdgpu_debugfs_regs_didt_fops = {
1141 .owner = THIS_MODULE,
1142 .read = amdgpu_debugfs_regs_didt_read,
1143 .write = amdgpu_debugfs_regs_didt_write,
1144 .llseek = default_llseek
1146 static const struct file_operations amdgpu_debugfs_regs_pcie_fops = {
1147 .owner = THIS_MODULE,
1148 .read = amdgpu_debugfs_regs_pcie_read,
1149 .write = amdgpu_debugfs_regs_pcie_write,
1150 .llseek = default_llseek
1152 static const struct file_operations amdgpu_debugfs_regs_smc_fops = {
1153 .owner = THIS_MODULE,
1154 .read = amdgpu_debugfs_regs_smc_read,
1155 .write = amdgpu_debugfs_regs_smc_write,
1156 .llseek = default_llseek
1159 static const struct file_operations amdgpu_debugfs_gca_config_fops = {
1160 .owner = THIS_MODULE,
1161 .read = amdgpu_debugfs_gca_config_read,
1162 .llseek = default_llseek
1165 static const struct file_operations amdgpu_debugfs_sensors_fops = {
1166 .owner = THIS_MODULE,
1167 .read = amdgpu_debugfs_sensor_read,
1168 .llseek = default_llseek
1171 static const struct file_operations amdgpu_debugfs_wave_fops = {
1172 .owner = THIS_MODULE,
1173 .read = amdgpu_debugfs_wave_read,
1174 .llseek = default_llseek
1176 static const struct file_operations amdgpu_debugfs_gpr_fops = {
1177 .owner = THIS_MODULE,
1178 .read = amdgpu_debugfs_gpr_read,
1179 .llseek = default_llseek
1182 static const struct file_operations amdgpu_debugfs_gfxoff_fops = {
1183 .owner = THIS_MODULE,
1184 .read = amdgpu_debugfs_gfxoff_read,
1185 .write = amdgpu_debugfs_gfxoff_write,
1186 .llseek = default_llseek
1189 static const struct file_operations *debugfs_regs[] = {
1190 &amdgpu_debugfs_regs_fops,
1191 &amdgpu_debugfs_regs_didt_fops,
1192 &amdgpu_debugfs_regs_pcie_fops,
1193 &amdgpu_debugfs_regs_smc_fops,
1194 &amdgpu_debugfs_gca_config_fops,
1195 &amdgpu_debugfs_sensors_fops,
1196 &amdgpu_debugfs_wave_fops,
1197 &amdgpu_debugfs_gpr_fops,
1198 &amdgpu_debugfs_gfxoff_fops,
1201 static const char *debugfs_regs_names[] = {
1206 "amdgpu_gca_config",
1214 * amdgpu_debugfs_regs_init - Initialize debugfs entries that provide
1217 * @adev: The device to attach the debugfs entries to
1219 int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
1221 struct drm_minor *minor = adev_to_drm(adev)->primary;
1222 struct dentry *ent, *root = minor->debugfs_root;
1225 for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
1226 ent = debugfs_create_file(debugfs_regs_names[i],
1227 S_IFREG | S_IRUGO, root,
1228 adev, debugfs_regs[i]);
1229 if (!i && !IS_ERR_OR_NULL(ent))
1230 i_size_write(ent->d_inode, adev->rmmio_size);
1231 adev->debugfs_regs[i] = ent;
1237 static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)
1239 struct drm_info_node *node = (struct drm_info_node *) m->private;
1240 struct drm_device *dev = node->minor->dev;
1241 struct amdgpu_device *adev = drm_to_adev(dev);
1244 r = pm_runtime_get_sync(dev->dev);
1246 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1250 /* Avoid accidently unparking the sched thread during GPU reset */
1251 r = down_read_killable(&adev->reset_sem);
1255 /* hold on the scheduler */
1256 for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
1257 struct amdgpu_ring *ring = adev->rings[i];
1259 if (!ring || !ring->sched.thread)
1261 kthread_park(ring->sched.thread);
1264 seq_printf(m, "run ib test:\n");
1265 r = amdgpu_ib_ring_tests(adev);
1267 seq_printf(m, "ib ring tests failed (%d).\n", r);
1269 seq_printf(m, "ib ring tests passed.\n");
1271 /* go on the scheduler */
1272 for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
1273 struct amdgpu_ring *ring = adev->rings[i];
1275 if (!ring || !ring->sched.thread)
1277 kthread_unpark(ring->sched.thread);
1280 up_read(&adev->reset_sem);
1282 pm_runtime_mark_last_busy(dev->dev);
1283 pm_runtime_put_autosuspend(dev->dev);
1288 static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data)
1290 struct drm_info_node *node = (struct drm_info_node *) m->private;
1291 struct drm_device *dev = node->minor->dev;
1292 struct amdgpu_device *adev = drm_to_adev(dev);
1294 seq_write(m, adev->bios, adev->bios_size);
1298 static int amdgpu_debugfs_evict_vram(struct seq_file *m, void *data)
1300 struct drm_info_node *node = (struct drm_info_node *)m->private;
1301 struct drm_device *dev = node->minor->dev;
1302 struct amdgpu_device *adev = drm_to_adev(dev);
1305 r = pm_runtime_get_sync(dev->dev);
1307 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1311 seq_printf(m, "(%d)\n", amdgpu_bo_evict_vram(adev));
1313 pm_runtime_mark_last_busy(dev->dev);
1314 pm_runtime_put_autosuspend(dev->dev);
1319 static int amdgpu_debugfs_evict_gtt(struct seq_file *m, void *data)
1321 struct drm_info_node *node = (struct drm_info_node *)m->private;
1322 struct drm_device *dev = node->minor->dev;
1323 struct amdgpu_device *adev = drm_to_adev(dev);
1324 struct ttm_resource_manager *man;
1327 r = pm_runtime_get_sync(dev->dev);
1329 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1333 man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
1334 r = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
1335 seq_printf(m, "(%d)\n", r);
1337 pm_runtime_mark_last_busy(dev->dev);
1338 pm_runtime_put_autosuspend(dev->dev);
1343 static int amdgpu_debugfs_vm_info(struct seq_file *m, void *data)
1345 struct drm_info_node *node = (struct drm_info_node *)m->private;
1346 struct drm_device *dev = node->minor->dev;
1347 struct drm_file *file;
1350 r = mutex_lock_interruptible(&dev->filelist_mutex);
1354 list_for_each_entry(file, &dev->filelist, lhead) {
1355 struct amdgpu_fpriv *fpriv = file->driver_priv;
1356 struct amdgpu_vm *vm = &fpriv->vm;
1358 seq_printf(m, "pid:%d\tProcess:%s ----------\n",
1359 vm->task_info.pid, vm->task_info.process_name);
1360 r = amdgpu_bo_reserve(vm->root.base.bo, true);
1363 amdgpu_debugfs_vm_bo_info(vm, m);
1364 amdgpu_bo_unreserve(vm->root.base.bo);
1367 mutex_unlock(&dev->filelist_mutex);
1372 static const struct drm_info_list amdgpu_debugfs_list[] = {
1373 {"amdgpu_vbios", amdgpu_debugfs_get_vbios_dump},
1374 {"amdgpu_test_ib", &amdgpu_debugfs_test_ib},
1375 {"amdgpu_evict_vram", &amdgpu_debugfs_evict_vram},
1376 {"amdgpu_evict_gtt", &amdgpu_debugfs_evict_gtt},
1377 {"amdgpu_vm_info", &amdgpu_debugfs_vm_info},
1380 static void amdgpu_ib_preempt_fences_swap(struct amdgpu_ring *ring,
1381 struct dma_fence **fences)
1383 struct amdgpu_fence_driver *drv = &ring->fence_drv;
1384 uint32_t sync_seq, last_seq;
1386 last_seq = atomic_read(&ring->fence_drv.last_seq);
1387 sync_seq = ring->fence_drv.sync_seq;
1389 last_seq &= drv->num_fences_mask;
1390 sync_seq &= drv->num_fences_mask;
1393 struct dma_fence *fence, **ptr;
1396 last_seq &= drv->num_fences_mask;
1397 ptr = &drv->fences[last_seq];
1399 fence = rcu_dereference_protected(*ptr, 1);
1400 RCU_INIT_POINTER(*ptr, NULL);
1405 fences[last_seq] = fence;
1407 } while (last_seq != sync_seq);
1410 static void amdgpu_ib_preempt_signal_fences(struct dma_fence **fences,
1414 struct dma_fence *fence;
1416 for (i = 0; i < length; i++) {
1420 dma_fence_signal(fence);
1421 dma_fence_put(fence);
1425 static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched)
1427 struct drm_sched_job *s_job;
1428 struct dma_fence *fence;
1430 spin_lock(&sched->job_list_lock);
1431 list_for_each_entry(s_job, &sched->pending_list, list) {
1432 fence = sched->ops->run_job(s_job);
1433 dma_fence_put(fence);
1435 spin_unlock(&sched->job_list_lock);
1438 static void amdgpu_ib_preempt_mark_partial_job(struct amdgpu_ring *ring)
1440 struct amdgpu_job *job;
1441 struct drm_sched_job *s_job, *tmp;
1442 uint32_t preempt_seq;
1443 struct dma_fence *fence, **ptr;
1444 struct amdgpu_fence_driver *drv = &ring->fence_drv;
1445 struct drm_gpu_scheduler *sched = &ring->sched;
1446 bool preempted = true;
1448 if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
1451 preempt_seq = le32_to_cpu(*(drv->cpu_addr + 2));
1452 if (preempt_seq <= atomic_read(&drv->last_seq)) {
1457 preempt_seq &= drv->num_fences_mask;
1458 ptr = &drv->fences[preempt_seq];
1459 fence = rcu_dereference_protected(*ptr, 1);
1462 spin_lock(&sched->job_list_lock);
1463 list_for_each_entry_safe(s_job, tmp, &sched->pending_list, list) {
1464 if (dma_fence_is_signaled(&s_job->s_fence->finished)) {
1465 /* remove job from ring_mirror_list */
1466 list_del_init(&s_job->list);
1467 sched->ops->free_job(s_job);
1470 job = to_amdgpu_job(s_job);
1471 if (preempted && job->fence == fence)
1472 /* mark the job as preempted */
1473 job->preemption_status |= AMDGPU_IB_PREEMPTED;
1475 spin_unlock(&sched->job_list_lock);
1478 static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
1480 int r, resched, length;
1481 struct amdgpu_ring *ring;
1482 struct dma_fence **fences = NULL;
1483 struct amdgpu_device *adev = (struct amdgpu_device *)data;
1485 if (val >= AMDGPU_MAX_RINGS)
1488 ring = adev->rings[val];
1490 if (!ring || !ring->funcs->preempt_ib || !ring->sched.thread)
1493 /* the last preemption failed */
1494 if (ring->trail_seq != le32_to_cpu(*ring->trail_fence_cpu_addr))
1497 length = ring->fence_drv.num_fences_mask + 1;
1498 fences = kcalloc(length, sizeof(void *), GFP_KERNEL);
1502 /* Avoid accidently unparking the sched thread during GPU reset */
1503 r = down_read_killable(&adev->reset_sem);
1507 /* stop the scheduler */
1508 kthread_park(ring->sched.thread);
1510 resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
1512 /* preempt the IB */
1513 r = amdgpu_ring_preempt_ib(ring);
1515 DRM_WARN("failed to preempt ring %d\n", ring->idx);
1519 amdgpu_fence_process(ring);
1521 if (atomic_read(&ring->fence_drv.last_seq) !=
1522 ring->fence_drv.sync_seq) {
1523 DRM_INFO("ring %d was preempted\n", ring->idx);
1525 amdgpu_ib_preempt_mark_partial_job(ring);
1527 /* swap out the old fences */
1528 amdgpu_ib_preempt_fences_swap(ring, fences);
1530 amdgpu_fence_driver_force_completion(ring);
1532 /* resubmit unfinished jobs */
1533 amdgpu_ib_preempt_job_recovery(&ring->sched);
1535 /* wait for jobs finished */
1536 amdgpu_fence_wait_empty(ring);
1538 /* signal the old fences */
1539 amdgpu_ib_preempt_signal_fences(fences, length);
1543 /* restart the scheduler */
1544 kthread_unpark(ring->sched.thread);
1546 up_read(&adev->reset_sem);
1548 ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
1556 static int amdgpu_debugfs_sclk_set(void *data, u64 val)
1559 uint32_t max_freq, min_freq;
1560 struct amdgpu_device *adev = (struct amdgpu_device *)data;
1562 if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
1565 ret = pm_runtime_get_sync(adev_to_drm(adev)->dev);
1567 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1571 if (is_support_sw_smu(adev)) {
1572 ret = smu_get_dpm_freq_range(&adev->smu, SMU_SCLK, &min_freq, &max_freq);
1573 if (ret || val > max_freq || val < min_freq)
1575 ret = smu_set_soft_freq_range(&adev->smu, SMU_SCLK, (uint32_t)val, (uint32_t)val);
1580 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
1581 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1589 DEFINE_SIMPLE_ATTRIBUTE(fops_ib_preempt, NULL,
1590 amdgpu_debugfs_ib_preempt, "%llu\n");
1592 DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
1593 amdgpu_debugfs_sclk_set, "%llu\n");
1595 int amdgpu_debugfs_init(struct amdgpu_device *adev)
1599 adev->debugfs_preempt =
1600 debugfs_create_file("amdgpu_preempt_ib", 0600,
1601 adev_to_drm(adev)->primary->debugfs_root, adev,
1603 if (!(adev->debugfs_preempt)) {
1604 DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n");
1608 adev->smu.debugfs_sclk =
1609 debugfs_create_file("amdgpu_force_sclk", 0200,
1610 adev_to_drm(adev)->primary->debugfs_root, adev,
1612 if (!(adev->smu.debugfs_sclk)) {
1613 DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
1617 /* Register debugfs entries for amdgpu_ttm */
1618 r = amdgpu_ttm_debugfs_init(adev);
1620 DRM_ERROR("Failed to init debugfs\n");
1624 r = amdgpu_debugfs_pm_init(adev);
1626 DRM_ERROR("Failed to register debugfs file for dpm!\n");
1630 if (amdgpu_debugfs_sa_init(adev)) {
1631 dev_err(adev->dev, "failed to register debugfs file for SA\n");
1634 if (amdgpu_debugfs_fence_init(adev))
1635 dev_err(adev->dev, "fence debugfs file creation failed\n");
1637 r = amdgpu_debugfs_gem_init(adev);
1639 DRM_ERROR("registering gem debugfs failed (%d).\n", r);
1641 r = amdgpu_debugfs_regs_init(adev);
1643 DRM_ERROR("registering register debugfs failed (%d).\n", r);
1645 r = amdgpu_debugfs_firmware_init(adev);
1647 DRM_ERROR("registering firmware debugfs failed (%d).\n", r);
1649 #if defined(CONFIG_DRM_AMD_DC)
1650 if (amdgpu_device_has_dc_support(adev)) {
1651 if (dtn_debugfs_init(adev))
1652 DRM_ERROR("amdgpu: failed initialize dtn debugfs support.\n");
1656 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
1657 struct amdgpu_ring *ring = adev->rings[i];
1662 if (amdgpu_debugfs_ring_init(adev, ring)) {
1663 DRM_ERROR("Failed to register debugfs file for rings !\n");
1667 amdgpu_ras_debugfs_create_all(adev);
1669 amdgpu_debugfs_autodump_init(adev);
1671 amdgpu_rap_debugfs_init(adev);
1673 amdgpu_securedisplay_debugfs_init(adev);
1675 amdgpu_fw_attestation_debugfs_init(adev);
1677 return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_list,
1678 ARRAY_SIZE(amdgpu_debugfs_list));
1682 int amdgpu_debugfs_init(struct amdgpu_device *adev)
1686 int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)