]> www.infradead.org Git - users/hch/misc.git/commit
drm/vmwgfx: Fix a deadlock in dma buf fence polling
authorZack Rusin <zack.rusin@broadcom.com>
Mon, 22 Jul 2024 18:41:13 +0000 (14:41 -0400)
committerZack Rusin <zack.rusin@broadcom.com>
Thu, 25 Jul 2024 02:21:36 +0000 (22:21 -0400)
commite58337100721f3cc0c7424a18730e4f39844934f
treec310b6d8572d25391fe8139b4445219e42f7bdbb
parent445d336cd15860f1efb441e6d694f829fbf679eb
drm/vmwgfx: Fix a deadlock in dma buf fence polling

Introduce a version of the fence ops that on release doesn't remove
the fence from the pending list, and thus doesn't require a lock to
fix poll->fence wait->fence unref deadlocks.

vmwgfx overwrites the wait callback to iterate over the list of all
fences and update their status, to do that it holds a lock to prevent
the list modifcations from other threads. The fence destroy callback
both deletes the fence and removes it from the list of pending
fences, for which it holds a lock.

dma buf polling cb unrefs a fence after it's been signaled: so the poll
calls the wait, which signals the fences, which are being destroyed.
The destruction tries to acquire the lock on the pending fences list
which it can never get because it's held by the wait from which it
was called.

Old bug, but not a lot of userspace apps were using dma-buf polling
interfaces. Fix those, in particular this fixes KDE stalls/deadlock.

Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Fixes: 2298e804e96e ("drm/vmwgfx: rework to new fence interface, v2")
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.2+
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Reviewed-by: Martin Krastev <martin.krastev@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240722184313.181318-2-zack.rusin@broadcom.com
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c