From 77d04989135233c7b276bca3912ab07a12d9f362 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 13 May 2021 17:24:31 -0400 Subject: [PATCH] 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 Cc: mesa-stable Part-of: --- src/panfrost/lib/pan_bo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/panfrost/lib/pan_bo.c b/src/panfrost/lib/pan_bo.c index 291e6c347f5..ef24c35a6c5 100644 --- a/src/panfrost/lib/pan_bo.c +++ b/src/panfrost/lib/pan_bo.c @@ -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,