panfrost: Maintain a whitelist of supported GPU's

Submitted by Rohan Garg on June 24, 2019, 2:43 p.m.

Details

Message ID 20190624144352.5509-1-rohan.garg@collabora.com
State New
Headers show
Series "panfrost: Maintain a whitelist of supported GPU's" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Rohan Garg June 24, 2019, 2:43 p.m.
Maintain a list of panfrost supported GPU's and exit early when
running on a unsupported GPU.

Signed-off-by: Rohan Garg <rohan.garg@collabora.com>
---
 src/gallium/drivers/panfrost/pan_screen.c | 15 +++++++++++++++
 src/gallium/drivers/panfrost/pan_screen.h |  6 ++++++
 2 files changed, 21 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index dccb0143a53..a0c940d4c30 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -563,6 +563,8 @@  panfrost_screen_get_compiler_options(struct pipe_screen *pscreen,
 struct pipe_screen *
 panfrost_create_screen(int fd, struct renderonly *ro)
 {
+        unsigned gpu_id;
+        bool supported_gpu = false;
         struct panfrost_screen *screen = rzalloc(NULL, struct panfrost_screen);
 
 	pan_debug = debug_get_option_pan_debug();
@@ -581,6 +583,19 @@  panfrost_create_screen(int fd, struct renderonly *ro)
 
         screen->fd = fd;
 
+        gpu_id = panfrost_drm_query_gpu_version(screen);
+
+        for (int i = 0; i < ARRAY_SIZE(panfrost_supported_gpus); i++) {
+                if (panfrost_supported_gpus[i] == gpu_id)
+                        supported_gpu = true;
+        }
+
+        if (!supported_gpu) {
+                fprintf(stderr, "Unsupported GPU\n");
+                free(screen);
+                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 4907bd4395f..8c8915d0ad5 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -46,6 +46,12 @@  struct panfrost_screen;
 #define PAN_ALLOCATE_INVISIBLE (1 << 2)
 #define PAN_ALLOCATE_COHERENT_LOCAL (1 << 3)
 
+static const panfrost_supported_gpus[] = {
+        0x0750,
+        0x0820,
+        0x0860
+};
+
 struct panfrost_screen {
         struct pipe_screen base;
         int fd;

Comments