drivers/gpu/drm/tegra/submit.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tegra/submit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tegra/submit.c- Extension
.c- Size
- 16977 bytes
- Lines
- 684
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/dma-fence-array.hlinux/dma-mapping.hlinux/file.hlinux/host1x.hlinux/iommu.hlinux/kref.hlinux/list.hlinux/nospec.hlinux/pm_runtime.hlinux/scatterlist.hlinux/slab.hlinux/sync_file.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_syncobj.hdrm.hgem.hsubmit.huapi.h
Detected Declarations
struct gather_bofunction gather_bo_releasefunction gather_bo_putfunction gather_bo_pinfunction gather_bo_unpinfunction gather_bo_munmapfunction tegra_drm_mapping_getfunction submit_copy_gather_datafunction submit_write_relocfunction submit_process_bufsfunction submit_get_syncptfunction submit_job_add_gatherfunction submit_create_jobfunction release_jobfunction tegra_drm_ioctl_channel_submit
Annotated Snippet
struct gather_bo {
struct host1x_bo base;
struct kref ref;
struct device *dev;
u32 *gather_data;
dma_addr_t gather_data_dma;
size_t gather_data_words;
};
static struct host1x_bo *gather_bo_get(struct host1x_bo *host_bo)
{
struct gather_bo *bo = container_of(host_bo, struct gather_bo, base);
kref_get(&bo->ref);
return host_bo;
}
static void gather_bo_release(struct kref *ref)
{
struct gather_bo *bo = container_of(ref, struct gather_bo, ref);
dma_free_attrs(bo->dev, bo->gather_data_words * 4, bo->gather_data, bo->gather_data_dma,
0);
kfree(bo);
}
static void gather_bo_put(struct host1x_bo *host_bo)
{
struct gather_bo *bo = container_of(host_bo, struct gather_bo, base);
kref_put(&bo->ref, gather_bo_release);
}
static struct host1x_bo_mapping *
gather_bo_pin(struct device *dev, struct host1x_bo *bo, enum dma_data_direction direction)
{
struct gather_bo *gather = container_of(bo, struct gather_bo, base);
struct host1x_bo_mapping *map;
int err;
map = kzalloc_obj(*map);
if (!map)
return ERR_PTR(-ENOMEM);
kref_init(&map->ref);
map->bo = bo;
map->direction = direction;
map->dev = dev;
map->sgt = kzalloc_obj(*map->sgt);
if (!map->sgt) {
err = -ENOMEM;
goto free;
}
err = dma_get_sgtable(gather->dev, map->sgt, gather->gather_data, gather->gather_data_dma,
gather->gather_data_words * 4);
if (err)
goto free_sgt;
err = dma_map_sgtable(dev, map->sgt, direction, 0);
if (err)
goto free_sgt;
map->phys = sg_dma_address(map->sgt->sgl);
map->size = gather->gather_data_words * 4;
map->chunks = err;
return map;
free_sgt:
sg_free_table(map->sgt);
kfree(map->sgt);
free:
kfree(map);
return ERR_PTR(err);
}
static void gather_bo_unpin(struct host1x_bo_mapping *map)
{
if (!map)
return;
dma_unmap_sgtable(map->dev, map->sgt, map->direction, 0);
sg_free_table(map->sgt);
kfree(map->sgt);
Annotation
- Immediate include surface: `linux/dma-fence-array.h`, `linux/dma-mapping.h`, `linux/file.h`, `linux/host1x.h`, `linux/iommu.h`, `linux/kref.h`, `linux/list.h`, `linux/nospec.h`.
- Detected declarations: `struct gather_bo`, `function gather_bo_release`, `function gather_bo_put`, `function gather_bo_pin`, `function gather_bo_unpin`, `function gather_bo_munmap`, `function tegra_drm_mapping_get`, `function submit_copy_gather_data`, `function submit_write_reloc`, `function submit_process_bufs`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.