[PATCH 07/10] drm/amdgpu: implement gart recovery

Chunming Zhou David1.Zhou at amd.com
Tue Aug 2 08:00:37 UTC 2016


recover gart bo from its shadow bo.

Change-Id: Idbb91d62b1c3cf73f7d90b5f2c650f2690e5a42b
Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 2985578d..3ee01fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -667,6 +667,7 @@ void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset,
 int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset,
 		     int pages, struct page **pagelist,
 		     dma_addr_t *dma_addr, uint32_t flags);
+int amdgpu_gart_table_recover_from_shadow(struct amdgpu_device *adev);
 
 /*
  * GPU MC structures, functions & helpers
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index b306684..baeaee2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -135,6 +135,37 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
 	return 0;
 }
 
+int amdgpu_gart_table_recover_from_shadow(struct amdgpu_device *adev)
+{
+	struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
+	struct fence *fence;
+	int r;
+
+	if (!amdgpu_vm_need_backup(adev))
+		return 0;
+	/* bo and shadow use same resv, so reserve one time */
+	r = amdgpu_bo_reserve(adev->gart.robj, false);
+	if (unlikely(r != 0))
+		return r;
+
+	r = amdgpu_bo_recover_bo_from_shadow(adev, ring,
+					     &adev->gart.recover_entity,
+					     adev->gart.robj,
+					     NULL, &fence);
+	amdgpu_bo_unreserve(adev->gart.robj);
+	if (r) {
+		DRM_ERROR("recover page table failed!\n");
+		goto err;
+	}
+
+	if (fence)
+		r = fence_wait(fence, false);
+	fence_put(fence);
+
+err:
+	return r;
+}
+
 /**
  * amdgpu_gart_table_vram_pin - pin gart page table in vram
  *
-- 
1.9.1



More information about the amd-gfx mailing list