Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Mika Kahola <mika.kahola@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH] tests: Move wait_for_pageflip as library function
Date: Wed, 23 May 2018 16:32:11 +0300	[thread overview]
Message-ID: <20180523133211.GL23723@intel.com> (raw)
In-Reply-To: <1527078006-12834-1-git-send-email-mika.kahola@intel.com>

On Wed, May 23, 2018 at 03:20:06PM +0300, Mika Kahola wrote:
> Two tests uses the very same wait_for_pageflip() routine. These tests are
> 'kms_rotation_crc' and 'kms_flip_tiling'. In order to decrease code
> repetition, let's move this function as part of kms function collection
> in igt_kms.
> 
> No functional changes.
> 
> Signed-off-by: Mika Kahola <mika.kahola@intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  lib/igt_kms.c            | 24 ++++++++++++++++++++++++
>  lib/igt_kms.h            |  1 +
>  tests/kms_flip_tiling.c  | 20 +-------------------
>  tests/kms_rotation_crc.c | 19 +------------------
>  4 files changed, 27 insertions(+), 37 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 0cee0c0..0438f64 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -1458,6 +1458,30 @@ unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags)
>  	return vbl.reply.sequence;
>  }
>  
> +/**
> + * kmstest_wait_for_pageflip:
> + * @fd: Opened drm file descriptor
> + *
> + * Blocks until pageflip is completed
> + *
> + */
> +void kmstest_wait_for_pageflip(int fd)
> +{
> +	drmEventContext evctx = { .version = 2 };
> +	struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
> +	fd_set fds;
> +	int ret;
> +
> +	/* Wait for pageflip completion, then consume event on fd */
> +	FD_ZERO(&fds);
> +	FD_SET(fd, &fds);
> +	do {
> +		ret = select(fd + 1, &fds, NULL, NULL, &timeout);
> +	} while (ret < 0 && errno == EINTR);
> +	igt_assert_eq(ret, 1);
> +	igt_assert(drmHandleEvent(fd, &evctx) == 0);
> +}
> +
>  static void get_plane(char *str, int type, struct kmstest_plane *plane)
>  {
>  	int ret;
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 0e75d0c..4525238 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -222,6 +222,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
>  
>  void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
>  			      unsigned prot);
> +void kmstest_wait_for_pageflip(int fd);
>  unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
>  void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility);
>  
> diff --git a/tests/kms_flip_tiling.c b/tests/kms_flip_tiling.c
> index 5aae29a..beeb111 100644
> --- a/tests/kms_flip_tiling.c
> +++ b/tests/kms_flip_tiling.c
> @@ -30,7 +30,6 @@
>  #include <stdio.h>
>  #include <string.h>
>  
> -
>  IGT_TEST_DESCRIPTION("Test page flips and tiling scenarios");
>  
>  typedef struct {
> @@ -62,23 +61,6 @@ static void pipe_crc_free(void)
>  	}
>  }
>  
> -static void wait_for_pageflip(int fd)
> -{
> -	drmEventContext evctx = { .version = 2 };
> -	struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
> -	fd_set fds;
> -	int ret;
> -
> -	/* Wait for pageflip completion, then consume event on fd */
> -	FD_ZERO(&fds);
> -	FD_SET(fd, &fds);
> -	do {
> -		ret = select(fd + 1, &fds, NULL, NULL, &timeout);
> -	} while (ret < 0 && errno == EINTR);
> -	igt_assert_eq(ret, 1);
> -	igt_assert(drmHandleEvent(fd, &evctx) == 0);
> -}
> -
>  static void
>  test_flip_tiling(data_t *data, enum pipe pipe, igt_output_t *output, uint64_t tiling[2])
>  {
> @@ -139,7 +121,7 @@ test_flip_tiling(data_t *data, enum pipe pipe, igt_output_t *output, uint64_t ti
>  	 */
>  	igt_require(ret == 0);
>  
> -	wait_for_pageflip(data->drm_fd);
> +	kmstest_wait_for_pageflip(data->drm_fd);
>  
>  	/* Get a crc and compare with the reference. */
>  	igt_pipe_crc_collect_crc(pipe_crc, &crc);
> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> index 0cd5c6e..6cb5858 100644
> --- a/tests/kms_rotation_crc.c
> +++ b/tests/kms_rotation_crc.c
> @@ -284,23 +284,6 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
>  		igt_plane_set_position(plane, data->pos_x, data->pos_y);
>  }
>  
> -static void wait_for_pageflip(int fd)
> -{
> -	drmEventContext evctx = { .version = 2 };
> -	struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
> -	fd_set fds;
> -	int ret;
> -
> -	/* Wait for pageflip completion, then consume event on fd */
> -	FD_ZERO(&fds);
> -	FD_SET(fd, &fds);
> -	do {
> -		ret = select(fd + 1, &fds, NULL, NULL, &timeout);
> -	} while (ret < 0 && errno == EINTR);
> -	igt_assert_eq(ret, 1);
> -	igt_assert(drmHandleEvent(fd, &evctx) == 0);
> -}
> -
>  static void test_single_case(data_t *data, enum pipe pipe,
>  			     igt_output_t *output, igt_plane_t *plane,
>  			     enum rectangle_type rect,
> @@ -350,7 +333,7 @@ static void test_single_case(data_t *data, enum pipe pipe,
>  					NULL);
>  			igt_assert_eq(ret, 0);
>  		}
> -		wait_for_pageflip(data->gfx_fd);
> +		kmstest_wait_for_pageflip(data->gfx_fd);
>  		igt_pipe_crc_drain(data->pipe_crc);
>  		igt_pipe_crc_get_single(data->pipe_crc, &crc_output);
>  		igt_assert_crc_equal(&data->flip_crc,
> -- 
> 2.7.4
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

-- 
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2018-05-23 13:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 12:20 [igt-dev] [PATCH] tests: Move wait_for_pageflip as library function Mika Kahola
2018-05-23 13:19 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-05-23 13:32 ` Ville Syrjälä [this message]
2018-05-24  7:17   ` [igt-dev] [PATCH] " Mika Kahola
2018-05-23 14:32 ` [igt-dev] ✓ Fi.CI.IGT: success for " 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=20180523133211.GL23723@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=mika.kahola@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