From 6bf80841a81abe2d8ac1658fc7b14923dad668f7 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Fri, 5 Apr 2024 14:15:10 +0200 Subject: [PATCH] panfrost: add tiler-heap driconfs We currently allocate 10 MB up-front for tiler heaps. That can sometimes be a lot, depending on the system. So let's add some DRIconf variables to allow tweaking these. Until we have incremental-rendering implemented, it's a bit risky to lower these too much. Be warned. Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/driinfo_panfrost.h | 8 ++++++++ src/gallium/drivers/panfrost/pan_csf.c | 13 ++++--------- src/gallium/drivers/panfrost/pan_screen.c | 7 +++++++ src/gallium/drivers/panfrost/pan_screen.h | 6 ++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/panfrost/driinfo_panfrost.h b/src/gallium/drivers/panfrost/driinfo_panfrost.h index 2c11602a95d..a39dd06006e 100644 --- a/src/gallium/drivers/panfrost/driinfo_panfrost.h +++ b/src/gallium/drivers/panfrost/driinfo_panfrost.h @@ -1,4 +1,12 @@ /* panfrost specific driconf options */ DRI_CONF_SECTION_PERFORMANCE DRI_CONF_OPT_B(pan_force_afbc_packing, false, "Use AFBC-P for textures") + + /* 2M chunks. */ + DRI_CONF_OPT_I(pan_csf_chunk_size, 2 * 1024 * 1024, 256 * 1024, 8 * 1024 * 1024, "CSF Tiler Chunk Size") + DRI_CONF_OPT_I(pan_csf_initial_chunks, 5, 1, 65535, "CSF Tiler Initial Chunks") + /* 64 x 2M = 128M, which matches the tiler_heap BO allocated in + * panfrost_open_device() for pre-v10 HW. + */ + DRI_CONF_OPT_I(pan_csf_max_chunks, 64, 1, 65535, "CSF Tiler Max Chunks") DRI_CONF_SECTION_END diff --git a/src/gallium/drivers/panfrost/pan_csf.c b/src/gallium/drivers/panfrost/pan_csf.c index a37c785542b..6333b0ed60c 100644 --- a/src/gallium/drivers/panfrost/pan_csf.c +++ b/src/gallium/drivers/panfrost/pan_csf.c @@ -974,14 +974,9 @@ GENX(csf_init_context)(struct panfrost_context *ctx) /* Get tiler heap */ struct drm_panthor_tiler_heap_create thc = { .vm_id = pan_kmod_vm_handle(dev->kmod.vm), - /* 2M chunks. */ - .chunk_size = 2 * 1024 * 1024, - .initial_chunk_count = 5, - - /* 64 x 2M = 128M, which matches the tiler_heap BO allocated in - * panfrost_open_device() for pre-v10 HW. - */ - .max_chunks = 64, + .chunk_size = pan_screen(ctx->base.screen)->csf_tiler_heap.chunk_size, + .initial_chunk_count = pan_screen(ctx->base.screen)->csf_tiler_heap.initial_chunks, + .max_chunks = pan_screen(ctx->base.screen)->csf_tiler_heap.max_chunks, .target_in_flight = 65535, }; ret = drmIoctl(panfrost_device_fd(dev), DRM_IOCTL_PANTHOR_TILER_HEAP_CREATE, @@ -994,7 +989,7 @@ GENX(csf_init_context)(struct panfrost_context *ctx) ctx->csf.heap.desc_bo = panfrost_bo_create(dev, pan_size(TILER_HEAP), 0, "Tiler Heap"); pan_pack(ctx->csf.heap.desc_bo->ptr.cpu, TILER_HEAP, heap) { - heap.size = 2 * 1024 * 1024; + heap.size = pan_screen(ctx->base.screen)->csf_tiler_heap.chunk_size; heap.base = thc.first_heap_chunk_gpu_va; heap.bottom = heap.base + 64; heap.top = heap.base + heap.size; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 23bd6de2627..7c5a8f186ac 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -861,6 +861,13 @@ panfrost_create_screen(int fd, const struct pipe_screen_config *config, screen->force_afbc_packing = driQueryOptionb(config->options, "pan_force_afbc_packing"); + screen->csf_tiler_heap.chunk_size = driQueryOptioni(config->options, + "pan_csf_chunk_size"); + screen->csf_tiler_heap.initial_chunks = driQueryOptioni(config->options, + "pan_csf_initial_chunks"); + screen->csf_tiler_heap.max_chunks = driQueryOptioni(config->options, + "pan_csf_max_chunks"); + dev->ro = ro; screen->base.destroy = panfrost_destroy_screen; diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h index 256872d532f..58bb6cbaed6 100644 --- a/src/gallium/drivers/panfrost/pan_screen.h +++ b/src/gallium/drivers/panfrost/pan_screen.h @@ -118,6 +118,12 @@ struct panfrost_screen { struct disk_cache *disk_cache; unsigned max_afbc_packing_ratio; bool force_afbc_packing; + + struct { + unsigned chunk_size; + unsigned initial_chunks; + unsigned max_chunks; + } csf_tiler_heap; }; static inline struct panfrost_screen *