Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: add debugfs support for VM pagetable per client

Add a debugfs file under the client directory which shares
the root page table base address of the VM.

This address could be used to dump the pagetable for debug
memory issues.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20250704075548.1549849-4-sunil.khatri@amd.com
Signed-off-by: Christian König <christian.koenig@amd.com>

authored by

Sunil Khatri and committed by
Christian König
719b378d 1fd45bc2

+55
+52
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
··· 2131 2131 return 0; 2132 2132 } 2133 2133 2134 + static int amdgpu_pt_info_read(struct seq_file *m, void *unused) 2135 + { 2136 + struct drm_file *file; 2137 + struct amdgpu_fpriv *fpriv; 2138 + struct amdgpu_bo *root_bo; 2139 + int r; 2140 + 2141 + file = m->private; 2142 + if (!file) 2143 + return -EINVAL; 2144 + 2145 + fpriv = file->driver_priv; 2146 + if (!fpriv && !fpriv->vm.root.bo) 2147 + return -ENODEV; 2148 + 2149 + root_bo = amdgpu_bo_ref(fpriv->vm.root.bo); 2150 + r = amdgpu_bo_reserve(root_bo, true); 2151 + if (r) { 2152 + amdgpu_bo_unref(&root_bo); 2153 + return -EINVAL; 2154 + } 2155 + 2156 + seq_printf(m, "gpu_address: 0x%llx\n", amdgpu_bo_gpu_offset(fpriv->vm.root.bo)); 2157 + 2158 + amdgpu_bo_unreserve(root_bo); 2159 + amdgpu_bo_unref(&root_bo); 2160 + 2161 + return 0; 2162 + } 2163 + 2164 + static int amdgpu_pt_info_open(struct inode *inode, struct file *file) 2165 + { 2166 + return single_open(file, amdgpu_pt_info_read, inode->i_private); 2167 + } 2168 + 2169 + static const struct file_operations amdgpu_pt_info_fops = { 2170 + .owner = THIS_MODULE, 2171 + .open = amdgpu_pt_info_open, 2172 + .read = seq_read, 2173 + .llseek = seq_lseek, 2174 + .release = single_release, 2175 + }; 2176 + 2177 + void amdgpu_debugfs_vm_init(struct drm_file *file) 2178 + { 2179 + debugfs_create_file("vm_pagetable_info", 0444, file->debugfs_client, file, 2180 + &amdgpu_pt_info_fops); 2181 + } 2182 + 2134 2183 #else 2135 2184 int amdgpu_debugfs_init(struct amdgpu_device *adev) 2136 2185 { ··· 2188 2139 int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) 2189 2140 { 2190 2141 return 0; 2142 + } 2143 + void amdgpu_debugfs_vm_init(struct drm_file *file) 2144 + { 2191 2145 } 2192 2146 #endif
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h
··· 33 33 void amdgpu_debugfs_firmware_init(struct amdgpu_device *adev); 34 34 void amdgpu_debugfs_gem_init(struct amdgpu_device *adev); 35 35 void amdgpu_debugfs_mes_event_log_init(struct amdgpu_device *adev); 36 + void amdgpu_debugfs_vm_init(struct drm_file *file); 36 37
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 1395 1395 if (r) 1396 1396 goto error_pasid; 1397 1397 1398 + amdgpu_debugfs_vm_init(file_priv); 1399 + 1398 1400 r = amdgpu_vm_init(adev, &fpriv->vm, fpriv->xcp_id); 1399 1401 if (r) 1400 1402 goto error_pasid;