Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
To: Naladala Ramanaidu <ramanaidu.naladala@intel.com>,
	<igt-dev@lists.freedesktop.org>
Cc: <mitulkumar.ajitkumar.golani@intel.com>
Subject: Re: [PATCH i-g-t v5 1/3] lib/igt_kms: Add helper to return vblank timestamp and sequence
Date: Thu, 27 Aug 2026 12:24:14 +0530	[thread overview]
Message-ID: <c492af94-cac9-4e0e-b737-68ce25a36733@intel.com> (raw)
In-Reply-To: <20260825183359.2791891-2-ramanaidu.naladala@intel.com>



On 8/26/2026 12:03 AM, Naladala Ramanaidu wrote:
> Add a utility that waits for the next vertical blanking interval on a
> specified CRTC and returns the timestamp and sequence number reported
> by the kernel for that event.
> 
> Several tests need access not only to vblank synchronization but also
> to the exact timing information associated with the completed vblank.
> Having a common helper avoids repeating the same wait and timestamp
> extraction.
> 
> Assisted-by: GitHub Copilot:Claude Opus 4.6
> Signed-off-by: Naladala Ramanaidu <ramanaidu.naladala@intel.com>
> ---
>   lib/igt_kms.c | 25 +++++++++++++++++++++++++
>   lib/igt_kms.h |  1 +
>   2 files changed, 26 insertions(+)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 42cc7c3bd..cd4783db9 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -5876,6 +5876,31 @@ void igt_wait_for_vblank_count(igt_crtc_t *crtc, int count)
>   	igt_assert(__igt_vblank_wait(crtc->display->drm_fd, crtc->crtc_index, count) == 0);
>   }
>   
> +/**
> + * igt_wait_for_vblank_ts_seq:
> + * @crtc: the CRTC.
> + * @ts_ns: returns the vblank timestamp in nanoseconds.
> + * @seq: returns the vblank sequence number.

  * @ts_ns: returns the vblank timestamp in nanoseconds, can be NULL.
  * @seq: returns the vblank sequence number, can be NULL.

> + *
> + * Waits for the next vertical blank interval on @crtc and hands back the
> + * timestamp and the sequence number.
> + */
> +void igt_wait_for_vblank_ts_seq(igt_crtc_t *crtc, uint64_t *ts_ns, unsigned int *seq)
> +{
> +	drmVBlank wait_vbl = {
> +		.request.type = DRM_VBLANK_RELATIVE | igt_crtc_get_vbl_flag(crtc),
> +		.request.sequence = 1,
> +	};
> +
> +	do_or_die(drmWaitVBlank(crtc->display->drm_fd, &wait_vbl));
> +
> +	if (ts_ns)
> +		*ts_ns = wait_vbl.reply.tval_sec * NSEC_PER_SEC +
> +			 wait_vbl.reply.tval_usec * NSEC_PER_USEC;
> +	if (seq)
> +		*seq = wait_vbl.reply.sequence;
> +}
> +
>   /**
>    * igt_wait_for_vblank:
>    * @drm_fd: A drm file descriptor
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 8d4d14847..8d1928af6 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -652,6 +652,7 @@ static inline bool igt_plane_has_rotation(igt_plane_t *plane, igt_rotation_t rot
>   const char *igt_plane_rotation_name(igt_rotation_t rotation);
>   
>   void igt_wait_for_vblank(igt_crtc_t *crtc);
> +void igt_wait_for_vblank_ts_seq(igt_crtc_t *crtc, uint64_t *ts_ns, unsigned int *seq);
>   void igt_wait_for_vblank_count(igt_crtc_t *crtc, int count);

nit: Add in the same sequence as in the c file.

With that, LGTM

Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>

You can now replace the local function in kms_async_flip. But that is 
for another patch.


>   
>   /**


  reply	other threads:[~2026-08-27  6:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 18:33 [PATCH i-g-t v5 0/3] Add CMRR subtests Naladala Ramanaidu
2026-08-25 18:33 ` [PATCH i-g-t v5 1/3] lib/igt_kms: Add helper to return vblank timestamp and sequence Naladala Ramanaidu
2026-08-27  6:54   ` Borah, Chaitanya Kumar [this message]
2026-08-31  9:02   ` Jani Nikula
2026-08-25 18:33 ` [PATCH i-g-t v5 2/3] lib/igt_vrr:Add VRR helper library for display refresh rate testing Naladala Ramanaidu
2026-08-26 12:03   ` Kamil Konieczny
2026-09-07 14:28     ` Naladala, Ramanaidu
2026-08-27  6:54   ` Borah, Chaitanya Kumar
2026-09-07 14:34     ` Naladala, Ramanaidu
2026-08-25 18:33 ` [PATCH i-g-t v5 3/3] tests/kms_vrr: add CMRR fixed and video mode subtests Naladala Ramanaidu
2026-08-27  6:54   ` Borah, Chaitanya Kumar
2026-08-25 19:39 ` ✓ Xe.CI.BAT: success for Add CMRR subtests (rev5) Patchwork
2026-08-25 19:42 ` ✓ i915.CI.BAT: " Patchwork
2026-08-25 21:54 ` ✗ i915.CI.Full: failure " Patchwork
2026-08-25 23:43 ` ✗ Xe.CI.FULL: " Patchwork

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=c492af94-cac9-4e0e-b737-68ce25a36733@intel.com \
    --to=chaitanya.kumar.borah@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=mitulkumar.ajitkumar.golani@intel.com \
    --cc=ramanaidu.naladala@intel.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