mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
drm/v3d: Size the kperfmon_ids array at runtime
Instead of statically reserving pessimistic space for the kperfmon_ids array, make the userspace extension code allocate the exactly required amount of space. Apart from saving some memory at runtime, this also removes the need for the V3D_MAX_PERFMONS macro whose removal will benefit further driver cleanup. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Signed-off-by: Maíra Canal <mcanal@igalia.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240711135340.84617-8-tursulin@igalia.com
This commit is contained in:
committed by
Maíra Canal
parent
4bd75a81e6
commit
c9d6630f7c
@@ -671,10 +671,20 @@ v3d_copy_query_info(struct v3d_performance_query_info *query_info,
|
||||
goto error;
|
||||
}
|
||||
|
||||
query->kperfmon_ids =
|
||||
kvmalloc_array(nperfmons,
|
||||
sizeof(struct v3d_performance_query *),
|
||||
GFP_KERNEL);
|
||||
if (!query->kperfmon_ids) {
|
||||
err = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
ids_pointer = u64_to_user_ptr(ids);
|
||||
|
||||
for (j = 0; j < nperfmons; j++) {
|
||||
if (get_user(id, ids_pointer++)) {
|
||||
kvfree(query->kperfmon_ids);
|
||||
err = -EFAULT;
|
||||
goto error;
|
||||
}
|
||||
@@ -684,6 +694,7 @@ v3d_copy_query_info(struct v3d_performance_query_info *query_info,
|
||||
|
||||
query->syncobj = drm_syncobj_find(file_priv, sync);
|
||||
if (!query->syncobj) {
|
||||
kvfree(query->kperfmon_ids);
|
||||
err = -ENOENT;
|
||||
goto error;
|
||||
}
|
||||
@@ -717,9 +728,6 @@ v3d_get_cpu_reset_performance_params(struct drm_file *file_priv,
|
||||
if (copy_from_user(&reset, ext, sizeof(reset)))
|
||||
return -EFAULT;
|
||||
|
||||
if (reset.nperfmons > V3D_MAX_PERFMONS)
|
||||
return -EINVAL;
|
||||
|
||||
job->job_type = V3D_CPU_JOB_TYPE_RESET_PERFORMANCE_QUERY;
|
||||
|
||||
job->performance_query.queries = kvmalloc_array(reset.count,
|
||||
@@ -767,9 +775,6 @@ v3d_get_cpu_copy_performance_query_params(struct drm_file *file_priv,
|
||||
if (copy.pad)
|
||||
return -EINVAL;
|
||||
|
||||
if (copy.nperfmons > V3D_MAX_PERFMONS)
|
||||
return -EINVAL;
|
||||
|
||||
job->job_type = V3D_CPU_JOB_TYPE_COPY_PERFORMANCE_QUERY;
|
||||
|
||||
job->performance_query.queries = kvmalloc_array(copy.count,
|
||||
|
||||
Reference in New Issue
Block a user