panfrost: Stub out panfrost_bo_cache_put
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 15:19:53 +0000 (08:19 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 23:12:56 +0000 (16:12 -0700)
..so we can intercept the BO free.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_bo_cache.c
src/gallium/drivers/panfrost/pan_drm.c
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_screen.h

index b64f9fe2fbac83554f38c7bfd1cc3990ce131191..3804592b41d683751c6ee2fe1e82a06637195ce4 100644 (file)
@@ -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;
+}
+
+
index 135eb4d829146c5da75e4ba26bae7e8c47b2560d..8ff761ab2bde9a14f27c7b1f0298c71d6d2af75d 100644 (file)
@@ -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);
index 5f6eaa42c98b737a555bfdeceeebffcbe304a6e8..e630f1b579a31dbcca60179a9c676e0759ee4c65 100644 (file)
@@ -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
index d34574f7a7550d9a5d6961a4777c1d558affebf7..b90d9febad206c00b7f366c2abea70a918878887 100644 (file)
@@ -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 */