drivers/gpu/drm/msm/msm_submitqueue.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/msm_submitqueue.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/msm_submitqueue.c- Extension
.c- Size
- 7619 bytes
- Lines
- 354
- 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/kref.hlinux/uaccess.hmsm_gpu.h
Detected Declarations
function msm_context_set_sysproffunction __msm_context_destroyfunction msm_submitqueue_destroyfunction list_for_each_entryfunction msm_submitqueue_closefunction get_sched_entityfunction msm_submitqueue_createfunction msm_submitqueue_initfunction msm_submitqueue_query_faultsfunction msm_submitqueue_queryfunction msm_submitqueue_removefunction list_for_each_entry
Annotated Snippet
if (entry->id == id) {
kref_get(&entry->ref);
read_unlock(&ctx->queuelock);
return entry;
}
}
read_unlock(&ctx->queuelock);
return NULL;
}
void msm_submitqueue_close(struct msm_context *ctx)
{
struct msm_gpu_submitqueue *queue, *tmp;
if (!ctx)
return;
/*
* No lock needed in close and there won't
* be any more user ioctls coming our way
*/
list_for_each_entry_safe(queue, tmp, &ctx->submitqueues, node) {
if (queue->entity == &queue->_vm_bind_entity[0])
drm_sched_entity_flush(queue->entity, MAX_WAIT_SCHED_ENTITY_Q_EMPTY);
list_del(&queue->node);
msm_submitqueue_put(queue);
}
if (!ctx->vm)
return;
msm_gem_vm_close(ctx->vm);
}
static struct drm_sched_entity *
get_sched_entity(struct msm_context *ctx, struct msm_ringbuffer *ring,
unsigned ring_nr, enum drm_sched_priority sched_prio)
{
static DEFINE_MUTEX(entity_lock);
unsigned idx = (ring_nr * NR_SCHED_PRIORITIES) + sched_prio;
/* We should have already validated that the requested priority is
* valid by the time we get here.
*/
if (WARN_ON(idx >= ARRAY_SIZE(ctx->entities)))
return ERR_PTR(-EINVAL);
mutex_lock(&entity_lock);
if (!ctx->entities[idx]) {
struct drm_sched_entity *entity;
struct drm_gpu_scheduler *sched = &ring->sched;
int ret;
entity = kzalloc_obj(*ctx->entities[idx]);
ret = drm_sched_entity_init(entity, sched_prio, &sched, 1, NULL);
if (ret) {
mutex_unlock(&entity_lock);
kfree(entity);
return ERR_PTR(ret);
}
ctx->entities[idx] = entity;
}
mutex_unlock(&entity_lock);
return ctx->entities[idx];
}
int msm_submitqueue_create(struct drm_device *drm, struct msm_context *ctx,
u32 prio, u32 flags, u32 *id)
{
struct msm_drm_private *priv = drm->dev_private;
struct msm_gpu_submitqueue *queue;
enum drm_sched_priority sched_prio;
unsigned ring_nr;
int ret;
if (!ctx)
return -ENODEV;
if (!priv->gpu)
return -ENODEV;
if (flags & MSM_SUBMITQUEUE_VM_BIND) {
unsigned sz;
Annotation
- Immediate include surface: `linux/kref.h`, `linux/uaccess.h`, `msm_gpu.h`.
- Detected declarations: `function msm_context_set_sysprof`, `function __msm_context_destroy`, `function msm_submitqueue_destroy`, `function list_for_each_entry`, `function msm_submitqueue_close`, `function get_sched_entity`, `function msm_submitqueue_create`, `function msm_submitqueue_init`, `function msm_submitqueue_query_faults`, `function msm_submitqueue_query`.
- 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.