diff options
author | Christian König <christian.koenig@amd.com> | 2015-09-03 10:40:39 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-09-23 17:23:34 -0400 |
commit | a5b750583eb4af69da1e659c7684b6d370b2ae97 (patch) | |
tree | 250180ea814a918940a90c0986a855f935acf417 /drivers/gpu/drm/amd/amdgpu | |
parent | 72d7668b5ba5180b651e8a07dd6ed62e4e26f207 (diff) |
drm/amdgpu: validate duplicates in the CS as well
This allows for multiple BOs to have the same reservation object.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 3b355aeb62fd..4b92e3836684 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -321,25 +321,17 @@ static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) | |||
321 | return max(bytes_moved_threshold, 1024*1024ull); | 321 | return max(bytes_moved_threshold, 1024*1024ull); |
322 | } | 322 | } |
323 | 323 | ||
324 | int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p) | 324 | int amdgpu_cs_list_validate(struct amdgpu_device *adev, |
325 | struct amdgpu_vm *vm, | ||
326 | struct list_head *validated) | ||
325 | { | 327 | { |
326 | struct amdgpu_fpriv *fpriv = p->filp->driver_priv; | ||
327 | struct amdgpu_vm *vm = &fpriv->vm; | ||
328 | struct amdgpu_device *adev = p->adev; | ||
329 | struct amdgpu_bo_list_entry *lobj; | 328 | struct amdgpu_bo_list_entry *lobj; |
330 | struct list_head duplicates; | ||
331 | struct amdgpu_bo *bo; | 329 | struct amdgpu_bo *bo; |
332 | u64 bytes_moved = 0, initial_bytes_moved; | 330 | u64 bytes_moved = 0, initial_bytes_moved; |
333 | u64 bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(adev); | 331 | u64 bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(adev); |
334 | int r; | 332 | int r; |
335 | 333 | ||
336 | INIT_LIST_HEAD(&duplicates); | 334 | list_for_each_entry(lobj, validated, tv.head) { |
337 | r = ttm_eu_reserve_buffers(&p->ticket, &p->validated, true, &duplicates); | ||
338 | if (unlikely(r != 0)) { | ||
339 | return r; | ||
340 | } | ||
341 | |||
342 | list_for_each_entry(lobj, &p->validated, tv.head) { | ||
343 | bo = lobj->robj; | 335 | bo = lobj->robj; |
344 | if (!bo->pin_count) { | 336 | if (!bo->pin_count) { |
345 | u32 domain = lobj->prefered_domains; | 337 | u32 domain = lobj->prefered_domains; |
@@ -373,7 +365,6 @@ int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p) | |||
373 | domain = lobj->allowed_domains; | 365 | domain = lobj->allowed_domains; |
374 | goto retry; | 366 | goto retry; |
375 | } | 367 | } |
376 | ttm_eu_backoff_reservation(&p->ticket, &p->validated); | ||
377 | return r; | 368 | return r; |
378 | } | 369 | } |
379 | } | 370 | } |
@@ -386,6 +377,7 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p) | |||
386 | { | 377 | { |
387 | struct amdgpu_fpriv *fpriv = p->filp->driver_priv; | 378 | struct amdgpu_fpriv *fpriv = p->filp->driver_priv; |
388 | struct amdgpu_cs_buckets buckets; | 379 | struct amdgpu_cs_buckets buckets; |
380 | struct list_head duplicates; | ||
389 | bool need_mmap_lock = false; | 381 | bool need_mmap_lock = false; |
390 | int i, r; | 382 | int i, r; |
391 | 383 | ||
@@ -405,8 +397,22 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p) | |||
405 | if (need_mmap_lock) | 397 | if (need_mmap_lock) |
406 | down_read(¤t->mm->mmap_sem); | 398 | down_read(¤t->mm->mmap_sem); |
407 | 399 | ||
408 | r = amdgpu_cs_list_validate(p); | 400 | INIT_LIST_HEAD(&duplicates); |
401 | r = ttm_eu_reserve_buffers(&p->ticket, &p->validated, true, &duplicates); | ||
402 | if (unlikely(r != 0)) | ||
403 | goto error_reserve; | ||
404 | |||
405 | r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &p->validated); | ||
406 | if (r) | ||
407 | goto error_validate; | ||
408 | |||
409 | r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &duplicates); | ||
410 | |||
411 | error_validate: | ||
412 | if (r) | ||
413 | ttm_eu_backoff_reservation(&p->ticket, &p->validated); | ||
409 | 414 | ||
415 | error_reserve: | ||
410 | if (need_mmap_lock) | 416 | if (need_mmap_lock) |
411 | up_read(¤t->mm->mmap_sem); | 417 | up_read(¤t->mm->mmap_sem); |
412 | 418 | ||