Instead of relying on the plane_state->uapi.state back-pointer to reach
the intel_atomic_state inside intel_plane_color_copy_uapi_to_hw_state(),
accept the intel_atomic_state as an argument to make the dependency
explicit.

Update intel_plane_copy_uapi_to_hw_state() and its callers accordingly.
Call sites that do not have an atomic state available (e.g. legacy cursor
update and initial plane setup) pass NULL.

In such cases, skip color pipeline programming as there is no
corresponding atomic colorop state to consume.

v2:
 - Rebase

Suggested-by: Ville Syrjälä <[email protected]>
Assisted-by: GitHub-Copilot:Claude-Sonnet-4.6
Signed-off-by: Chaitanya Kumar Borah <[email protected]>
Reviewed-by: Uma Shankar <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_cursor.c   |  2 +-
 .../drm/i915/display/intel_initial_plane.c    |  2 +-
 drivers/gpu/drm/i915/display/intel_plane.c    | 22 +++++++++++--------
 drivers/gpu/drm/i915/display/intel_plane.h    |  3 ++-
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 52347668f27d..88384dea868b 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -876,7 +876,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
        new_plane_state->uapi.crtc_w = crtc_w;
        new_plane_state->uapi.crtc_h = crtc_h;
 
-       intel_plane_copy_uapi_to_hw_state(new_plane_state, new_plane_state, 
crtc);
+       intel_plane_copy_uapi_to_hw_state(NULL, new_plane_state, 
new_plane_state, crtc);
 
        ret = intel_plane_atomic_check_with_state(crtc_state, new_crtc_state,
                                                  old_plane_state, 
new_plane_state);
diff --git a/drivers/gpu/drm/i915/display/intel_initial_plane.c 
b/drivers/gpu/drm/i915/display/intel_initial_plane.c
index 6aa253678ec9..e414b5d1085c 100644
--- a/drivers/gpu/drm/i915/display/intel_initial_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_initial_plane.c
@@ -170,7 +170,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,
        drm_framebuffer_get(fb);
 
        plane_state->uapi.crtc = &crtc->base;
-       intel_plane_copy_uapi_to_hw_state(plane_state, plane_state, crtc);
+       intel_plane_copy_uapi_to_hw_state(NULL, plane_state, plane_state, crtc);
 
        atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits);
 
diff --git a/drivers/gpu/drm/i915/display/intel_plane.c 
b/drivers/gpu/drm/i915/display/intel_plane.c
index f55a6a2f7dd1..974cb671e1b9 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_plane.c
@@ -381,25 +381,27 @@ intel_plane_colorop_replace_blob(struct intel_plane_state 
*plane_state,
 }
 
 static void
-intel_plane_color_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
+intel_plane_color_copy_uapi_to_hw_state(struct intel_atomic_state *state,
+                                       struct intel_plane_state *plane_state,
                                        const struct intel_plane_state 
*from_plane_state,
                                        struct intel_crtc *crtc)
 {
        struct drm_colorop *iter_colorop, *colorop;
        struct drm_colorop_state *new_colorop_state;
-       struct drm_atomic_commit *state = plane_state->uapi.state;
        struct intel_colorop *intel_colorop;
        struct drm_property_blob *blob;
-       struct intel_atomic_state *intel_atomic_state = 
to_intel_atomic_state(state);
-       struct intel_crtc_state *new_crtc_state = intel_atomic_state ?
-               intel_atomic_get_new_crtc_state(intel_atomic_state, crtc) : 
NULL;
+       struct intel_crtc_state *new_crtc_state = state ?
+               intel_atomic_get_new_crtc_state(state, crtc) : NULL;
        bool changed = false;
        int i = 0;
 
+       if (!state)
+               return;
+
        iter_colorop = from_plane_state->uapi.color_pipeline;
 
        while (iter_colorop) {
-               for_each_new_colorop_in_state(state, colorop, 
new_colorop_state, i) {
+               for_each_new_colorop_in_state(&state->base, colorop, 
new_colorop_state, i) {
                        if (new_colorop_state->colorop == iter_colorop) {
                                blob = new_colorop_state->bypass ? NULL : 
new_colorop_state->data;
                                intel_colorop = to_intel_colorop(colorop);
@@ -415,7 +417,8 @@ intel_plane_color_copy_uapi_to_hw_state(struct 
intel_plane_state *plane_state,
                new_crtc_state->plane_color_changed = true;
 }
 
-void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
+void intel_plane_copy_uapi_to_hw_state(struct intel_atomic_state *state,
+                                      struct intel_plane_state *plane_state,
                                       const struct intel_plane_state 
*from_plane_state,
                                       struct intel_crtc *crtc)
 {
@@ -444,7 +447,7 @@ void intel_plane_copy_uapi_to_hw_state(struct 
intel_plane_state *plane_state,
        plane_state->uapi.src = drm_plane_state_src(&from_plane_state->uapi);
        plane_state->uapi.dst = drm_plane_state_dest(&from_plane_state->uapi);
 
-       intel_plane_color_copy_uapi_to_hw_state(plane_state, from_plane_state, 
crtc);
+       intel_plane_color_copy_uapi_to_hw_state(state, plane_state, 
from_plane_state, crtc);
 }
 
 void intel_plane_copy_hw_state(struct intel_plane_state *plane_state,
@@ -841,7 +844,8 @@ static int plane_atomic_check(struct intel_atomic_state 
*state,
                                           old_primary_crtc_plane_state,
                                           new_primary_crtc_plane_state);
 
-       intel_plane_copy_uapi_to_hw_state(new_plane_state,
+       intel_plane_copy_uapi_to_hw_state(state,
+                                         new_plane_state,
                                          new_primary_crtc_plane_state,
                                          crtc);
 
diff --git a/drivers/gpu/drm/i915/display/intel_plane.h 
b/drivers/gpu/drm/i915/display/intel_plane.h
index a6338bba72d9..87c79a644052 100644
--- a/drivers/gpu/drm/i915/display/intel_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_plane.h
@@ -35,7 +35,8 @@ unsigned int intel_plane_pixel_rate(const struct 
intel_crtc_state *crtc_state,
 unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
                                   const struct intel_plane_state *plane_state,
                                   int color_plane);
-void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
+void intel_plane_copy_uapi_to_hw_state(struct intel_atomic_state *state,
+                                      struct intel_plane_state *plane_state,
                                       const struct intel_plane_state 
*from_plane_state,
                                       struct intel_crtc *crtc);
 void intel_plane_copy_hw_state(struct intel_plane_state *plane_state,
-- 
2.25.1

Reply via email to