diff options
author | Chunming Zhou <David1.Zhou@amd.com> | 2016-08-04 04:51:18 -0400 |
---|---|---|
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, | |||
445 | return r; | 445 | return r; |
446 | } | 446 | } |
447 | 447 | ||
448 | int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev, | ||
449 | struct amdgpu_ring *ring, | ||
450 | struct amdgpu_bo *bo, | ||
451 | struct reservation_object *resv, | ||
452 | struct fence **fence, | ||
453 | bool direct) | ||
454 | |||
455 | { | ||
456 | struct amdgpu_bo *shadow = bo->shadow; | ||
457 | uint64_t bo_addr, shadow_addr; | ||
458 | int r; | ||
459 | |||
460 | if (!shadow) | ||
461 | return -EINVAL; | ||
462 | |||
463 | bo_addr = amdgpu_bo_gpu_offset(bo); | ||
464 | shadow_addr = amdgpu_bo_gpu_offset(bo->shadow); | ||
465 | |||
466 | r = reservation_object_reserve_shared(bo->tbo.resv); | ||
467 | if (r) | ||
468 | goto err; | ||
469 | |||
470 | r = amdgpu_copy_buffer(ring, bo_addr, shadow_addr, | ||
471 | amdgpu_bo_size(bo), resv, fence, | ||
472 | direct); | ||
473 | if (!r) | ||
474 | amdgpu_bo_fence(bo, *fence, true); | ||
475 | |||
476 | err: | ||
477 | return r; | ||
478 | } | ||
479 | |||
480 | int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev, | ||
481 | struct amdgpu_ring *ring, | ||
482 | struct amdgpu_bo *bo, | ||
483 | struct reservation_object *resv, | ||
484 | struct fence **fence, | ||
485 | bool direct) | ||
486 | |||
487 | { | ||
488 | struct amdgpu_bo *shadow = bo->shadow; | ||
489 | uint64_t bo_addr, shadow_addr; | ||
490 | int r; | ||
491 | |||
492 | if (!shadow) | ||
493 | return -EINVAL; | ||
494 | |||
495 | bo_addr = amdgpu_bo_gpu_offset(bo); | ||
496 | shadow_addr = amdgpu_bo_gpu_offset(bo->shadow); | ||
497 | |||
498 | r = reservation_object_reserve_shared(bo->tbo.resv); | ||
499 | if (r) | ||
500 | goto err; | ||
501 | |||
502 | r = amdgpu_copy_buffer(ring, shadow_addr, bo_addr, | ||
503 | amdgpu_bo_size(bo), resv, fence, | ||
504 | direct); | ||
505 | if (!r) | ||
506 | amdgpu_bo_fence(bo, *fence, true); | ||
507 | |||
508 | err: | ||
509 | return r; | ||
510 | } | ||
511 | |||
448 | int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr) | 512 | int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr) |
449 | { | 513 | { |
450 | bool is_iomem; | 514 | bool is_iomem; |