[igt-dev] [PATCH i-g-t 1/3] lib/debugfs: Fix wraparound handling for crc frame counter check

Ville Syrjala ville.syrjala at linux.intel.com
Tue Nov 6 16:19:41 UTC 2018


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Deal with frame counter wraparound correcrtly.

Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_debugfs.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a3aca8466658..70874416d128 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -975,6 +975,16 @@ void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
 	crc_sanity_checks(crc);
 }
 
+static bool vbl_after_eq(uint32_t a, uint32_t b)
+{
+	return (int32_t)(a - b) >= 0;
+}
+
+static bool vbl_before_eq(uint32_t a, uint32_t b)
+{
+	return vbl_after_eq(b, a);
+}
+
 /**
  * igt_pipe_crc_get_current:
  * @drm_fd: Pointer to drm fd for vblank counter
@@ -999,7 +1009,7 @@ igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc)
 			igt_pipe_crc_get_single(pipe_crc, crc);
 			return;
 		}
-	} while (crc->frame <= vblank);
+	} while (vbl_before_eq(crc->frame, vblank));
 
 	crc_sanity_checks(crc);
 }
-- 
2.18.1



More information about the igt-dev mailing list