From 0ecbfcc892b89aebe30a266b05922a782ed324a5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 25 May 2022 14:34:39 -0400 Subject: [PATCH] panfrost: Add panfrost_query_l2_slices helper 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 Reviewed-by: Antonio Caggiano Part-of: --- src/panfrost/lib/pan_device.h | 3 +++ src/panfrost/lib/pan_props.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/panfrost/lib/pan_device.h b/src/panfrost/lib/pan_device.h index a334a19..dbd9faf 100644 --- a/src/panfrost/lib/pan_device.h +++ b/src/panfrost/lib/pan_device.h @@ -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) { diff --git a/src/panfrost/lib/pan_props.c b/src/panfrost/lib/pan_props.c index 8ec6049..3cc1616 100644 --- a/src/panfrost/lib/pan_props.c +++ b/src/panfrost/lib/pan_props.c @@ -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) { -- 2.7.4