drivers/gpu/drm/nouveau/nouveau_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nouveau_debugfs.c- Extension
.c- Size
- 8405 bytes
- Lines
- 328
- 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.hnvif/class.hnvif/if0001.hnouveau_debugfs.hnouveau_drv.h
Detected Declarations
function Copyrightfunction nouveau_debugfs_strap_peekfunction nouveau_debugfs_pstate_getfunction nouveau_debugfs_pstate_setfunction nouveau_debugfs_pstate_openfunction nouveau_debugfs_gpuva_regionsfunction nouveau_debugfs_gpuvafunction nouveau_drm_debugfs_initfunction nouveau_debugfs_initfunction nouveau_debugfs_finifunction nouveau_module_debugfs_initfunction nouveau_module_debugfs_fini
Annotated Snippet
static const struct file_operations nouveau_pstate_fops = {
.owner = THIS_MODULE,
.open = nouveau_debugfs_pstate_open,
.read = seq_read,
.write = nouveau_debugfs_pstate_set,
.release = single_release,
};
static struct drm_info_list nouveau_debugfs_list[] = {
{ "vbios.rom", nouveau_debugfs_vbios_image, 0, NULL },
{ "strap_peek", nouveau_debugfs_strap_peek, 0, NULL },
DRM_DEBUGFS_GPUVA_INFO(nouveau_debugfs_gpuva, NULL),
};
#define NOUVEAU_DEBUGFS_ENTRIES ARRAY_SIZE(nouveau_debugfs_list)
static const struct nouveau_debugfs_files {
const char *name;
const struct file_operations *fops;
} nouveau_debugfs_files[] = {
{"pstate", &nouveau_pstate_fops},
};
void
nouveau_drm_debugfs_init(struct drm_minor *minor)
{
struct nouveau_drm *drm = nouveau_drm(minor->dev);
struct dentry *dentry;
int i;
for (i = 0; i < ARRAY_SIZE(nouveau_debugfs_files); i++) {
debugfs_create_file(nouveau_debugfs_files[i].name,
S_IRUGO | S_IWUSR,
minor->debugfs_root, minor->dev,
nouveau_debugfs_files[i].fops);
}
drm_debugfs_create_files(nouveau_debugfs_list,
NOUVEAU_DEBUGFS_ENTRIES,
minor->debugfs_root, minor);
/* Set the size of the vbios since we know it, and it's confusing to
* userspace if it wants to seek() but the file has a length of 0
*/
dentry = debugfs_lookup("vbios.rom", minor->debugfs_root);
if (!dentry)
return;
d_inode(dentry)->i_size = drm->vbios.length;
dput(dentry);
}
int
nouveau_debugfs_init(struct nouveau_drm *drm)
{
drm->debugfs = kzalloc_obj(*drm->debugfs);
if (!drm->debugfs)
return -ENOMEM;
return nvif_object_ctor(&drm->client.device.object, "debugfsCtrl", 0,
NVIF_CLASS_CONTROL, NULL, 0,
&drm->debugfs->ctrl);
}
void
nouveau_debugfs_fini(struct nouveau_drm *drm)
{
if (drm->debugfs && drm->debugfs->ctrl.priv)
nvif_object_dtor(&drm->debugfs->ctrl);
kfree(drm->debugfs);
drm->debugfs = NULL;
}
void
nouveau_module_debugfs_init(void)
{
nouveau_debugfs_root = debugfs_create_dir("nouveau", NULL);
}
void
nouveau_module_debugfs_fini(void)
{
debugfs_remove(nouveau_debugfs_root);
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `nvif/class.h`, `nvif/if0001.h`, `nouveau_debugfs.h`, `nouveau_drv.h`.
- Detected declarations: `function Copyright`, `function nouveau_debugfs_strap_peek`, `function nouveau_debugfs_pstate_get`, `function nouveau_debugfs_pstate_set`, `function nouveau_debugfs_pstate_open`, `function nouveau_debugfs_gpuva_regions`, `function nouveau_debugfs_gpuva`, `function nouveau_drm_debugfs_init`, `function nouveau_debugfs_init`, `function nouveau_debugfs_fini`.
- 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.