..so we can intercept the BO free.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
/* Stub */
return NULL;
}
+
+/* Tries to add a BO to the cache. Returns if it was
+ * successful */
+
+bool
+panfrost_bo_cache_put(
+ struct panfrost_screen *screen,
+ struct panfrost_bo *bo)
+{
+ /* Stub */
+ return false;
+}
+
+
}
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;
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);
/* When the reference count goes to zero, we need to cleanup */
if (pipe_reference(&bo->reference, NULL))
- panfrost_drm_release_bo(pan_screen(screen), bo);
+ panfrost_drm_release_bo(pan_screen(screen), bo, true);
}
static void
void
panfrost_drm_mmap_bo(struct panfrost_screen *screen, struct panfrost_bo *bo);
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 panfrost_bo *
panfrost_drm_import_bo(struct panfrost_screen *screen, int fd);
int
struct panfrost_screen *screen,
size_t size, uint32_t flags);
+bool
+panfrost_bo_cache_put(
+ struct panfrost_screen *screen,
+ struct panfrost_bo *bo);
+
#endif /* PAN_SCREEN_H */