Commit 73cfa5f5 authored by Monk Liu's avatar Monk Liu Committed by Alex Deucher

drm/amdgpu: move ib.fence to job.fence

Signed-off-by: default avatarMonk Liu <Monk.Liu@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent cc55c45d
...@@ -762,7 +762,6 @@ struct amdgpu_ib { ...@@ -762,7 +762,6 @@ struct amdgpu_ib {
uint32_t length_dw; uint32_t length_dw;
uint64_t gpu_addr; uint64_t gpu_addr;
uint32_t *ptr; uint32_t *ptr;
struct fence *fence;
struct amdgpu_user_fence *user; struct amdgpu_user_fence *user;
struct amdgpu_vm *vm; struct amdgpu_vm *vm;
unsigned vm_id; unsigned vm_id;
...@@ -1240,6 +1239,7 @@ struct amdgpu_job { ...@@ -1240,6 +1239,7 @@ struct amdgpu_job {
struct amdgpu_ring *ring; struct amdgpu_ring *ring;
struct amdgpu_sync sync; struct amdgpu_sync sync;
struct amdgpu_ib *ibs; struct amdgpu_ib *ibs;
struct fence *fence; /* the hw fence */
uint32_t num_ibs; uint32_t num_ibs;
void *owner; void *owner;
struct amdgpu_user_fence uf; struct amdgpu_user_fence uf;
......
...@@ -92,7 +92,6 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, ...@@ -92,7 +92,6 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib, struct fence *f) void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib, struct fence *f)
{ {
amdgpu_sa_bo_free(adev, &ib->sa_bo, f); amdgpu_sa_bo_free(adev, &ib->sa_bo, f);
fence_put(ib->fence);
} }
/** /**
...@@ -124,6 +123,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, ...@@ -124,6 +123,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
struct amdgpu_ib *ib = &ibs[0]; struct amdgpu_ib *ib = &ibs[0];
struct amdgpu_ctx *ctx, *old_ctx; struct amdgpu_ctx *ctx, *old_ctx;
struct amdgpu_vm *vm; struct amdgpu_vm *vm;
struct fence *hwf;
unsigned i; unsigned i;
int r = 0; int r = 0;
...@@ -180,7 +180,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, ...@@ -180,7 +180,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
amdgpu_ring_emit_hdp_invalidate(ring); amdgpu_ring_emit_hdp_invalidate(ring);
} }
r = amdgpu_fence_emit(ring, &ib->fence); r = amdgpu_fence_emit(ring, &hwf);
if (r) { if (r) {
dev_err(adev->dev, "failed to emit fence (%d)\n", r); dev_err(adev->dev, "failed to emit fence (%d)\n", r);
ring->current_ctx = old_ctx; ring->current_ctx = old_ctx;
...@@ -199,7 +199,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, ...@@ -199,7 +199,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
} }
if (f) if (f)
*f = fence_get(ib->fence); *f = fence_get(hwf);
amdgpu_ring_commit(ring); amdgpu_ring_commit(ring);
return 0; return 0;
......
...@@ -72,8 +72,8 @@ void amdgpu_job_free(struct amdgpu_job *job) ...@@ -72,8 +72,8 @@ void amdgpu_job_free(struct amdgpu_job *job)
unsigned i; unsigned i;
for (i = 0; i < job->num_ibs; ++i) for (i = 0; i < job->num_ibs; ++i)
amdgpu_sa_bo_free(job->adev, &job->ibs[i].sa_bo, job->ibs[job->num_ibs - 1].fence); amdgpu_sa_bo_free(job->adev, &job->ibs[i].sa_bo, job->fence);
fence_put(job->ibs[job->num_ibs - 1].fence); fence_put(job->fence);
amdgpu_bo_unref(&job->uf.bo); amdgpu_bo_unref(&job->uf.bo);
amdgpu_sync_free(&job->sync); amdgpu_sync_free(&job->sync);
...@@ -157,6 +157,7 @@ static struct fence *amdgpu_job_run(struct amd_sched_job *sched_job) ...@@ -157,6 +157,7 @@ static struct fence *amdgpu_job_run(struct amd_sched_job *sched_job)
} }
err: err:
job->fence = fence;
amdgpu_job_free(job); amdgpu_job_free(job);
return fence; return fence;
} }
......
...@@ -880,6 +880,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo, ...@@ -880,6 +880,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,
if (direct) { if (direct) {
r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
job->fence = f;
if (r) if (r)
goto err_free; goto err_free;
......
...@@ -426,6 +426,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, ...@@ -426,6 +426,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
ib->ptr[i] = 0x0; ib->ptr[i] = 0x0;
r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
job->fence = f;
if (r) if (r)
goto err; goto err;
...@@ -487,6 +488,7 @@ int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, ...@@ -487,6 +488,7 @@ int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
if (direct) { if (direct) {
r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
job->fence = f;
if (r) if (r)
goto err; goto err;
......
...@@ -670,6 +670,7 @@ static int cik_sdma_ring_test_ib(struct amdgpu_ring *ring) ...@@ -670,6 +670,7 @@ static int cik_sdma_ring_test_ib(struct amdgpu_ring *ring)
err1: err1:
fence_put(f); fence_put(f);
amdgpu_ib_free(adev, &ib, NULL); amdgpu_ib_free(adev, &ib, NULL);
fence_put(f);
err0: err0:
amdgpu_wb_free(adev, index); amdgpu_wb_free(adev, index);
return r; return r;
......
...@@ -2164,6 +2164,7 @@ static int gfx_v7_0_ring_test_ib(struct amdgpu_ring *ring) ...@@ -2164,6 +2164,7 @@ static int gfx_v7_0_ring_test_ib(struct amdgpu_ring *ring)
err2: err2:
fence_put(f); fence_put(f);
amdgpu_ib_free(adev, &ib, NULL); amdgpu_ib_free(adev, &ib, NULL);
fence_put(f);
err1: err1:
amdgpu_gfx_scratch_free(adev, scratch); amdgpu_gfx_scratch_free(adev, scratch);
return r; return r;
......
...@@ -733,6 +733,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring) ...@@ -733,6 +733,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring)
err2: err2:
fence_put(f); fence_put(f);
amdgpu_ib_free(adev, &ib, NULL); amdgpu_ib_free(adev, &ib, NULL);
fence_put(f);
err1: err1:
amdgpu_gfx_scratch_free(adev, scratch); amdgpu_gfx_scratch_free(adev, scratch);
return r; return r;
...@@ -1290,6 +1291,7 @@ static int gfx_v8_0_do_edc_gpr_workarounds(struct amdgpu_device *adev) ...@@ -1290,6 +1291,7 @@ static int gfx_v8_0_do_edc_gpr_workarounds(struct amdgpu_device *adev)
fail: fail:
fence_put(f); fence_put(f);
amdgpu_ib_free(adev, &ib, NULL); amdgpu_ib_free(adev, &ib, NULL);
fence_put(f);
return r; return r;
} }
......
...@@ -728,6 +728,7 @@ static int sdma_v2_4_ring_test_ib(struct amdgpu_ring *ring) ...@@ -728,6 +728,7 @@ static int sdma_v2_4_ring_test_ib(struct amdgpu_ring *ring)
err1: err1:
fence_put(f); fence_put(f);
amdgpu_ib_free(adev, &ib, NULL); amdgpu_ib_free(adev, &ib, NULL);
fence_put(f);
err0: err0:
amdgpu_wb_free(adev, index); amdgpu_wb_free(adev, index);
return r; return r;
......
...@@ -879,6 +879,7 @@ static int sdma_v3_0_ring_test_ib(struct amdgpu_ring *ring) ...@@ -879,6 +879,7 @@ static int sdma_v3_0_ring_test_ib(struct amdgpu_ring *ring)
err1: err1:
fence_put(f); fence_put(f);
amdgpu_ib_free(adev, &ib, NULL); amdgpu_ib_free(adev, &ib, NULL);
fence_put(f);
err0: err0:
amdgpu_wb_free(adev, index); amdgpu_wb_free(adev, index);
return r; return r;
......
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