|
39 | 39 | #include <drm/drm_file.h>
|
40 | 40 | #include <drm/drm_gem.h>
|
41 | 41 | #include <drm/drm_managed.h>
|
| 42 | +#include <drm/drm_gpuva_mgr.h> |
42 | 43 |
|
43 | 44 | #include "drm_crtc_internal.h"
|
44 | 45 | #include "drm_internal.h"
|
@@ -175,6 +176,45 @@ static const struct file_operations drm_debugfs_fops = {
|
175 | 176 | .release = single_release,
|
176 | 177 | };
|
177 | 178 |
|
| 179 | +/** |
| 180 | + * drm_debugfs_gpuva_info - dump the given DRM GPU VA space |
| 181 | + * @m: pointer to the &seq_file to write |
| 182 | + * @mgr: the &drm_gpuva_manager representing the GPU VA space |
| 183 | + * |
| 184 | + * Dumps the GPU VA mappings of a given DRM GPU VA manager. |
| 185 | + * |
| 186 | + * For each DRM GPU VA space drivers should call this function from their |
| 187 | + * &drm_info_list's show callback. |
| 188 | + * |
| 189 | + * Returns: 0 on success, -ENODEV if the &mgr is not initialized |
| 190 | + */ |
| 191 | +int drm_debugfs_gpuva_info(struct seq_file *m, |
| 192 | + struct drm_gpuva_manager *mgr) |
| 193 | +{ |
| 194 | + struct drm_gpuva *va, *kva = &mgr->kernel_alloc_node; |
| 195 | + |
| 196 | + if (!mgr->name) |
| 197 | + return -ENODEV; |
| 198 | + |
| 199 | + seq_printf(m, "DRM GPU VA space (%s) [0x%016llx;0x%016llx]\n", |
| 200 | + mgr->name, mgr->mm_start, mgr->mm_start + mgr->mm_range); |
| 201 | + seq_printf(m, "Kernel reserved node [0x%016llx;0x%016llx]\n", |
| 202 | + kva->va.addr, kva->va.addr + kva->va.range); |
| 203 | + seq_puts(m, "\n"); |
| 204 | + seq_puts(m, " VAs | start | range | end | object | object offset\n"); |
| 205 | + seq_puts(m, "-------------------------------------------------------------------------------------------------------------\n"); |
| 206 | + drm_gpuva_for_each_va(va, mgr) { |
| 207 | + if (unlikely(va == kva)) |
| 208 | + continue; |
| 209 | + |
| 210 | + seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx\n", |
| 211 | + va->va.addr, va->va.range, va->va.addr + va->va.range, |
| 212 | + (u64)va->gem.obj, va->gem.offset); |
| 213 | + } |
| 214 | + |
| 215 | + return 0; |
| 216 | +} |
| 217 | +EXPORT_SYMBOL(drm_debugfs_gpuva_info); |
178 | 218 |
|
179 | 219 | /**
|
180 | 220 | * drm_debugfs_create_files - Initialize a given set of debugfs files for DRM
|
|
0 commit comments