Home | History | Annotate | Line # | Download | only in amdgpu
      1  1.1  riastrad /*	$NetBSD: amdgpu_ids.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 2017 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_IDS_H__
     26  1.1  riastrad #define __AMDGPU_IDS_H__
     27  1.1  riastrad 
     28  1.1  riastrad #include <linux/types.h>
     29  1.1  riastrad #include <linux/mutex.h>
     30  1.1  riastrad #include <linux/list.h>
     31  1.1  riastrad #include <linux/dma-fence.h>
     32  1.1  riastrad 
     33  1.1  riastrad #include "amdgpu_sync.h"
     34  1.1  riastrad 
     35  1.1  riastrad /* maximum number of VMIDs */
     36  1.1  riastrad #define AMDGPU_NUM_VMID	16
     37  1.1  riastrad 
     38  1.1  riastrad struct amdgpu_device;
     39  1.1  riastrad struct amdgpu_vm;
     40  1.1  riastrad struct amdgpu_ring;
     41  1.1  riastrad struct amdgpu_sync;
     42  1.1  riastrad struct amdgpu_job;
     43  1.1  riastrad 
     44  1.1  riastrad struct amdgpu_vmid {
     45  1.1  riastrad 	struct list_head	list;
     46  1.1  riastrad 	struct amdgpu_sync	active;
     47  1.1  riastrad 	struct dma_fence	*last_flush;
     48  1.1  riastrad 	uint64_t		owner;
     49  1.1  riastrad 
     50  1.1  riastrad 	uint64_t		pd_gpu_addr;
     51  1.1  riastrad 	/* last flushed PD/PT update */
     52  1.1  riastrad 	struct dma_fence	*flushed_updates;
     53  1.1  riastrad 
     54  1.1  riastrad 	uint32_t                current_gpu_reset_count;
     55  1.1  riastrad 
     56  1.1  riastrad 	uint32_t		gds_base;
     57  1.1  riastrad 	uint32_t		gds_size;
     58  1.1  riastrad 	uint32_t		gws_base;
     59  1.1  riastrad 	uint32_t		gws_size;
     60  1.1  riastrad 	uint32_t		oa_base;
     61  1.1  riastrad 	uint32_t		oa_size;
     62  1.1  riastrad 
     63  1.1  riastrad 	unsigned		pasid;
     64  1.1  riastrad 	struct dma_fence	*pasid_mapping;
     65  1.1  riastrad };
     66  1.1  riastrad 
     67  1.1  riastrad struct amdgpu_vmid_mgr {
     68  1.1  riastrad 	struct mutex		lock;
     69  1.1  riastrad 	unsigned		num_ids;
     70  1.1  riastrad 	struct list_head	ids_lru;
     71  1.1  riastrad 	struct amdgpu_vmid	ids[AMDGPU_NUM_VMID];
     72  1.1  riastrad 	atomic_t		reserved_vmid_num;
     73  1.1  riastrad };
     74  1.1  riastrad 
     75  1.1  riastrad int amdgpu_pasid_alloc(unsigned int bits);
     76  1.1  riastrad void amdgpu_pasid_free(unsigned int pasid);
     77  1.1  riastrad void amdgpu_pasid_free_delayed(struct dma_resv *resv,
     78  1.1  riastrad 			       unsigned int pasid);
     79  1.1  riastrad 
     80  1.1  riastrad bool amdgpu_vmid_had_gpu_reset(struct amdgpu_device *adev,
     81  1.1  riastrad 			       struct amdgpu_vmid *id);
     82  1.1  riastrad int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev,
     83  1.1  riastrad 			       struct amdgpu_vm *vm,
     84  1.1  riastrad 			       unsigned vmhub);
     85  1.1  riastrad void amdgpu_vmid_free_reserved(struct amdgpu_device *adev,
     86  1.1  riastrad 			       struct amdgpu_vm *vm,
     87  1.1  riastrad 			       unsigned vmhub);
     88  1.1  riastrad int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
     89  1.1  riastrad 		     struct amdgpu_sync *sync, struct dma_fence *fence,
     90  1.1  riastrad 		     struct amdgpu_job *job);
     91  1.1  riastrad void amdgpu_vmid_reset(struct amdgpu_device *adev, unsigned vmhub,
     92  1.1  riastrad 		       unsigned vmid);
     93  1.1  riastrad void amdgpu_vmid_reset_all(struct amdgpu_device *adev);
     94  1.1  riastrad 
     95  1.1  riastrad void amdgpu_vmid_mgr_init(struct amdgpu_device *adev);
     96  1.1  riastrad void amdgpu_vmid_mgr_fini(struct amdgpu_device *adev);
     97  1.1  riastrad 
     98  1.1  riastrad #endif
     99