/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2020-2025 Intel Corporation3*/45#ifndef __IVPU_JOB_H__6#define __IVPU_JOB_H__78#include <linux/kref.h>9#include <linux/idr.h>1011#include "ivpu_gem.h"1213struct ivpu_device;14struct ivpu_file_priv;1516/**17* struct ivpu_cmdq - Represents a command queue for submitting jobs to the VPU.18* Tracks queue memory, preemption buffers, and metadata for job management.19* @jobq: Pointer to job queue memory shared with the device20* @primary_preempt_buf: Primary preemption buffer for this queue (optional)21* @secondary_preempt_buf: Secondary preemption buffer for this queue (optional)22* @mem: Memory allocated for the job queue, shared with device23* @entry_count: Number of job entries in the queue24* @id: Unique command queue ID25* @db_id: Doorbell ID assigned to this job queue26* @priority: Priority level of the command queue27* @is_legacy: True if this is a legacy command queue28*/29struct ivpu_cmdq {30struct vpu_job_queue *jobq;31struct ivpu_bo *primary_preempt_buf;32struct ivpu_bo *secondary_preempt_buf;33struct ivpu_bo *mem;34u32 entry_count;35u32 id;36u32 db_id;37u8 priority;38bool is_legacy;39};4041/**42* struct ivpu_job - Representing a batch or DMA buffer submitted to the VPU.43* Each job is a unit of execution, tracked by job_id for status reporting from VPU FW.44* The structure holds all resources and metadata needed for job submission, execution,45* and completion handling.46* @vdev: Pointer to the VPU device47* @file_priv: The client context that submitted this job48* @done_fence: Fence signaled when job completes49* @cmd_buf_vpu_addr: VPU address of the command buffer for this job50* @cmdq_id: Command queue ID used for submission51* @job_id: Unique job ID for tracking and status reporting52* @engine_idx: Engine index for job execution53* @job_status: Status reported by firmware for this job54* @primary_preempt_buf: Primary preemption buffer for job55* @secondary_preempt_buf: Secondary preemption buffer for job (optional)56* @bo_count: Number of buffer objects associated with this job57* @bos: Array of buffer objects used by the job (batch buffer is at index 0)58*/59struct ivpu_job {60struct ivpu_device *vdev;61struct ivpu_file_priv *file_priv;62struct dma_fence *done_fence;63u64 cmd_buf_vpu_addr;64u32 cmdq_id;65u32 job_id;66u32 engine_idx;67u32 job_status;68struct ivpu_bo *primary_preempt_buf;69struct ivpu_bo *secondary_preempt_buf;70size_t bo_count;71struct ivpu_bo *bos[] __counted_by(bo_count);72};7374int ivpu_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file);75int ivpu_cmdq_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file);76int ivpu_cmdq_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file);77int ivpu_cmdq_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file);7879void ivpu_context_abort_locked(struct ivpu_file_priv *file_priv);8081void ivpu_cmdq_release_all_locked(struct ivpu_file_priv *file_priv);82void ivpu_cmdq_reset_all_contexts(struct ivpu_device *vdev);83void ivpu_cmdq_abort_all_jobs(struct ivpu_device *vdev, u32 ctx_id, u32 cmdq_id);8485void ivpu_job_done_consumer_init(struct ivpu_device *vdev);86void ivpu_job_done_consumer_fini(struct ivpu_device *vdev);87bool ivpu_job_handle_engine_error(struct ivpu_device *vdev, u32 job_id, u32 job_status);88void ivpu_context_abort_work_fn(struct work_struct *work);8990void ivpu_jobs_abort_all(struct ivpu_device *vdev);9192#endif /* __IVPU_JOB_H__ */939495