From: Christian König Date: Thu, 12 Jan 2023 13:46:00 +0000 (+0100) Subject: drm/amdgpu: fix amdgpu_job_free_resources v2 X-Git-Tag: v6.1.8~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af4a3c274a92ee0545d65b9102b398fb75d7cc9a;p=platform%2Fkernel%2Flinux-starfive.git drm/amdgpu: fix amdgpu_job_free_resources v2 commit 74ea8e78ab349514c9f4df0be1189d91267d750d upstream. It can be that neither fence were initialized when we run out of UVD streams for example. v2: fix typo breaking compile Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2324 Signed-off-by: Christian König Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org # 6.1.x Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index adac650..3bf0e89 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -154,8 +154,14 @@ void amdgpu_job_free_resources(struct amdgpu_job *job) struct dma_fence *f; unsigned i; - /* use sched fence if available */ - f = job->base.s_fence ? &job->base.s_fence->finished : &job->hw_fence; + /* Check if any fences where initialized */ + if (job->base.s_fence && job->base.s_fence->finished.ops) + f = &job->base.s_fence->finished; + else if (job->hw_fence.ops) + f = &job->hw_fence; + else + f = NULL; + for (i = 0; i < job->num_ibs; ++i) amdgpu_ib_free(ring->adev, &job->ibs[i], f); }