[Mesa-dev] [PATCH 09/11] panfrost: Check GPU version before loading

Alyssa Rosenzweig alyssa.rosenzweig at collabora.com
Wed Jul 10 13:24:36 UTC 2019


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 <alyssa.rosenzweig at collabora.com>
---
 src/gallium/drivers/panfrost/pan_context.c |  7 ++----
 src/gallium/drivers/panfrost/pan_screen.c  | 25 ++++++++++++++++++++++
 src/gallium/drivers/panfrost/pan_screen.h  |  1 +
 3 files changed, 28 insertions(+), 5 deletions(-)

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;
 
-- 
2.20.1



More information about the mesa-dev mailing list