]> www.infradead.org Git - users/dwmw2/linux.git/commit
drm/vmwgfx: Prevent unmapping active read buffers
authorZack Rusin <zack.rusin@broadcom.com>
Fri, 16 Aug 2024 18:32:05 +0000 (14:32 -0400)
committerZack Rusin <zack.rusin@broadcom.com>
Mon, 26 Aug 2024 04:19:40 +0000 (00:19 -0400)
commitaba07b9a0587f50e5d3346eaa19019cf3f86c0ea
treeb40756c01fc30a00746e30ab5ee6324b5a280a07
parentc358a809cb58af944d496944391a240e02f5837a
drm/vmwgfx: Prevent unmapping active read buffers

The kms paths keep a persistent map active to read and compare the cursor
buffer. These maps can race with each other in simple scenario where:
a) buffer "a" mapped for update
b) buffer "a" mapped for compare
c) do the compare
d) unmap "a" for compare
e) update the cursor
f) unmap "a" for update
At step "e" the buffer has been unmapped and the read contents is bogus.

Prevent unmapping of active read buffers by simply keeping a count of
how many paths have currently active maps and unmap only when the count
reaches 0.

Fixes: 485d98d472d5 ("drm/vmwgfx: Add support for CursorMob and CursorBypass 4")
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v5.19+
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240816183332.31961-2-zack.rusin@broadcom.com
Reviewed-by: Martin Krastev <martin.krastev@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h