Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2020-2025 Intel Corporation
4 */
5
6#ifndef __IVPU_JOB_H__
7#define __IVPU_JOB_H__
8
9#include <linux/kref.h>
10#include <linux/idr.h>
11
12#include "ivpu_gem.h"
13
14struct ivpu_device;
15struct ivpu_file_priv;
16
17/**
18 * struct ivpu_cmdq - Represents a command queue for submitting jobs to the VPU.
19 * Tracks queue memory, preemption buffers, and metadata for job management.
20 * @jobq: Pointer to job queue memory shared with the device
21 * @primary_preempt_buf: Primary preemption buffer for this queue (optional)
22 * @secondary_preempt_buf: Secondary preemption buffer for this queue (optional)
23 * @mem: Memory allocated for the job queue, shared with device
24 * @entry_count: Number of job entries in the queue
25 * @id: Unique command queue ID
26 * @db_id: Doorbell ID assigned to this job queue
27 * @priority: Priority level of the command queue
28 * @is_legacy: True if this is a legacy command queue
29 */
30struct ivpu_cmdq {
31 struct vpu_job_queue *jobq;
32 struct ivpu_bo *primary_preempt_buf;
33 struct ivpu_bo *secondary_preempt_buf;
34 struct ivpu_bo *mem;
35 u32 entry_count;
36 u32 id;
37 u32 db_id;
38 u8 priority;
39 bool is_legacy;
40};
41
42/**
43 * struct ivpu_job - Representing a batch or DMA buffer submitted to the VPU.
44 * Each job is a unit of execution, tracked by job_id for status reporting from VPU FW.
45 * The structure holds all resources and metadata needed for job submission, execution,
46 * and completion handling.
47 * @vdev: Pointer to the VPU device
48 * @file_priv: The client context that submitted this job
49 * @done_fence: Fence signaled when job completes
50 * @cmd_buf_vpu_addr: VPU address of the command buffer for this job
51 * @cmdq_id: Command queue ID used for submission
52 * @job_id: Unique job ID for tracking and status reporting
53 * @engine_idx: Engine index for job execution
54 * @job_status: Status reported by firmware for this job
55 * @primary_preempt_buf: Primary preemption buffer for job
56 * @secondary_preempt_buf: Secondary preemption buffer for job (optional)
57 * @bo_count: Number of buffer objects associated with this job
58 * @bos: Array of buffer objects used by the job (batch buffer is at index 0)
59 */
60struct ivpu_job {
61 struct ivpu_device *vdev;
62 struct ivpu_file_priv *file_priv;
63 struct dma_fence *done_fence;
64 u64 cmd_buf_vpu_addr;
65 u32 cmdq_id;
66 u32 job_id;
67 u32 engine_idx;
68 u32 job_status;
69 struct ivpu_bo *primary_preempt_buf;
70 struct ivpu_bo *secondary_preempt_buf;
71 size_t bo_count;
72 struct ivpu_bo *bos[] __counted_by(bo_count);
73};
74
75int ivpu_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file);
76int ivpu_cmdq_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file);
77int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file);
78int ivpu_cmdq_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file);
79
80void ivpu_context_abort_locked(struct ivpu_file_priv *file_priv);
81
82void ivpu_cmdq_release_all_locked(struct ivpu_file_priv *file_priv);
83void ivpu_cmdq_reset_all_contexts(struct ivpu_device *vdev);
84void ivpu_cmdq_abort_all_jobs(struct ivpu_device *vdev, u32 ctx_id, u32 cmdq_id);
85
86void ivpu_job_done_consumer_init(struct ivpu_device *vdev);
87void ivpu_job_done_consumer_fini(struct ivpu_device *vdev);
88bool ivpu_job_handle_engine_error(struct ivpu_device *vdev, u32 job_id, u32 job_status);
89void ivpu_context_abort_work_fn(struct work_struct *work);
90
91void ivpu_jobs_abort_all(struct ivpu_device *vdev);
92
93#endif /* __IVPU_JOB_H__ */