]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/i915/dsb: Convert dewake_scanline to a hw scanline number earlier
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 24 Jun 2024 19:10:22 +0000 (22:10 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 29 Aug 2024 11:54:03 +0000 (14:54 +0300)
Currently we switch from out software idea of a scanline
to the hw's idea of a scanline during the commit phase in
_intel_dsb_commit(). While that is slightly easier due to
fastsets fiddling with the timings, we'll also need to
generate proper hw scanline numbers already when emitting
DSB scanline wait instructions. So this approach won't
do in the future. Switch to hw scanline numbers earlier.

Also intel_dsb_dewake_scanline() itself already makes
some assumptions about VRR that don't take into account
VRR toggling during fastsets, so technically delaying
the sw->hw conversion doesn't even help us.

The other reason for delaying the conversion was that we
are using intel_get_crtc_scanline() during intel_dsb_commit()
which gives us the current sw scanline. But this is pretty
low level stuff anyway so just using raw PIPEDSL reads seems
fine here, and that of course gives us the hw scanline
directly, reducing the need to do so many conversions.

v2: Return the non-hw scanline from intel_dsb_dewake_scanline()

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240624191032.27333-5-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_dsb.c
drivers/gpu/drm/i915/display/intel_vblank.c
drivers/gpu/drm/i915/display/intel_vblank.h

index 3453989728aa4dd6570e77811aed8503fcb9851a..54969660333a99e70dd80b30c250eefaf585c7ee 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "i915_drv.h"
 #include "i915_irq.h"
+#include "i915_reg.h"
 #include "intel_crtc.h"
 #include "intel_de.h"
 #include "intel_display_types.h"
@@ -42,7 +43,7 @@ struct intel_dsb {
         */
        unsigned int ins_start_offset;
 
-       int dewake_scanline;
+       int hw_dewake_scanline;
 };
 
 /**
@@ -374,7 +375,7 @@ static u32 dsb_error_int_en(struct intel_display *display)
 }
 
 static void _intel_dsb_commit(struct intel_dsb *dsb, u32 ctrl,
-                             int dewake_scanline)
+                             int hw_dewake_scanline)
 {
        struct intel_crtc *crtc = dsb->crtc;
        struct intel_display *display = to_intel_display(crtc->base.dev);
@@ -404,10 +405,8 @@ static void _intel_dsb_commit(struct intel_dsb *dsb, u32 ctrl,
        intel_de_write_fw(display, DSB_HEAD(pipe, dsb->id),
                          intel_dsb_buffer_ggtt_offset(&dsb->dsb_buf));
 
-       if (dewake_scanline >= 0) {
-               int diff, hw_dewake_scanline;
-
-               hw_dewake_scanline = intel_crtc_scanline_to_hw(crtc, dewake_scanline);
+       if (hw_dewake_scanline >= 0) {
+               int diff, position;
 
                intel_de_write_fw(display, DSB_PMCTRL(pipe, dsb->id),
                                  DSB_ENABLE_DEWAKE |
@@ -417,7 +416,9 @@ static void _intel_dsb_commit(struct intel_dsb *dsb, u32 ctrl,
                 * Force DEwake immediately if we're already past
                 * or close to racing past the target scanline.
                 */
-               diff = dewake_scanline - intel_get_crtc_scanline(crtc);
+               position = intel_de_read_fw(display, PIPEDSL(display, pipe)) & PIPEDSL_LINE_MASK;
+
+               diff = hw_dewake_scanline - position;
                intel_de_write_fw(display, DSB_PMCTRL_2(pipe, dsb->id),
                                  (diff >= 0 && diff < 5 ? DSB_FORCE_DEWAKE : 0) |
                                  DSB_BLOCK_DEWAKE_EXTENSION);
@@ -439,7 +440,7 @@ void intel_dsb_commit(struct intel_dsb *dsb,
 {
        _intel_dsb_commit(dsb,
                          wait_for_vblank ? DSB_WAIT_FOR_VBLANK : 0,
-                         wait_for_vblank ? dsb->dewake_scanline : -1);
+                         wait_for_vblank ? dsb->hw_dewake_scanline : -1);
 }
 
 void intel_dsb_wait(struct intel_dsb *dsb)
@@ -527,7 +528,9 @@ struct intel_dsb *intel_dsb_prepare(struct intel_atomic_state *state,
        dsb->size = size / 4; /* in dwords */
        dsb->free_pos = 0;
        dsb->ins_start_offset = 0;
-       dsb->dewake_scanline = intel_dsb_dewake_scanline(crtc_state);
+
+       dsb->hw_dewake_scanline =
+               intel_crtc_scanline_to_hw(crtc_state, intel_dsb_dewake_scanline(crtc_state));
 
        return dsb;
 
index 838b55ecb1d8a806ef2f6258542608261d6efd61..f337cde821985f7d7463590570f03ed9070711d9 100644 (file)
@@ -284,13 +284,12 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
        return (position + vtotal + crtc->scanline_offset) % vtotal;
 }
 
-int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
+int intel_crtc_scanline_to_hw(const struct intel_crtc_state *crtc_state,
+                             int scanline)
 {
-       const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
-       const struct drm_display_mode *mode = &vblank->hwmode;
-       int vtotal = intel_mode_vtotal(mode);
+       int vtotal = intel_mode_vtotal(&crtc_state->hw.adjusted_mode);
 
-       return (scanline + vtotal - crtc->scanline_offset) % vtotal;
+       return (scanline + vtotal - intel_crtc_scanline_offset(crtc_state)) % vtotal;
 }
 
 /*
index 7e526f6861e4509f83c01923d4b7290c8c5a3266..45a4a961aaabc590844e5fb4e43ec1448957283e 100644 (file)
@@ -40,6 +40,7 @@ void intel_wait_for_pipe_scanline_stopped(struct intel_crtc *crtc);
 void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc);
 void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
                                      bool vrr_enable);
-int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline);
+int intel_crtc_scanline_to_hw(const struct intel_crtc_state *crtc_state,
+                             int scanline);
 
 #endif /* __INTEL_VBLANK_H__ */