lkml.org 
[lkml]   [2017]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 5/7] RISC-V: arch/riscv/lib
On Tue, May 23, 2017 at 2:41 AM, Palmer Dabbelt <palmer@dabbelt.com> wrote:
> diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
> new file mode 100644
> index 000000000000..f644e582f4b8
> --- /dev/null
> +++ b/arch/riscv/lib/Makefile

> +
> +void __delay(unsigned long cycles)
> +{
> + u64 t0 = get_cycles();
> +
> + while ((unsigned long)(get_cycles() - t0) < cycles)
> + cpu_relax();
> +}
> +
> +void udelay(unsigned long usecs)
> +{
> + u64 ucycles = (u64)usecs * timebase;
> + do_div(ucycles, 1000000U);
> + __delay((unsigned long)ucycles);
> +}
> +EXPORT_SYMBOL(udelay);
> +
> +void ndelay(unsigned long nsecs)
> +{
> + u64 ncycles = (u64)nsecs * timebase;
> + do_div(ncycles, 1000000000U);
> + __delay((unsigned long)ncycles);
> +}

I'd be slightly worried about a global 'timebase' identifier that
might conflict with a variable in some random driver.

Also, it would be good to replace the multiply+div64
with a single multiplication here, see how x86 and arm do it
(for the tsc/__timer_delay case).

Arnd

\
 
 \ /
  Last update: 2017-05-23 13:20    [W:0.769 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site