From fdf43f915203dd239e745eb8fe53d31eabc8034f Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Mon, 7 Apr 2025 17:31:28 -0700 Subject: [PATCH] panfrost: add core mask driconf options These options are equivalent to the corresponding panvk options. Signed-off-by: Benjamin Lee Reviewed-by: Boris Brezillon Part-of: --- .../drivers/panfrost/driinfo_panfrost.h | 5 +++ src/gallium/drivers/panfrost/pan_csf.c | 9 +++--- src/gallium/drivers/panfrost/pan_screen.c | 31 +++++++++++++++++++ src/gallium/drivers/panfrost/pan_screen.h | 2 ++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/panfrost/driinfo_panfrost.h b/src/gallium/drivers/panfrost/driinfo_panfrost.h index a39dd06006e..0d7c32b8aac 100644 --- a/src/gallium/drivers/panfrost/driinfo_panfrost.h +++ b/src/gallium/drivers/panfrost/driinfo_panfrost.h @@ -10,3 +10,8 @@ DRI_CONF_SECTION_PERFORMANCE */ DRI_CONF_OPT_I(pan_csf_max_chunks, 64, 1, 65535, "CSF Tiler Max Chunks") DRI_CONF_SECTION_END + +DRI_CONF_SECTION_MISCELLANEOUS + DRI_CONF_PAN_COMPUTE_CORE_MASK(~0ull) + DRI_CONF_PAN_FRAGMENT_CORE_MASK(~0ull) +DRI_CONF_SECTION_END diff --git a/src/gallium/drivers/panfrost/pan_csf.c b/src/gallium/drivers/panfrost/pan_csf.c index 2058134b840..0091eba77e6 100644 --- a/src/gallium/drivers/panfrost/pan_csf.c +++ b/src/gallium/drivers/panfrost/pan_csf.c @@ -1401,6 +1401,7 @@ get_panthor_group_priority(struct panfrost_context *ctx) int GENX(csf_init_context)(struct panfrost_context *ctx) { + struct panfrost_screen *screen = pan_screen(ctx->base.screen); struct panfrost_device *dev = pan_device(ctx->base.screen); struct drm_panthor_queue_create qc[] = {{ .priority = 1, @@ -1408,11 +1409,11 @@ GENX(csf_init_context)(struct panfrost_context *ctx) }}; struct drm_panthor_group_create gc = { - .compute_core_mask = dev->kmod.props.shader_present, - .fragment_core_mask = dev->kmod.props.shader_present, + .compute_core_mask = screen->compute_core_mask, + .fragment_core_mask = screen->fragment_core_mask, .tiler_core_mask = 1, - .max_compute_cores = util_bitcount64(dev->kmod.props.shader_present), - .max_fragment_cores = util_bitcount64(dev->kmod.props.shader_present), + .max_compute_cores = util_bitcount64(screen->compute_core_mask), + .max_fragment_cores = util_bitcount64(screen->fragment_core_mask), .max_tiler_cores = 1, .priority = get_panthor_group_priority(ctx), .queues = DRM_PANTHOR_OBJ_ARRAY(ARRAY_SIZE(qc), qc), diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index b2c5d49db69..b7958a25cdd 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -780,6 +780,24 @@ panfrost_get_timestamp(struct pipe_screen *pscreen) return pan_gpu_time_to_ns(dev, pan_kmod_query_timestamp(dev->kmod.dev)); } +static int +get_core_mask(const struct panfrost_device *dev, + const struct pipe_screen_config *config, + const char *option_name, uint64_t *mask) +{ + uint64_t present = dev->kmod.props.shader_present; + *mask = driQueryOptionu64(config->options, option_name) & present; + + if (!*mask) { + debug_printf("panfrost: None of the cores specified in %s are present. " + "Available shader cores are 0x%" PRIx64 ".\n", + option_name, present); + return -1; + } + + return 0; +} + struct pipe_screen * panfrost_create_screen(int fd, const struct pipe_screen_config *config, struct renderonly *ro) @@ -836,6 +854,19 @@ panfrost_create_screen(int fd, const struct pipe_screen_config *config, screen->force_afrc_rate = rate; } + int result = get_core_mask(dev, config, "pan_compute_core_mask", + &screen->compute_core_mask); + if (result) { + panfrost_destroy_screen(&(screen->base)); + return NULL; + } + result = get_core_mask(dev, config, "pan_fragment_core_mask", + &screen->fragment_core_mask); + if (result) { + panfrost_destroy_screen(&(screen->base)); + return NULL; + } + screen->csf_tiler_heap.chunk_size = driQueryOptioni(config->options, "pan_csf_chunk_size"); screen->csf_tiler_heap.initial_chunks = driQueryOptioni(config->options, diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h index c53338fffea..e8fe9b17f3d 100644 --- a/src/gallium/drivers/panfrost/pan_screen.h +++ b/src/gallium/drivers/panfrost/pan_screen.h @@ -129,6 +129,8 @@ struct panfrost_screen { unsigned max_afbc_packing_ratio; bool force_afbc_packing; int force_afrc_rate; + uint64_t compute_core_mask; + uint64_t fragment_core_mask; struct { unsigned chunk_size;