162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2020-2023 Intel Corporation 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __IVPU_JOB_H__ 762306a36Sopenharmony_ci#define __IVPU_JOB_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/kref.h> 1062306a36Sopenharmony_ci#include <linux/idr.h> 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include "ivpu_gem.h" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cistruct ivpu_device; 1562306a36Sopenharmony_cistruct ivpu_file_priv; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/** 1862306a36Sopenharmony_ci * struct ivpu_cmdq - Object representing device queue used to send jobs. 1962306a36Sopenharmony_ci * @jobq: Pointer to job queue memory shared with the device 2062306a36Sopenharmony_ci * @mem: Memory allocated for the job queue, shared with device 2162306a36Sopenharmony_ci * @entry_count Number of job entries in the queue 2262306a36Sopenharmony_ci * @db_id: Doorbell assigned to this job queue 2362306a36Sopenharmony_ci * @db_registered: True if doorbell is registered in device 2462306a36Sopenharmony_ci */ 2562306a36Sopenharmony_cistruct ivpu_cmdq { 2662306a36Sopenharmony_ci struct vpu_job_queue *jobq; 2762306a36Sopenharmony_ci struct ivpu_bo *mem; 2862306a36Sopenharmony_ci u32 entry_count; 2962306a36Sopenharmony_ci u32 db_id; 3062306a36Sopenharmony_ci bool db_registered; 3162306a36Sopenharmony_ci}; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/** 3462306a36Sopenharmony_ci * struct ivpu_job - KMD object that represents batchbuffer / DMA buffer. 3562306a36Sopenharmony_ci * Each batch / DMA buffer is a job to be submitted and executed by the VPU FW. 3662306a36Sopenharmony_ci * This is a unit of execution, and be tracked by the job_id for 3762306a36Sopenharmony_ci * any status reporting from VPU FW through IPC JOB RET/DONE message. 3862306a36Sopenharmony_ci * @file_priv: The client that submitted this job 3962306a36Sopenharmony_ci * @job_id: Job ID for KMD tracking and job status reporting from VPU FW 4062306a36Sopenharmony_ci * @status: Status of the Job from IPC JOB RET/DONE message 4162306a36Sopenharmony_ci * @batch_buffer: CPU vaddr points to the batch buffer memory allocated for the job 4262306a36Sopenharmony_ci * @submit_status_offset: Offset within batch buffer where job completion handler 4362306a36Sopenharmony_ci will update the job status 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_cistruct ivpu_job { 4662306a36Sopenharmony_ci struct kref ref; 4762306a36Sopenharmony_ci struct ivpu_device *vdev; 4862306a36Sopenharmony_ci struct ivpu_file_priv *file_priv; 4962306a36Sopenharmony_ci struct dma_fence *done_fence; 5062306a36Sopenharmony_ci u64 cmd_buf_vpu_addr; 5162306a36Sopenharmony_ci u32 job_id; 5262306a36Sopenharmony_ci u32 engine_idx; 5362306a36Sopenharmony_ci size_t bo_count; 5462306a36Sopenharmony_ci struct ivpu_bo *bos[]; 5562306a36Sopenharmony_ci}; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ciint ivpu_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file); 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_civoid ivpu_cmdq_release_all(struct ivpu_file_priv *file_priv); 6062306a36Sopenharmony_civoid ivpu_cmdq_reset_all_contexts(struct ivpu_device *vdev); 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ciint ivpu_job_done_thread_init(struct ivpu_device *vdev); 6362306a36Sopenharmony_civoid ivpu_job_done_thread_fini(struct ivpu_device *vdev); 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_civoid ivpu_jobs_abort_all(struct ivpu_device *vdev); 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#endif /* __IVPU_JOB_H__ */ 68