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@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10794>
(cherry picked from commit 77d0498913)
This commit is contained in:
Alyssa Rosenzweig 2021-05-13 17:24:31 -04:00 committed by Eric Engestrom
parent d87dc12a41
commit 914f4e943b
2 changed files with 4 additions and 2 deletions

View file

@ -13,7 +13,7 @@
"description": "panfrost: Fix major flaw in BO cache",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": null
},

View file

@ -201,9 +201,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,