Skip to content

Commit

Permalink
drm/v3d: Use v3d_get_extensions() to parse CPU job data
Browse files Browse the repository at this point in the history
Currently, v3d_get_extensions() only parses multisync data and assigns
it to the `struct v3d_submit_ext`. But, to implement the CPU job with
user extensions, we want v3d_get_extensions() to be able to parse CPU
job data and assign it to the `struct v3d_cpu_job`.

Therefore, allow the function v3d_get_extensions() to use `struct v3d_cpu_job *`
as a parameter. If the `struct v3d_cpu_job *` is assigned to NULL, it means
that the job is a GPU job and CPU job extensions should be rejected.

Signed-off-by: Maíra Canal <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
mairacanal committed Dec 1, 2023
1 parent aafc1a2 commit c5195d0
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions drivers/gpu/drm/v3d/v3d_submit.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,9 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
static int
v3d_get_multisync_submit_deps(struct drm_file *file_priv,
struct drm_v3d_extension __user *ext,
void *data)
struct v3d_submit_ext *se)
{
struct drm_v3d_multi_sync multisync;
struct v3d_submit_ext *se = data;
int ret;

if (se->in_sync_count || se->out_sync_count) {
Expand All @@ -340,7 +339,7 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
if (multisync.pad)
return -EINVAL;

ret = v3d_get_multisync_post_deps(file_priv, data, multisync.out_sync_count,
ret = v3d_get_multisync_post_deps(file_priv, se, multisync.out_sync_count,
multisync.out_syncs);
if (ret)
return ret;
Expand All @@ -359,7 +358,8 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
static int
v3d_get_extensions(struct drm_file *file_priv,
u64 ext_handles,
void *data)
struct v3d_submit_ext *se,
struct v3d_cpu_job *job)
{
struct drm_v3d_extension __user *user_ext;
int ret;
Expand All @@ -375,15 +375,16 @@ v3d_get_extensions(struct drm_file *file_priv,

switch (ext.id) {
case DRM_V3D_EXT_ID_MULTI_SYNC:
ret = v3d_get_multisync_submit_deps(file_priv, user_ext, data);
if (ret)
return ret;
ret = v3d_get_multisync_submit_deps(file_priv, user_ext, se);
break;
default:
DRM_DEBUG_DRIVER("Unknown extension id: %d\n", ext.id);
return -EINVAL;
}

if (ret)
return ret;

user_ext = u64_to_user_ptr(ext.next);
}

Expand Down Expand Up @@ -430,7 +431,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
}

if (args->flags & DRM_V3D_SUBMIT_EXTENSION) {
ret = v3d_get_extensions(file_priv, args->extensions, &se);
ret = v3d_get_extensions(file_priv, args->extensions, &se, NULL);
if (ret) {
DRM_DEBUG("Failed to get extensions.\n");
return ret;
Expand Down Expand Up @@ -585,7 +586,7 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,
}

if (args->flags & DRM_V3D_SUBMIT_EXTENSION) {
ret = v3d_get_extensions(file_priv, args->extensions, &se);
ret = v3d_get_extensions(file_priv, args->extensions, &se, NULL);
if (ret) {
DRM_DEBUG("Failed to get extensions.\n");
return ret;
Expand Down Expand Up @@ -692,7 +693,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
}

if (args->flags & DRM_V3D_SUBMIT_EXTENSION) {
ret = v3d_get_extensions(file_priv, args->extensions, &se);
ret = v3d_get_extensions(file_priv, args->extensions, &se, NULL);
if (ret) {
DRM_DEBUG("Failed to get extensions.\n");
return ret;
Expand Down Expand Up @@ -805,7 +806,7 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,
return ret;

if (args->flags & DRM_V3D_SUBMIT_EXTENSION) {
ret = v3d_get_extensions(file_priv, args->extensions, &se);
ret = v3d_get_extensions(file_priv, args->extensions, &se, cpu_job);
if (ret) {
DRM_DEBUG("Failed to get extensions.\n");
goto fail;
Expand Down

0 comments on commit c5195d0

Please sign in to comment.