From 2fdd6eb09e2140286444df46121d59d75dfa26bb Mon Sep 17 00:00:00 2001 From: "Eric R. Smith" Date: Thu, 4 Dec 2025 20:18:00 -0400 Subject: [PATCH] pan drm-shim: add a way to specify the GPU variant in PAN_GPU_ID This lets us compile shaders for different GPU variants on the PC. Reviewed-by: Christoph Pillmayer Part-of: --- src/panfrost/drm-shim/panfrost_noop.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/panfrost/drm-shim/panfrost_noop.c b/src/panfrost/drm-shim/panfrost_noop.c index 3c06efd6822..b1966855328 100644 --- a/src/panfrost/drm-shim/panfrost_noop.c +++ b/src/panfrost/drm-shim/panfrost_noop.c @@ -50,6 +50,23 @@ pan_get_gpu_id(void) return PAN_GPU_ID_DEFAULT; } +/* + * The gpu variant is specified as a hex value after the GPU id + * in PAN_GPU_ID, e.g. PAN_GPU_ID=ac04:4. + */ +static uint64_t +pan_get_gpu_variant(void) +{ + const char *override_version = os_get_option("PAN_GPU_ID"); + + if (override_version) { + const char *sep = strchr(override_version, ':'); + if (sep) + return strtol(sep+1, NULL, 16); + } + return 0; +} + static int pan_ioctl_noop(int fd, unsigned long request, void *arg) { @@ -170,6 +187,10 @@ panthor_ioctl_dev_query(int fd, unsigned long request, void *arg) gpu_info->gpu_id = pan_get_gpu_id() << 16; gpu_info->gpu_rev = 0; + /* for some reason the variant is in the bottom 8 bits of + * the core_features */ + gpu_info->core_features = pan_get_gpu_variant(); + /* Dumped from a G610 */ gpu_info->csf_id = 0x40a0412; gpu_info->l2_features = 0x7120306;