From: jsg Date: Wed, 25 Jan 2023 01:46:56 +0000 (+0000) Subject: drm/amdgpu: fix amdgpu_job_free_resources v2 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=92fe9140c4a7edc29326cccd6a734cc749c02b9d;p=openbsd drm/amdgpu: fix amdgpu_job_free_resources v2 From Christian Koenig af4a3c274a92ee0545d65b9102b398fb75d7cc9a in linux-6.1.y/6.1.8 74ea8e78ab349514c9f4df0be1189d91267d750d in mainline linux --- diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_job.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_job.c index adac650cf54..3bf0e893c07 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_job.c +++ b/sys/dev/pci/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); }