]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/i915/dsb: Extract assert_dsb_tail_is_aligned()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 23 May 2025 06:20:32 +0000 (11:50 +0530)
committerAnimesh Manna <animesh.manna@intel.com>
Mon, 26 May 2025 07:48:15 +0000 (13:18 +0530)
Extract the DSB tail alignment checks into helper. We already
have two uses of this, and soon we'll get a third.

v2: s/soo/soon in commit message (Animesh)

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
Reviewed-by: Animesh Manna <animesh.manna@intel.com>
Signed-off-by: Animesh Manna <animesh.manna@intel.com>
Link: https://lore.kernel.org/r/20250523062041.166468-3-chaitanya.kumar.borah@intel.com
drivers/gpu/drm/i915/display/intel_dsb.c

index d6641cfe80617134ab2f338d3a39ae81bdc20877..f2574e6812d185e04c2ae8f1946c8d88ccc2ce93 100644 (file)
@@ -204,6 +204,15 @@ static bool assert_dsb_has_room(struct intel_dsb *dsb)
                         crtc->base.base.id, crtc->base.name, dsb->id);
 }
 
+static bool assert_dsb_tail_is_aligned(struct intel_dsb *dsb)
+{
+       struct intel_crtc *crtc = dsb->crtc;
+       struct intel_display *display = to_intel_display(crtc->base.dev);
+
+       return !drm_WARN_ON(display->drm,
+                           !IS_ALIGNED(dsb->free_pos * 4, CACHELINE_BYTES));
+}
+
 static void intel_dsb_dump(struct intel_dsb *dsb)
 {
        struct intel_crtc *crtc = dsb->crtc;
@@ -621,10 +630,11 @@ static void _intel_dsb_chain(struct intel_atomic_state *state,
        if (drm_WARN_ON(display->drm, dsb->id == chained_dsb->id))
                return;
 
-       tail = chained_dsb->free_pos * 4;
-       if (drm_WARN_ON(display->drm, !IS_ALIGNED(tail, CACHELINE_BYTES)))
+       if (!assert_dsb_tail_is_aligned(chained_dsb))
                return;
 
+       tail = chained_dsb->free_pos * 4;
+
        intel_dsb_reg_write(dsb, DSB_CTRL(pipe, chained_dsb->id),
                            ctrl | DSB_ENABLE);
 
@@ -695,10 +705,11 @@ static void _intel_dsb_commit(struct intel_dsb *dsb, u32 ctrl,
        enum pipe pipe = crtc->pipe;
        u32 tail;
 
-       tail = dsb->free_pos * 4;
-       if (drm_WARN_ON(display->drm, !IS_ALIGNED(tail, CACHELINE_BYTES)))
+       if (!assert_dsb_tail_is_aligned(dsb))
                return;
 
+       tail = dsb->free_pos * 4;
+
        if (is_dsb_busy(display, pipe, dsb->id)) {
                drm_err(display->drm, "[CRTC:%d:%s] DSB %d is busy\n",
                        crtc->base.base.id, crtc->base.name, dsb->id);