panfrost: Add panfrost_query_l2_slices helper
authorAlyssa Rosenzweig <alyssa@collabora.com>
Wed, 25 May 2022 18:34:39 +0000 (14:34 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Jun 2022 13:57:18 +0000 (13:57 +0000)
The number of L2 performance counter blocks equals the number of L2 slices, so
add a query to get this. This information isn't needed by the Mesa driver, so
don't get it in the default device initialization path.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16803>

src/panfrost/lib/pan_device.h
src/panfrost/lib/pan_props.c

index a334a19..dbd9faf 100644 (file)
@@ -272,6 +272,9 @@ panfrost_query_sample_position(
                 unsigned sample_idx,
                 float *out);
 
+unsigned
+panfrost_query_l2_slices(const struct panfrost_device *dev);
+
 static inline struct panfrost_bo *
 pan_lookup_bo(struct panfrost_device *dev, uint32_t gem_handle)
 {
index 8ec6049..3cc1616 100644 (file)
@@ -125,6 +125,18 @@ panfrost_query_gpu_revision(int fd)
         return panfrost_query_raw(fd, DRM_PANFROST_PARAM_GPU_REVISION, true, 0);
 }
 
+unsigned
+panfrost_query_l2_slices(const struct panfrost_device *dev)
+{
+        /* Query MEM_FEATURES register */
+        uint32_t mem_features =
+                panfrost_query_raw(dev->fd, DRM_PANFROST_PARAM_MEM_FEATURES,
+                                   true, 0);
+
+        /* L2_SLICES is MEM_FEATURES[11:8] minus(1) */
+        return ((mem_features >> 8) & 0xF) + 1;
+}
+
 static struct panfrost_tiler_features
 panfrost_query_tiler_features(int fd)
 {