drm/amdgpu: Fix circular locking in userq creation
authorJesse.Zhang <Jesse.Zhang@amd.com>
Tue, 13 May 2025 02:09:04 +0000 (10:09 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 14 May 2025 15:29:38 +0000 (11:29 -0400)
commit96a86dcb5b5ca65564efeaaeecfca669e79a57e1
tree8137929a954283b4720e74ab1e6a6c30d217d434
parent07c9db090b86e5211188e1b351303fbc673378cf
drm/amdgpu: Fix circular locking in userq creation

A circular locking dependency was detected between the global
`adev->userq_mutex` and per-file `userq_mgr->userq_mutex` when
creating user queues. The issue occurs because:

1. `amdgpu_userq_suspend()` and `amdgpu_userq_resume` take `adev->userq_mutex` first, then
   `userq_mgr->userq_mutex`
2. While `amdgpu_userq_create()` takes them in reverse order

This patch resolves the issue by:
1. Moving the `adev->userq_mutex` lock earlier in `amdgpu_userq_create()`
   to cover the `amdgpu_userq_ensure_ev_fence()` call
2. Releasing it after we're done with both queue creation and the
   scheduling halt check

v2: remove unused adev->userq_mutex lock (Prike)

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Prike Liang <Prike.Liang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c