aspeed/timer: Ensure positive muldiv delta
commit055762479be1575377ecf2d8fceb9d8df2703d0f
authorChristian Svensson <bluecmd@google.com>
Mon, 1 Jul 2019 16:26:17 +0000 (1 17:26 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 1 Jul 2019 16:28:59 +0000 (1 17:28 +0100)
treef93e04303fc7da74f8889a600dd358518849163f
parent696942b8bc6562a2b23c6ed8ae32ecdeb9bf4b60
aspeed/timer: Ensure positive muldiv delta

If the host decrements the counter register that results in a negative
delta. This is then passed to muldiv64 which only handles unsigned
numbers resulting in bogus results.

This fix ensures the delta being operated on is positive.

Test case: kexec a kernel using aspeed_timer and it will freeze on the
second bootup when the kernel initializes the timer. With this patch
that no longer happens and the timer appears to run OK.

Signed-off-by: Christian Svensson <bluecmd@google.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Message-id: 20190618165311.27066-12-clg@kaod.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/timer/aspeed_timer.c