diff options
author | Christian König <christian.koenig@amd.com> | 2017-08-24 06:32:55 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-08-29 15:27:56 -0400 |
commit | 34d7be5dc28041b95254da517fd0f0f740544ece (patch) | |
tree | 3cb6ab57a8e2e59347216a2daf24e93068c6c3e2 /drivers/gpu/drm/amd | |
parent | 87f64a76b38acaa081b2bc46c3169884b9ccd6f2 (diff) |
drm/amdgpu: fix and cleanup VM ready check
Stop checking the mapped BO itself, cause that one is
certainly not a page table.
Additional to that move the code into amdgpu_vm.c
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 33 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 32 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 |
3 files changed, 35 insertions, 31 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 7171968f261e..9b1b6bdd4841 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |||
@@ -127,35 +127,6 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj, | |||
127 | return 0; | 127 | return 0; |
128 | } | 128 | } |
129 | 129 | ||
130 | static int amdgpu_gem_vm_check(void *param, struct amdgpu_bo *bo) | ||
131 | { | ||
132 | /* if anything is swapped out don't swap it in here, | ||
133 | just abort and wait for the next CS */ | ||
134 | if (!amdgpu_bo_gpu_accessible(bo)) | ||
135 | return -ERESTARTSYS; | ||
136 | |||
137 | if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) | ||
138 | return -ERESTARTSYS; | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static bool amdgpu_gem_vm_ready(struct amdgpu_device *adev, | ||
144 | struct amdgpu_vm *vm, | ||
145 | struct list_head *list) | ||
146 | { | ||
147 | struct ttm_validate_buffer *entry; | ||
148 | |||
149 | list_for_each_entry(entry, list, head) { | ||
150 | struct amdgpu_bo *bo = | ||
151 | container_of(entry->bo, struct amdgpu_bo, tbo); | ||
152 | if (amdgpu_gem_vm_check(NULL, bo)) | ||
153 | return false; | ||
154 | } | ||
155 | |||
156 | return !amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_gem_vm_check, NULL); | ||
157 | } | ||
158 | |||
159 | void amdgpu_gem_object_close(struct drm_gem_object *obj, | 130 | void amdgpu_gem_object_close(struct drm_gem_object *obj, |
160 | struct drm_file *file_priv) | 131 | struct drm_file *file_priv) |
161 | { | 132 | { |
@@ -189,7 +160,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj, | |||
189 | if (bo_va && --bo_va->ref_count == 0) { | 160 | if (bo_va && --bo_va->ref_count == 0) { |
190 | amdgpu_vm_bo_rmv(adev, bo_va); | 161 | amdgpu_vm_bo_rmv(adev, bo_va); |
191 | 162 | ||
192 | if (amdgpu_gem_vm_ready(adev, vm, &list)) { | 163 | if (amdgpu_vm_ready(adev, vm)) { |
193 | struct dma_fence *fence = NULL; | 164 | struct dma_fence *fence = NULL; |
194 | 165 | ||
195 | r = amdgpu_vm_clear_freed(adev, vm, &fence); | 166 | r = amdgpu_vm_clear_freed(adev, vm, &fence); |
@@ -513,7 +484,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, | |||
513 | { | 484 | { |
514 | int r = -ERESTARTSYS; | 485 | int r = -ERESTARTSYS; |
515 | 486 | ||
516 | if (!amdgpu_gem_vm_ready(adev, vm, list)) | 487 | if (!amdgpu_vm_ready(adev, vm)) |
517 | goto error; | 488 | goto error; |
518 | 489 | ||
519 | r = amdgpu_vm_update_directories(adev, vm); | 490 | r = amdgpu_vm_update_directories(adev, vm); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index db63ff5c80f2..67c37b22f8ef 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -232,6 +232,38 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
232 | } | 232 | } |
233 | 233 | ||
234 | /** | 234 | /** |
235 | * amdgpu_vm_check - helper for amdgpu_vm_ready | ||
236 | */ | ||
237 | static int amdgpu_vm_check(void *param, struct amdgpu_bo *bo) | ||
238 | { | ||
239 | /* if anything is swapped out don't swap it in here, | ||
240 | just abort and wait for the next CS */ | ||
241 | if (!amdgpu_bo_gpu_accessible(bo)) | ||
242 | return -ERESTARTSYS; | ||
243 | |||
244 | if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) | ||
245 | return -ERESTARTSYS; | ||
246 | |||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | /** | ||
251 | * amdgpu_vm_ready - check VM is ready for updates | ||
252 | * | ||
253 | * @adev: amdgpu device | ||
254 | * @vm: VM to check | ||
255 | * | ||
256 | * Check if all VM PDs/PTs are ready for updates | ||
257 | */ | ||
258 | bool amdgpu_vm_ready(struct amdgpu_device *adev, struct amdgpu_vm *vm) | ||
259 | { | ||
260 | if (amdgpu_vm_check(NULL, vm->root.bo)) | ||
261 | return false; | ||
262 | |||
263 | return !amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_vm_check, NULL); | ||
264 | } | ||
265 | |||
266 | /** | ||
235 | * amdgpu_vm_alloc_levels - allocate the PD/PT levels | 267 | * amdgpu_vm_alloc_levels - allocate the PD/PT levels |
236 | * | 268 | * |
237 | * @adev: amdgpu_device pointer | 269 | * @adev: amdgpu_device pointer |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index ba6691b58ee7..9347d28c3c1e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |||
@@ -225,6 +225,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm); | |||
225 | void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, | 225 | void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, |
226 | struct list_head *validated, | 226 | struct list_head *validated, |
227 | struct amdgpu_bo_list_entry *entry); | 227 | struct amdgpu_bo_list_entry *entry); |
228 | bool amdgpu_vm_ready(struct amdgpu_device *adev, struct amdgpu_vm *vm); | ||
228 | int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | 229 | int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, |
229 | int (*callback)(void *p, struct amdgpu_bo *bo), | 230 | int (*callback)(void *p, struct amdgpu_bo *bo), |
230 | void *param); | 231 | void *param); |