aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h84
1 files changed, 59 insertions, 25 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 9fa9df0c5e7f..2a8898d19c8b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -29,6 +29,8 @@
29#include <linux/rbtree.h> 29#include <linux/rbtree.h>
30#include <drm/gpu_scheduler.h> 30#include <drm/gpu_scheduler.h>
31#include <drm/drm_file.h> 31#include <drm/drm_file.h>
32#include <drm/ttm/ttm_bo_driver.h>
33#include <linux/chash.h>
32 34
33#include "amdgpu_sync.h" 35#include "amdgpu_sync.h"
34#include "amdgpu_ring.h" 36#include "amdgpu_ring.h"
@@ -48,9 +50,6 @@ struct amdgpu_bo_list_entry;
48/* number of entries in page table */ 50/* number of entries in page table */
49#define AMDGPU_VM_PTE_COUNT(adev) (1 << (adev)->vm_manager.block_size) 51#define AMDGPU_VM_PTE_COUNT(adev) (1 << (adev)->vm_manager.block_size)
50 52
51/* PTBs (Page Table Blocks) need to be aligned to 32K */
52#define AMDGPU_VM_PTB_ALIGN_SIZE 32768
53
54#define AMDGPU_PTE_VALID (1ULL << 0) 53#define AMDGPU_PTE_VALID (1ULL << 0)
55#define AMDGPU_PTE_SYSTEM (1ULL << 1) 54#define AMDGPU_PTE_SYSTEM (1ULL << 1)
56#define AMDGPU_PTE_SNOOPED (1ULL << 2) 55#define AMDGPU_PTE_SNOOPED (1ULL << 2)
@@ -103,19 +102,6 @@ struct amdgpu_bo_list_entry;
103/* hardcode that limit for now */ 102/* hardcode that limit for now */
104#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20) 103#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20)
105 104
106/* VA hole for 48bit addresses on Vega10 */
107#define AMDGPU_VA_HOLE_START 0x0000800000000000ULL
108#define AMDGPU_VA_HOLE_END 0xffff800000000000ULL
109
110/*
111 * Hardware is programmed as if the hole doesn't exists with start and end
112 * address values.
113 *
114 * This mask is used to remove the upper 16bits of the VA and so come up with
115 * the linear addr value.
116 */
117#define AMDGPU_VA_HOLE_MASK 0x0000ffffffffffffULL
118
119/* max vmids dedicated for process */ 105/* max vmids dedicated for process */
120#define AMDGPU_VM_MAX_RESERVED_VMID 1 106#define AMDGPU_VM_MAX_RESERVED_VMID 1
121 107
@@ -143,7 +129,7 @@ struct amdgpu_vm_bo_base {
143 struct amdgpu_bo *bo; 129 struct amdgpu_bo *bo;
144 130
145 /* protected by bo being reserved */ 131 /* protected by bo being reserved */
146 struct list_head bo_list; 132 struct amdgpu_vm_bo_base *next;
147 133
148 /* protected by spinlock */ 134 /* protected by spinlock */
149 struct list_head vm_status; 135 struct list_head vm_status;
@@ -160,6 +146,27 @@ struct amdgpu_vm_pt {
160 struct amdgpu_vm_pt *entries; 146 struct amdgpu_vm_pt *entries;
161}; 147};
162 148
149/* provided by hw blocks that can write ptes, e.g., sdma */
150struct amdgpu_vm_pte_funcs {
151 /* number of dw to reserve per operation */
152 unsigned copy_pte_num_dw;
153
154 /* copy pte entries from GART */
155 void (*copy_pte)(struct amdgpu_ib *ib,
156 uint64_t pe, uint64_t src,
157 unsigned count);
158
159 /* write pte one entry at a time with addr mapping */
160 void (*write_pte)(struct amdgpu_ib *ib, uint64_t pe,
161 uint64_t value, unsigned count,
162 uint32_t incr);
163 /* for linear pte/pde updates without addr mapping */
164 void (*set_pte_pde)(struct amdgpu_ib *ib,
165 uint64_t pe,
166 uint64_t addr, unsigned count,
167 uint32_t incr, uint64_t flags);
168};
169
163#define AMDGPU_VM_FAULT(pasid, addr) (((u64)(pasid) << 48) | (addr)) 170#define AMDGPU_VM_FAULT(pasid, addr) (((u64)(pasid) << 48) | (addr))
164#define AMDGPU_VM_FAULT_PASID(fault) ((u64)(fault) >> 48) 171#define AMDGPU_VM_FAULT_PASID(fault) ((u64)(fault) >> 48)
165#define AMDGPU_VM_FAULT_ADDR(fault) ((u64)(fault) & 0xfffffffff000ULL) 172#define AMDGPU_VM_FAULT_ADDR(fault) ((u64)(fault) & 0xfffffffff000ULL)
@@ -172,6 +179,13 @@ struct amdgpu_task_info {
172 pid_t tgid; 179 pid_t tgid;
173}; 180};
174 181
182#define AMDGPU_PAGEFAULT_HASH_BITS 8
183struct amdgpu_retryfault_hashtable {
184 DECLARE_CHASH_TABLE(hash, AMDGPU_PAGEFAULT_HASH_BITS, 8, 0);
185 spinlock_t lock;
186 int count;
187};
188
175struct amdgpu_vm { 189struct amdgpu_vm {
176 /* tree of virtual addresses mapped */ 190 /* tree of virtual addresses mapped */
177 struct rb_root_cached va; 191 struct rb_root_cached va;
@@ -182,13 +196,16 @@ struct amdgpu_vm {
182 /* PT BOs which relocated and their parent need an update */ 196 /* PT BOs which relocated and their parent need an update */
183 struct list_head relocated; 197 struct list_head relocated;
184 198
185 /* BOs moved, but not yet updated in the PT */ 199 /* per VM BOs moved, but not yet updated in the PT */
186 struct list_head moved; 200 struct list_head moved;
187 spinlock_t moved_lock;
188 201
189 /* All BOs of this VM not currently in the state machine */ 202 /* All BOs of this VM not currently in the state machine */
190 struct list_head idle; 203 struct list_head idle;
191 204
205 /* regular invalidated BOs, but not yet updated in the PT */
206 struct list_head invalidated;
207 spinlock_t invalidated_lock;
208
192 /* BO mappings freed, but not yet updated in the PT */ 209 /* BO mappings freed, but not yet updated in the PT */
193 struct list_head freed; 210 struct list_head freed;
194 211
@@ -226,6 +243,12 @@ struct amdgpu_vm {
226 243
227 /* Some basic info about the task */ 244 /* Some basic info about the task */
228 struct amdgpu_task_info task_info; 245 struct amdgpu_task_info task_info;
246
247 /* Store positions of group of BOs */
248 struct ttm_lru_bulk_move lru_bulk_move;
249 /* mark whether can do the bulk move */
250 bool bulk_moveable;
251 struct amdgpu_retryfault_hashtable *fault_hash;
229}; 252};
230 253
231struct amdgpu_vm_manager { 254struct amdgpu_vm_manager {
@@ -244,10 +267,9 @@ struct amdgpu_vm_manager {
244 /* vram base address for page table entry */ 267 /* vram base address for page table entry */
245 u64 vram_base_offset; 268 u64 vram_base_offset;
246 /* vm pte handling */ 269 /* vm pte handling */
247 const struct amdgpu_vm_pte_funcs *vm_pte_funcs; 270 const struct amdgpu_vm_pte_funcs *vm_pte_funcs;
248 struct amdgpu_ring *vm_pte_rings[AMDGPU_MAX_RINGS]; 271 struct drm_sched_rq *vm_pte_rqs[AMDGPU_MAX_RINGS];
249 unsigned vm_pte_num_rings; 272 unsigned vm_pte_num_rqs;
250 atomic_t vm_pte_next_ring;
251 273
252 /* partial resident texture handling */ 274 /* partial resident texture handling */
253 spinlock_t prt_lock; 275 spinlock_t prt_lock;
@@ -266,11 +288,16 @@ struct amdgpu_vm_manager {
266 spinlock_t pasid_lock; 288 spinlock_t pasid_lock;
267}; 289};
268 290
291#define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
292#define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
293#define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
294
269void amdgpu_vm_manager_init(struct amdgpu_device *adev); 295void amdgpu_vm_manager_init(struct amdgpu_device *adev);
270void amdgpu_vm_manager_fini(struct amdgpu_device *adev); 296void amdgpu_vm_manager_fini(struct amdgpu_device *adev);
271int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, 297int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
272 int vm_context, unsigned int pasid); 298 int vm_context, unsigned int pasid);
273int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm); 299int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm, unsigned int pasid);
300void amdgpu_vm_release_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm);
274void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm); 301void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm);
275bool amdgpu_vm_pasid_fault_credit(struct amdgpu_device *adev, 302bool amdgpu_vm_pasid_fault_credit(struct amdgpu_device *adev,
276 unsigned int pasid); 303 unsigned int pasid);
@@ -330,8 +357,15 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
330void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev); 357void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev);
331 358
332void amdgpu_vm_get_task_info(struct amdgpu_device *adev, unsigned int pasid, 359void amdgpu_vm_get_task_info(struct amdgpu_device *adev, unsigned int pasid,
333 struct amdgpu_task_info *task_info); 360 struct amdgpu_task_info *task_info);
334 361
335void amdgpu_vm_set_task_info(struct amdgpu_vm *vm); 362void amdgpu_vm_set_task_info(struct amdgpu_vm *vm);
336 363