drivers/gpu/drm/nouveau/nouveau_sched.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_sched.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nouveau_sched.c- Extension
.c- Size
- 11493 bytes
- Lines
- 523
- 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.
- 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/slab.hdrm/gpu_scheduler.hdrm/drm_syncobj.hnouveau_drv.hnouveau_gem.hnouveau_mem.hnouveau_dma.hnouveau_exec.hnouveau_abi16.hnouveau_sched.h
Detected Declarations
enum nouveau_sched_priorityfunction nouveau_job_initfunction nouveau_job_finifunction nouveau_job_donefunction nouveau_job_freefunction sync_find_fencefunction nouveau_job_add_depsfunction nouveau_job_fence_attach_cleanupfunction nouveau_job_fence_attach_preparefunction nouveau_job_fence_attachfunction nouveau_job_submitfunction nouveau_job_runfunction nouveau_sched_run_jobfunction nouveau_sched_timedout_jobfunction nouveau_sched_free_jobfunction nouveau_sched_initfunction nouveau_sched_createfunction nouveau_sched_job_list_emptyfunction nouveau_sched_finifunction nouveau_sched_destroy
Annotated Snippet
if (job->sync) {
ret = -EINVAL;
goto err_free_in_sync;
}
job->out_sync.data = kmemdup(args->out_sync.s,
sizeof(*args->out_sync.s) *
args->out_sync.count,
GFP_KERNEL);
if (!job->out_sync.data) {
ret = -ENOMEM;
goto err_free_in_sync;
}
job->out_sync.objs = kzalloc_objs(*job->out_sync.objs,
job->out_sync.count);
if (!job->out_sync.objs) {
ret = -ENOMEM;
goto err_free_out_sync;
}
job->out_sync.chains = kzalloc_objs(*job->out_sync.chains,
job->out_sync.count);
if (!job->out_sync.chains) {
ret = -ENOMEM;
goto err_free_objs;
}
}
ret = drm_sched_job_init(&job->base, &sched->entity,
args->credits, NULL,
job->file_priv->client_id);
if (ret)
goto err_free_chains;
job->state = NOUVEAU_JOB_INITIALIZED;
return 0;
err_free_chains:
kfree(job->out_sync.chains);
err_free_objs:
kfree(job->out_sync.objs);
err_free_out_sync:
kfree(job->out_sync.data);
err_free_in_sync:
kfree(job->in_sync.data);
return ret;
}
void
nouveau_job_fini(struct nouveau_job *job)
{
dma_fence_put(job->done_fence);
drm_sched_job_cleanup(&job->base);
job->ops->free(job);
}
void
nouveau_job_done(struct nouveau_job *job)
{
struct nouveau_sched *sched = job->sched;
spin_lock(&sched->job.list.lock);
list_del(&job->entry);
spin_unlock(&sched->job.list.lock);
wake_up(&sched->job.wq);
}
void
nouveau_job_free(struct nouveau_job *job)
{
kfree(job->in_sync.data);
kfree(job->out_sync.data);
kfree(job->out_sync.objs);
kfree(job->out_sync.chains);
}
static int
sync_find_fence(struct nouveau_job *job,
struct drm_nouveau_sync *sync,
struct dma_fence **fence)
{
u32 stype = sync->flags & DRM_NOUVEAU_SYNC_TYPE_MASK;
u64 point = 0;
int ret;
if (stype != DRM_NOUVEAU_SYNC_SYNCOBJ &&
Annotation
- Immediate include surface: `linux/slab.h`, `drm/gpu_scheduler.h`, `drm/drm_syncobj.h`, `nouveau_drv.h`, `nouveau_gem.h`, `nouveau_mem.h`, `nouveau_dma.h`, `nouveau_exec.h`.
- Detected declarations: `enum nouveau_sched_priority`, `function nouveau_job_init`, `function nouveau_job_fini`, `function nouveau_job_done`, `function nouveau_job_free`, `function sync_find_fence`, `function nouveau_job_add_deps`, `function nouveau_job_fence_attach_cleanup`, `function nouveau_job_fence_attach_prepare`, `function nouveau_job_fence_attach`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.