]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915: Move initial plane vblank wait into display code
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 10 Apr 2026 15:04:44 +0000 (18:04 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 15 Apr 2026 09:37:51 +0000 (12:37 +0300)
The initial plane vblank wait operates on display registers,
so it really belongs in the display code proper. Move it there.

We can use intel_parent_irq_enabled() to determine if we can
rely on interrupts or not.

On average we should end up waiting half a frame here, so the
polling interval can be fairly long. 1 ms (which actually
makes poll_timeout_us() use ~250-1000 usec) seems good enough
to me.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/20260410150449.9699-6-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_initial_plane.c
drivers/gpu/drm/i915/i915_initial_plane.c
drivers/gpu/drm/xe/display/xe_initial_plane.c
include/drm/intel/display_parent_interface.h

index 911d67dceba92b92d0c2fb8bb6ca37b3f3ee558e..74e10d34c63cc4aa4b9e34d40d21f214cbc63291 100644 (file)
@@ -1,14 +1,20 @@
 // SPDX-License-Identifier: MIT
 /* Copyright © 2025 Intel Corporation */
 
+#include <linux/iopoll.h>
+
 #include <drm/drm_print.h>
 #include <drm/intel/display_parent_interface.h>
 
+#include "intel_crtc.h"
+#include "intel_de.h"
 #include "intel_display_core.h"
+#include "intel_display_regs.h"
 #include "intel_display_types.h"
 #include "intel_fb.h"
 #include "intel_frontbuffer.h"
 #include "intel_initial_plane.h"
+#include "intel_parent.h"
 #include "intel_plane.h"
 
 struct intel_initial_plane_configs {
@@ -18,8 +24,22 @@ struct intel_initial_plane_configs {
 void intel_initial_plane_vblank_wait(struct intel_crtc *crtc)
 {
        struct intel_display *display = to_intel_display(crtc);
+       u32 start_ts, end_ts;
+       int ret;
 
-       display->parent->initial_plane->vblank_wait(&crtc->base);
+       /* xe doesn't have interrupts enabled this early */
+       if (intel_parent_irq_enabled(display)) {
+               intel_crtc_wait_for_next_vblank(crtc);
+               return;
+       }
+
+       start_ts = intel_de_read(display, PIPE_FRMTMSTMP(crtc->pipe));
+
+       ret = poll_timeout_us(end_ts = intel_de_read(display, PIPE_FRMTMSTMP(crtc->pipe)),
+                             end_ts != start_ts, 1000, 40 * 1000, false);
+       if (ret)
+               drm_warn(display->drm, "[CRTC:%d:%s] early vblank wait timed out\n",
+                        crtc->base.base.id, crtc->base.name);
 }
 
 static const struct intel_plane_state *
index 5cb1adde67b6fcbaae07db8478943a7671ee0be8..7775e657271b0abd568b38162be9f5adf6c36893 100644 (file)
 #include "i915_drv.h"
 #include "i915_initial_plane.h"
 
-static void i915_initial_plane_vblank_wait(struct drm_crtc *crtc)
-{
-       intel_crtc_wait_for_next_vblank(to_intel_crtc(crtc));
-}
-
 static enum intel_memory_type
 initial_plane_memory_type(struct drm_i915_private *i915)
 {
@@ -282,7 +277,6 @@ static void i915_plane_config_fini(struct intel_initial_plane_config *plane_conf
 }
 
 const struct intel_display_initial_plane_interface i915_display_initial_plane_interface = {
-       .vblank_wait = i915_initial_plane_vblank_wait,
        .alloc_obj = i915_alloc_initial_plane_obj,
        .setup = i915_initial_plane_setup,
        .config_fini = i915_plane_config_fini,
index 8f2d0244c03f70de588d8e2344aef0c090fb4bb1..37bd15d12169deff412bdfdb5236bb3d87771481 100644 (file)
@@ -7,8 +7,6 @@
 
 #include "regs/xe_gtt_defs.h"
 
-#include "intel_crtc.h"
-#include "intel_display_regs.h"
 #include "intel_display_types.h"
 #include "intel_fb.h"
 #include "intel_fb_pin.h"
 #include "xe_mmio.h"
 #include "xe_vram_types.h"
 
-/* Early xe has no irq */
-static void xe_initial_plane_vblank_wait(struct drm_crtc *_crtc)
-{
-       struct intel_crtc *crtc = to_intel_crtc(_crtc);
-       struct xe_device *xe = to_xe_device(crtc->base.dev);
-       struct xe_reg pipe_frmtmstmp = XE_REG(i915_mmio_reg_offset(PIPE_FRMTMSTMP(crtc->pipe)));
-       u32 timestamp;
-       int ret;
-
-       timestamp = xe_mmio_read32(xe_root_tile_mmio(xe), pipe_frmtmstmp);
-
-       ret = xe_mmio_wait32_not(xe_root_tile_mmio(xe), pipe_frmtmstmp, ~0U, timestamp, 40000U, &timestamp, false);
-       if (ret < 0)
-               drm_warn(&xe->drm, "waiting for early vblank failed with %i\n", ret);
-}
-
 static struct xe_bo *
 initial_plane_bo(struct xe_device *xe,
                 struct intel_initial_plane_config *plane_config)
@@ -172,7 +154,6 @@ static void xe_plane_config_fini(struct intel_initial_plane_config *plane_config
 }
 
 const struct intel_display_initial_plane_interface xe_display_initial_plane_interface = {
-       .vblank_wait = xe_initial_plane_vblank_wait,
        .alloc_obj = xe_alloc_initial_plane_obj,
        .setup = xe_initial_plane_setup,
        .config_fini = xe_plane_config_fini,
index 9041897c772ed5ad97cde4636e07827bf8934f7d..b513e3f9924d3ce8bd1c6c2e9a7795ebfb9cccbd 100644 (file)
@@ -8,7 +8,6 @@
 
 enum vlv_iosf_sb_unit;
 struct dma_fence;
-struct drm_crtc;
 struct drm_device;
 struct drm_file;
 struct drm_framebuffer;
@@ -87,7 +86,6 @@ struct intel_display_hdcp_interface {
 };
 
 struct intel_display_initial_plane_interface {
-       void (*vblank_wait)(struct drm_crtc *crtc);
        struct drm_gem_object *(*alloc_obj)(struct drm_device *drm, struct intel_initial_plane_config *plane_config);
        int (*setup)(struct drm_plane_state *plane_state, struct intel_initial_plane_config *plane_config,
                     struct drm_framebuffer *fb, struct i915_vma *vma);