diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2018-09-25 17:38:03 +0300 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2018-09-27 15:18:47 +0300 |
commit | 036b60a388685dcd38c33dc4b7ba55130a2d200d (patch) | |
tree | 1dd6066adf2704106f9626eee60d433bd367540e /lib/igt_debugfs.c | |
parent | 38a633b50f0ee369570e1eadee724f62d59553b0 (diff) |
lib/debugfs: Use a blocking read in igt_pipe_crc_get_single()
All users of igt_pipe_crc_get_single() want a blocking read even if
the fd was opened in nonblocking mode. Make it so.
v2: Fix the docs for igt_pipe_crc_get_single()
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Diffstat (limited to 'lib/igt_debugfs.c')
-rw-r--r-- | lib/igt_debugfs.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index baedc225..937952fb 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -757,8 +757,13 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out) { int ret; - while ((ret = read_crc(pipe_crc, out)) <= 0 && ret != -EINVAL) - usleep(1000); + fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags & ~O_NONBLOCK); + + do { + ret = read_crc(pipe_crc, out); + } while (ret == -EINTR); + + fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags); } /** @@ -926,12 +931,8 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc) * @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(). + * Read a single @crc from @pipe_crc. This function blocks even + * when nonblocking CRC is requested. * * Callers must start and stop the capturing themselves by calling * igt_pipe_crc_start() and igt_pipe_crc_stop(). For one-shot CRC collecting @@ -939,26 +940,12 @@ void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc) * * If capturing has been going on for a while and a fresh crc is required, * you should use igt_pipe_crc_get_current() instead. - * - * 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) +void 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 = read_crc(pipe_crc, crc); - - found = ret > 0; - } else - read_one_crc(pipe_crc, crc); - - if (found) - crc_sanity_checks(crc); + read_one_crc(pipe_crc, crc); - return found; + crc_sanity_checks(crc); } /** @@ -976,7 +963,6 @@ igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc) { unsigned vblank = kmstest_get_vblank(drm_fd, pipe_crc->pipe, 0); - igt_assert(!(pipe_crc->flags & O_NONBLOCK)); do { read_one_crc(pipe_crc, crc); |