From: Alyssa Rosenzweig Date: Mon, 8 Jul 2019 16:14:59 +0000 (-0700) Subject: panfrost: Check GPU version before loading X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2f7145a6dee82779f5cd2183ed42f086c25aaf18;p=mesa.git panfrost: Check GPU version before loading Panfrost is known to only work on a select few CPU/GPU combinations at the moment (tested system-on-chips: RK3288, RK3399, and S912). Whitelist the combinations known to work and refuse to load on others where nothing works yet to avoid user confusion. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Tomeu Vizoso --- diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 69d877277be..29e36d02f8b 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -2675,12 +2675,9 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags) struct panfrost_screen *pscreen = pan_screen(screen); memset(ctx, 0, sizeof(*ctx)); struct pipe_context *gallium = (struct pipe_context *) ctx; - unsigned gpu_id; - gpu_id = panfrost_drm_query_gpu_version(pscreen); - - ctx->is_t6xx = gpu_id <= 0x0750; /* For now, this flag means T760 or less */ - ctx->require_sfbd = gpu_id < 0x0750; /* T760 is the first to support MFBD */ + ctx->is_t6xx = pscreen->gpu_id <= 0x0750; /* For now, this flag means T760 or less */ + ctx->require_sfbd = pscreen->gpu_id < 0x0750; /* T760 is the first to support MFBD */ gallium->screen = screen; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 6590359a53f..1aa0debb907 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -487,6 +487,31 @@ panfrost_create_screen(int fd, struct renderonly *ro) screen->fd = fd; + screen->gpu_id = panfrost_drm_query_gpu_version(screen); + + /* Check if we're loading against a supported GPU model + * paired with a supported CPU (differences from + * armhf/aarch64 break models on incompatible CPUs at the + * moment -- this is a TODO). In other words, we whitelist + * RK3288, RK3399, and S912, which are verified to work. */ + + switch (screen->gpu_id) { +#ifdef __LP64__ + case 0x820: /* T820 */ + case 0x860: /* T860 */ + break; +#else + case 0x750: /* T760 */ + break; +#endif + + default: + /* Fail to load against untested models */ + debug_printf("panfrost: Unsupported model %X", + screen->gpu_id); + return NULL; + } + if (pan_debug & PAN_DBG_TRACE) pandecode_initialize(); diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h index 9bcea611428..ddb89efe396 100644 --- a/src/gallium/drivers/panfrost/pan_screen.h +++ b/src/gallium/drivers/panfrost/pan_screen.h @@ -49,6 +49,7 @@ struct panfrost_screen; struct panfrost_screen { struct pipe_screen base; int fd; + unsigned gpu_id; struct renderonly *ro;