]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/hypervdrm: Use vblank timer
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 16 Sep 2025 08:36:22 +0000 (10:36 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 1 Oct 2025 06:32:02 +0000 (08:32 +0200)
HyperV's virtual hardware does not provide vblank interrupts. Use a
vblank timer to simulate the interrupt. Rate-limits the display's
update frequency to the display-mode settings. Avoids excessive CPU
overhead with compositors that do not rate-limit their output.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
Link: https://lore.kernel.org/r/20250916083816.30275-5-tzimmermann@suse.de
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c

index 945b9482bcb3a91bc2fa0a50917881612e84216c..6e6eb1c12a6873fe64dc6d121bc786f0df5ed588 100644 (file)
@@ -19,6 +19,8 @@
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_panic.h>
 #include <drm/drm_plane.h>
+#include <drm/drm_vblank.h>
+#include <drm/drm_vblank_helper.h>
 
 #include "hyperv_drm.h"
 
@@ -111,11 +113,15 @@ static void hyperv_crtc_helper_atomic_enable(struct drm_crtc *crtc,
                                crtc_state->mode.hdisplay,
                                crtc_state->mode.vdisplay,
                                plane_state->fb->pitches[0]);
+
+       drm_crtc_vblank_on(crtc);
 }
 
 static const struct drm_crtc_helper_funcs hyperv_crtc_helper_funcs = {
        .atomic_check = drm_crtc_helper_atomic_check,
+       .atomic_flush = drm_crtc_vblank_atomic_flush,
        .atomic_enable = hyperv_crtc_helper_atomic_enable,
+       .atomic_disable = drm_crtc_vblank_atomic_disable,
 };
 
 static const struct drm_crtc_funcs hyperv_crtc_funcs = {
@@ -125,6 +131,7 @@ static const struct drm_crtc_funcs hyperv_crtc_funcs = {
        .page_flip = drm_atomic_helper_page_flip,
        .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+       DRM_CRTC_VBLANK_TIMER_FUNCS,
 };
 
 static int hyperv_plane_atomic_check(struct drm_plane *plane,
@@ -321,6 +328,10 @@ int hyperv_mode_config_init(struct hyperv_drm_device *hv)
                return ret;
        }
 
+       ret = drm_vblank_init(dev, 1);
+       if (ret)
+               return ret;
+
        drm_mode_config_reset(dev);
 
        return 0;