Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/dsb: Extract intel_dsb_{head,tail}()

Extract the code that calculates the DSB_HEAD/TAIL register
values into small helpers. We already have two copies of this,
and soon there will be a third.

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-4-chaitanya.kumar.borah@intel.com

authored by

Ville Syrjälä and committed by
Animesh Manna
bb3de17e d535ae99

+14 -10
+14 -10
drivers/gpu/drm/i915/display/intel_dsb.c
··· 237 237 return intel_de_read_fw(display, DSB_CTRL(pipe, dsb_id)) & DSB_STATUS_BUSY; 238 238 } 239 239 240 + static unsigned int intel_dsb_head(struct intel_dsb *dsb) 241 + { 242 + return intel_dsb_buffer_ggtt_offset(&dsb->dsb_buf); 243 + } 244 + 245 + static unsigned int intel_dsb_tail(struct intel_dsb *dsb) 246 + { 247 + return intel_dsb_buffer_ggtt_offset(&dsb->dsb_buf) + dsb->free_pos * 4; 248 + } 249 + 240 250 static void intel_dsb_ins_align(struct intel_dsb *dsb) 241 251 { 242 252 /* ··· 635 625 struct intel_display *display = to_intel_display(state->base.dev); 636 626 struct intel_crtc *crtc = dsb->crtc; 637 627 enum pipe pipe = crtc->pipe; 638 - u32 tail; 639 628 640 629 if (drm_WARN_ON(display->drm, dsb->id == chained_dsb->id)) 641 630 return; 642 631 643 632 if (!assert_dsb_tail_is_aligned(chained_dsb)) 644 633 return; 645 - 646 - tail = chained_dsb->free_pos * 4; 647 634 648 635 intel_dsb_reg_write(dsb, DSB_CTRL(pipe, chained_dsb->id), 649 636 ctrl | DSB_ENABLE); ··· 662 655 } 663 656 664 657 intel_dsb_reg_write(dsb, DSB_HEAD(pipe, chained_dsb->id), 665 - intel_dsb_buffer_ggtt_offset(&chained_dsb->dsb_buf)); 658 + intel_dsb_head(chained_dsb)); 666 659 667 660 intel_dsb_reg_write(dsb, DSB_TAIL(pipe, chained_dsb->id), 668 - intel_dsb_buffer_ggtt_offset(&chained_dsb->dsb_buf) + tail); 661 + intel_dsb_tail(chained_dsb)); 669 662 670 663 if (ctrl & DSB_WAIT_FOR_VBLANK) { 671 664 /* ··· 710 703 struct intel_crtc *crtc = dsb->crtc; 711 704 struct intel_display *display = to_intel_display(crtc->base.dev); 712 705 enum pipe pipe = crtc->pipe; 713 - u32 tail; 714 706 715 707 if (!assert_dsb_tail_is_aligned(dsb)) 716 708 return; 717 - 718 - tail = dsb->free_pos * 4; 719 709 720 710 if (is_dsb_busy(display, pipe, dsb->id)) { 721 711 drm_err(display->drm, "[CRTC:%d:%s] DSB %d is busy\n", ··· 731 727 dsb_error_int_en(display) | DSB_PROG_INT_EN); 732 728 733 729 intel_de_write_fw(display, DSB_HEAD(pipe, dsb->id), 734 - intel_dsb_buffer_ggtt_offset(&dsb->dsb_buf)); 730 + intel_dsb_head(dsb)); 735 731 736 732 if (hw_dewake_scanline >= 0) { 737 733 int diff, position; ··· 753 749 } 754 750 755 751 intel_de_write_fw(display, DSB_TAIL(pipe, dsb->id), 756 - intel_dsb_buffer_ggtt_offset(&dsb->dsb_buf) + tail); 752 + intel_dsb_tail(dsb)); 757 753 } 758 754 759 755 /**