Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: cleanup hw reference handling in the IB tests

Reference should be taken when we make the assignment, not anywhere else.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
22a77cf6 08086635

+7 -19
+1 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
··· 122 122 bool skip_preamble, need_ctx_switch; 123 123 unsigned patch_offset = ~0; 124 124 struct amdgpu_vm *vm; 125 - struct fence *hwf; 126 125 uint64_t ctx; 127 126 128 127 unsigned i; ··· 189 190 if (ring->funcs->emit_hdp_invalidate) 190 191 amdgpu_ring_emit_hdp_invalidate(ring); 191 192 192 - r = amdgpu_fence_emit(ring, &hwf); 193 + r = amdgpu_fence_emit(ring, f); 193 194 if (r) { 194 195 dev_err(adev->dev, "failed to emit fence (%d)\n", r); 195 196 if (job && job->vm_id) ··· 203 204 amdgpu_ring_emit_fence(ring, job->uf_addr, job->uf_sequence, 204 205 AMDGPU_FENCE_FLAG_64BIT); 205 206 } 206 - 207 - if (f) 208 - *f = fence_get(hwf); 209 207 210 208 if (patch_offset != ~0 && ring->funcs->patch_cond_exec) 211 209 amdgpu_ring_patch_cond_exec(ring, patch_offset);
+3 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
··· 172 172 trace_amdgpu_sched_run_job(job); 173 173 r = amdgpu_ib_schedule(job->ring, job->num_ibs, job->ibs, 174 174 job->sync.last_vm_update, job, &fence); 175 - if (r) { 175 + if (r) 176 176 DRM_ERROR("Error scheduling IBs (%d)\n", r); 177 - goto err; 178 - } 179 177 180 - err: 181 178 /* if gpu reset, hw fence will be replaced here */ 182 179 fence_put(job->fence); 183 - job->fence = fence; 180 + job->fence = fence_get(fence); 181 + amdgpu_job_free_resources(job); 184 182 return fence; 185 183 } 186 184
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
··· 968 968 969 969 if (direct) { 970 970 r = amdgpu_ib_schedule(ring, 1, ib, NULL, NULL, &f); 971 - job->fence = f; 971 + job->fence = fence_get(f); 972 972 if (r) 973 973 goto err_free; 974 974
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
··· 432 432 ib->ptr[i] = 0x0; 433 433 434 434 r = amdgpu_ib_schedule(ring, 1, ib, NULL, NULL, &f); 435 - job->fence = f; 435 + job->fence = fence_get(f); 436 436 if (r) 437 437 goto err; 438 438 ··· 494 494 495 495 if (direct) { 496 496 r = amdgpu_ib_schedule(ring, 1, ib, NULL, NULL, &f); 497 - job->fence = f; 497 + job->fence = fence_get(f); 498 498 if (r) 499 499 goto err; 500 500
-1
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
··· 675 675 } 676 676 677 677 err1: 678 - fence_put(f); 679 678 amdgpu_ib_free(adev, &ib, NULL); 680 679 fence_put(f); 681 680 err0:
-1
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
··· 2158 2158 } 2159 2159 2160 2160 err2: 2161 - fence_put(f); 2162 2161 amdgpu_ib_free(adev, &ib, NULL); 2163 2162 fence_put(f); 2164 2163 err1:
-2
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
··· 829 829 r = -EINVAL; 830 830 } 831 831 err2: 832 - fence_put(f); 833 832 amdgpu_ib_free(adev, &ib, NULL); 834 833 fence_put(f); 835 834 err1: ··· 1718 1719 RREG32(sec_ded_counter_registers[i]); 1719 1720 1720 1721 fail: 1721 - fence_put(f); 1722 1722 amdgpu_ib_free(adev, &ib, NULL); 1723 1723 fence_put(f); 1724 1724
-1
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
··· 729 729 } 730 730 731 731 err1: 732 - fence_put(f); 733 732 amdgpu_ib_free(adev, &ib, NULL); 734 733 fence_put(f); 735 734 err0:
-1
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
··· 958 958 r = -EINVAL; 959 959 } 960 960 err1: 961 - fence_put(f); 962 961 amdgpu_ib_free(adev, &ib, NULL); 963 962 fence_put(f); 964 963 err0: