Commit fa4a427d authored by Victor Skvortsov's avatar Victor Skvortsov Committed by Alex Deucher

drm/amdgpu: SRIOV flr_work should use down_write

Host initiated VF FLR may fail if someone else is
already holding a read_lock. Change from down_write_trylock
to down_write to guarantee the reset goes through.
Signed-off-by: default avatarVictor Skvortsov <victor.skvortsov@amd.com>
Reviewed by: Shaoyun.liu <Shaoyun.liu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent b4acd97b
...@@ -252,11 +252,12 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) ...@@ -252,11 +252,12 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
* otherwise the mailbox msg will be ruined/reseted by * otherwise the mailbox msg will be ruined/reseted by
* the VF FLR. * the VF FLR.
*/ */
if (!down_write_trylock(&adev->reset_sem)) if (atomic_cmpxchg(&adev->in_gpu_reset, 0, 1) != 0)
return; return;
down_write(&adev->reset_sem);
amdgpu_virt_fini_data_exchange(adev); amdgpu_virt_fini_data_exchange(adev);
atomic_set(&adev->in_gpu_reset, 1);
xgpu_ai_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0); xgpu_ai_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0);
......
...@@ -281,11 +281,12 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) ...@@ -281,11 +281,12 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
* otherwise the mailbox msg will be ruined/reseted by * otherwise the mailbox msg will be ruined/reseted by
* the VF FLR. * the VF FLR.
*/ */
if (!down_write_trylock(&adev->reset_sem)) if (atomic_cmpxchg(&adev->in_gpu_reset, 0, 1) != 0)
return; return;
down_write(&adev->reset_sem);
amdgpu_virt_fini_data_exchange(adev); amdgpu_virt_fini_data_exchange(adev);
atomic_set(&adev->in_gpu_reset, 1);
xgpu_nv_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0); xgpu_nv_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment