[PATCH 5/5] drm/i915: Synchronize plane destroy and vblank unpin worker

Chaitanya Kumar Borah chaitanya.kumar.borah at intel.com
Tue Mar 5 15:57:24 UTC 2024


Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
---
 drivers/gpu/drm/i915/display/intel_atomic_plane.c  | 2 ++
 drivers/gpu/drm/i915/display/intel_crtc.c          | 4 +++-
 drivers/gpu/drm/i915/display/intel_cursor.c        | 4 ++++
 drivers/gpu/drm/i915/display/intel_display_types.h | 2 ++
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index a585e4aca309..a8b5beb77ac1 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1195,6 +1195,8 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
 		 * free is done from vblank worker
 		 */
 		memset(&state->base.planes[i], 0, sizeof(*state->base.planes));
+		if (state->base.legacy_cursor_update)
+			complete_all(&old_plane_state->clean_up_done);
 		return;
 	}
 
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index a7fb7f5ace07..debd573dc020 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -508,9 +508,11 @@ void intel_pipe_update_start(struct intel_atomic_state *state,
 
 		for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state,
 						     new_plane_state, i) {
-			if (old_plane_state->uapi.crtc == &crtc->base)
+			if (old_plane_state->uapi.crtc == &crtc->base) {
+				init_completion(&old_plane_state->clean_up_done);
 				intel_plane_init_cursor_vblank_work(old_plane_state,
 								    new_plane_state);
+			}
 		}
 	}
 
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index 32f9bb753331..35c7713f6890 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -661,6 +661,8 @@ void intel_cursor_unpin_work(struct kthread_work *base)
 		container_of(work, typeof(*plane_state), unpin_work);
 	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
 
+	wait_for_completion(&plane_state->clean_up_done);
+
 	intel_plane_unpin_fb(plane_state);
 	intel_cursor_destroy_state(&plane->base, &plane_state->uapi);
 }
@@ -808,6 +810,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
 	intel_psr_unlock(crtc_state);
 
+	init_completion(&old_plane_state->clean_up_done);
 	if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
 		drm_vblank_work_init(&old_plane_state->unpin_work, &crtc->base,
 				     intel_cursor_unpin_work);
@@ -828,6 +831,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 		intel_plane_destroy_state(&plane->base, &new_plane_state->uapi);
 	else if (old_plane_state)
 		intel_plane_destroy_state(&plane->base, &old_plane_state->uapi);
+	complete_all(&old_plane_state->clean_up_done);
 	return ret;
 
 slow:
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 9b7113cd86fc..00a4cff2b0e4 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -714,6 +714,8 @@ struct intel_plane_state {
 		enum drm_scaling_filter scaling_filter;
 	} hw;
 
+	struct completion clean_up_done;
+
 	struct i915_vma *ggtt_vma;
 	struct i915_vma *dpt_vma;
 	unsigned long flags;
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list