drm/amdgpu: move ib.fence to job.fence
authorMonk Liu <Monk.Liu@amd.com>
Thu, 17 Mar 2016 05:48:13 +0000 (13:48 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 17 Mar 2016 15:54:11 +0000 (11:54 -0400)
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c

index 0523f11d915a6c08e3a1dee591349626d1bfef1f..c28b23c707414a8897e64762b51695e4f53b5026 100644 (file)
@@ -762,7 +762,6 @@ struct amdgpu_ib {
        uint32_t                        length_dw;
        uint64_t                        gpu_addr;
        uint32_t                        *ptr;
-       struct fence                    *fence;
        struct amdgpu_user_fence        *user;
        struct amdgpu_vm                *vm;
        unsigned                        vm_id;
@@ -1240,6 +1239,7 @@ struct amdgpu_job {
        struct amdgpu_ring      *ring;
        struct amdgpu_sync      sync;
        struct amdgpu_ib        *ibs;
+       struct fence            *fence; /* the hw fence */
        uint32_t                num_ibs;
        void                    *owner;
        struct amdgpu_user_fence uf;
index 345cac9948be4778cea81ad38e1985be2567aa43..8443cea6821ad00cad2181d16ac450b8045223ec 100644 (file)
@@ -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)
 {
        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,
        struct amdgpu_ib *ib = &ibs[0];
        struct amdgpu_ctx *ctx, *old_ctx;
        struct amdgpu_vm *vm;
+       struct fence *hwf;
        unsigned i;
        int r = 0;
 
@@ -180,7 +180,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                        amdgpu_ring_emit_hdp_invalidate(ring);
        }
 
-       r = amdgpu_fence_emit(ring, &ib->fence);
+       r = amdgpu_fence_emit(ring, &hwf);
        if (r) {
                dev_err(adev->dev, "failed to emit fence (%d)\n", r);
                ring->current_ctx = old_ctx;
@@ -199,7 +199,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
        }
 
        if (f)
-               *f = fence_get(ib->fence);
+               *f = fence_get(hwf);
 
        amdgpu_ring_commit(ring);
        return 0;
index df2f66666f85e5f8915aefb40ca251cc0c68b7aa..063064c9351f4240082827d82e4de6d77eccfb5b 100644 (file)
@@ -72,8 +72,8 @@ void amdgpu_job_free(struct amdgpu_job *job)
        unsigned 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);
-       fence_put(job->ibs[job->num_ibs - 1].fence);
+               amdgpu_sa_bo_free(job->adev, &job->ibs[i].sa_bo, job->fence);
+       fence_put(job->fence);
 
        amdgpu_bo_unref(&job->uf.bo);
        amdgpu_sync_free(&job->sync);
@@ -157,6 +157,7 @@ static struct fence *amdgpu_job_run(struct amd_sched_job *sched_job)
        }
 
 err:
+       job->fence = fence;
        amdgpu_job_free(job);
        return fence;
 }
index 081ee0565f877b7a6d8a00f3d1bc94a6bb416dc2..c1a5810444174522193111d9a41ff26d6fc0eb16 100644 (file)
@@ -880,6 +880,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo,
 
        if (direct) {
                r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
+               job->fence = f;
                if (r)
                        goto err_free;
 
index 6d191fb40b38c308e2c1568cb91ca7c089182ca0..4bec0c108cea9887ed612b252fc6b990547f029a 100644 (file)
@@ -426,6 +426,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
                ib->ptr[i] = 0x0;
 
        r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
+       job->fence = f;
        if (r)
                goto err;
 
@@ -487,6 +488,7 @@ int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
 
        if (direct) {
                r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
+               job->fence = f;
                if (r)
                        goto err;
 
index 35cacc52e98411b07c3e9f16d595634090dfcd92..72543f1975609bf8210b367a3c02de9e41fb9854 100644 (file)
@@ -670,6 +670,7 @@ static int cik_sdma_ring_test_ib(struct amdgpu_ring *ring)
 err1:
        fence_put(f);
        amdgpu_ib_free(adev, &ib, NULL);
+       fence_put(f);
 err0:
        amdgpu_wb_free(adev, index);
        return r;
index 0b0689275b2684ad9b70ff5e027d1870449c6272..2fb43c8ada7c1da731979a20f4cf8fb40c71a20b 100644 (file)
@@ -2164,6 +2164,7 @@ static int gfx_v7_0_ring_test_ib(struct amdgpu_ring *ring)
 err2:
        fence_put(f);
        amdgpu_ib_free(adev, &ib, NULL);
+       fence_put(f);
 err1:
        amdgpu_gfx_scratch_free(adev, scratch);
        return r;
index 7075bf7fcd69fa534131e45fef6087e8b30c8815..cd388c2f519684a05dfd6971d8c584cbd6c12674 100644 (file)
@@ -733,6 +733,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring)
 err2:
        fence_put(f);
        amdgpu_ib_free(adev, &ib, NULL);
+       fence_put(f);
 err1:
        amdgpu_gfx_scratch_free(adev, scratch);
        return r;
@@ -1290,6 +1291,7 @@ static int gfx_v8_0_do_edc_gpr_workarounds(struct amdgpu_device *adev)
 fail:
        fence_put(f);
        amdgpu_ib_free(adev, &ib, NULL);
+       fence_put(f);
 
        return r;
 }
index 5f148bd2d8ef668930765d131c91aa46d12f7797..6e0a86a563f3e8d35e7bf907bdaaa845aca5d55c 100644 (file)
@@ -728,6 +728,7 @@ static int sdma_v2_4_ring_test_ib(struct amdgpu_ring *ring)
 err1:
        fence_put(f);
        amdgpu_ib_free(adev, &ib, NULL);
+       fence_put(f);
 err0:
        amdgpu_wb_free(adev, index);
        return r;
index 1d67bce5b3596b38314fd97890bc50da9671458c..8c8ca98dd1298af2a1e7b397eb8f9d964e4b81fe 100644 (file)
@@ -879,6 +879,7 @@ static int sdma_v3_0_ring_test_ib(struct amdgpu_ring *ring)
 err1:
        fence_put(f);
        amdgpu_ib_free(adev, &ib, NULL);
+       fence_put(f);
 err0:
        amdgpu_wb_free(adev, index);
        return r;