Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 928edf08 authored by Maria Yu's avatar Maria Yu Committed by Gerrit - the friendly Code Review server
Browse files

kernel: time: Fix low resolution timer not fire in 32bit case



Low resolution timer is not fired to run at given expired time
which is equal to this cpu's base clk time. This is caused by
32bit intergar overflow.
When pos_up is 0, and pos_down is -1, with unsigned add, it will
not seen pos_up + clk is bigger than pos_down + clk. So add
an cast to u64 to have the expected result.

Change-Id: I45777a1fd282d8f70ba94528b04fce2f0436d7e4
Signed-off-by: default avatarMaria Yu <aiquny@codeaurora.org>
parent 8e8b850c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1385,8 +1385,8 @@ static int next_pending_bucket(struct timer_base *base, unsigned offset,

	pos = find_next_bit(base->pending_map, start, offset);
	pos_down = pos < start ? pos + LVL_SIZE - start : -1;
	if (((pos_up + base->clk) << LVL_SHIFT(lvl)) >
		((pos_down + base->clk) << LVL_SHIFT(lvl)))
	if (((pos_up + (u64)base->clk) << LVL_SHIFT(lvl)) >
		((pos_down + (u64)base->clk) << LVL_SHIFT(lvl)))
		return pos_down;
	return pos_up;
}