drm/amdgpu: SRIOV flr_work should take write_lock
Subsystems (2)
PATCH 1/1 drm/amdgpu: SRIOV flr_work should take write_lock
[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.
--- 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(-)
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2 -2
@@ -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)
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2 -2
@@ -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)
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20210701101233.wlskqc2kjzwhiudv@wayne-build
Liu, Monk
Reviewed-by[AMD Official Use Only]
Thanks
------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------
-----Original Message-----
From: Jingwen Chen <[email protected]>
Sent: Thursday, July 1, 2021 6:13 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>; Chen, Horace <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: SRIOV flr_work should take write_lock
ping..
Quoted 60 lines · Jingwen Chen
[Why]
Ifflr_worktakesread_lock, then other threads who takesread_lockcan access hardware when host is doing vf flr.[How]
flr_workshould takewrite_lockto avoid this case.Signed-off-by Jingwen Chen <[email protected]>--- 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(-)drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2
-2@@ -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 */ drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +0
-0if (amdgpu_device_should_recover_gpu(adev)drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2
-2@@ -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 */
Quoted 4 lines
if (
amdgpu_device_should_recover_gpu(adev)
--
2.25.1
Best Regards,
JingWen Chen
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx