drivers/accel/rocket/rocket_job.c
Source file repositories/reference/linux-study-clean/drivers/accel/rocket/rocket_job.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/rocket/rocket_job.c- Extension
.c- Size
- 15382 bytes
- Lines
- 636
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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_print.hdrm/drm_file.hdrm/drm_gem.hdrm/rocket_accel.hlinux/interrupt.hlinux/iommu.hlinux/platform_device.hlinux/pm_runtime.hrocket_core.hrocket_device.hrocket_drv.hrocket_job.hrocket_registers.h
Detected Declarations
function to_rocket_jobfunction rocket_copy_tasksfunction rocket_job_hw_submitfunction rocket_acquire_object_fencesfunction rocket_attach_object_fencesfunction rocket_job_pushfunction scoped_guardfunction rocket_job_cleanupfunction rocket_job_putfunction rocket_job_freefunction scoped_guardfunction rocket_job_handle_irqfunction scoped_guardfunction rocket_resetfunction pm_runtime_put_noidlefunction rocket_job_timedoutfunction rocket_reset_workfunction rocket_job_irq_handler_threadfunction rocket_job_irq_handlerfunction rocket_job_initfunction rocket_job_finifunction rocket_job_openfunction rocket_job_closefunction rocket_job_is_idlefunction rocket_ioctl_submit_jobfunction rocket_ioctl_submit
Annotated Snippet
sizeof(task))) {
drm_dbg(dev, "Failed to copy incoming tasks\n");
ret = -EFAULT;
goto fail;
}
if (task.regcmd_count == 0) {
drm_dbg(dev, "regcmd_count field in drm_rocket_task should be > 0.\n");
ret = -EINVAL;
goto fail;
}
rjob->tasks[i].regcmd = task.regcmd;
rjob->tasks[i].regcmd_count = task.regcmd_count;
}
return 0;
fail:
kvfree(rjob->tasks);
return ret;
}
static void rocket_job_hw_submit(struct rocket_core *core, struct rocket_job *job)
{
struct rocket_task *task;
unsigned int extra_bit;
/* Don't queue the job if a reset is in progress */
if (atomic_read(&core->reset.pending))
return;
/* GO ! */
task = &job->tasks[job->next_task_idx];
job->next_task_idx++;
rocket_pc_writel(core, BASE_ADDRESS, 0x1);
/* From rknpu, in the TRM this bit is marked as reserved */
extra_bit = 0x10000000 * core->index;
rocket_cna_writel(core, S_POINTER, CNA_S_POINTER_POINTER_PP_EN(1) |
CNA_S_POINTER_EXECUTER_PP_EN(1) |
CNA_S_POINTER_POINTER_PP_MODE(1) |
extra_bit);
rocket_core_writel(core, S_POINTER, CORE_S_POINTER_POINTER_PP_EN(1) |
CORE_S_POINTER_EXECUTER_PP_EN(1) |
CORE_S_POINTER_POINTER_PP_MODE(1) |
extra_bit);
rocket_pc_writel(core, BASE_ADDRESS, task->regcmd);
rocket_pc_writel(core, REGISTER_AMOUNTS,
PC_REGISTER_AMOUNTS_PC_DATA_AMOUNT((task->regcmd_count + 1) / 2 - 1));
rocket_pc_writel(core, INTERRUPT_MASK, PC_INTERRUPT_MASK_DPU_0 | PC_INTERRUPT_MASK_DPU_1);
rocket_pc_writel(core, INTERRUPT_CLEAR, PC_INTERRUPT_CLEAR_DPU_0 | PC_INTERRUPT_CLEAR_DPU_1);
rocket_pc_writel(core, TASK_CON, PC_TASK_CON_RESERVED_0(1) |
PC_TASK_CON_TASK_COUNT_CLEAR(1) |
PC_TASK_CON_TASK_NUMBER(1) |
PC_TASK_CON_TASK_PP_EN(1));
rocket_pc_writel(core, TASK_DMA_BASE_ADDR, PC_TASK_DMA_BASE_ADDR_DMA_BASE_ADDR(0x0));
rocket_pc_writel(core, OPERATION_ENABLE, PC_OPERATION_ENABLE_OP_EN(1));
dev_dbg(core->dev, "Submitted regcmd at 0x%llx to core %d", task->regcmd, core->index);
}
static int rocket_acquire_object_fences(struct drm_gem_object **bos,
int bo_count,
struct drm_sched_job *job,
bool is_write)
{
int i, ret;
for (i = 0; i < bo_count; i++) {
ret = dma_resv_reserve_fences(bos[i]->resv, 1);
if (ret)
return ret;
ret = drm_sched_job_add_implicit_dependencies(job, bos[i],
is_write);
if (ret)
return ret;
}
return 0;
}
Annotation
- Immediate include surface: `drm/drm_print.h`, `drm/drm_file.h`, `drm/drm_gem.h`, `drm/rocket_accel.h`, `linux/interrupt.h`, `linux/iommu.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `function to_rocket_job`, `function rocket_copy_tasks`, `function rocket_job_hw_submit`, `function rocket_acquire_object_fences`, `function rocket_attach_object_fences`, `function rocket_job_push`, `function scoped_guard`, `function rocket_job_cleanup`, `function rocket_job_put`, `function rocket_job_free`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.