drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c- Extension
.c- Size
- 15243 bytes
- Lines
- 635
- 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.
- 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
drm/drm_file.hdrm/drm_print.hlinux/dma-fence-array.hlinux/file.hlinux/dma-resv.hlinux/sync_file.hlinux/uaccess.hlinux/vmalloc.hetnaviv_cmdbuf.hetnaviv_drv.hetnaviv_gpu.hetnaviv_gem.hetnaviv_perfmon.hetnaviv_sched.h
Detected Declarations
function Copyrightfunction submit_lookup_objectsfunction submit_unlock_objectfunction submit_lock_objectsfunction submit_fence_syncfunction submit_attach_object_fencesfunction submit_pin_objectsfunction submit_bofunction submit_relocfunction submit_perfmon_validatefunction submit_cleanupfunction etnaviv_submit_putfunction etnaviv_ioctl_gem_submit
Annotated Snippet
if (bo->flags & BO_INVALID_FLAGS) {
DRM_ERROR("invalid flags: %x\n", bo->flags);
ret = -EINVAL;
goto out_unlock;
}
submit->bos[i].flags = bo->flags;
if (submit->flags & ETNA_SUBMIT_SOFTPIN) {
if (bo->presumed < ETNAVIV_SOFTPIN_START_ADDRESS) {
DRM_ERROR("invalid softpin address\n");
ret = -EINVAL;
goto out_unlock;
}
submit->bos[i].va = bo->presumed;
}
/* normally use drm_gem_object_lookup(), but for bulk lookup
* all under single table_lock just hit object_idr directly:
*/
obj = idr_find(&file->object_idr, bo->handle);
if (!obj) {
DRM_ERROR("invalid handle %u at index %u\n",
bo->handle, i);
ret = -EINVAL;
goto out_unlock;
}
/*
* Take a refcount on the object. The file table lock
* prevents the object_idr's refcount on this being dropped.
*/
drm_gem_object_get(obj);
submit->bos[i].obj = to_etnaviv_bo(obj);
}
out_unlock:
submit->nr_bos = i;
spin_unlock(&file->table_lock);
return ret;
}
static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i)
{
if (submit->bos[i].flags & BO_LOCKED) {
struct drm_gem_object *obj = &submit->bos[i].obj->base;
dma_resv_unlock(obj->resv);
submit->bos[i].flags &= ~BO_LOCKED;
}
}
static int submit_lock_objects(struct etnaviv_gem_submit *submit,
struct ww_acquire_ctx *ticket)
{
int contended, slow_locked = -1, i, ret = 0;
retry:
for (i = 0; i < submit->nr_bos; i++) {
struct drm_gem_object *obj = &submit->bos[i].obj->base;
if (slow_locked == i)
slow_locked = -1;
contended = i;
if (!(submit->bos[i].flags & BO_LOCKED)) {
ret = dma_resv_lock_interruptible(obj->resv, ticket);
if (ret == -EALREADY)
DRM_ERROR("BO at index %u already on submit list\n",
i);
if (ret)
goto fail;
submit->bos[i].flags |= BO_LOCKED;
}
}
ww_acquire_done(ticket);
return 0;
fail:
for (; i >= 0; i--)
submit_unlock_object(submit, i);
if (slow_locked > 0)
submit_unlock_object(submit, slow_locked);
if (ret == -EDEADLK) {
Annotation
- Immediate include surface: `drm/drm_file.h`, `drm/drm_print.h`, `linux/dma-fence-array.h`, `linux/file.h`, `linux/dma-resv.h`, `linux/sync_file.h`, `linux/uaccess.h`, `linux/vmalloc.h`.
- Detected declarations: `function Copyright`, `function submit_lookup_objects`, `function submit_unlock_object`, `function submit_lock_objects`, `function submit_fence_sync`, `function submit_attach_object_fences`, `function submit_pin_objects`, `function submit_bo`, `function submit_reloc`, `function submit_perfmon_validate`.
- 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.
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.