]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/scheduler: fix drm_sched_job_add_implicit_dependencies harder
authorRob Clark <robdclark@chromium.org>
Tue, 16 Nov 2021 15:55:45 +0000 (07:55 -0800)
committerChristian König <christian.koenig@amd.com>
Wed, 17 Nov 2021 07:21:03 +0000 (08:21 +0100)
drm_sched_job_add_dependency() could drop the last ref, so we need to do
the dma_fence_get() first.

Cc: Christian König <christian.koenig@amd.com>
Fixes: 24545c6450ba ("drm/scheduler: use new iterator in drm_sched_job_add_implicit_dependencies v2")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20211116155545.473311-1-robdclark@gmail.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Christian König <christian.koenig@amd.com>
Tested-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Christian König <christian.koenig@amd.com>
drivers/gpu/drm/scheduler/sched_main.c

index 94fe51b3caa20a0b30b0e034d0b65095673989a9..f91fb31ab7a7c77e90631216d3b10de5cd92e5d8 100644 (file)
@@ -704,12 +704,13 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job,
        int ret;
 
        dma_resv_for_each_fence(&cursor, obj->resv, write, fence) {
-               ret = drm_sched_job_add_dependency(job, fence);
-               if (ret)
-                       return ret;
-
                /* Make sure to grab an additional ref on the added fence */
                dma_fence_get(fence);
+               ret = drm_sched_job_add_dependency(job, fence);
+               if (ret) {
+                       dma_fence_put(fence);
+                       return ret;
+               }
        }
        return 0;
 }