]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
x86: tsc_timer: Correct overflow in __udelay()
authorSimon Glass <sjg@chromium.org>
Thu, 14 Jan 2021 03:29:45 +0000 (20:29 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Mon, 1 Feb 2021 07:11:40 +0000 (15:11 +0800)
At present long delays such as msleep(2000) can cause an overflow in this
function. There is no need for this, since it already uses a 64-bit int.

Add a cast to correct this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/timer/tsc_timer.c

index 706d52b830a5f161d6a5825c4f8fbd7e7f6a4173..7d0fc66cc75a136117884534cf1a9aa4da143ab8 100644 (file)
@@ -372,7 +372,7 @@ void __udelay(unsigned long usec)
        u64 now = get_ticks();
        u64 stop;
 
-       stop = now + usec * get_tbclk_mhz();
+       stop = now + (u64)usec * get_tbclk_mhz();
 
        while ((int64_t)(stop - get_ticks()) > 0)
 #if defined(CONFIG_QEMU) && defined(CONFIG_SMP)