Re: [PATCH 2/2] drm/sched: fix dropping the last fence ref

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Am 16.11.21 um 19:07 schrieb Rob Clark:
On Tue, Nov 16, 2021 at 8:37 AM Daniel Vetter <daniel@xxxxxxxx> wrote:
On Tue, Nov 16, 2021 at 10:25:19AM +0100, Christian König wrote:
We need to grab another ref before trying to add the fence to the sched
job and not after.

Signed-off-by: Christian König <christian.koenig@xxxxxxx>
Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx>

I wondered first why this goes boom, but then I realized that in some
cases add_dependency() drops the reference of the passed-in fence.

Please also add the Fixes: line like in the previous patch.
oh, I sent https://patchwork.freedesktop.org/patch/463329/ before I
saw this.. it already has the fixes tag, and IMO a better description,
so I think you can just pick that one instead

Yeah, agree. You also have the missing Fixes line already.

Going to add Daniels rb to your patch as well since it is technically the same.

Thanks,
Christian.


BR,
-R

Cheers, Daniel

---
  drivers/gpu/drm/scheduler/sched_main.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 94fe51b3caa2..400d201c3c28 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -704,12 +704,14 @@ 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;
  }
--
2.25.1

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux