18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2018 Advanced Micro Devices, Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#ifndef __AMDGPU_JOB_H__ 248c2ecf20Sopenharmony_ci#define __AMDGPU_JOB_H__ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* bit set means command submit involves a preamble IB */ 278c2ecf20Sopenharmony_ci#define AMDGPU_PREAMBLE_IB_PRESENT (1 << 0) 288c2ecf20Sopenharmony_ci/* bit set means preamble IB is first presented in belonging context */ 298c2ecf20Sopenharmony_ci#define AMDGPU_PREAMBLE_IB_PRESENT_FIRST (1 << 1) 308c2ecf20Sopenharmony_ci/* bit set means context switch occured */ 318c2ecf20Sopenharmony_ci#define AMDGPU_HAVE_CTX_SWITCH (1 << 2) 328c2ecf20Sopenharmony_ci/* bit set means IB is preempted */ 338c2ecf20Sopenharmony_ci#define AMDGPU_IB_PREEMPTED (1 << 3) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define to_amdgpu_job(sched_job) \ 368c2ecf20Sopenharmony_ci container_of((sched_job), struct amdgpu_job, base) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define AMDGPU_JOB_GET_VMID(job) ((job) ? (job)->vmid : 0) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct amdgpu_fence; 418c2ecf20Sopenharmony_cienum amdgpu_ib_pool_type; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct amdgpu_job { 448c2ecf20Sopenharmony_ci struct drm_sched_job base; 458c2ecf20Sopenharmony_ci struct amdgpu_vm *vm; 468c2ecf20Sopenharmony_ci struct amdgpu_sync sync; 478c2ecf20Sopenharmony_ci struct amdgpu_sync sched_sync; 488c2ecf20Sopenharmony_ci struct amdgpu_ib *ibs; 498c2ecf20Sopenharmony_ci struct dma_fence *fence; /* the hw fence */ 508c2ecf20Sopenharmony_ci uint32_t preamble_status; 518c2ecf20Sopenharmony_ci uint32_t preemption_status; 528c2ecf20Sopenharmony_ci uint32_t num_ibs; 538c2ecf20Sopenharmony_ci bool vm_needs_flush; 548c2ecf20Sopenharmony_ci uint64_t vm_pd_addr; 558c2ecf20Sopenharmony_ci unsigned vmid; 568c2ecf20Sopenharmony_ci unsigned pasid; 578c2ecf20Sopenharmony_ci uint32_t gds_base, gds_size; 588c2ecf20Sopenharmony_ci uint32_t gws_base, gws_size; 598c2ecf20Sopenharmony_ci uint32_t oa_base, oa_size; 608c2ecf20Sopenharmony_ci uint32_t vram_lost_counter; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci /* user fence handling */ 638c2ecf20Sopenharmony_ci uint64_t uf_addr; 648c2ecf20Sopenharmony_ci uint64_t uf_sequence; 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciint amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, 688c2ecf20Sopenharmony_ci struct amdgpu_job **job, struct amdgpu_vm *vm); 698c2ecf20Sopenharmony_ciint amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size, 708c2ecf20Sopenharmony_ci enum amdgpu_ib_pool_type pool, struct amdgpu_job **job); 718c2ecf20Sopenharmony_civoid amdgpu_job_free_resources(struct amdgpu_job *job); 728c2ecf20Sopenharmony_civoid amdgpu_job_free(struct amdgpu_job *job); 738c2ecf20Sopenharmony_ciint amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity, 748c2ecf20Sopenharmony_ci void *owner, struct dma_fence **f); 758c2ecf20Sopenharmony_ciint amdgpu_job_submit_direct(struct amdgpu_job *job, struct amdgpu_ring *ring, 768c2ecf20Sopenharmony_ci struct dma_fence **fence); 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_civoid amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched); 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#endif 81