[PATCH 7/8] drm/amdgpu: implement recovery vram bo from shadow

Chunming Zhou David1.Zhou at amd.com
Wed Aug 17 06:05:18 UTC 2016


It will be used by gpu reset to recover vram bo.

Change-Id: Id3d954a05438c667f6ebdc4a05365e7c244ecf40
Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 35 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  4 ++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 5b536a7..c784d03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -491,6 +491,41 @@ err:
 	return r;
 }
 
+int amdgpu_bo_recover_vram_from_shadow(struct amdgpu_device *adev,
+				       struct amdgpu_ring *ring,
+				       struct amdgpu_bo *bo,
+				       struct fence **fence)
+{
+	struct fence *f;
+	uint32_t domain;
+	int r;
+
+       if (!bo->shadow)
+               return 0;
+
+       r = amdgpu_bo_reserve(bo, false);
+       if (r)
+               return r;
+       domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
+       /* if bo has been evicted, then no need to recover */
+       if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
+               bo->backup_shadow = AMDGPU_BO_SHADOW_TO_PARENT;
+               r = amdgpu_bo_backup_shadow(adev, ring, bo,
+                                           NULL, &f, true);
+               if (r) {
+                       DRM_ERROR("recover page table failed!\n");
+                       goto err;
+               }
+               if (fence) {
+                       fence_put(*fence);
+                       *fence = fence_get(f);
+               }
+       }
+err:
+       amdgpu_bo_unreserve(bo);
+       return r;
+}
+
 int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr)
 {
 	bool is_iomem;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index bb076d0..e8aef72 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -160,6 +160,10 @@ int amdgpu_bo_backup_shadow(struct amdgpu_device *adev,
 			    struct amdgpu_bo *bo,
 			    struct reservation_object *resv,
 			    struct fence **fence, bool direct);
+int amdgpu_bo_recover_vram_from_shadow(struct amdgpu_device *adev,
+				       struct amdgpu_ring *ring,
+				       struct amdgpu_bo *bo,
+				       struct fence **fence);
 
 /*
  * sub allocation
-- 
1.9.1



More information about the amd-gfx mailing list