[PATCH 06/10] drm/amdgpu: make recover_bo_from_shadow be generic
Chunming Zhou
David1.Zhou at amd.com
Tue Aug 2 08:00:36 UTC 2016
Change-Id: I74758b9ca84058f3f2db5509822d8aad840d283e
Signed-off-by: Chunming Zhou <David1.Zhou at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 40 +++++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 6 ++++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 48 ++++--------------------------
3 files changed, 51 insertions(+), 43 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index c1111c9..1d0bdfb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -439,6 +439,46 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
return r;
}
+int amdgpu_bo_recover_bo_from_shadow(struct amdgpu_device *adev,
+ struct amdgpu_ring *ring,
+ struct amd_sched_entity *entity,
+ struct amdgpu_bo *bo,
+ struct reservation_object *resv,
+ struct fence **fence)
+
+{
+ int r;
+ uint64_t vram_addr, gtt_addr;
+
+ r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_VRAM, &vram_addr);
+ if (r) {
+ DRM_ERROR("Failed to pin bo object\n");
+ goto err1;
+ }
+ r = amdgpu_bo_pin(bo->shadow, AMDGPU_GEM_DOMAIN_GTT, >t_addr);
+ if (r) {
+ DRM_ERROR("Failed to pin bo shadow object\n");
+ goto err2;
+ }
+
+ r = reservation_object_reserve_shared(bo->tbo.resv);
+ if (r)
+ goto err3;
+
+ r = amdgpu_copy_buffer(ring, entity, gtt_addr,
+ vram_addr, amdgpu_bo_size(bo), resv, fence);
+ if (!r)
+ amdgpu_bo_fence(bo, *fence, true);
+
+err3:
+ amdgpu_bo_unpin(bo->shadow);
+err2:
+ amdgpu_bo_unpin(bo);
+err1:
+
+ 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 b994fd4..f35fd68 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -158,6 +158,12 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);
void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence,
bool shared);
u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo);
+int amdgpu_bo_recover_bo_from_shadow(struct amdgpu_device *adev,
+ struct amdgpu_ring *ring,
+ struct amd_sched_entity *entity,
+ struct amdgpu_bo *bo,
+ struct reservation_object *resv,
+ struct fence **fence);
/*
* sub allocation
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 01dd888..3eecddc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -713,46 +713,6 @@ error_free:
return r;
}
-static int amdgpu_vm_recover_bo_from_shadow(struct amdgpu_device *adev,
- struct amdgpu_vm *vm,
- struct amdgpu_bo *bo,
- struct amdgpu_bo *bo_shadow,
- struct reservation_object *resv,
- struct fence **fence)
-
-{
- int r;
- uint64_t vram_addr, gtt_addr;
-
- r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_VRAM, &vram_addr);
- if (r) {
- DRM_ERROR("Failed to pin bo object\n");
- goto err1;
- }
- r = amdgpu_bo_pin(bo_shadow, AMDGPU_GEM_DOMAIN_GTT, >t_addr);
- if (r) {
- DRM_ERROR("Failed to pin bo shadow object\n");
- goto err2;
- }
-
- r = reservation_object_reserve_shared(bo->tbo.resv);
- if (r)
- goto err3;
-
- r = amdgpu_copy_buffer(vm->ring, &vm->recover_entity, gtt_addr,
- vram_addr, amdgpu_bo_size(bo), resv, fence);
- if (!r)
- amdgpu_bo_fence(bo, *fence, true);
-
-err3:
- amdgpu_bo_unpin(bo_shadow);
-err2:
- amdgpu_bo_unpin(bo);
-err1:
-
- return r;
-}
-
int amdgpu_vm_recover_page_table_from_shadow(struct amdgpu_device *adev,
struct amdgpu_vm *vm)
{
@@ -767,8 +727,9 @@ int amdgpu_vm_recover_page_table_from_shadow(struct amdgpu_device *adev,
if (unlikely(r != 0))
return r;
- r = amdgpu_vm_recover_bo_from_shadow(adev, vm, vm->page_directory,
- vm->page_directory->shadow,
+ r = amdgpu_bo_recover_bo_from_shadow(adev, vm->ring,
+ &vm->recover_entity,
+ vm->page_directory,
NULL, &fence);
if (r) {
DRM_ERROR("recover page table failed!\n");
@@ -784,7 +745,8 @@ int amdgpu_vm_recover_page_table_from_shadow(struct amdgpu_device *adev,
if (!bo || !bo_shadow)
continue;
- r = amdgpu_vm_recover_bo_from_shadow(adev, vm, bo, bo_shadow,
+ r = amdgpu_bo_recover_bo_from_shadow(adev, vm->ring,
+ &vm->recover_entity, bo,
NULL, &fence);
if (r) {
DRM_ERROR("recover page table failed!\n");
--
1.9.1
More information about the amd-gfx
mailing list