aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2017-04-12 08:24:39 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-12-06 12:48:01 -0500
commit19be5570107108fba772bc2e3a1eb22ec32fb021 (patch)
tree86b971706ea8fce92b58cac4ea73e8799564a6ef /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
parent750a25037cac56afeb48ab807ce80fa2cd518b8d (diff)
drm/ttm: add operation ctx to ttm_bo_validate v2
Give moving a BO into place an operation context to work with. v2: rebased Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de> Tested-by: Michel Dänzer <michel.daenzer@amd.com> Acked-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 3233d5988f66..c2419bc6b3df 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -552,6 +552,7 @@ err:
552 552
553int amdgpu_bo_validate(struct amdgpu_bo *bo) 553int amdgpu_bo_validate(struct amdgpu_bo *bo)
554{ 554{
555 struct ttm_operation_ctx ctx = { false, false };
555 uint32_t domain; 556 uint32_t domain;
556 int r; 557 int r;
557 558
@@ -562,7 +563,7 @@ int amdgpu_bo_validate(struct amdgpu_bo *bo)
562 563
563retry: 564retry:
564 amdgpu_ttm_placement_from_domain(bo, domain); 565 amdgpu_ttm_placement_from_domain(bo, domain);
565 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 566 r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
566 if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { 567 if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) {
567 domain = bo->allowed_domains; 568 domain = bo->allowed_domains;
568 goto retry; 569 goto retry;
@@ -673,6 +674,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
673 u64 *gpu_addr) 674 u64 *gpu_addr)
674{ 675{
675 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 676 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
677 struct ttm_operation_ctx ctx = { false, false };
676 int r, i; 678 int r, i;
677 679
678 if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm)) 680 if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
@@ -723,7 +725,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
723 bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT; 725 bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
724 } 726 }
725 727
726 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 728 r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
727 if (unlikely(r)) { 729 if (unlikely(r)) {
728 dev_err(adev->dev, "%p pin failed\n", bo); 730 dev_err(adev->dev, "%p pin failed\n", bo);
729 goto error; 731 goto error;
@@ -760,6 +762,7 @@ int amdgpu_bo_pin(struct amdgpu_bo *bo, u32 domain, u64 *gpu_addr)
760int amdgpu_bo_unpin(struct amdgpu_bo *bo) 762int amdgpu_bo_unpin(struct amdgpu_bo *bo)
761{ 763{
762 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 764 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
765 struct ttm_operation_ctx ctx = { false, false };
763 int r, i; 766 int r, i;
764 767
765 if (!bo->pin_count) { 768 if (!bo->pin_count) {
@@ -773,7 +776,7 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
773 bo->placements[i].lpfn = 0; 776 bo->placements[i].lpfn = 0;
774 bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT; 777 bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
775 } 778 }
776 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 779 r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
777 if (unlikely(r)) { 780 if (unlikely(r)) {
778 dev_err(adev->dev, "%p validate failed for unpin\n", bo); 781 dev_err(adev->dev, "%p validate failed for unpin\n", bo);
779 goto error; 782 goto error;
@@ -945,6 +948,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
945int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) 948int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
946{ 949{
947 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); 950 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
951 struct ttm_operation_ctx ctx = { false, false };
948 struct amdgpu_bo *abo; 952 struct amdgpu_bo *abo;
949 unsigned long offset, size; 953 unsigned long offset, size;
950 int r; 954 int r;
@@ -978,7 +982,7 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
978 abo->placement.num_busy_placement = 1; 982 abo->placement.num_busy_placement = 1;
979 abo->placement.busy_placement = &abo->placements[1]; 983 abo->placement.busy_placement = &abo->placements[1];
980 984
981 r = ttm_bo_validate(bo, &abo->placement, false, false); 985 r = ttm_bo_validate(bo, &abo->placement, &ctx);
982 if (unlikely(r != 0)) 986 if (unlikely(r != 0))
983 return r; 987 return r;
984 988