diff options
| author | Chunming Zhou <David1.Zhou@amd.com> | 2016-08-04 16:51:18 +0800 | 
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2016-08-22 13:47:18 -0400 | 
| commit | 20f4eff1c8ba344d5c22234ac5611ff1489fbea6 (patch) | |
| tree | 5269d95537b47d5d33558888f9c66a2fb4f0fe13 /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |
| parent | e24db98529ab90387b4603ce580b04f7ad152e8a (diff) | |
drm/amdgpu: sync bo and shadow V3
Use shadow flag to judge which direction to sync.
V2:
Don't need bo pin, so remove it.
V3:
1. Split to two functions, one is backup_to_shadow, another is
restore_from_shadow.
2. Clean up previous shadow direction difinitions.
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@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.c | 64 | 
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 60acbd22174e..84990415a3dc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -445,6 +445,70 @@ int amdgpu_bo_create(struct amdgpu_device *adev,  	return r;  } +int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev, +			       struct amdgpu_ring *ring, +			       struct amdgpu_bo *bo, +			       struct reservation_object *resv, +			       struct fence **fence, +			       bool direct) + +{ +	struct amdgpu_bo *shadow = bo->shadow; +	uint64_t bo_addr, shadow_addr; +	int r; + +	if (!shadow) +		return -EINVAL; + +	bo_addr = amdgpu_bo_gpu_offset(bo); +	shadow_addr = amdgpu_bo_gpu_offset(bo->shadow); + +	r = reservation_object_reserve_shared(bo->tbo.resv); +	if (r) +		goto err; + +	r = amdgpu_copy_buffer(ring, bo_addr, shadow_addr, +			       amdgpu_bo_size(bo), resv, fence, +			       direct); +	if (!r) +		amdgpu_bo_fence(bo, *fence, true); + +err: +	return r; +} + +int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev, +				  struct amdgpu_ring *ring, +				  struct amdgpu_bo *bo, +				  struct reservation_object *resv, +				  struct fence **fence, +				  bool direct) + +{ +	struct amdgpu_bo *shadow = bo->shadow; +	uint64_t bo_addr, shadow_addr; +	int r; + +	if (!shadow) +		return -EINVAL; + +	bo_addr = amdgpu_bo_gpu_offset(bo); +	shadow_addr = amdgpu_bo_gpu_offset(bo->shadow); + +	r = reservation_object_reserve_shared(bo->tbo.resv); +	if (r) +		goto err; + +	r = amdgpu_copy_buffer(ring, shadow_addr, bo_addr, +			       amdgpu_bo_size(bo), resv, fence, +			       direct); +	if (!r) +		amdgpu_bo_fence(bo, *fence, true); + +err: +	return r; +} +  int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr)  {  	bool is_iomem;  | 
