diff options
| author | Dmitry Torokhov <[email protected]> | 2024-07-15 14:03:44 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2024-07-15 14:03:44 -0700 | 
| commit | a23e1966932464e1c5226cb9ac4ce1d5fc10ba22 (patch) | |
| tree | bf5f1b57faa01ca31656bfc48c7d6b6f0bc39189 /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |
| parent | 7c7b1be19b228b450c2945ec379d7fc6bfef9852 (diff) | |
| parent | f3efefb6fdcce604413135bd8d4c5568e53a1f13 (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.11 merge window.
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 121 | 
1 files changed, 93 insertions, 28 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index ffac7413c657..047ec1930d12 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -36,6 +36,8 @@  #include "amdgpu_ring.h"  #include "amdgpu_ids.h" +struct drm_exec; +  struct amdgpu_bo_va;  struct amdgpu_job;  struct amdgpu_bo_list_entry; @@ -84,7 +86,13 @@ struct amdgpu_mem_stats;  /* PDE Block Fragment Size for VEGA10 */  #define AMDGPU_PDE_BFS(a)	((uint64_t)a << 59) +/* Flag combination to set no-retry with TF disabled */ +#define AMDGPU_VM_NORETRY_FLAGS	(AMDGPU_PTE_EXECUTABLE | AMDGPU_PDE_PTE | \ +				AMDGPU_PTE_TF) +/* Flag combination to set no-retry with TF enabled */ +#define AMDGPU_VM_NORETRY_FLAGS_TF (AMDGPU_PTE_VALID | AMDGPU_PTE_SYSTEM | \ +				   AMDGPU_PTE_PRT)  /* For GFX9 */  #define AMDGPU_PTE_MTYPE_VG10(a)	((uint64_t)(a) << 57)  #define AMDGPU_PTE_MTYPE_VG10_MASK	AMDGPU_PTE_MTYPE_VG10(3ULL) @@ -108,7 +116,7 @@ struct amdgpu_mem_stats;  #define AMDGPU_VM_FAULT_STOP_FIRST	1  #define AMDGPU_VM_FAULT_STOP_ALWAYS	2 -/* Reserve 4MB VRAM for page tables */ +/* How much VRAM be reserved for page tables */  #define AMDGPU_VM_RESERVED_VRAM		(8ULL << 20)  /* @@ -116,12 +124,32 @@ struct amdgpu_mem_stats;   * layout: max 8 GFXHUB + 4 MMHUB0 + 1 MMHUB1   */  #define AMDGPU_MAX_VMHUBS			13 -#define AMDGPU_GFXHUB(x)			(x) -#define AMDGPU_MMHUB0(x)			(8 + x) -#define AMDGPU_MMHUB1(x)			(8 + 4 + x) - -/* Reserve 2MB at top/bottom of address space for kernel use */ -#define AMDGPU_VA_RESERVED_SIZE			(2ULL << 20) +#define AMDGPU_GFXHUB_START			0 +#define AMDGPU_MMHUB0_START			8 +#define AMDGPU_MMHUB1_START			12 +#define AMDGPU_GFXHUB(x)			(AMDGPU_GFXHUB_START + (x)) +#define AMDGPU_MMHUB0(x)			(AMDGPU_MMHUB0_START + (x)) +#define AMDGPU_MMHUB1(x)			(AMDGPU_MMHUB1_START + (x)) + +#define AMDGPU_IS_GFXHUB(x) ((x) >= AMDGPU_GFXHUB_START && (x) < AMDGPU_MMHUB0_START) +#define AMDGPU_IS_MMHUB0(x) ((x) >= AMDGPU_MMHUB0_START && (x) < AMDGPU_MMHUB1_START) +#define AMDGPU_IS_MMHUB1(x) ((x) >= AMDGPU_MMHUB1_START && (x) < AMDGPU_MAX_VMHUBS) + +/* Reserve space at top/bottom of address space for kernel use */ +#define AMDGPU_VA_RESERVED_CSA_SIZE		(2ULL << 20) +#define AMDGPU_VA_RESERVED_CSA_START(adev)	(((adev)->vm_manager.max_pfn \ +						  << AMDGPU_GPU_PAGE_SHIFT)  \ +						 - AMDGPU_VA_RESERVED_CSA_SIZE) +#define AMDGPU_VA_RESERVED_SEQ64_SIZE		(2ULL << 20) +#define AMDGPU_VA_RESERVED_SEQ64_START(adev)	(AMDGPU_VA_RESERVED_CSA_START(adev) \ +						 - AMDGPU_VA_RESERVED_SEQ64_SIZE) +#define AMDGPU_VA_RESERVED_TRAP_SIZE		(2ULL << 12) +#define AMDGPU_VA_RESERVED_TRAP_START(adev)	(AMDGPU_VA_RESERVED_SEQ64_START(adev) \ +						 - AMDGPU_VA_RESERVED_TRAP_SIZE) +#define AMDGPU_VA_RESERVED_BOTTOM		(1ULL << 16) +#define AMDGPU_VA_RESERVED_TOP			(AMDGPU_VA_RESERVED_TRAP_SIZE + \ +						 AMDGPU_VA_RESERVED_SEQ64_SIZE + \ +						 AMDGPU_VA_RESERVED_CSA_SIZE)  /* See vm_update_mode */  #define AMDGPU_VM_USE_CPU_FOR_GFX (1 << 0) @@ -175,10 +203,11 @@ struct amdgpu_vm_pte_funcs {  };  struct amdgpu_task_info { -	char	process_name[TASK_COMM_LEN]; -	char	task_name[TASK_COMM_LEN]; -	pid_t	pid; -	pid_t	tgid; +	char		process_name[TASK_COMM_LEN]; +	char		task_name[TASK_COMM_LEN]; +	pid_t		pid; +	pid_t		tgid; +	struct kref	refcount;  };  /** @@ -231,6 +260,12 @@ struct amdgpu_vm_update_params {  	 * @table_freed: return true if page table is freed when updating  	 */  	bool table_freed; + +	/** +	 * @allow_override: true for memory that is not uncached: allows MTYPE +	 * to be overridden for NUMA local memory. +	 */ +	bool allow_override;  };  struct amdgpu_vm_update_funcs { @@ -244,6 +279,15 @@ struct amdgpu_vm_update_funcs {  		      struct dma_fence **fence);  }; +struct amdgpu_vm_fault_info { +	/* fault address */ +	uint64_t	addr; +	/* fault status register */ +	uint32_t	status; +	/* which vmhub? gfxhub, mmhub, etc. */ +	unsigned int	vmhub; +}; +  struct amdgpu_vm {  	/* tree of virtual addresses mapped */  	struct rb_root_cached	va; @@ -258,9 +302,12 @@ struct amdgpu_vm {  	/* Lock to protect vm_bo add/del/move on all lists of vm */  	spinlock_t		status_lock; -	/* BOs who needs a validation */ +	/* Per-VM and PT BOs who needs a validation */  	struct list_head	evicted; +	/* BOs for user mode queues that need a validation */ +	struct list_head	evicted_user; +  	/* PT BOs which relocated and their parent need an update */  	struct list_head	relocated; @@ -294,6 +341,7 @@ struct amdgpu_vm {  	/* Last finished delayed update */  	atomic64_t		tlb_seq;  	struct dma_fence	*last_tlb_flush; +	atomic64_t		kfd_last_flushed_seq;  	/* How many times we had to re-generate the page tables */  	uint64_t		generation; @@ -310,9 +358,6 @@ struct amdgpu_vm {  	/* Functions to use for VM table updates */  	const struct amdgpu_vm_update_funcs	*update_funcs; -	/* Flag to indicate ATS support from PTE for GFX9 */ -	bool			pte_support_ats; -  	/* Up to 128 pending retry page faults */  	DECLARE_KFIFO(faults, u64, 128); @@ -326,7 +371,7 @@ struct amdgpu_vm {  	uint64_t		pd_phys_addr;  	/* Some basic info about the task */ -	struct amdgpu_task_info task_info; +	struct amdgpu_task_info *task_info;  	/* Store positions of group of BOs */  	struct ttm_lru_bulk_move lru_bulk_move; @@ -335,6 +380,9 @@ struct amdgpu_vm {  	/* Memory partition number, -1 means any partition */  	int8_t			mem_id; + +	/* cached fault info */ +	struct amdgpu_vm_fault_info fault_info;  };  struct amdgpu_vm_manager { @@ -396,14 +444,14 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, int32_t xcp  int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm);  void amdgpu_vm_release_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm);  void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm); -void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, -			 struct list_head *validated, -			 struct amdgpu_bo_list_entry *entry); +int amdgpu_vm_lock_pd(struct amdgpu_vm *vm, struct drm_exec *exec, +		      unsigned int num_fences);  bool amdgpu_vm_ready(struct amdgpu_vm *vm);  uint64_t amdgpu_vm_generation(struct amdgpu_device *adev, struct amdgpu_vm *vm); -int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, -			      int (*callback)(void *p, struct amdgpu_bo *bo), -			      void *param); +int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm, +		       struct ww_acquire_ctx *ticket, +		       int (*callback)(void *p, struct amdgpu_bo *bo), +		       void *param);  int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_pipe_sync);  int amdgpu_vm_update_pdes(struct amdgpu_device *adev,  			  struct amdgpu_vm *vm, bool immediate); @@ -411,11 +459,16 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,  			  struct amdgpu_vm *vm,  			  struct dma_fence **fence);  int amdgpu_vm_handle_moved(struct amdgpu_device *adev, -			   struct amdgpu_vm *vm); +			   struct amdgpu_vm *vm, +			   struct ww_acquire_ctx *ticket); +int amdgpu_vm_flush_compute_tlb(struct amdgpu_device *adev, +				struct amdgpu_vm *vm, +				uint32_t flush_type, +				uint32_t xcc_mask);  void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base,  			    struct amdgpu_vm *vm, struct amdgpu_bo *bo);  int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, -			   bool immediate, bool unlocked, bool flush_tlb, +			   bool immediate, bool unlocked, bool flush_tlb, bool allow_override,  			   struct dma_resv *resv, uint64_t start, uint64_t last,  			   uint64_t flags, uint64_t offset, uint64_t vram_base,  			   struct ttm_resource *res, dma_addr_t *pages_addr, @@ -459,8 +512,14 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,  				  struct amdgpu_job *job);  void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev); -void amdgpu_vm_get_task_info(struct amdgpu_device *adev, u32 pasid, -			     struct amdgpu_task_info *task_info); +struct amdgpu_task_info * +amdgpu_vm_get_task_info_pasid(struct amdgpu_device *adev, u32 pasid); + +struct amdgpu_task_info * +amdgpu_vm_get_task_info_vm(struct amdgpu_vm *vm); + +void amdgpu_vm_put_task_info(struct amdgpu_task_info *task_info); +  bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,  			    u32 vmid, u32 node_id, uint64_t addr,  			    bool write_fault); @@ -478,8 +537,6 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm,  			int level, bool immediate, struct amdgpu_bo_vm **vmbo,  			int32_t xcp_id);  void amdgpu_vm_pt_free_root(struct amdgpu_device *adev, struct amdgpu_vm *vm); -bool amdgpu_vm_pt_is_root_clean(struct amdgpu_device *adev, -				struct amdgpu_vm *vm);  int amdgpu_vm_pde_update(struct amdgpu_vm_update_params *params,  			 struct amdgpu_vm_bo_base *entry); @@ -492,6 +549,8 @@ void amdgpu_vm_pt_free_work(struct work_struct *work);  void amdgpu_debugfs_vm_bo_info(struct amdgpu_vm *vm, struct seq_file *m);  #endif +int amdgpu_vm_pt_map_tables(struct amdgpu_device *adev, struct amdgpu_vm *vm); +  /**   * amdgpu_vm_tlb_seq - return tlb flush sequence number   * @vm: the amdgpu_vm structure to query @@ -545,4 +604,10 @@ static inline void amdgpu_vm_eviction_unlock(struct amdgpu_vm *vm)  	mutex_unlock(&vm->eviction_lock);  } +void amdgpu_vm_update_fault_cache(struct amdgpu_device *adev, +				  unsigned int pasid, +				  uint64_t addr, +				  uint32_t status, +				  unsigned int vmhub); +  #endif |