All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: SRIOV flr_work should take write_lock
@ 2021-07-01  2:22 Jingwen Chen
       [not found] ` <20210701101233.wlskqc2kjzwhiudv@wayne-build>
  0 siblings, 1 reply; 2+ messages in thread
From: Jingwen Chen @ 2021-07-01  2:22 UTC (permalink / raw)
  To: amd-gfx; +Cc: horace.chen, Jingwen Chen, monk.liu

[Why]
If flr_work takes read_lock, then other threads who takes
read_lock can access hardware when host is doing vf flr.

[How]
flr_work should take write_lock to avoid this case.

Signed-off-by: Jingwen Chen <Jingwen.Chen2@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
index 3ee481557fc9..ff2307d7ee0f 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
@@ -252,7 +252,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
 	 * otherwise the mailbox msg will be ruined/reseted by
 	 * the VF FLR.
 	 */
-	if (!down_read_trylock(&adev->reset_sem))
+	if (!down_write_trylock(&adev->reset_sem))
 		return;
 
 	amdgpu_virt_fini_data_exchange(adev);
@@ -268,7 +268,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
 
 flr_done:
 	atomic_set(&adev->in_gpu_reset, 0);
-	up_read(&adev->reset_sem);
+	up_write(&adev->reset_sem);
 
 	/* Trigger recovery for world switch failure if no TDR */
 	if (amdgpu_device_should_recover_gpu(adev)
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
index 48e588d3c409..9f7aac435d69 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
@@ -273,7 +273,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
 	 * otherwise the mailbox msg will be ruined/reseted by
 	 * the VF FLR.
 	 */
-	if (!down_read_trylock(&adev->reset_sem))
+	if (!down_write_trylock(&adev->reset_sem))
 		return;
 
 	amdgpu_virt_fini_data_exchange(adev);
@@ -289,7 +289,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
 
 flr_done:
 	atomic_set(&adev->in_gpu_reset, 0);
-	up_read(&adev->reset_sem);
+	up_write(&adev->reset_sem);
 
 	/* Trigger recovery for world switch failure if no TDR */
 	if (amdgpu_device_should_recover_gpu(adev)
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* RE: [PATCH] drm/amdgpu: SRIOV flr_work should take write_lock
       [not found] ` <20210701101233.wlskqc2kjzwhiudv@wayne-build>
@ 2021-07-06  7:37   ` Liu, Monk
  0 siblings, 0 replies; 2+ messages in thread
From: Liu, Monk @ 2021-07-06  7:37 UTC (permalink / raw)
  To: Chen, JingWen, amd-gfx; +Cc: Chen, Horace

[AMD Official Use Only]

Reviewed-by: Mon Liu <monk.liu@amd.com>

Thanks 

------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------

-----Original Message-----
From: Jingwen Chen <Jingwen.Chen2@amd.com> 
Sent: Thursday, July 1, 2021 6:13 PM
To: amd-gfx@lists.freedesktop.org
Cc: Liu, Monk <Monk.Liu@amd.com>; Chen, Horace <Horace.Chen@amd.com>
Subject: Re: [PATCH] drm/amdgpu: SRIOV flr_work should take write_lock

ping..

On Thu Jul 01, 2021 at 10:22:57AM +0800, Jingwen Chen wrote:
> [Why]
> If flr_work takes read_lock, then other threads who takes read_lock 
> can access hardware when host is doing vf flr.
> 
> [How]
> flr_work should take write_lock to avoid this case.
> 
> Signed-off-by: Jingwen Chen <Jingwen.Chen2@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 ++--  
> drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c 
> b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
> index 3ee481557fc9..ff2307d7ee0f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
> @@ -252,7 +252,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
>  	 * otherwise the mailbox msg will be ruined/reseted by
>  	 * the VF FLR.
>  	 */
> -	if (!down_read_trylock(&adev->reset_sem))
> +	if (!down_write_trylock(&adev->reset_sem))
>  		return;
>  
>  	amdgpu_virt_fini_data_exchange(adev);
> @@ -268,7 +268,7 @@ static void xgpu_ai_mailbox_flr_work(struct 
> work_struct *work)
>  
>  flr_done:
>  	atomic_set(&adev->in_gpu_reset, 0);
> -	up_read(&adev->reset_sem);
> +	up_write(&adev->reset_sem);
>  
>  	/* Trigger recovery for world switch failure if no TDR */
>  	if (amdgpu_device_should_recover_gpu(adev)
> diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c 
> b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
> index 48e588d3c409..9f7aac435d69 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
> @@ -273,7 +273,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
>  	 * otherwise the mailbox msg will be ruined/reseted by
>  	 * the VF FLR.
>  	 */
> -	if (!down_read_trylock(&adev->reset_sem))
> +	if (!down_write_trylock(&adev->reset_sem))
>  		return;
>  
>  	amdgpu_virt_fini_data_exchange(adev);
> @@ -289,7 +289,7 @@ static void xgpu_nv_mailbox_flr_work(struct 
> work_struct *work)
>  
>  flr_done:
>  	atomic_set(&adev->in_gpu_reset, 0);
> -	up_read(&adev->reset_sem);
> +	up_write(&adev->reset_sem);
>  
>  	/* Trigger recovery for world switch failure if no TDR */
>  	if (amdgpu_device_should_recover_gpu(adev)
> --
> 2.25.1
> 
Best Regards,
JingWen Chen
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2021-07-06  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01  2:22 [PATCH] drm/amdgpu: SRIOV flr_work should take write_lock Jingwen Chen
     [not found] ` <20210701101233.wlskqc2kjzwhiudv@wayne-build>
2021-07-06  7:37   ` Liu, Monk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.