drivers/gpu/drm/etnaviv/etnaviv_drv.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/etnaviv/etnaviv_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/etnaviv/etnaviv_drv.c- Extension
.c- Size
- 18384 bytes
- Lines
- 778
- 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.
- 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/component.hlinux/dma-mapping.hlinux/module.hlinux/of.hlinux/of_device.hlinux/platform_device.hlinux/uaccess.hdrm/drm_debugfs.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_ioctl.hdrm/drm_of.hdrm/drm_prime.hdrm/drm_print.hetnaviv_cmdbuf.hetnaviv_drv.hetnaviv_gpu.hetnaviv_gem.hetnaviv_mmu.hetnaviv_perfmon.h
Detected Declarations
function Copyrightfunction for_each_compatible_nodefunction load_gpufunction etnaviv_openfunction etnaviv_postclosefunction etnaviv_gem_showfunction etnaviv_mm_showfunction etnaviv_mmu_showfunction etnaviv_buffer_dumpfunction etnaviv_ring_showfunction show_unlockedfunction show_each_gpufunction etnaviv_debugfs_initfunction etnaviv_ioctl_get_paramfunction etnaviv_ioctl_gem_newfunction etnaviv_ioctl_gem_cpu_prepfunction etnaviv_ioctl_gem_cpu_finifunction etnaviv_ioctl_gem_infofunction etnaviv_ioctl_wait_fencefunction etnaviv_ioctl_gem_userptrfunction etnaviv_ioctl_gem_waitfunction etnaviv_ioctl_pm_query_domfunction etnaviv_ioctl_pm_query_sigfunction etnaviv_show_fdinfofunction etnaviv_bindfunction etnaviv_unbindfunction etnaviv_pdev_probefunction for_each_compatible_nodefunction dma_set_coherent_maskfunction etnaviv_pdev_removefunction etnaviv_create_platform_devicefunction etnaviv_destroy_platform_devicefunction etnaviv_initfunction etnaviv_exitmodule init etnaviv_init
Annotated Snippet
static const struct file_operations fops = {
.owner = THIS_MODULE,
DRM_GEM_FOPS,
.show_fdinfo = drm_show_fdinfo,
};
static const struct drm_driver etnaviv_drm_driver = {
.driver_features = DRIVER_GEM | DRIVER_RENDER,
.open = etnaviv_open,
.postclose = etnaviv_postclose,
.gem_prime_import_sg_table = etnaviv_gem_prime_import_sg_table,
#ifdef CONFIG_DEBUG_FS
.debugfs_init = etnaviv_debugfs_init,
#endif
.show_fdinfo = etnaviv_show_fdinfo,
.ioctls = etnaviv_ioctls,
.num_ioctls = DRM_ETNAVIV_NUM_IOCTLS,
.fops = &fops,
.name = "etnaviv",
.desc = "etnaviv DRM",
.major = 1,
.minor = 4,
};
/*
* Platform driver:
*/
static int etnaviv_bind(struct device *dev)
{
struct etnaviv_drm_private *priv;
struct drm_device *drm;
int ret;
drm = drm_dev_alloc(&etnaviv_drm_driver, dev);
if (IS_ERR(drm))
return PTR_ERR(drm);
priv = kzalloc_obj(*priv);
if (!priv) {
dev_err(dev, "failed to allocate private data\n");
ret = -ENOMEM;
goto out_put;
}
drm->dev_private = priv;
dma_set_max_seg_size(dev, SZ_2G);
xa_init_flags(&priv->active_contexts, XA_FLAGS_ALLOC);
mutex_init(&priv->gem_lock);
INIT_LIST_HEAD(&priv->gem_list);
priv->num_gpus = 0;
priv->shm_gfp_mask = GFP_HIGHUSER | __GFP_RETRY_MAYFAIL | __GFP_NOWARN;
/*
* If the GPU is part of a system with DMA addressing limitations,
* request pages for our SHM backend buffers from the DMA32 zone to
* hopefully avoid performance killing SWIOTLB bounce buffering.
*/
if (dma_addressing_limited(dev)) {
priv->shm_gfp_mask |= GFP_DMA32;
priv->shm_gfp_mask &= ~__GFP_HIGHMEM;
}
priv->cmdbuf_suballoc = etnaviv_cmdbuf_suballoc_new(drm->dev);
if (IS_ERR(priv->cmdbuf_suballoc)) {
dev_err(drm->dev, "Failed to create cmdbuf suballocator\n");
ret = PTR_ERR(priv->cmdbuf_suballoc);
goto out_free_priv;
}
dev_set_drvdata(dev, drm);
ret = component_bind_all(dev, drm);
if (ret < 0)
goto out_destroy_suballoc;
load_gpu(drm);
ret = drm_dev_register(drm, 0);
if (ret)
goto out_unbind;
return 0;
out_unbind:
component_unbind_all(dev, drm);
out_destroy_suballoc:
etnaviv_cmdbuf_suballoc_destroy(priv->cmdbuf_suballoc);
out_free_priv:
Annotation
- Immediate include surface: `linux/component.h`, `linux/dma-mapping.h`, `linux/module.h`, `linux/of.h`, `linux/of_device.h`, `linux/platform_device.h`, `linux/uaccess.h`, `drm/drm_debugfs.h`.
- Detected declarations: `function Copyright`, `function for_each_compatible_node`, `function load_gpu`, `function etnaviv_open`, `function etnaviv_postclose`, `function etnaviv_gem_show`, `function etnaviv_mm_show`, `function etnaviv_mmu_show`, `function etnaviv_buffer_dump`, `function etnaviv_ring_show`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- 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.