[PATCH 4/4] drm/i915: do not destroy plane state if cursor unpin worker is scheduled
Chaitanya Kumar Borah
chaitanya.kumar.borah at intel.com
Thu Jan 11 04:13:46 UTC 2024
Don't destroy plane state if cursor unpin worker is scheduled
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
---
.../gpu/drm/i915/display/intel_atomic_plane.c | 40 ++++++++++++++++++-
.../gpu/drm/i915/display/intel_atomic_plane.h | 2 +
drivers/gpu/drm/i915/display/intel_crtc.c | 5 ++-
drivers/gpu/drm/i915/display/intel_cursor.c | 13 +++++-
4 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index cb4153ca1867..897175e60eb7 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -135,6 +135,37 @@ intel_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state)
{
struct intel_plane_state *plane_state = to_intel_plane_state(state);
+ struct intel_plane *intel_plane = to_intel_plane(plane);
+
+ printk(KERN_DEBUG"Exodus: intel_plane_destroy_state plane id %d", intel_plane->id);
+ /*
+ if(intel_plane->rmfb_flag != true)
+ return;
+
+ intel_plane->rmfb_flag = false;
+ */
+ if(plane_state->unpin_work.vblank) {
+ printk(KERN_DEBUG"Exodus: intel_plane_destroy_state vblank work pending! don't destroy %p", plane_state);
+ return;
+ }
+
+ drm_WARN_ON(plane->dev, plane_state->ggtt_vma);
+ drm_WARN_ON(plane->dev, plane_state->dpt_vma);
+
+ __drm_atomic_helper_plane_destroy_state(&plane_state->uapi);
+ if (plane_state->hw.fb)
+ drm_framebuffer_put(plane_state->hw.fb);
+ kfree(plane_state);
+}
+
+void
+intel_plane_destroy_state_custom(struct drm_plane *plane,
+ struct drm_plane_state *state)
+{
+ struct intel_plane_state *plane_state = to_intel_plane_state(state);
+ struct intel_plane *intel_plane = to_intel_plane(plane);
+
+ printk(KERN_DEBUG"Exodus: intel_plane_destroy_state_CUSTOM plane id %d", intel_plane->id);
drm_WARN_ON(plane->dev, plane_state->ggtt_vma);
drm_WARN_ON(plane->dev, plane_state->dpt_vma);
@@ -1157,7 +1188,13 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
struct intel_atomic_state *state =
to_intel_atomic_state(old_plane_state->uapi.state);
struct drm_i915_private *dev_priv = to_i915(plane->dev);
- struct drm_i915_gem_object *obj = intel_fb_obj(old_plane_state->hw.fb);
+ struct drm_i915_gem_object *obj = NULL;
+// struct drm_i915_gem_object *obj = intel_fb_obj(old_plane_state->hw.fb);
+
+
+ if(!old_plane_state->unpin_work.vblank) {
+ obj = intel_fb_obj(old_plane_state->hw.fb);
+ }
if (!obj)
return;
@@ -1199,6 +1236,7 @@ void intel_plane_init_cursor_vblank_work(struct intel_plane_state *old_plane_sta
old_plane_state->ggtt_vma == new_plane_state->ggtt_vma)
return;
+ printk(KERN_DEBUG"Exodus: intel_pipe_update_end drm_vblank_work_schedule scheduled old_plane_state %p new_plane_state %p\n", old_plane_state, new_plane_state);
drm_vblank_work_init(&old_plane_state->unpin_work, old_plane_state->uapi.crtc,
intel_cursor_unpin_work);
}
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 5a897cf6fa02..24251cc91def 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -45,6 +45,8 @@ void intel_plane_free(struct intel_plane *plane);
struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
void intel_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state);
+void intel_plane_destroy_state_custom(struct drm_plane *plane,
+ struct drm_plane_state *state);
void intel_crtc_planes_update_noarm(struct intel_atomic_state *state,
struct intel_crtc *crtc);
void intel_crtc_planes_update_arm(struct intel_atomic_state *state,
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index 13fa7423b029..1934f1c41cc2 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -573,9 +573,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) {
+ printk(KERN_DEBUG"Exodus: cursor worked initialized in pipe update start old %p new %p", old_plane_state, new_plane_state);
intel_plane_init_cursor_vblank_work(old_plane_state,
new_plane_state);
+ }
}
}
@@ -726,6 +728,7 @@ void intel_pipe_update_end(struct intel_atomic_state *state,
* event outside of the critical section - the spinlock might spin for a
* while ... */
if (intel_crtc_needs_vblank_work(new_crtc_state)) {
+ printk(KERN_DEBUG"Exodus: intel_pipe_update_end drm_vblank_work_schedule scheduled \n");
drm_vblank_work_schedule(&new_crtc_state->vblank_work,
drm_crtc_accurate_vblank_count(&crtc->base) + 1,
false);
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index 2a1e7e03236c..43ea4e76dba3 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -659,9 +659,14 @@ void intel_cursor_unpin_work(struct kthread_work *base)
struct intel_plane_state *plane_state =
container_of(work, typeof(*plane_state), unpin_work);
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
+ struct drm_framebuffer *fb = plane_state->hw.fb;
+
+ printk(KERN_DEBUG"Exodus: intel_cursor_unpin_work %p %p\n", plane_state, fb);
intel_plane_unpin_fb(plane_state);
- intel_plane_destroy_state(&plane->base, &plane_state->uapi);
+
+ intel_plane_destroy_state_custom(&plane->base, &plane_state->uapi);
+ printk(KERN_DEBUG"Exodus: intel_cursor_unpin_work done %p\n", plane_state);
}
static int
@@ -721,6 +726,8 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
!old_plane_state->uapi.fb != !fb)
goto slow;
+ printk(KERN_DEBUG"Exodus: intel_legacy_cursor_update: crtc_state %p old_plane_state %p fb %p\n", crtc_state, old_plane_state, fb);
+
new_plane_state = to_intel_plane_state(intel_plane_duplicate_state(&plane->base));
if (!new_plane_state)
return -ENOMEM;
@@ -749,6 +756,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (ret)
goto out_free;
+ /* This is where ggtt_vma is assigned to new_plane_state */
ret = intel_plane_pin_fb(new_plane_state);
if (ret)
goto out_free;
@@ -791,7 +799,10 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
local_irq_enable();
+
if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
+ printk(KERN_DEBUG"Exodus: intel_legacy_cursor_update: crtc_state %p drm_vblank_work_schedule scheduled %p\n", crtc_state, old_plane_state);
+
drm_vblank_work_init(&old_plane_state->unpin_work, &crtc->base,
intel_cursor_unpin_work);
--
2.25.1
More information about the Intel-gfx-trybot
mailing list