aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost/pan_drm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_drm.c')
-rw-r--r--src/gallium/drivers/panfrost/pan_drm.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
index 135eb4d8291..8ff761ab2bd 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -134,7 +134,7 @@ panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
}
void
-panfrost_drm_release_bo(struct panfrost_screen *screen, struct panfrost_bo *bo)
+panfrost_drm_release_bo(struct panfrost_screen *screen, struct panfrost_bo *bo, bool cacheable)
{
struct drm_gem_close gem_close = { .handle = bo->gem_handle };
int ret;
@@ -142,6 +142,18 @@ panfrost_drm_release_bo(struct panfrost_screen *screen, struct panfrost_bo *bo)
if (!bo)
return;
+ /* Rather than freeing the BO now, we'll cache the BO for later
+ * allocations if we're allowed to */
+
+ if (cacheable) {
+ bool cached = panfrost_bo_cache_put(screen, bo);
+
+ if (cached)
+ return;
+ }
+
+ /* Otherwise, if the BO wasn't cached, we'll legitimately free the BO */
+
panfrost_drm_munmap_bo(screen, bo);
ret = drmIoctl(screen->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);