aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-07-15 08:19:53 -0700
committerAlyssa Rosenzweig <[email protected]>2019-07-15 16:12:56 -0700
commit74ad5f89f82185bb2a2853d5ec1a59310627a435 (patch)
tree07c4adc85ceec23fd37483f78b89ed0cca005f6b
parentb5a28f61aef6f030e4cc1c8678c964ba8b81b51d (diff)
panfrost: Stub out panfrost_bo_cache_put
..so we can intercept the BO free. Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r--src/gallium/drivers/panfrost/pan_bo_cache.c14
-rw-r--r--src/gallium/drivers/panfrost/pan_drm.c14
-rw-r--r--src/gallium/drivers/panfrost/pan_resource.c2
-rw-r--r--src/gallium/drivers/panfrost/pan_screen.h7
4 files changed, 34 insertions, 3 deletions
diff --git a/src/gallium/drivers/panfrost/pan_bo_cache.c b/src/gallium/drivers/panfrost/pan_bo_cache.c
index b64f9fe2fba..3804592b41d 100644
--- a/src/gallium/drivers/panfrost/pan_bo_cache.c
+++ b/src/gallium/drivers/panfrost/pan_bo_cache.c
@@ -34,3 +34,17 @@ panfrost_bo_cache_fetch(
/* 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;
+}
+
+
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);
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 5f6eaa42c98..e630f1b579a 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -445,7 +445,7 @@ panfrost_bo_unreference(struct pipe_screen *screen, struct panfrost_bo *bo)
/* 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
diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
index d34574f7a75..b90d9febad2 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -137,7 +137,7 @@ panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
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
@@ -166,5 +166,10 @@ panfrost_bo_cache_fetch(
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 */