[PATCH v2] drm/v3d: fix missing unlock

Melissa Wen mwen at igalia.com
Fri Jan 28 12:55:10 UTC 2022


On 01/27, Yongzhi Liu wrote:
> [why]
> Unlock is needed on the error handling path to prevent dead lock.
> v3d_submit_cl_ioctl and v3d_submit_csd_ioctl is missing unlock.
> 
> [how]
> Fix this by change goto target on the error handling path.
s/change/changing/g

I would just say: `Changing the goto to target an error handling path
that includes drm_gem_unlock reservations.`

and drop the explanation below

> As unlock is handle in fail_unreserve, i keep the failures
> handling around there. So the goto targets a place between
> `fail_unreserve:` and `fail:`.
> 
> Signed-off-by: Yongzhi Liu <lyz_cs at pku.edu.cn>
> ---
>  drivers/gpu/drm/v3d/v3d_gem.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
> index c7ed2e1..d9c7b39 100644
> --- a/drivers/gpu/drm/v3d/v3d_gem.c
> +++ b/drivers/gpu/drm/v3d/v3d_gem.c
> @@ -798,7 +798,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
>  
>  		if (!render->base.perfmon) {
>  			ret = -ENOENT;
> -			goto fail;
> +			goto v3d_unlock;
We usually use a `fail` prefix when handling failures.
A suggestion: `fail_perfmon` ?
>  		}
>  	}
>  
> @@ -847,6 +847,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
>  
>  fail_unreserve:
>  	mutex_unlock(&v3d->sched_lock);
> +v3d_unlock:
>  	drm_gem_unlock_reservations(last_job->bo,
>  				    last_job->bo_count, &acquire_ctx);
>  fail:
> @@ -1027,7 +1028,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
>  						     args->perfmon_id);
>  		if (!job->base.perfmon) {
>  			ret = -ENOENT;
> -			goto fail;
> +			goto v3d_unlock;
>  		}
>  	}
>  
> @@ -1056,6 +1057,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
>  
>  fail_unreserve:
>  	mutex_unlock(&v3d->sched_lock);
> +v3d_unlock:
>  	drm_gem_unlock_reservations(clean_job->bo, clean_job->bo_count,
>  				    &acquire_ctx);
>  fail:

With these changes, you can include in the next version my r-b:
Reviewed-by: Melissa Wen <mwen at igalia.com>

> -- 
> 2.7.4
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20220128/86be716c/attachment.sig>


More information about the dri-devel mailing list