From 036b60a388685dcd38c33dc4b7ba55130a2d200d Mon Sep 17 00:00:00 2001 From: Ville Syrjälä Date: Tue, 25 Sep 2018 17:38:03 +0300 Subject: lib/debugfs: Use a blocking read in igt_pipe_crc_get_single() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Cc: Maarten Lankhorst Signed-off-by: Ville Syrjälä Reviewed-by: Juha-Pekka Heikkila --- lib/igt_debugfs.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'lib/igt_debugfs.c') 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); -- cgit v1.2.3