Mesa (staging/21.0): panfrost: Fix major flaw in BO cache

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 21 03:56:26 UTC 2021


Module: Mesa
Branch: staging/21.0
Commit: a32fc0d25bde7aa80260edf85bfc9ef22f4e3b9c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a32fc0d25bde7aa80260edf85bfc9ef22f4e3b9c

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Thu May 13 17:24:31 2021 -0400

panfrost: Fix major flaw in BO cache

BOs in the cache are chronological, so we try oldest BOs first. That
means if we find the oldest BO is busy, likely every BO is busy, and we
should bail early. This dramatically reduces the useless cycles spent in
bo_wait.

I studied the BO cache of the following drivers, all of which handle
this correctly: iris, lima, etnaviv, freedreno, vc4, v3d, v3dv.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10794>
(cherry picked from commit 77d04989135233c7b276bca3912ab07a12d9f362)

---

 .pick_status.json         | 2 +-
 src/panfrost/lib/pan_bo.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index be893b0379a..016d337720c 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1399,7 +1399,7 @@
         "description": "panfrost: Fix major flaw in BO cache",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/panfrost/lib/pan_bo.c b/src/panfrost/lib/pan_bo.c
index 0852ac63c7c..9466b414e88 100644
--- a/src/panfrost/lib/pan_bo.c
+++ b/src/panfrost/lib/pan_bo.c
@@ -200,9 +200,11 @@ panfrost_bo_cache_fetch(struct panfrost_device *dev,
                 if (entry->size < size || entry->flags != flags)
                         continue;
 
+                /* If the oldest BO in the cache is busy, likely so is
+                 * everything newer, so bail. */
                 if (!panfrost_bo_wait(entry, dontwait ? 0 : INT64_MAX,
                                       PAN_BO_ACCESS_RW))
-                        continue;
+                        break;
 
                 struct drm_panfrost_madvise madv = {
                         .handle = entry->gem_handle,



More information about the mesa-commit mailing list