Re: [PATCH i-g-t 5/8] lib/kms: Simplify kmstest_get_vbl_flag()

Jani Nikula
2026-01-13T14:34:01Z

On Tue, 13 Jan 2026, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Simplify kmstest_get_vbl_flag() by observing that:
> - '0 << DRM_VBLANK_HIGH_CRTC_SHIFT == 0' so we don't
> have to have special treatment for crtc_offset==0
> - the kernel will treat '1 << DRM_VBLANK_HIGH_CRTC_SHIFT'
> and 'DRM_VBLANK_SECONDARY' identically, so the
> crtc_offset==1 special case can also go away.
>
> DRM_VBLANK_HIGH_CRTC_* was added in 2011, so there is no real
> point in keeping support for old kernels that don't have it.
> And in case someone is crazy enoguh to run igt on a kernel older
> than that we can toss in a DRM_CAP_VBLANK_HIGH_CRTC check into
> igt_display_require().
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
> lib/igt_kms.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 8581a218a83c..3cb1273f3041 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -3186,6 +3186,8 @@ void igt_display_require(igt_display_t *display, int drm_fd)
> display->drm_fd = drm_fd;
> is_intel_dev = is_intel_device(drm_fd);
>
> + igt_require(igt_has_drm_cap(drm_fd, DRM_CAP_VBLANK_HIGH_CRTC));
> +
> if (drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0)
> display->is_atomic = 1;
>
> @@ -6125,19 +6127,13 @@ void igt_cleanup_uevents(struct udev_monitor *mon)
> */
> uint32_t kmstest_get_vbl_flag(int crtc_offset)
> {
> - uint32_t pipe_id;
> + uint32_t flag;
>
> - if (crtc_offset == 0)
> - pipe_id = 0;
> - else if (crtc_offset == 1)
> - pipe_id = _DRM_VBLANK_SECONDARY;
> - else {
> - uint32_t pipe_flag = crtc_offset << 1;
> - igt_assert(!(pipe_flag & ~DRM_VBLANK_HIGH_CRTC_MASK));
> - pipe_id = pipe_flag;
> - }
> + flag = crtc_offset << DRM_VBLANK_HIGH_CRTC_SHIFT;
> +
> + igt_assert_eq(flag & ~DRM_VBLANK_HIGH_CRTC_MASK, 0);
>
> - return pipe_id;
> + return flag;
> }
>
> static inline const uint32_t *

--
Jani Nikula, Intel