diff options
| author | Clarence Ip <cip@codeaurora.org> | 2016-09-09 16:45:44 -0400 |
|---|---|---|
| committer | Clarence Ip <cip@codeaurora.org> | 2016-09-09 16:45:44 -0400 |
| commit | a44cd3b3d38baf7289ac5a33c9009773fed91c66 (patch) | |
| tree | 526aab7b195f32ded604ce5fd37fb056fd63c63f | |
| parent | 5105e4297a9bdd0013a5f44a0bd2c7712a045ad4 (diff) | |
drm/msm/sde: add helper macro for performing ktime comparisons
Linux ktime events can not be directly compared if the timer
has overflowed between them. This change adds a helper macro
to first take the difference between the events and then
compare the result against zero in an attempt to handle timer
overflow situations.
Change-Id: Ic32afc35fbabb757714b5a583cc384389176b239
Signed-off-by: Clarence Ip <cip@codeaurora.org>
| -rw-r--r-- | drivers/gpu/drm/msm/sde/sde_kms.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/gpu/drm/msm/sde/sde_kms.h b/drivers/gpu/drm/msm/sde/sde_kms.h index 6f1628151511..a15e5cd1bddb 100644 --- a/drivers/gpu/drm/msm/sde/sde_kms.h +++ b/drivers/gpu/drm/msm/sde/sde_kms.h @@ -63,6 +63,17 @@ #define CHECK_LAYER_BOUNDS(offset, size, max_size) \ (((size) > (max_size)) || ((offset) > ((max_size) - (size)))) +/** + * ktime_compare_safe - compare two ktime structures + * This macro is similar to the standard ktime_compare() function, but + * attempts to also handle ktime overflows. + * @A: First ktime value + * @B: Second ktime value + * Returns: -1 if A < B, 0 if A == B, 1 if A > B + */ +#define ktime_compare_safe(A, B) \ + ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0)) + /* * struct sde_irq_callback - IRQ callback handlers * @func: intr handler |
