Commit 0cf3d67a authored by Ville Syrjälä's avatar Ville Syrjälä

lib/debugfs: Fix wraparound handling for crc frame counter check

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ä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> #v1
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 34b87e11
......@@ -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);
}
......
......@@ -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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment