drivers/accel/ivpu/ivpu_job.c
Source file repositories/reference/linux-study-clean/drivers/accel/ivpu/ivpu_job.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/ivpu/ivpu_job.c- Extension
.c- Size
- 32912 bytes
- Lines
- 1216
- Domain
- Driver Families
- Bucket
- drivers/accel
- 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.hlinux/bitfield.hlinux/highmem.hlinux/pci.hlinux/pm_runtime.hlinux/module.huapi/drm/ivpu_accel.hivpu_drv.hivpu_fw.hivpu_hw.hivpu_ipc.hivpu_job.hivpu_jsm_msg.hivpu_mmu.hivpu_pm.hivpu_trace.hvpu_boot_api.h
Detected Declarations
struct ivpu_fencefunction Copyrightfunction ivpu_preemption_buffers_createfunction ivpu_preemption_buffers_freefunction ivpu_preemption_job_initfunction ivpu_cmdq_get_entry_countfunction ivpu_cmdq_get_flagsfunction ivpu_cmdq_freefunction ivpu_hws_cmdq_initfunction ivpu_register_dbfunction ivpu_cmdq_jobq_resetfunction ivpu_cmdq_registerfunction ivpu_cmdq_unregisterfunction ivpu_job_to_jsm_priorityfunction ivpu_cmdq_destroyfunction ivpu_cmdq_release_all_lockedfunction ivpu_cmdq_resetfunction xa_for_eachfunction ivpu_cmdq_reset_all_contextsfunction ivpu_context_abort_lockedfunction ivpu_cmdq_push_jobfunction ivpu_job_destroyfunction ivpu_job_createfunction ivpu_job_handle_engine_errorfunction ivpu_job_signal_and_destroyfunction ivpu_jobs_abort_allfunction ivpu_cmdq_abort_all_jobsfunction ivpu_job_submitfunction ivpu_job_prepare_bos_for_submitfunction ivpu_submitfunction ivpu_submit_ioctlfunction ivpu_cmdq_submit_ioctlfunction ivpu_cmdq_create_ioctlfunction ivpu_cmdq_destroy_ioctlfunction ivpu_job_done_callbackfunction ivpu_job_done_consumer_initfunction ivpu_job_done_consumer_finifunction reset_engine_and_mark_faulty_contextsfunction ivpu_context_abort_work_fn
Annotated Snippet
struct ivpu_fence {
struct dma_fence base;
spinlock_t lock; /* protects base */
struct ivpu_device *vdev;
};
static inline struct ivpu_fence *to_vpu_fence(struct dma_fence *fence)
{
return container_of(fence, struct ivpu_fence, base);
}
static const char *ivpu_fence_get_driver_name(struct dma_fence *fence)
{
return DRIVER_NAME;
}
static const char *ivpu_fence_get_timeline_name(struct dma_fence *fence)
{
struct ivpu_fence *ivpu_fence = to_vpu_fence(fence);
return dev_name(ivpu_fence->vdev->drm.dev);
}
static const struct dma_fence_ops ivpu_fence_ops = {
.get_driver_name = ivpu_fence_get_driver_name,
.get_timeline_name = ivpu_fence_get_timeline_name,
};
static struct dma_fence *ivpu_fence_create(struct ivpu_device *vdev)
{
struct ivpu_fence *fence;
fence = kzalloc_obj(*fence);
if (!fence)
return NULL;
fence->vdev = vdev;
spin_lock_init(&fence->lock);
dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1);
return &fence->base;
}
static void ivpu_job_destroy(struct ivpu_job *job)
{
struct ivpu_device *vdev = job->vdev;
u32 i;
ivpu_dbg(vdev, JOB, "Job destroyed: id %3u ctx %2d cmdq_id %u engine %d",
job->job_id, job->file_priv->ctx.id, job->cmdq_id, job->engine_idx);
for (i = 0; i < job->bo_count; i++)
if (job->bos[i])
drm_gem_object_put(&job->bos[i]->base.base);
dma_fence_put(job->done_fence);
ivpu_file_priv_put(&job->file_priv);
kfree(job);
}
static struct ivpu_job *
ivpu_job_create(struct ivpu_file_priv *file_priv, u32 engine_idx, u32 bo_count)
{
struct ivpu_device *vdev = file_priv->vdev;
struct ivpu_job *job;
job = kzalloc_flex(*job, bos, bo_count);
if (!job)
return NULL;
job->vdev = vdev;
job->engine_idx = engine_idx;
job->bo_count = bo_count;
job->done_fence = ivpu_fence_create(vdev);
if (!job->done_fence) {
ivpu_err(vdev, "Failed to create a fence\n");
goto err_free_job;
}
job->file_priv = ivpu_file_priv_get(file_priv);
trace_job("create", job);
ivpu_dbg(vdev, JOB, "Job created: ctx %2d engine %d", file_priv->ctx.id, job->engine_idx);
return job;
err_free_job:
kfree(job);
return NULL;
}
Annotation
- Immediate include surface: `drm/drm_file.h`, `linux/bitfield.h`, `linux/highmem.h`, `linux/pci.h`, `linux/pm_runtime.h`, `linux/module.h`, `uapi/drm/ivpu_accel.h`, `ivpu_drv.h`.
- Detected declarations: `struct ivpu_fence`, `function Copyright`, `function ivpu_preemption_buffers_create`, `function ivpu_preemption_buffers_free`, `function ivpu_preemption_job_init`, `function ivpu_cmdq_get_entry_count`, `function ivpu_cmdq_get_flags`, `function ivpu_cmdq_free`, `function ivpu_hws_cmdq_init`, `function ivpu_register_db`.
- Atlas domain: Driver Families / drivers/accel.
- 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.