Mesa (staging/21.2): freedreno/drm: Move pipe unref after fence removal

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 11 16:26:39 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: 7dcced8e7400d631bb22e62701c0fe7d8d9e3dd2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7dcced8e7400d631bb22e62701c0fe7d8d9e3dd2

Author: Rob Clark <robdclark at chromium.org>
Date:   Thu Oct  7 16:59:53 2021 -0700

freedreno/drm: Move pipe unref after fence removal

Dropping the final pipe ref could in turn drop the final ref to one
of a couple other bo's, which in turn could indirectly recurse back
into cleanup_fences() on the same bo, resulting in a double decrement
of bo->nr_fences and underflow to a large positive #.  This happens
because free'ing a bo back to the bo cache periodically calls
fd_bo_cache_cleanup() and any bo's that have not been re-used can
be really free'd, which in turn calls cleanup_fences().

Fixes: 7dabd624649 ("freedreno/drm: Userspace fences")
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13263>
(cherry picked from commit faed3d4dfe37b9ca0afb10a63854a1c9fa05bc4f)

---

 .pick_status.json                | 2 +-
 src/freedreno/drm/freedreno_bo.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 65b18e397df..8f202ee34a3 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -508,7 +508,7 @@
         "description": "freedreno/drm: Move pipe unref after fence removal",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "7dabd62464982e545a094f22d9ca23a77730c536"
     },
diff --git a/src/freedreno/drm/freedreno_bo.c b/src/freedreno/drm/freedreno_bo.c
index 7be0c7839a0..2039377e5ca 100644
--- a/src/freedreno/drm/freedreno_bo.c
+++ b/src/freedreno/drm/freedreno_bo.c
@@ -315,7 +315,8 @@ cleanup_fences(struct fd_bo *bo, bool expired)
       if (expired && fd_fence_before(f->pipe->control->fence, f->fence))
          continue;
 
-      fd_pipe_del_locked(f->pipe);
+      struct fd_pipe *pipe = f->pipe;
+
       bo->nr_fences--;
 
       if (bo->nr_fences > 0) {
@@ -323,6 +324,8 @@ cleanup_fences(struct fd_bo *bo, bool expired)
          bo->fences[i] = bo->fences[bo->nr_fences];
          i--;
       }
+
+      fd_pipe_del_locked(pipe);
    }
 }
 



More information about the mesa-commit mailing list