Skip to content

Commit 354c2d3

Browse files
committed
drm: damage_helper: Fix race checking plane->state->fb
Since the dirtyfb ioctl doesn't give us any hints as to which plane is scanning out the fb it's marking as damaged, we need to loop through planes to find it. Currently we just reach into plane state and check, but that can race with another commit changing the fb out from under us. This patch locks the plane before checking the fb and will release the lock if the plane is not displaying the dirty fb. Fixes: b9fc5e0 ("drm: Add helper to implement legacy dirtyfb") Cc: Rob Clark <[email protected]> Cc: Deepak Rawat <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Thomas Hellstrom <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: [email protected] Cc: <[email protected]> # v5.0+ Reported-by: Daniel Vetter <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Sean Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 9a197c8 commit 354c2d3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/gpu/drm/drm_damage_helper.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,14 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
212212
drm_for_each_plane(plane, fb->dev) {
213213
struct drm_plane_state *plane_state;
214214

215-
if (plane->state->fb != fb)
215+
ret = drm_modeset_lock(&plane->mutex, state->acquire_ctx);
216+
if (ret)
217+
goto out;
218+
219+
if (plane->state->fb != fb) {
220+
drm_modeset_unlock(&plane->mutex);
216221
continue;
222+
}
217223

218224
plane_state = drm_atomic_get_plane_state(state, plane);
219225
if (IS_ERR(plane_state)) {

0 commit comments

Comments
 (0)