panfrost: Delay resource mmaps
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 12 Jul 2019 22:50:58 +0000 (15:50 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 15:03:34 +0000 (08:03 -0700)
We use the new PAN_ALLOCATE_DELAY_MMAP flag to only map resources
on-demand, which should avoid mapping FBOs.

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

index dbf95a25232b28f607fdebe4049d9beff5cf98ad..c64117ce014ad35da0c23c52870207c463aa4afe 100644 (file)
@@ -38,7 +38,7 @@
 #include "pan_util.h"
 #include "pandecode/decode.h"
 
-static void
+void
 panfrost_drm_mmap_bo(struct panfrost_screen *screen, struct panfrost_bo *bo)
 {
         struct drm_panfrost_mmap_bo mmap_bo = { .handle = bo->gem_handle };
@@ -112,7 +112,7 @@ panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
          * never map since we don't care about their contents; they're purely
          * for GPU-internal use. */
 
-        if (!(flags & PAN_ALLOCATE_INVISIBLE))
+        if (!(flags & (PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_DELAY_MMAP)))
                 panfrost_drm_mmap_bo(screen, bo);
 
         pipe_reference_init(&bo->reference, 1);
index 4c794798d3275a743ca13a2c4c5fdec0bd4fa2f2..cdff805ab13274d303956d1b06f12d4c7e616f4e 100644 (file)
@@ -390,7 +390,10 @@ panfrost_resource_create_bo(struct panfrost_screen *screen, struct panfrost_reso
         size_t bo_size;
 
         panfrost_setup_slices(pres, &bo_size);
-        pres->bo = panfrost_drm_create_bo(screen, bo_size, 0);
+
+        /* We create a BO immediately but don't bother mapping, since we don't
+         * care to map e.g. FBOs which the CPU probably won't touch */
+        pres->bo = panfrost_drm_create_bo(screen, bo_size, PAN_ALLOCATE_DELAY_MMAP);
 }
 
 static struct pipe_resource *
@@ -483,6 +486,13 @@ panfrost_transfer_map(struct pipe_context *pctx,
 
         *out_transfer = &transfer->base;
 
+        /* If we haven't already mmaped, now's the time */
+
+        if (!bo->cpu) {
+                struct panfrost_screen *screen = pan_screen(pctx->screen);
+                panfrost_drm_mmap_bo(screen, bo);
+        }
+
         /* Check if we're bound for rendering and this is a read pixels. If so,
          * we need to flush */
 
index 026a23b4541f5fd2bc0fde4e0979bcab2b9719d3..8a01baabaf4691a0288864fd5ea7bc05efd05b8e 100644 (file)
@@ -135,6 +135,8 @@ struct panfrost_bo *
 panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
                        uint32_t flags);
 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);
 struct panfrost_bo *
 panfrost_drm_import_bo(struct panfrost_screen *screen, int fd);