From f4ecc432bf7603b86935580785a3015fc92d1b15 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 21 Oct 2020 17:17:41 -0400 Subject: [PATCH] panfrost: Record architecture major version This tends to be easier to work with than the raw GPU ID and needs some special casing for Midgard vs Bifrost/Valhall. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/pan_device.h | 1 + src/panfrost/lib/pan_props.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/panfrost/lib/pan_device.h b/src/panfrost/lib/pan_device.h index 9a7b31d1ad7..664204ede97 100644 --- a/src/panfrost/lib/pan_device.h +++ b/src/panfrost/lib/pan_device.h @@ -96,6 +96,7 @@ struct panfrost_device { int fd; /* Properties of the GPU in use */ + unsigned arch; unsigned gpu_id; unsigned core_count; unsigned thread_tls_alloc; diff --git a/src/panfrost/lib/pan_props.c b/src/panfrost/lib/pan_props.c index 831b203bd04..627828c326f 100644 --- a/src/panfrost/lib/pan_props.c +++ b/src/panfrost/lib/pan_props.c @@ -132,6 +132,29 @@ panfrost_supports_compressed_format(struct panfrost_device *dev, unsigned fmt) return dev->compressed_formats & (1 << idx); } +/* Returns the architecture version given a GPU ID, either from a table for + * old-style Midgard versions or directly for new-style Bifrost/Valhall + * versions */ + +static unsigned +panfrost_major_version(unsigned gpu_id) +{ + switch (gpu_id) { + case 0x600: + case 0x620: + case 0x720: + return 4; + case 0x750: + case 0x820: + case 0x830: + case 0x860: + case 0x880: + return 5; + default: + return gpu_id >> 12; + } +} + /* Given a GPU ID like 0x860, return a prettified model name */ const char * @@ -160,6 +183,7 @@ panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev) dev->fd = fd; dev->memctx = memctx; dev->gpu_id = panfrost_query_gpu_version(fd); + dev->arch = panfrost_major_version(dev->gpu_id); dev->core_count = panfrost_query_core_count(fd); dev->thread_tls_alloc = panfrost_query_thread_tls_alloc(fd); dev->kernel_version = drmGetVersion(fd);