Skip to content

Commit 71a0556

Browse files
gfxstrandgregkh
authored andcommitted
drm/syncobj: Don't leak fences when WAIT_FOR_SUBMIT is set
commit 337fe9f upstream. We attempt to get fences earlier in the hopes that everything will already have fences and no callbacks will be needed. If we do succeed in getting a fence, getting one a second time will result in a duplicate ref with no unref. This is causing memory leaks in Vulkan applications that create a lot of fences; playing for a few hours can, apparently, bring down the system. Cc: stable@vger.kernel.org Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899 Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: https://patchwork.freedesktop.org/patch/msgid/20180926071703.15257-1-jason.ekstrand@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0c0dd18 commit 71a0556

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/gpu/drm/drm_syncobj.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj,
9696
{
9797
int ret;
9898

99+
WARN_ON(*fence);
100+
99101
*fence = drm_syncobj_fence_get(syncobj);
100102
if (*fence)
101103
return 1;
@@ -656,6 +658,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
656658

657659
if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
658660
for (i = 0; i < count; ++i) {
661+
if (entries[i].fence)
662+
continue;
663+
659664
drm_syncobj_fence_get_or_add_callback(syncobjs[i],
660665
&entries[i].fence,
661666
&entries[i].syncobj_cb,

0 commit comments

Comments
 (0)