[igt-dev] [PATCH i-g-t 1/2] lib/igt_kms: Decouple ioctl call logic for vblank wait

Daniel Vetter daniel at ffwll.ch
Thu Feb 18 09:59:15 UTC 2021


On Thu, Feb 04, 2021 at 06:14:36PM +0530, Sumera Priyadarsini wrote:
> Extract the ioctl call logic in igt_wait_for_vblank_count() into
> a helper function, __igt_vblank_wait(). Adjust igt_assert() test
> in igt_wait_for_vblank_count() and igt_wait_for_vblank() accordingly.
> 
> Signed-off-by: Sumera Priyadarsini <sylphrenadin at gmail.com>

Maybe a bit more context for why I think we'll need this: For virtual hw
emulation in vkms (i.e. simulating an uapi like vmwgfx or virtio-gpu have
it) there's not going to be much vblank, but we still want crc.

And atm our crc code is littered with calls to igt_wait_for_vblank(), and
I think we could just auto-skip those if vblanks dont exist. While the calls to
igt_wait_for_vblank_count is generally relevant for test logic, so maybe
those should result in an igt_skip if vblanks don't exist.

Anyway, thanks for your patch, applied.
-Daniel

> ---
>  lib/igt_kms.c | 28 ++++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 0dc2fda4..08d429a8 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -4190,6 +4190,20 @@ void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb)
>  					  (ptrdiff_t)&output->writeback_out_fence_fd);
>  }
>  
> +static int __igt_vblank_wait(int drm_fd, int crtc_offset, int count)
> +{
> +	drmVBlank wait_vbl;
> +	uint32_t pipe_id_flag;
> +
> +	memset(&wait_vbl, 0, sizeof(wait_vbl));
> +	pipe_id_flag = kmstest_get_vbl_flag(crtc_offset);
> +
> +	wait_vbl.request.type = DRM_VBLANK_RELATIVE | pipe_id_flag;
> +	wait_vbl.request.sequence = count;
> +
> +	return drmWaitVBlank(drm_fd, &wait_vbl);
> +}
> +
>  /**
>   * igt_wait_for_vblank_count:
>   * @drm_fd: A drm file descriptor
> @@ -4209,17 +4223,7 @@ void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb)
>   */
>  void igt_wait_for_vblank_count(int drm_fd, int crtc_offset, int count)
>  {
> -	drmVBlank wait_vbl;
> -	uint32_t pipe_id_flag;
> -
> -	memset(&wait_vbl, 0, sizeof(wait_vbl));
> -	pipe_id_flag = kmstest_get_vbl_flag(crtc_offset);
> -
> -	wait_vbl.request.type = DRM_VBLANK_RELATIVE;
> -	wait_vbl.request.type |= pipe_id_flag;
> -	wait_vbl.request.sequence = count;
> -
> -	igt_assert(drmWaitVBlank(drm_fd, &wait_vbl) == 0);
> +	igt_assert(__igt_vblank_wait(drm_fd, crtc_offset, count) == 0);
>  }
>  
>  /**
> @@ -4233,7 +4237,7 @@ void igt_wait_for_vblank_count(int drm_fd, int crtc_offset, int count)
>   */
>  void igt_wait_for_vblank(int drm_fd, int crtc_offset)
>  {
> -	igt_wait_for_vblank_count(drm_fd, crtc_offset, 1);
> +	igt_assert(__igt_vblank_wait(drm_fd, crtc_offset, 1) == 0);
>  }
>  
>  /**
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the igt-dev mailing list