drivers/gpu/drm/drm_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_debugfs.c- Extension
.c- Size
- 23387 bytes
- Lines
- 884
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/export.hlinux/seq_file.hlinux/slab.hlinux/uaccess.hdrm/drm_atomic.hdrm/drm_auth.hdrm/drm_bridge.hdrm/drm_debugfs.hdrm/drm_device.hdrm/drm_drv.hdrm/drm_edid.hdrm/drm_file.hdrm/drm_gem.hdrm/drm_managed.hdrm/drm_gpuvm.hdrm_crtc_internal.hdrm_internal.h
Detected Declarations
function drm_name_infofunction drm_clients_infofunction drm_gem_one_name_infofunction drm_gem_name_infofunction drm_debugfs_openfunction drm_debugfs_entry_openfunction drm_debugfs_gpuva_infofunction drm_debugfs_dev_finifunction drm_debugfs_remove_filesfunction drm_debugfs_bridge_paramsfunction drm_debugfs_init_rootfunction drm_debugfs_remove_rootfunction drm_debugfs_proc_info_showfunction drm_debufs_proc_info_openfunction drm_debugfs_clients_addfunction drm_debugfs_clients_removefunction drm_debugfs_dev_initfunction drm_debugfs_dev_finifunction drm_debugfs_dev_registerfunction drm_debugfs_registerfunction drm_debugfs_unregisterfunction drm_debugfs_add_filefunction drm_debugfs_add_filesfunction connector_showfunction connector_openfunction connector_writefunction edid_showfunction edid_openfunction edid_writefunction vrr_range_showfunction output_bpc_showfunction audio_infoframe_readfunction create_hdmi_audio_infoframe_filefunction create_hdmi_infoframe_filesfunction hdmi_debugfs_addfunction drm_debugfs_connector_addfunction drm_debugfs_connector_removefunction drm_debugfs_crtc_addfunction drm_debugfs_crtc_removefunction drm_debugfs_encoder_addfunction drm_debugfs_encoder_removeexport drm_debugfs_gpuva_infoexport drm_debugfs_create_filesexport drm_debugfs_remove_filesexport drm_debugfs_add_fileexport drm_debugfs_add_files
Annotated Snippet
static const struct file_operations drm_debugfs_entry_fops = {
.owner = THIS_MODULE,
.open = drm_debugfs_entry_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const struct file_operations drm_debugfs_fops = {
.owner = THIS_MODULE,
.open = drm_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/**
* drm_debugfs_gpuva_info - dump the given DRM GPU VA space
* @m: pointer to the &seq_file to write
* @gpuvm: the &drm_gpuvm representing the GPU VA space
*
* Dumps the GPU VA mappings of a given DRM GPU VA manager.
*
* For each DRM GPU VA space drivers should call this function from their
* &drm_info_list's show callback.
*
* Returns: 0 on success, -ENODEV if the &gpuvm is not initialized
*/
int drm_debugfs_gpuva_info(struct seq_file *m,
struct drm_gpuvm *gpuvm)
{
struct drm_gpuva *va, *kva = &gpuvm->kernel_alloc_node;
if (!gpuvm->name)
return -ENODEV;
seq_printf(m, "DRM GPU VA space (%s) [0x%016llx;0x%016llx]\n",
gpuvm->name, gpuvm->mm_start, gpuvm->mm_start + gpuvm->mm_range);
seq_printf(m, "Kernel reserved node [0x%016llx;0x%016llx]\n",
kva->va.addr, kva->va.addr + kva->va.range);
seq_puts(m, "\n");
seq_puts(m, " VAs | start | range | end | object | object offset\n");
seq_puts(m, "-------------------------------------------------------------------------------------------------------------\n");
drm_gpuvm_for_each_va(va, gpuvm) {
if (unlikely(va == kva))
continue;
seq_printf(m, " | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx | 0x%016llx\n",
va->va.addr, va->va.range, va->va.addr + va->va.range,
(u64)(uintptr_t)va->gem.obj, va->gem.offset);
}
return 0;
}
EXPORT_SYMBOL(drm_debugfs_gpuva_info);
/**
* drm_debugfs_create_files - Initialize a given set of debugfs files for DRM
* minor
* @files: The array of files to create
* @count: The number of files given
* @root: DRI debugfs dir entry.
* @minor: device minor number
*
* Create a given set of debugfs files represented by an array of
* &struct drm_info_list in the given root directory. These files will be removed
* automatically on drm_debugfs_dev_fini().
*/
void drm_debugfs_create_files(const struct drm_info_list *files, int count,
struct dentry *root, struct drm_minor *minor)
{
struct drm_device *dev = minor->dev;
struct drm_info_node *tmp;
int i;
for (i = 0; i < count; i++) {
u32 features = files[i].driver_features;
if (features && !drm_core_check_all_features(dev, features))
continue;
tmp = drmm_kzalloc(dev, sizeof(*tmp), GFP_KERNEL);
if (tmp == NULL)
continue;
tmp->minor = minor;
tmp->dent = debugfs_create_file(files[i].name,
0444, root, tmp,
&drm_debugfs_fops);
tmp->info_ent = &files[i];
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/export.h`, `linux/seq_file.h`, `linux/slab.h`, `linux/uaccess.h`, `drm/drm_atomic.h`, `drm/drm_auth.h`, `drm/drm_bridge.h`.
- Detected declarations: `function drm_name_info`, `function drm_clients_info`, `function drm_gem_one_name_info`, `function drm_gem_name_info`, `function drm_debugfs_open`, `function drm_debugfs_entry_open`, `function drm_debugfs_gpuva_info`, `function drm_debugfs_dev_fini`, `function drm_debugfs_remove_files`, `function drm_debugfs_bridge_params`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.