From: Christian König Date: Tue, 14 Jan 2025 12:51:39 +0000 (+0100) Subject: drm/amdgpu: grab an additional reference on the gang fence v2 X-Git-Tag: v6.15-rc1~120^2~1^2~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d9a95099dcb05b5f4719c830d15bf4fdcad0dc2;p=thirdparty%2Fkernel%2Flinux.git drm/amdgpu: grab an additional reference on the gang fence v2 We keep the gang submission fence around in adev, make sure that it stays alive. v2: fix memory leak on retry Signed-off-by: Christian König Acked-by: Srinivasan Shanmugam Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index e63bcd5edab97..35ace1368b9ca 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -6913,18 +6913,26 @@ struct dma_fence *amdgpu_device_switch_gang(struct amdgpu_device *adev, { struct dma_fence *old = NULL; + dma_fence_get(gang); do { dma_fence_put(old); old = amdgpu_device_get_gang(adev); if (old == gang) break; - if (!dma_fence_is_signaled(old)) + if (!dma_fence_is_signaled(old)) { + dma_fence_put(gang); return old; + } } while (cmpxchg((struct dma_fence __force **)&adev->gang_submit, old, gang) != old); + /* + * Drop it once for the exchanged reference in adev and once for the + * thread local reference acquired in amdgpu_device_get_gang(). + */ + dma_fence_put(old); dma_fence_put(old); return NULL; }