panfrost: Fix TLS sizing if cores are missing
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 7 Jan 2021 23:22:54 +0000 (18:22 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 Jan 2021 16:55:43 +0000 (16:55 +0000)
I have no idea if there are any implementations we care about that have
missing shader cores (a mask of 1101 or something like that), but if one
crops up, this would be a royal pain to debug so let's just get it
right...

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8723>

src/panfrost/lib/pan_props.c

index 334c36e..38c1018 100644 (file)
@@ -91,7 +91,13 @@ panfrost_query_core_count(int fd)
         unsigned mask = panfrost_query_raw(fd,
                         DRM_PANFROST_PARAM_SHADER_PRESENT, false, 0xffff);
 
-        return util_bitcount(mask);
+        /* Some cores might be absent. For TLS computation purposes, we care
+         * about the greatest ID + 1, which equals the core count if all cores
+         * are present, but allocates space for absent cores if needed.
+         * util_last_bit is defined to return the greatest bit set + 1, which
+         * is exactly what we need. */
+
+        return util_last_bit(mask);
 }
 
 /* Architectural maximums, since this register may be not implemented