From: Thomas Zimmermann <tzimmermann@suse.de>
To: zack.rusin@broadcom.com, bcm-kernel-feedback-list@broadcom.com,
maarten.lankhorst@linux.intel.com, mripard@kernel.org
Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v2 2/3] drm/vmwgfx: Move vblank handling into separate helper
Date: Mon, 27 Apr 2026 17:00:39 +0200 [thread overview]
Message-ID: <20260427150250.699768-3-tzimmermann@suse.de> (raw)
In-Reply-To: <20260427150250.699768-1-tzimmermann@suse.de>
Decouple vblank handling from the underlying hrtimer. This will be
helpful for replacing vmwgfx's vblank timer with DRM's common
implementation.
The new helper vmw_vkms_handle_vblank_timeout() can later be used as
callback for DRM's handle_vblank call as-is. The helper also keeps the
current semantics for restarting the timer. It returns true to restart
the next vblank timeout even if it could not acquire vmwgfx's vblank
lock.
The remaining code in vmw_vkms_vblank_simulate() will be replaced by
the DRM implementation in a later patch.
v2:
- clarify return-value semantics in commit message (Zack)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c | 37 +++++++++++++++++++---------
drivers/gpu/drm/vmwgfx/vmwgfx_vkms.h | 1 +
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
index 7862f6972512..15439ddd4f22 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
@@ -157,27 +157,19 @@ crc_generate_worker(struct work_struct *work)
drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
}
-static enum hrtimer_restart
-vmw_vkms_vblank_simulate(struct hrtimer *timer)
+bool
+vmw_vkms_handle_vblank_timeout(struct drm_crtc *crtc)
{
- struct vmw_display_unit *du = container_of(timer, struct vmw_display_unit, vkms.timer);
- struct drm_crtc *crtc = &du->crtc;
+ struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
struct vmw_private *vmw = vmw_priv(crtc->dev);
bool has_surface = false;
- u64 ret_overrun;
bool locked, ret;
- ret_overrun = hrtimer_forward_now(&du->vkms.timer,
- du->vkms.period_ns);
- if (ret_overrun != 1)
- drm_dbg_driver(crtc->dev, "vblank timer missed %lld frames.\n",
- ret_overrun - 1);
-
locked = vmw_vkms_vblank_trylock(crtc);
ret = drm_crtc_handle_vblank(crtc);
WARN_ON(!ret);
if (!locked)
- return HRTIMER_RESTART;
+ return true;
has_surface = du->vkms.surface != NULL;
vmw_vkms_unlock(crtc);
@@ -200,6 +192,27 @@ vmw_vkms_vblank_simulate(struct hrtimer *timer)
drm_dbg_driver(crtc->dev, "Composer worker already queued\n");
}
+ return true;
+}
+
+static enum hrtimer_restart
+vmw_vkms_vblank_simulate(struct hrtimer *timer)
+{
+ struct vmw_display_unit *du = container_of(timer, struct vmw_display_unit, vkms.timer);
+ struct drm_crtc *crtc = &du->crtc;
+ u64 ret_overrun;
+ bool success;
+
+ ret_overrun = hrtimer_forward_now(&du->vkms.timer,
+ du->vkms.period_ns);
+ if (ret_overrun != 1)
+ drm_dbg_driver(crtc->dev, "vblank timer missed %lld frames.\n",
+ ret_overrun - 1);
+
+ success = vmw_vkms_handle_vblank_timeout(crtc);
+ if (!success)
+ return HRTIMER_NORESTART;
+
return HRTIMER_RESTART;
}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.h
index 69ddd33a8444..0b6bbf7c4487 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.h
@@ -45,6 +45,7 @@ bool vmw_vkms_modeset_lock_relaxed(struct drm_crtc *crtc);
bool vmw_vkms_vblank_trylock(struct drm_crtc *crtc);
void vmw_vkms_unlock(struct drm_crtc *crtc);
+bool vmw_vkms_handle_vblank_timeout(struct drm_crtc *crtc);
bool vmw_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
int *max_error,
ktime_t *vblank_time,
--
2.54.0
next prev parent reply other threads:[~2026-04-27 15:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 15:00 [PATCH v2 0/3] drm/vmwgfx: Use DRM's vblank timer Thomas Zimmermann
2026-04-27 15:00 ` [PATCH v2 1/3] drm/vmwgfx: Determine lock-waiting timeout from vblank state Thomas Zimmermann
2026-04-27 15:00 ` Thomas Zimmermann [this message]
2026-04-27 15:00 ` [PATCH v2 3/3] drm/vmwgfx: Convert to DRM vblank timers Thomas Zimmermann
2026-04-28 5:54 ` [PATCH v2 0/3] drm/vmwgfx: Use DRM's vblank timer Zack Rusin
2026-04-28 6:08 ` Thomas Zimmermann
2026-05-04 12:21 ` Thomas Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260427150250.699768-3-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=zack.rusin@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox