drivers/gpu/drm/msm/msm_gem_submit.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/msm_gem_submit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/msm_gem_submit.c- Extension
.c- Size
- 21341 bytes
- Lines
- 857
- 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
linux/dma-fence-unwrap.hlinux/file.hlinux/sync_file.hlinux/uaccess.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_syncobj.hmsm_drv.hmsm_gpu.hmsm_gem.hmsm_gpu_trace.hmsm_syncobj.h
Detected Declarations
function Copyrightfunction __msm_gem_submit_destroyfunction msm_job_runfunction submit_lookup_objectsfunction submit_lookup_cmdsfunction submit_lock_objects_vmbindfunction drm_exec_until_all_lockedfunction submit_lock_objectsfunction drm_exec_until_all_lockedfunction submit_fence_syncfunction submit_pin_objectsfunction submit_unpin_objectsfunction submit_attach_object_fencesfunction submit_bofunction submit_relocfunction submit_cleanupfunction msm_submit_retirefunction msm_ioctl_gem_submit
Annotated Snippet
if (copy_from_user(&submit_bo, userptr, sizeof(submit_bo))) {
ret = -EFAULT;
i = 0;
goto out;
}
/* at least one of READ and/or WRITE flags should be set: */
#define MANDATORY_FLAGS (MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE)
if ((submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) ||
!(submit_bo.flags & MANDATORY_FLAGS)) {
ret = SUBMIT_ERROR(EINVAL, submit, "invalid flags: %x\n", submit_bo.flags);
i = 0;
goto out;
}
submit->bos[i].handle = submit_bo.handle;
submit->bos[i].flags = submit_bo.flags;
}
spin_lock(&file->table_lock);
for (i = 0; i < args->nr_bos; i++) {
struct drm_gem_object *obj;
/* 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, submit->bos[i].handle);
if (!obj) {
ret = SUBMIT_ERROR(EINVAL, submit, "invalid handle %u at index %u\n", submit->bos[i].handle, i);
goto out_unlock;
}
drm_gem_object_get(obj);
submit->bos[i].obj = obj;
}
out_unlock:
spin_unlock(&file->table_lock);
out:
submit->nr_bos = i;
return ret;
}
static int submit_lookup_cmds(struct msm_gem_submit *submit,
struct drm_msm_gem_submit *args, struct drm_file *file)
{
struct msm_context *ctx = file->driver_priv;
unsigned i;
size_t sz;
int ret = 0;
for (i = 0; i < args->nr_cmds; i++) {
struct drm_msm_gem_submit_cmd submit_cmd;
void __user *userptr =
u64_to_user_ptr(args->cmds + (i * sizeof(submit_cmd)));
ret = copy_from_user(&submit_cmd, userptr, sizeof(submit_cmd));
if (ret) {
ret = -EFAULT;
goto out;
}
/* validate input from userspace: */
switch (submit_cmd.type) {
case MSM_SUBMIT_CMD_BUF:
case MSM_SUBMIT_CMD_IB_TARGET_BUF:
case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
break;
default:
return SUBMIT_ERROR(EINVAL, submit, "invalid type: %08x\n", submit_cmd.type);
}
if (submit_cmd.size % 4) {
ret = SUBMIT_ERROR(EINVAL, submit, "non-aligned cmdstream buffer size: %u\n",
submit_cmd.size);
goto out;
}
if (msm_context_is_vmbind(ctx)) {
if (submit_cmd.nr_relocs) {
ret = SUBMIT_ERROR(EINVAL, submit, "nr_relocs must be zero");
goto out;
}
if (submit_cmd.submit_idx || submit_cmd.submit_offset) {
Annotation
- Immediate include surface: `linux/dma-fence-unwrap.h`, `linux/file.h`, `linux/sync_file.h`, `linux/uaccess.h`, `drm/drm_drv.h`, `drm/drm_file.h`, `drm/drm_syncobj.h`, `msm_drv.h`.
- Detected declarations: `function Copyright`, `function __msm_gem_submit_destroy`, `function msm_job_run`, `function submit_lookup_objects`, `function submit_lookup_cmds`, `function submit_lock_objects_vmbind`, `function drm_exec_until_all_locked`, `function submit_lock_objects`, `function drm_exec_until_all_locked`, `function submit_fence_sync`.
- 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.