Skip to content

Commit fa4a427

Browse files
vskvortsalexdeucher
authored andcommitted
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: Victor Skvortsov <[email protected]> Reviewed by: Shaoyun.liu <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b4acd97 commit fa4a427

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,12 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)
252252
* otherwise the mailbox msg will be ruined/reseted by
253253
* the VF FLR.
254254
*/
255-
if (!down_write_trylock(&adev->reset_sem))
255+
if (atomic_cmpxchg(&adev->in_gpu_reset, 0, 1) != 0)
256256
return;
257257

258+
down_write(&adev->reset_sem);
259+
258260
amdgpu_virt_fini_data_exchange(adev);
259-
atomic_set(&adev->in_gpu_reset, 1);
260261

261262
xgpu_ai_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0);
262263

drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,12 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)
281281
* otherwise the mailbox msg will be ruined/reseted by
282282
* the VF FLR.
283283
*/
284-
if (!down_write_trylock(&adev->reset_sem))
284+
if (atomic_cmpxchg(&adev->in_gpu_reset, 0, 1) != 0)
285285
return;
286286

287+
down_write(&adev->reset_sem);
288+
287289
amdgpu_virt_fini_data_exchange(adev);
288-
atomic_set(&adev->in_gpu_reset, 1);
289290

290291
xgpu_nv_mailbox_trans_msg(adev, IDH_READY_TO_RESET, 0, 0, 0);
291292

0 commit comments

Comments
 (0)