]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/v3d: Different V3D versions can have different number of perfcnt
authorMaíra Canal <mcanal@igalia.com>
Sun, 12 May 2024 22:23:25 +0000 (19:23 -0300)
committerMaíra Canal <mcanal@igalia.com>
Mon, 20 May 2024 19:38:00 +0000 (16:38 -0300)
Currently, even though V3D 7.1 has 93 performance counters, it is not
possible to create counters bigger than 87, as
`v3d_perfmon_create_ioctl()` understands that counters bigger than 87
are invalid.

Therefore, create a device variable to expose the maximum
number of counters for a given V3D version and make
`v3d_perfmon_create_ioctl()` check this variable.

This commit fixes CTS failures in the performance queries tests
`dEQP-VK.query_pool.performance_query.*` [1]

Link: https://gitlab.freedesktop.org/mesa/mesa/-/commit/ea1f09a5f21839f4f3b93610b58507c4bd9b9b81
Fixes: 6fd9487147c4 ("drm/v3d: add brcm,2712-v3d as a compatible V3D device")
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240512222655.2792754-3-mcanal@igalia.com
drivers/gpu/drm/v3d/v3d_drv.c
drivers/gpu/drm/v3d/v3d_drv.h
drivers/gpu/drm/v3d/v3d_perfmon.c

index 28b7ddce774770a1af5f28ef22ad8386603a2e67..6b9dd26df9fe20c6cccf741257a2cbe45a264e35 100644 (file)
@@ -294,6 +294,13 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
        v3d->cores = V3D_GET_FIELD(ident1, V3D_HUB_IDENT1_NCORES);
        WARN_ON(v3d->cores > 1); /* multicore not yet implemented */
 
+       if (v3d->ver >= 71)
+               v3d->max_counters = ARRAY_SIZE(v3d_v71_performance_counters);
+       else if (v3d->ver >= 42)
+               v3d->max_counters = ARRAY_SIZE(v3d_v42_performance_counters);
+       else
+               v3d->max_counters = 0;
+
        v3d->reset = devm_reset_control_get_exclusive(dev, NULL);
        if (IS_ERR(v3d->reset)) {
                ret = PTR_ERR(v3d->reset);
index 671375a3bb6653ab7ab2846760bbc798a0c6819b..bd1e38f7d10a7833096a787cd73f20e72d87686b 100644 (file)
@@ -104,6 +104,11 @@ struct v3d_dev {
        int ver;
        bool single_irq_line;
 
+       /* Different revisions of V3D have different total number of performance
+        * counters
+        */
+       unsigned int max_counters;
+
        void __iomem *hub_regs;
        void __iomem *core_regs[3];
        void __iomem *bridge_regs;
index e1be7368b87dfc5a0a2ab17a2d840f66b9f091e9..f268d9466c0f6df81bd5fe84c432c628bd76b1f3 100644 (file)
@@ -123,6 +123,7 @@ int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
 {
        struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
        struct drm_v3d_perfmon_create *req = data;
+       struct v3d_dev *v3d = v3d_priv->v3d;
        struct v3d_perfmon *perfmon;
        unsigned int i;
        int ret;
@@ -134,7 +135,7 @@ int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
 
        /* Make sure all counters are valid. */
        for (i = 0; i < req->ncounters; i++) {
-               if (req->counters[i] >= V3D_PERFCNT_NUM)
+               if (req->counters[i] >= v3d->max_counters)
                        return -EINVAL;
        }