aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/v3d/v3d_perfmon.c
diff options
context:
space:
mode:
authorMaíra Canal <[email protected]>2024-05-12 19:23:27 -0300
committerMaíra Canal <[email protected]>2024-05-20 16:38:02 -0300
commitf33fe58298e686e7cc2d24f747c980457812b566 (patch)
tree1c15a23a2a2a72da530860becfd41c46ee3b536b /drivers/gpu/drm/v3d/v3d_perfmon.c
parent36b75080e68b4a27ae1c40beffb3d6131f8eeeff (diff)
drm/v3d: Create new IOCTL to expose performance counters information
Userspace usually needs some information about the performance counters available. Although we could replicate this information in the kernel and user-space, let's use the kernel as the "single source of truth" to avoid issues in the future (e.g. list of performance counters is updated in user-space, but not in the kernel, generating invalid requests). Therefore, create a new IOCTL to expose the performance counters information, that is name, category, and description. Signed-off-by: Maíra Canal <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Diffstat (limited to 'drivers/gpu/drm/v3d/v3d_perfmon.c')
-rw-r--r--drivers/gpu/drm/v3d/v3d_perfmon.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/gpu/drm/v3d/v3d_perfmon.c b/drivers/gpu/drm/v3d/v3d_perfmon.c
index f268d9466c0f..73e2bb8bdb7f 100644
--- a/drivers/gpu/drm/v3d/v3d_perfmon.c
+++ b/drivers/gpu/drm/v3d/v3d_perfmon.c
@@ -217,3 +217,36 @@ int v3d_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
return ret;
}
+
+int v3d_perfmon_get_counter_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_v3d_perfmon_get_counter *req = data;
+ struct v3d_dev *v3d = to_v3d_dev(dev);
+ const struct v3d_perf_counter_desc *counter;
+
+ for (int i = 0; i < ARRAY_SIZE(req->reserved); i++) {
+ if (req->reserved[i] != 0)
+ return -EINVAL;
+ }
+
+ /* Make sure that the counter ID is valid */
+ if (req->counter >= v3d->max_counters)
+ return -EINVAL;
+
+ if (v3d->ver >= 71) {
+ WARN_ON(v3d->max_counters != ARRAY_SIZE(v3d_v71_performance_counters));
+ counter = &v3d_v71_performance_counters[req->counter];
+ } else if (v3d->ver >= 42) {
+ WARN_ON(v3d->max_counters != ARRAY_SIZE(v3d_v42_performance_counters));
+ counter = &v3d_v42_performance_counters[req->counter];
+ } else {
+ return -EOPNOTSUPP;
+ }
+
+ strscpy(req->name, counter->name, sizeof(req->name));
+ strscpy(req->category, counter->category, sizeof(req->category));
+ strscpy(req->description, counter->description, sizeof(req->description));
+
+ return 0;
+}