Commit b5840166 authored by Jingwen Chen's avatar Jingwen Chen Committed by Alex Deucher

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.
Signed-off-by: default avatarJingwen Chen <Jingwen.Chen2@amd.com>
Reviewed-by: default avatarMonk Liu <monk.liu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c0838d3a
...@@ -252,7 +252,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) ...@@ -252,7 +252,7 @@ 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_read_trylock(&adev->reset_sem)) if (!down_write_trylock(&adev->reset_sem))
return; return;
amdgpu_virt_fini_data_exchange(adev); amdgpu_virt_fini_data_exchange(adev);
...@@ -268,7 +268,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) ...@@ -268,7 +268,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
flr_done: flr_done:
atomic_set(&adev->in_gpu_reset, 0); 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 */ /* Trigger recovery for world switch failure if no TDR */
if (amdgpu_device_should_recover_gpu(adev) if (amdgpu_device_should_recover_gpu(adev)
......
...@@ -273,7 +273,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) ...@@ -273,7 +273,7 @@ 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_read_trylock(&adev->reset_sem)) if (!down_write_trylock(&adev->reset_sem))
return; return;
amdgpu_virt_fini_data_exchange(adev); amdgpu_virt_fini_data_exchange(adev);
...@@ -289,7 +289,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) ...@@ -289,7 +289,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
flr_done: flr_done:
atomic_set(&adev->in_gpu_reset, 0); 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 */ /* Trigger recovery for world switch failure if no TDR */
if (amdgpu_device_should_recover_gpu(adev) if (amdgpu_device_should_recover_gpu(adev)
......
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