drm/i915/dsb: Extract assert_dsb_tail_is_aligned()

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
This commit is contained in:
Ville Syrjälä 2025-05-23 11:50:32 +05:30 committed by Animesh Manna
parent 55f233aaad
commit d535ae997d

View 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);