Skip to content

v3d: Don't use performance counters names array with an older kernel

Maíra Canal requested to merge mairacanal/mesa:v3d/fix-perfcnt-segfault into main

Starting with Linux v6.11+, performance counter information is no longer duplicated in both the kernel and userspace. Instead, an IOCTL retrieves this information, allowing userspace to maintain a local array for reuse, thus avoiding redundant kernel queries.

However, support for older kernels without these new IOCTLs remains. To distinguish between versions, we check devinfo->max_perfcnt - which is non-zero on Linux v6.11+ and zero on older kernels.

Currently, applications using performance queries on platforms with older kernels encounter a SEGFAULT, as we don't validate devinfo->max_perfcnt before accessing the userspace array for performance counter information.

This commit adds a check for DRM_IOCTL_V3D_GET_COUNTER support before attempting to use the userspace array, ensuring compatibility with older kernels.

/cc @jasuarez

Merge request reports

Loading