aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorRoger.He <Hongbo.He@amd.com>2017-04-21 01:08:43 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-04-28 17:33:08 -0400
commit82521316395a37a2ec1d7e396c055f3c7de9d93b (patch)
tree45fa90db68afefba7d11671ee969e13eea354cc8 /drivers/gpu/drm/amd
parent4a9ed1009b8b01409bdda899c0ff0d7fd2c6d094 (diff)
drm/amdgpu: validate shadow before restoring from it
Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Roger.He <Hongbo.He@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_device.c12
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c21
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.h1
3 files changed, 34 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 234d90a12482..3c1754df4c40 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2429,6 +2429,18 @@ static int amdgpu_recover_vram_from_shadow(struct amdgpu_device *adev,
2429 domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); 2429 domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
2430 /* if bo has been evicted, then no need to recover */ 2430 /* if bo has been evicted, then no need to recover */
2431 if (domain == AMDGPU_GEM_DOMAIN_VRAM) { 2431 if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
2432 r = amdgpu_bo_validate(bo->shadow);
2433 if (r) {
2434 DRM_ERROR("bo validate failed!\n");
2435 goto err;
2436 }
2437
2438 r = amdgpu_ttm_bind(&bo->shadow->tbo, &bo->shadow->tbo.mem);
2439 if (r) {
2440 DRM_ERROR("%p bind failed\n", bo->shadow);
2441 goto err;
2442 }
2443
2432 r = amdgpu_bo_restore_from_shadow(adev, ring, bo, 2444 r = amdgpu_bo_restore_from_shadow(adev, ring, bo,
2433 NULL, fence, true); 2445 NULL, fence, true);
2434 if (r) { 2446 if (r) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 60de77b153b7..365883d7948d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -543,6 +543,27 @@ err:
543 return r; 543 return r;
544} 544}
545 545
546int amdgpu_bo_validate(struct amdgpu_bo *bo)
547{
548 uint32_t domain;
549 int r;
550
551 if (bo->pin_count)
552 return 0;
553
554 domain = bo->prefered_domains;
555
556retry:
557 amdgpu_ttm_placement_from_domain(bo, domain);
558 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
559 if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) {
560 domain = bo->allowed_domains;
561 goto retry;
562 }
563
564 return r;
565}
566
546int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev, 567int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,
547 struct amdgpu_ring *ring, 568 struct amdgpu_ring *ring,
548 struct amdgpu_bo *bo, 569 struct amdgpu_bo *bo,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 15a723adca76..382485115b06 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -175,6 +175,7 @@ int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev,
175 struct amdgpu_bo *bo, 175 struct amdgpu_bo *bo,
176 struct reservation_object *resv, 176 struct reservation_object *resv,
177 struct dma_fence **fence, bool direct); 177 struct dma_fence **fence, bool direct);
178int amdgpu_bo_validate(struct amdgpu_bo *bo);
178int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev, 179int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,
179 struct amdgpu_ring *ring, 180 struct amdgpu_ring *ring,
180 struct amdgpu_bo *bo, 181 struct amdgpu_bo *bo,