Skip to content

Commit 88c511d

Browse files
committed
drm/amd/gfx11: move the gfx mutex into the caller
Otherwise we can fail to drop the software mutex when we fail to take the hardware mutex. Fixes: 76acba7 ("drm/amdgpu/gfx11: add a mutex for the gfx semaphore") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 186fb12 commit 88c511d

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4747,8 +4747,6 @@ int gfx_v11_0_request_gfx_index_mutex(struct amdgpu_device *adev,
47474747
{
47484748
u32 i, tmp, val;
47494749

4750-
if (req)
4751-
mutex_lock(&adev->gfx.reset_sem_mutex);
47524750
for (i = 0; i < adev->usec_timeout; i++) {
47534751
/* Request with MeId=2, PipeId=0 */
47544752
tmp = REG_SET_FIELD(0, CP_GFX_INDEX_MUTEX, REQUEST, req);
@@ -4769,8 +4767,6 @@ int gfx_v11_0_request_gfx_index_mutex(struct amdgpu_device *adev,
47694767
}
47704768
udelay(1);
47714769
}
4772-
if (!req)
4773-
mutex_unlock(&adev->gfx.reset_sem_mutex);
47744770

47754771
if (i >= adev->usec_timeout)
47764772
return -EINVAL;
@@ -4818,8 +4814,10 @@ static int gfx_v11_0_soft_reset(void *handle)
48184814
mutex_unlock(&adev->srbm_mutex);
48194815

48204816
/* Try to acquire the gfx mutex before access to CP_VMID_RESET */
4817+
mutex_lock(&adev->gfx.reset_sem_mutex);
48214818
r = gfx_v11_0_request_gfx_index_mutex(adev, true);
48224819
if (r) {
4820+
mutex_unlock(&adev->gfx.reset_sem_mutex);
48234821
DRM_ERROR("Failed to acquire the gfx mutex during soft reset\n");
48244822
return r;
48254823
}
@@ -4834,6 +4832,7 @@ static int gfx_v11_0_soft_reset(void *handle)
48344832

48354833
/* release the gfx mutex */
48364834
r = gfx_v11_0_request_gfx_index_mutex(adev, false);
4835+
mutex_unlock(&adev->gfx.reset_sem_mutex);
48374836
if (r) {
48384837
DRM_ERROR("Failed to release the gfx mutex during soft reset\n");
48394838
return r;

0 commit comments

Comments
 (0)