linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/v3d: Add missing unlock
@ 2022-01-22 16:26 Yongzhi Liu
  2022-01-26 20:57 ` Melissa Wen
  0 siblings, 1 reply; 5+ messages in thread
From: Yongzhi Liu @ 2022-01-22 16:26 UTC (permalink / raw)
  To: emma, airlied, daniel; +Cc: dri-devel, linux-kernel, Yongzhi Liu

[why]
Unlock is needed on the error handling path to prevent dead lock.

[how]
Fix this by adding drm_gem_unlock_reservations on the error handling path.

Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
---
 drivers/gpu/drm/v3d/v3d_gem.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index c7ed2e1..0c989dc 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -798,6 +798,8 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 
 		if (!render->base.perfmon) {
 			ret = -ENOENT;
+			drm_gem_unlock_reservations(last_job->bo,
+				    last_job->bo_count, &acquire_ctx);
 			goto fail;
 		}
 	}
@@ -1027,6 +1029,8 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
 						     args->perfmon_id);
 		if (!job->base.perfmon) {
 			ret = -ENOENT;
+			drm_gem_unlock_reservations(clean_job->bo, clean_job->bo_count,
+						    &acquire_ctx);
 			goto fail;
 		}
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/v3d: Add missing unlock
  2022-01-22 16:26 [PATCH] drm/v3d: Add missing unlock Yongzhi Liu
@ 2022-01-26 20:57 ` Melissa Wen
  2022-01-27 10:14   ` [PATCH v2] drm/v3d: fix " Yongzhi Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Melissa Wen @ 2022-01-26 20:57 UTC (permalink / raw)
  To: Yongzhi Liu; +Cc: emma, airlied, daniel, linux-kernel, dri-devel

[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]

On 01/22, Yongzhi Liu wrote:
> [why]
> Unlock is needed on the error handling path to prevent dead lock.
> 
> [how]
> Fix this by adding drm_gem_unlock_reservations on the error handling path.
> 
> Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
> ---
>  drivers/gpu/drm/v3d/v3d_gem.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
> index c7ed2e1..0c989dc 100644
> --- a/drivers/gpu/drm/v3d/v3d_gem.c
> +++ b/drivers/gpu/drm/v3d/v3d_gem.c
> @@ -798,6 +798,8 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
>  
>  		if (!render->base.perfmon) {
>  			ret = -ENOENT;
> +			drm_gem_unlock_reservations(last_job->bo,
> +				    last_job->bo_count, &acquire_ctx);
>  			goto fail;
Hi,

Nice catch!

As unlock is handle in fail_unreserve, I would suggest you to keep the
failures handling around there. In that case, the goto will target a
place between `fail_unreserve:` and `fail:`, i.e. calls
drm_gem_unlock_reservations (and the following cleanings) but don't call
mutex_unlock.

Thanks,

Melissa

>  		}
>  	}
> @@ -1027,6 +1029,8 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
>  						     args->perfmon_id);
>  		if (!job->base.perfmon) {
>  			ret = -ENOENT;
> +			drm_gem_unlock_reservations(clean_job->bo, clean_job->bo_count,
> +						    &acquire_ctx);
>  			goto fail;
>  		}
>  	}
> -- 
> 2.7.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] drm/v3d: fix missing unlock
  2022-01-26 20:57 ` Melissa Wen
@ 2022-01-27 10:14   ` Yongzhi Liu
  2022-01-28 12:55     ` Melissa Wen
  0 siblings, 1 reply; 5+ messages in thread
From: Yongzhi Liu @ 2022-01-27 10:14 UTC (permalink / raw)
  To: emma, airlied, daniel, mwen; +Cc: dri-devel, linux-kernel, Yongzhi Liu

[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.
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@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;
 		}
 	}
 
@@ -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:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/v3d: fix missing unlock
  2022-01-27 10:14   ` [PATCH v2] drm/v3d: fix " Yongzhi Liu
@ 2022-01-28 12:55     ` Melissa Wen
  2022-01-28 13:41       ` [PATCH v3] " Yongzhi Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Melissa Wen @ 2022-01-28 12:55 UTC (permalink / raw)
  To: Yongzhi Liu; +Cc: emma, airlied, daniel, linux-kernel, dri-devel

[-- Attachment #1: Type: text/plain, Size: 2117 bytes --]

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@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@igalia.com>

> -- 
> 2.7.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3] drm/v3d: fix missing unlock
  2022-01-28 12:55     ` Melissa Wen
@ 2022-01-28 13:41       ` Yongzhi Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Yongzhi Liu @ 2022-01-28 13:41 UTC (permalink / raw)
  To: emma, airlied, daniel, mwen; +Cc: dri-devel, linux-kernel, Yongzhi Liu

[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 changing goto target on the error handling path. So
changing the goto to target an error handling path
that includes drm_gem_unlock reservations.

Signed-off-by: Yongzhi Liu <lyz_cs@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..92bc0fa 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 fail_perfmon;
 		}
 	}
 
@@ -847,6 +847,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 
 fail_unreserve:
 	mutex_unlock(&v3d->sched_lock);
+fail_perfmon:
 	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 fail_perfmon;
 		}
 	}
 
@@ -1056,6 +1057,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *data,
 
 fail_unreserve:
 	mutex_unlock(&v3d->sched_lock);
+fail_perfmon:
 	drm_gem_unlock_reservations(clean_job->bo, clean_job->bo_count,
 				    &acquire_ctx);
 fail:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-28 13:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22 16:26 [PATCH] drm/v3d: Add missing unlock Yongzhi Liu
2022-01-26 20:57 ` Melissa Wen
2022-01-27 10:14   ` [PATCH v2] drm/v3d: fix " Yongzhi Liu
2022-01-28 12:55     ` Melissa Wen
2022-01-28 13:41       ` [PATCH v3] " Yongzhi Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).