Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 76acba7b7f12 ("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>

+3 -4
+3 -4
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
··· 4747 4747 { 4748 4748 u32 i, tmp, val; 4749 4749 4750 - if (req) 4751 - mutex_lock(&adev->gfx.reset_sem_mutex); 4752 4750 for (i = 0; i < adev->usec_timeout; i++) { 4753 4751 /* Request with MeId=2, PipeId=0 */ 4754 4752 tmp = REG_SET_FIELD(0, CP_GFX_INDEX_MUTEX, REQUEST, req); ··· 4767 4769 } 4768 4770 udelay(1); 4769 4771 } 4770 - if (!req) 4771 - mutex_unlock(&adev->gfx.reset_sem_mutex); 4772 4772 4773 4773 if (i >= adev->usec_timeout) 4774 4774 return -EINVAL; ··· 4814 4818 mutex_unlock(&adev->srbm_mutex); 4815 4819 4816 4820 /* Try to acquire the gfx mutex before access to CP_VMID_RESET */ 4821 + mutex_lock(&adev->gfx.reset_sem_mutex); 4817 4822 r = gfx_v11_0_request_gfx_index_mutex(adev, true); 4818 4823 if (r) { 4824 + mutex_unlock(&adev->gfx.reset_sem_mutex); 4819 4825 DRM_ERROR("Failed to acquire the gfx mutex during soft reset\n"); 4820 4826 return r; 4821 4827 } ··· 4832 4834 4833 4835 /* release the gfx mutex */ 4834 4836 r = gfx_v11_0_request_gfx_index_mutex(adev, false); 4837 + mutex_unlock(&adev->gfx.reset_sem_mutex); 4835 4838 if (r) { 4836 4839 DRM_ERROR("Failed to release the gfx mutex during soft reset\n"); 4837 4840 return r;