Commit e24db985 authored by Chunming Zhou's avatar Chunming Zhou Committed by Alex Deucher

drm/amdgpu: add direct submision option for copy_buffer

Signed-off-by: default avatarChunming Zhou <David1.Zhou@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 3ad81f16
...@@ -39,7 +39,8 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size, ...@@ -39,7 +39,8 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size,
start_jiffies = jiffies; start_jiffies = jiffies;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring;
r = amdgpu_copy_buffer(ring, saddr, daddr, size, NULL, &fence); r = amdgpu_copy_buffer(ring, saddr, daddr, size, NULL, &fence,
false);
if (r) if (r)
goto exit_do_move; goto exit_do_move;
r = fence_wait(fence, false); r = fence_wait(fence, false);
......
...@@ -111,7 +111,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) ...@@ -111,7 +111,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
amdgpu_bo_kunmap(gtt_obj[i]); amdgpu_bo_kunmap(gtt_obj[i]);
r = amdgpu_copy_buffer(ring, gtt_addr, vram_addr, r = amdgpu_copy_buffer(ring, gtt_addr, vram_addr,
size, NULL, &fence); size, NULL, &fence, false);
if (r) { if (r) {
DRM_ERROR("Failed GTT->VRAM copy %d\n", i); DRM_ERROR("Failed GTT->VRAM copy %d\n", i);
...@@ -156,7 +156,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) ...@@ -156,7 +156,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
amdgpu_bo_kunmap(vram_obj); amdgpu_bo_kunmap(vram_obj);
r = amdgpu_copy_buffer(ring, vram_addr, gtt_addr, r = amdgpu_copy_buffer(ring, vram_addr, gtt_addr,
size, NULL, &fence); size, NULL, &fence, false);
if (r) { if (r) {
DRM_ERROR("Failed VRAM->GTT copy %d\n", i); DRM_ERROR("Failed VRAM->GTT copy %d\n", i);
......
...@@ -282,7 +282,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, ...@@ -282,7 +282,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
r = amdgpu_copy_buffer(ring, old_start, new_start, r = amdgpu_copy_buffer(ring, old_start, new_start,
new_mem->num_pages * PAGE_SIZE, /* bytes */ new_mem->num_pages * PAGE_SIZE, /* bytes */
bo->resv, &fence); bo->resv, &fence, false);
if (r) if (r)
return r; return r;
...@@ -1143,7 +1143,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, ...@@ -1143,7 +1143,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,
uint64_t dst_offset, uint64_t dst_offset,
uint32_t byte_count, uint32_t byte_count,
struct reservation_object *resv, struct reservation_object *resv,
struct fence **fence) struct fence **fence, bool direct_submit)
{ {
struct amdgpu_device *adev = ring->adev; struct amdgpu_device *adev = ring->adev;
struct amdgpu_job *job; struct amdgpu_job *job;
...@@ -1187,12 +1187,21 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, ...@@ -1187,12 +1187,21 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,
amdgpu_ring_pad_ib(ring, &job->ibs[0]); amdgpu_ring_pad_ib(ring, &job->ibs[0]);
WARN_ON(job->ibs[0].length_dw > num_dw); WARN_ON(job->ibs[0].length_dw > num_dw);
r = amdgpu_job_submit(job, ring, &adev->mman.entity, if (direct_submit) {
AMDGPU_FENCE_OWNER_UNDEFINED, fence); r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs,
if (r) NULL, NULL, fence);
goto error_free; job->fence = fence_get(*fence);
if (r)
DRM_ERROR("Error scheduling IBs (%d)\n", r);
amdgpu_job_free(job);
} else {
r = amdgpu_job_submit(job, ring, &adev->mman.entity,
AMDGPU_FENCE_OWNER_UNDEFINED, fence);
if (r)
goto error_free;
}
return 0; return r;
error_free: error_free:
amdgpu_job_free(job); amdgpu_job_free(job);
......
...@@ -68,7 +68,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, ...@@ -68,7 +68,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,
uint64_t dst_offset, uint64_t dst_offset,
uint32_t byte_count, uint32_t byte_count,
struct reservation_object *resv, struct reservation_object *resv,
struct fence **fence); struct fence **fence, bool direct_submit);
int amdgpu_fill_buffer(struct amdgpu_bo *bo, int amdgpu_fill_buffer(struct amdgpu_bo *bo,
uint32_t src_data, uint32_t src_data,
struct reservation_object *resv, struct reservation_object *resv,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment