Skip to content

Commit

Permalink
timekeeping: Fix cross-timestamp interpolation on counter wrap
Browse files Browse the repository at this point in the history
[ Upstream commit 84dccadd3e2a3f1a373826ad71e5ced5e76b0c00 ]

cycle_between() decides whether get_device_system_crosststamp() will
interpolate for older counter readings.

cycle_between() yields wrong results for a counter wrap-around where after
< before < test, and for the case after < test < before.

Fix the comparison logic.

Fixes: 2c756fe ("time: Add history to cross timestamp interface supporting slower devices")
Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/r/20231218073849.35294-2-peter.hilber@opensynergy.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
peter-hilber-at-opensynergy-dot-com authored and Sasha Levin committed Mar 26, 2024
1 parent 835ae8a commit c56317c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/time/timekeeping.c
Expand Up @@ -1186,7 +1186,7 @@ static bool cycle_between(u64 before, u64 test, u64 after)
{
if (test > before && test < after)
return true;
if (test < before && before > after)
if (before > after && (test > before || test < after))
return true;
return false;
}
Expand Down

0 comments on commit c56317c

Please sign in to comment.