aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 504ae09d3991..a13e551e67cf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -388,9 +388,9 @@ retry:
388 388
389/* Last resort, try to evict something from the current working set */ 389/* Last resort, try to evict something from the current working set */
390static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, 390static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
391 struct amdgpu_bo_list_entry *lobj) 391 struct amdgpu_bo *validated)
392{ 392{
393 uint32_t domain = lobj->robj->allowed_domains; 393 uint32_t domain = validated->allowed_domains;
394 int r; 394 int r;
395 395
396 if (!p->evictable) 396 if (!p->evictable)
@@ -406,7 +406,7 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
406 uint32_t other; 406 uint32_t other;
407 407
408 /* If we reached our current BO we can forget it */ 408 /* If we reached our current BO we can forget it */
409 if (candidate == lobj) 409 if (candidate->robj == validated)
410 break; 410 break;
411 411
412 other = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); 412 other = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
@@ -439,6 +439,23 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
439 return false; 439 return false;
440} 440}
441 441
442static int amdgpu_cs_validate(void *param, struct amdgpu_bo *bo)
443{
444 struct amdgpu_cs_parser *p = param;
445 int r;
446
447 do {
448 r = amdgpu_cs_bo_validate(p, bo);
449 } while (r == -ENOMEM && amdgpu_cs_try_evict(p, bo));
450 if (r)
451 return r;
452
453 if (bo->shadow)
454 r = amdgpu_cs_bo_validate(p, bo);
455
456 return r;
457}
458
442static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, 459static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,
443 struct list_head *validated) 460 struct list_head *validated)
444{ 461{
@@ -466,18 +483,10 @@ static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,
466 if (p->evictable == lobj) 483 if (p->evictable == lobj)
467 p->evictable = NULL; 484 p->evictable = NULL;
468 485
469 do { 486 r = amdgpu_cs_validate(p, bo);
470 r = amdgpu_cs_bo_validate(p, bo);
471 } while (r == -ENOMEM && amdgpu_cs_try_evict(p, lobj));
472 if (r) 487 if (r)
473 return r; 488 return r;
474 489
475 if (bo->shadow) {
476 r = amdgpu_cs_bo_validate(p, bo);
477 if (r)
478 return r;
479 }
480
481 if (binding_userptr) { 490 if (binding_userptr) {
482 drm_free_large(lobj->user_pages); 491 drm_free_large(lobj->user_pages);
483 lobj->user_pages = NULL; 492 lobj->user_pages = NULL;
@@ -595,14 +604,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
595 list_splice(&need_pages, &p->validated); 604 list_splice(&need_pages, &p->validated);
596 } 605 }
597 606
598 amdgpu_vm_get_pt_bos(p->adev, &fpriv->vm, &duplicates);
599
600 p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); 607 p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev);
601 p->bytes_moved = 0; 608 p->bytes_moved = 0;
602 p->evictable = list_last_entry(&p->validated, 609 p->evictable = list_last_entry(&p->validated,
603 struct amdgpu_bo_list_entry, 610 struct amdgpu_bo_list_entry,
604 tv.head); 611 tv.head);
605 612
613 r = amdgpu_vm_validate_pt_bos(p->adev, &fpriv->vm,
614 amdgpu_cs_validate, p);
615 if (r) {
616 DRM_ERROR("amdgpu_vm_validate_pt_bos() failed.\n");
617 goto error_validate;
618 }
619
606 r = amdgpu_cs_list_validate(p, &duplicates); 620 r = amdgpu_cs_list_validate(p, &duplicates);
607 if (r) { 621 if (r) {
608 DRM_ERROR("amdgpu_cs_list_validate(duplicates) failed.\n"); 622 DRM_ERROR("amdgpu_cs_list_validate(duplicates) failed.\n");