Home | History | Annotate | Line # | Download | only in amdgpu
      1  1.1  riastrad /*	$NetBSD: amdgpu_job.h,v 1.2 2021/12/18 23:44:58 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 2018 Advanced Micro Devices, Inc.
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     14  1.1  riastrad  * all copies or substantial portions of the Software.
     15  1.1  riastrad  *
     16  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  1.1  riastrad  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     23  1.1  riastrad  *
     24  1.1  riastrad  */
     25  1.1  riastrad #ifndef __AMDGPU_JOB_H__
     26  1.1  riastrad #define __AMDGPU_JOB_H__
     27  1.1  riastrad 
     28  1.1  riastrad /* bit set means command submit involves a preamble IB */
     29  1.1  riastrad #define AMDGPU_PREAMBLE_IB_PRESENT          (1 << 0)
     30  1.1  riastrad /* bit set means preamble IB is first presented in belonging context */
     31  1.1  riastrad #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST    (1 << 1)
     32  1.1  riastrad /* bit set means context switch occured */
     33  1.1  riastrad #define AMDGPU_HAVE_CTX_SWITCH              (1 << 2)
     34  1.1  riastrad /* bit set means IB is preempted */
     35  1.1  riastrad #define AMDGPU_IB_PREEMPTED                 (1 << 3)
     36  1.1  riastrad 
     37  1.1  riastrad #define to_amdgpu_job(sched_job)		\
     38  1.1  riastrad 		container_of((sched_job), struct amdgpu_job, base)
     39  1.1  riastrad 
     40  1.1  riastrad #define AMDGPU_JOB_GET_VMID(job) ((job) ? (job)->vmid : 0)
     41  1.1  riastrad 
     42  1.1  riastrad struct amdgpu_fence;
     43  1.1  riastrad 
     44  1.1  riastrad struct amdgpu_job {
     45  1.1  riastrad 	struct drm_sched_job    base;
     46  1.1  riastrad 	struct amdgpu_vm	*vm;
     47  1.1  riastrad 	struct amdgpu_sync	sync;
     48  1.1  riastrad 	struct amdgpu_sync	sched_sync;
     49  1.1  riastrad 	struct amdgpu_ib	*ibs;
     50  1.1  riastrad 	struct dma_fence	*fence; /* the hw fence */
     51  1.1  riastrad 	uint32_t		preamble_status;
     52  1.1  riastrad 	uint32_t                preemption_status;
     53  1.1  riastrad 	uint32_t		num_ibs;
     54  1.1  riastrad 	bool                    vm_needs_flush;
     55  1.1  riastrad 	uint64_t		vm_pd_addr;
     56  1.1  riastrad 	unsigned		vmid;
     57  1.1  riastrad 	unsigned		pasid;
     58  1.1  riastrad 	uint32_t		gds_base, gds_size;
     59  1.1  riastrad 	uint32_t		gws_base, gws_size;
     60  1.1  riastrad 	uint32_t		oa_base, oa_size;
     61  1.1  riastrad 	uint32_t		vram_lost_counter;
     62  1.1  riastrad 
     63  1.1  riastrad 	/* user fence handling */
     64  1.1  riastrad 	uint64_t		uf_addr;
     65  1.1  riastrad 	uint64_t		uf_sequence;
     66  1.1  riastrad 
     67  1.1  riastrad };
     68  1.1  riastrad 
     69  1.1  riastrad int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
     70  1.1  riastrad 		     struct amdgpu_job **job, struct amdgpu_vm *vm);
     71  1.1  riastrad int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size,
     72  1.1  riastrad 			     struct amdgpu_job **job);
     73  1.1  riastrad 
     74  1.1  riastrad void amdgpu_job_free_resources(struct amdgpu_job *job);
     75  1.1  riastrad void amdgpu_job_free(struct amdgpu_job *job);
     76  1.1  riastrad int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,
     77  1.1  riastrad 		      void *owner, struct dma_fence **f);
     78  1.1  riastrad int amdgpu_job_submit_direct(struct amdgpu_job *job, struct amdgpu_ring *ring,
     79  1.1  riastrad 			     struct dma_fence **fence);
     80  1.1  riastrad 
     81  1.1  riastrad void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched);
     82  1.1  riastrad 
     83  1.1  riastrad #endif
     84