All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 05/12] lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain.
Date: Tue, 6 Feb 2018 18:11:15 +0200	[thread overview]
Message-ID: <20180206161115.GN5453@intel.com> (raw)
In-Reply-To: <20180206101417.59979-5-maarten.lankhorst@linux.intel.com>

On Tue, Feb 06, 2018 at 11:14:10AM +0100, Maarten Lankhorst wrote:
> Collecting CRC may result in a modeset and extra vblank waits. On some
> tests this will increase the runtime a lot, so it makes sense to
> keep it enabled, and only collect the most recent CRC when needed.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_debugfs.c         | 73 ++++++++++++++++++++++++++++++++++++++++++++---
>  lib/igt_debugfs.h         |  2 ++
>  tests/kms_cursor_legacy.c | 21 ++++----------
>  3 files changed, 76 insertions(+), 20 deletions(-)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 1aec079c52bb..ad3e7bcf38fa 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -33,6 +33,7 @@
>  #include <limits.h>
>  #include <string.h>
>  #include <fcntl.h>
> +#include <poll.h>
>  #include <unistd.h>
>  #include <i915_drm.h>
>  
> @@ -697,7 +698,7 @@ static bool pipe_crc_init_from_string(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc,
>  	return true;
>  }
>  
> -static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
> +static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out, bool override_nonblock)
>  {
>  	ssize_t bytes_read;
>  	char buf[MAX_LINE_LEN + 1];
> @@ -706,7 +707,7 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
>  	bytes_read = read(pipe_crc->crc_fd, &buf, MAX_LINE_LEN);
>  	igt_reset_timeout();
>  
> -	if (bytes_read < 0 && errno == EAGAIN)
> +	if (bytes_read < 0 && errno == EAGAIN && !override_nonblock)
>  		igt_assert(pipe_crc->flags & O_NONBLOCK);
>  
>  	if (bytes_read < 0)
> @@ -722,7 +723,7 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
>  
>  static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
>  {
> -	while (read_crc(pipe_crc, out) == 0)
> +	while (read_crc(pipe_crc, out, false) == 0)
>  		usleep(1000);
>  }
>  
> @@ -794,7 +795,7 @@ igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
>  		igt_crc_t *crc = &crcs[n];
>  		int ret;
>  
> -		ret = read_crc(pipe_crc, crc);
> +		ret = read_crc(pipe_crc, crc, false);
>  		if (ret < 0)
>  			continue;
>  		if (ret == 0)
> @@ -854,6 +855,70 @@ void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc)
>  	crc_sanity_checks(out_crc);
>  }
>  
> +/**
> + * igt_pipe_crc_drain:
> + * @pipe_crc: pipe CRC object
> + *
> + * Discards all currently queued CRC values from @pipe_crc. This function does
> + * not block, and is useful to flush @pipe_crc. Afterwards you can get a fresh
> + * CRC with igt_pipe_crc_get_single().
> + */
> +void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc)
> +{
> +	igt_crc_t crc;
> +	int ret;
> +
> +	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags | O_NONBLOCK);
> +	do {
> +		ret = read_crc(pipe_crc, &crc, true);
> +	} while (ret > 0 || errno == EINTR);

Is errno valid for ret==0?

> +	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags);
> +}
> +
> +/**
> + * igt_pipe_crc_get_single:
> + * @pipe_crc: pipe CRC object
> + * @crc: buffer pointer for the captured CRC value
> + *
> + * Read a single @crc from @pipe_crc. This function does not block
> + * when nonblocking CRC is requested, and will return false if no CRC
> + * can be captured.
> + *
> + * If opened in blocking mode it will always block until a new CRC is read, like
> + * igt_pipe_crc_collect_crc().
> + *
> + * Callers must start and stop the capturing themselves by calling
> + * igt_pipe_crc_start() and igt_pipe_crc_stop(). For one-shot CRC collecting
> + * look at igt_pipe_crc_collect_crc().
> + *
> + * If capturing has been going on for a while and a fresh crc is required,
> + * you will need to call igt_pipe_crc_drain() first to remove stale entries.
> + *
> + * Returns:
> + * Whether a crc is captured, only false in non-blocking mode.
> + */
> +bool
> +igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
> +{
> +	bool found = true;
> +
> +	if (pipe_crc->flags & O_NONBLOCK) {
> +		int ret;
> +
> +		do {
> +			ret = read_crc(pipe_crc, crc, false);
> +		} while (ret < 0);
> +
> +		found = ret;
> +	} else
> +		read_one_crc(pipe_crc, crc);
> +
> +	if (found)
> +		crc_sanity_checks(crc);
> +
> +	return found;
> +}
> +
>  /*
>   * Drop caches
>   */
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> index d90dd7a68bb0..8d25abfe43c1 100644
> --- a/lib/igt_debugfs.h
> +++ b/lib/igt_debugfs.h
> @@ -130,6 +130,8 @@ void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
>  __attribute__((warn_unused_result))
>  int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
>  			  igt_crc_t **out_crcs);
> +void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc);
> +bool igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
>  void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
>  
>  void igt_hpd_storm_set_threshold(int fd, unsigned int threshold);
> diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
> index 5011e78e5c2f..d0a28b3c442c 100644
> --- a/tests/kms_cursor_legacy.c
> +++ b/tests/kms_cursor_legacy.c
> @@ -1276,7 +1276,7 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)
>  	enum pipe pipe = find_connected_pipe(display, false);
>  	igt_pipe_t *pipe_connected = &display->pipes[pipe];
>  	igt_plane_t *plane_primary = igt_pipe_get_plane_type(pipe_connected, DRM_PLANE_TYPE_PRIMARY);
> -	igt_crc_t crcs[2];
> +	igt_crc_t crcs[2], test_crc;
>  
>  	if (atomic)
>  		igt_require(display->is_atomic);
> @@ -1290,7 +1290,7 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)
>  
>  	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
>  
> -	pipe_crc = igt_pipe_crc_new_nonblock(display->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
> +	pipe_crc = igt_pipe_crc_new(display->drm_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
>  
>  	set_cursor_on_pipe(display, pipe, &cursor_fb);
>  	igt_display_commit2(display, COMMIT_UNIVERSAL);
> @@ -1322,9 +1322,6 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)
>  	/* Disable cursor, and immediately queue a flip. Check if resulting crc is correct. */
>  	for (int i = 1; i >= 0; i--) {
>  		igt_spin_t *spin;
> -		igt_crc_t *received_crcs = NULL;
> -		int ncrcs;
> -		static const int max_crcs = 8;
>  
>  		spin = igt_spin_batch_new(display->drm_fd, 0, 0,
>  					  fb_info[1].gem_handle);
> @@ -1336,7 +1333,8 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)
>  
>  		igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start);
>  
> -		ncrcs = igt_pipe_crc_get_crcs(pipe_crc, max_crcs, &received_crcs);
> +		igt_pipe_crc_drain(pipe_crc);
> +		igt_pipe_crc_get_single(pipe_crc, &test_crc);
>  
>  		igt_spin_batch_free(display->drm_fd, spin);
>  
> @@ -1349,16 +1347,7 @@ static void flip_vs_cursor_busy_crc(igt_display_t *display, bool atomic)
>  		igt_plane_set_fb(plane_primary, &fb_info[0]);
>  		igt_display_commit2(display, COMMIT_UNIVERSAL);
>  
> -		/*
> -		 * We collect the crc nonblockingly, and should have at least 1
> -		 * but not so many crcs that we overflow. Last CRC is the only
> -		 * one we care about here. Other CRCs may have been from before
> -		 * the cursor update and can contain garbage.
> -		 */
> -		igt_assert(ncrcs > 0 && ncrcs < max_crcs);
> -
> -		igt_assert_crc_equal(&crcs[i], &received_crcs[ncrcs - 1]);
> -		free(received_crcs);
> +		igt_assert_crc_equal(&crcs[i], &test_crc);
>  	}
>  
>  	igt_remove_fb(display->drm_fd, &fb_info[1]);
> -- 
> 2.16.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

  reply	other threads:[~2018-02-06 16:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 10:14 [igt-dev] [PATCH i-g-t 01/12] lib/igt_fb: Make igt_remove_fb more robust Maarten Lankhorst
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 02/12] tests: Always call igt_remove_fb without checking Maarten Lankhorst
2018-02-07 13:42   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 03/12] lib/igt_fb: Add igt_fb_supported_format() Maarten Lankhorst
2018-02-08  8:08   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 04/12] lib/igt_fb: Remove igt_get_all_cairo_formats() Maarten Lankhorst
2018-02-08  8:15   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 05/12] lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain Maarten Lankhorst
2018-02-06 16:11   ` Ville Syrjälä [this message]
2018-02-06 16:30     ` Maarten Lankhorst
2018-02-07 11:47     ` [igt-dev] [PATCH i-g-t] lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain, v2 Maarten Lankhorst
2018-02-08 11:15       ` Mika Kahola
2018-02-08 12:31         ` [PATCH i-g-t] lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain, v3 Maarten Lankhorst
2018-02-09 10:01           ` [igt-dev] [PATCH i-g-t] lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain, v4 Maarten Lankhorst
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 06/12] tests/kms_rotation_crc: Fix bad-tiling testcase Maarten Lankhorst
2018-02-08 12:08   ` Mika Kahola
2018-02-08 12:12     ` Maarten Lankhorst
2018-02-08 12:19   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 07/12] tests/kms_rotation_crc: Move bad_format parameter to test_plane_rotation Maarten Lankhorst
2018-02-08 13:07   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 08/12] tests/kms_rotation_crc: Always run the flip tests when available Maarten Lankhorst
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 09/12] tests/kms_rotation_crc: Remove primary-rotation-90-Y-tiled Maarten Lankhorst
2018-02-09  8:25   ` Kahola, Mika
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 10/12] tests/kms_rotation_crc: Perform lazy cleanup and require atomic Maarten Lankhorst
2018-02-09  9:39   ` Kahola, Mika
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 11/12] tests/kms_rotation_crc: Clean up exhaust-fences subtest Maarten Lankhorst
2018-02-12 11:20   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 12/12] tests/kms_rotation_crc: Test all pixel formats on all planes Maarten Lankhorst
2018-02-08  3:33   ` Srinivas, Vidya
2018-02-12 13:09   ` Mika Kahola
2018-02-12 14:20     ` Maarten Lankhorst
2018-02-06 11:25 ` [igt-dev] ✗ Fi.CI.BAT: warning for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust Patchwork
2018-02-07 13:30 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust (rev2) Patchwork
2018-02-07 13:39 ` [igt-dev] [PATCH i-g-t 01/12] lib/igt_fb: Make igt_remove_fb more robust Mika Kahola
2018-02-07 16:36 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust (rev2) Patchwork
2018-02-08 19:06 ` ✓ Fi.CI.BAT: success for lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain, v3 Patchwork
2018-02-09  4:48 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-02-09 16:33 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust (rev3) Patchwork
2018-02-09 18:21 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20180206161115.GN5453@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.