drivers/gpu/drm/tegra/drm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tegra/drm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tegra/drm.c- Extension
.c- Size
- 36346 bytes
- Lines
- 1460
- 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/aperture.hlinux/bitops.hlinux/host1x.hlinux/idr.hlinux/iommu.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hdrm/clients/drm_client_setup.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_debugfs.hdrm/drm_drv.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_ioctl.hdrm/drm_prime.hdrm/drm_print.hdrm/drm_vblank.hasm/dma-iommu.hdc.hdrm.hgem.huapi.h
Detected Declarations
function Copyrightfunction tegra_atomic_post_commitfunction tegra_atomic_commit_tailfunction tegra_drm_openfunction tegra_drm_context_freefunction host1x_reloc_copy_from_userfunction tegra_drm_submitfunction tegra_gem_createfunction tegra_gem_mmapfunction tegra_syncpt_readfunction tegra_syncpt_incrfunction tegra_syncpt_waitfunction tegra_client_openfunction tegra_open_channelfunction list_for_each_entryfunction tegra_close_channelfunction tegra_get_syncptfunction tegra_submitfunction tegra_get_syncpt_basefunction tegra_gem_set_tilingfunction tegra_gem_get_tilingfunction tegra_gem_set_flagsfunction tegra_gem_get_flagsfunction tegra_drm_context_cleanupfunction tegra_drm_postclosefunction tegra_debugfs_framebuffersfunction list_for_each_entryfunction tegra_debugfs_iovafunction tegra_debugfs_initfunction tegra_drm_register_clientfunction tegra_drm_unregister_clientfunction host1x_client_iommu_attachfunction host1x_client_iommu_detachfunction tegra_drm_freefunction host1x_drm_wants_iommufunction host1x_drm_probefunction host1x_drm_removefunction host1x_drm_shutdownfunction host1x_drm_suspendfunction host1x_drm_resumefunction host1x_drm_initfunction host1x_drm_exitmodule init host1x_drm_init
Annotated Snippet
static const struct file_operations tegra_drm_fops = {
.owner = THIS_MODULE,
.open = drm_open,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
.mmap = tegra_drm_mmap,
.poll = drm_poll,
.read = drm_read,
.compat_ioctl = drm_compat_ioctl,
.llseek = noop_llseek,
.fop_flags = FOP_UNSIGNED_OFFSET,
};
static int tegra_drm_context_cleanup(int id, void *p, void *data)
{
struct tegra_drm_context *context = p;
tegra_drm_context_free(context);
return 0;
}
static void tegra_drm_postclose(struct drm_device *drm, struct drm_file *file)
{
struct tegra_drm_file *fpriv = file->driver_priv;
mutex_lock(&fpriv->lock);
idr_for_each(&fpriv->legacy_contexts, tegra_drm_context_cleanup, NULL);
tegra_drm_uapi_close_file(fpriv);
mutex_unlock(&fpriv->lock);
idr_destroy(&fpriv->legacy_contexts);
mutex_destroy(&fpriv->lock);
kfree(fpriv);
}
#ifdef CONFIG_DEBUG_FS
static int tegra_debugfs_framebuffers(struct seq_file *s, void *data)
{
struct drm_info_node *node = (struct drm_info_node *)s->private;
struct drm_device *drm = node->minor->dev;
struct drm_framebuffer *fb;
mutex_lock(&drm->mode_config.fb_lock);
list_for_each_entry(fb, &drm->mode_config.fb_list, head) {
seq_printf(s, "%3d: user size: %d x %d, depth %d, %d bpp, refcount %d\n",
fb->base.id, fb->width, fb->height,
fb->format->depth,
fb->format->cpp[0] * 8,
drm_framebuffer_read_refcount(fb));
}
mutex_unlock(&drm->mode_config.fb_lock);
return 0;
}
static int tegra_debugfs_iova(struct seq_file *s, void *data)
{
struct drm_info_node *node = (struct drm_info_node *)s->private;
struct drm_device *drm = node->minor->dev;
struct tegra_drm *tegra = drm->dev_private;
struct drm_printer p = drm_seq_file_printer(s);
if (tegra->domain) {
mutex_lock(&tegra->mm_lock);
drm_mm_print(&tegra->mm, &p);
mutex_unlock(&tegra->mm_lock);
}
return 0;
}
static struct drm_info_list tegra_debugfs_list[] = {
{ "framebuffers", tegra_debugfs_framebuffers, 0 },
{ "iova", tegra_debugfs_iova, 0 },
};
static void tegra_debugfs_init(struct drm_minor *minor)
{
drm_debugfs_create_files(tegra_debugfs_list,
ARRAY_SIZE(tegra_debugfs_list),
minor->debugfs_root, minor);
}
#endif
static const struct drm_driver tegra_drm_driver = {
.driver_features = DRIVER_MODESET | DRIVER_GEM |
DRIVER_ATOMIC | DRIVER_RENDER | DRIVER_SYNCOBJ,
Annotation
- Immediate include surface: `linux/aperture.h`, `linux/bitops.h`, `linux/host1x.h`, `linux/idr.h`, `linux/iommu.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `function Copyright`, `function tegra_atomic_post_commit`, `function tegra_atomic_commit_tail`, `function tegra_drm_open`, `function tegra_drm_context_free`, `function host1x_reloc_copy_from_user`, `function tegra_drm_submit`, `function tegra_gem_create`, `function tegra_gem_mmap`, `function tegra_syncpt_read`.
- 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.