public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/5] lib/debugfs: Fix wraparound handling for crc frame counter check
@ 2019-03-07 21:39 Ville Syrjala
  2019-03-07 21:39 ` [igt-dev] [PATCH i-g-t 2/5] tests/kms_setmode: Request the initial vbl count with RELATIVE instead of ABSOLUTE Ville Syrjala
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Ville Syrjala @ 2019-03-07 21:39 UTC (permalink / raw)
  To: igt-dev

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

Deal with frame counter wraparound correcrtly.

v2: Make the comparison functions available for everyone (Chris)
    Add some docs (gtk-doc seems obtuse so not 100% warning free)

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> #v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> #v1
---
 lib/igt_debugfs.c |  2 +-
 lib/igt_kms.h     | 60 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 640c78e972e9..b782a2a88b03 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -971,7 +971,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 (igt_vblank_before_eq(crc->frame, vblank));
 
 	crc_sanity_checks(crc);
 }
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index a29ad7836465..3c602576db34 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -767,4 +767,64 @@ void igt_cleanup_hotplug(struct udev_monitor *mon);
 bool igt_display_has_format_mod(igt_display_t *display, uint32_t format, uint64_t modifier);
 bool igt_plane_has_format_mod(igt_plane_t *plane, uint32_t format, uint64_t modifier);
 
+/**
+ * igt_vblank_after_eq:
+ * @a: First vblank sequence number.
+ * @b: Second vblank sequence number.
+ *
+ * Compare vblank sequence numbers,
+ * handling wraparound correctly.
+ *
+ * Returns: @a >= @b
+ */
+static inline bool igt_vblank_after_eq(uint32_t a, uint32_t b)
+{
+	return (int32_t)(a - b) >= 0;
+}
+
+/**
+ * igt_vblank_before_eq:
+ * @a: First vblank sequence number.
+ * @b: Second vblank sequence number.
+ *
+ * Compare vblank sequence numbers,
+ * handling wraparound correctly.
+ *
+ * Returns: @a <= @b
+ */
+static inline bool igt_vblank_before_eq(uint32_t a, uint32_t b)
+{
+	return igt_vblank_after_eq(b, a);
+}
+
+/**
+ * igt_vblank_after:
+ * @a: First vblank sequence number.
+ * @b: Second vblank sequence number.
+ *
+ * Compare vblank sequence numbers,
+ * handling wraparound correctly.
+ *
+ * Returns: @a > @b
+ */
+static inline bool igt_vblank_after(uint32_t a, uint32_t b)
+{
+	return (int32_t)(b - a) < 0;
+}
+
+/**
+ * igt_vblank_before:
+ * @a: First vblank sequence number.
+ * @b: Second vblank sequence number.
+ *
+ * Compare vblank sequence numbers,
+ * handling wraparound correctly.
+ *
+ * Returns: @a < @b
+ */
+static inline bool igt_vblank_before(uint32_t a, uint32_t b)
+{
+	return igt_vblank_after(b, a);
+}
+
 #endif /* __IGT_KMS_H__ */
-- 
2.19.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-03-09  8:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-07 21:39 [igt-dev] [PATCH i-g-t 1/5] lib/debugfs: Fix wraparound handling for crc frame counter check Ville Syrjala
2019-03-07 21:39 ` [igt-dev] [PATCH i-g-t 2/5] tests/kms_setmode: Request the initial vbl count with RELATIVE instead of ABSOLUTE Ville Syrjala
2019-03-07 21:48   ` Chris Wilson
2019-03-08 16:45     ` Ville Syrjälä
2019-03-08 16:49   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2019-03-07 21:39 ` [igt-dev] [PATCH i-g-t 3/5] tests/kms_flip: " Ville Syrjala
2019-03-07 21:49   ` Chris Wilson
2019-03-08 16:50   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2019-03-08 17:14     ` Chris Wilson
2019-03-07 21:39 ` [igt-dev] [PATCH i-g-t 4/5] tests/kms_flip: Validate the vbl sequence numbers Ville Syrjala
2019-03-07 21:39 ` [igt-dev] [PATCH i-g-t 5/5] tests/kms_setmode: " Ville Syrjala
2019-03-07 21:51   ` Chris Wilson
2019-03-08 17:14     ` Chris Wilson
2019-03-07 22:03 ` [igt-dev] [PATCH i-g-t 1/5] lib/debugfs: Fix wraparound handling for crc frame counter check Chris Wilson
2019-03-07 23:43 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] " Patchwork
2019-03-08  2:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-03-09  1:15 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] lib/debugfs: Fix wraparound handling for crc frame counter check (rev3) Patchwork
2019-03-09  8:28 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox