[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a0d7_nZMT+WNnKrnT_ftZqpbztnkevRTqwtv6s2MDk8jQ@mail.gmail.com>
Date: Tue, 23 May 2017 13:19:42 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Palmer Dabbelt <palmer@...belt.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Olof Johansson <olof@...om.net>, albert@...ive.com
Subject: Re: [PATCH 5/7] RISC-V: arch/riscv/lib
On Tue, May 23, 2017 at 2:41 AM, Palmer Dabbelt <palmer@...belt.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
Powered by blists - more mailing lists