[U-Boot] [PATCH 08/24] armv8: add simple sdelay implementation

Alexander Graf agraf at suse.de
Mon Nov 21 16:52:47 CET 2016



On 20/11/2016 15:57, Andre Przywara wrote:
> The sunxi DRAM setup code needs an sdelay() implementation, which
> wasn't defined for armv8 so far.
> Shamelessly copy the armv7 version and adjust it to work in AArch64.
>
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>

I don't think it hurts to write this in C - and I also doubt that 
inlining has any negative effect.

Something along the lines of

static inline void sdelay(...) {
   for (; loops; loops--)
     asm volatile("");
}

inside a header should do the trick as well and is much more readable.


Alex

> ---
>  arch/arm/cpu/armv8/cpu.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/arch/arm/cpu/armv8/cpu.c b/arch/arm/cpu/armv8/cpu.c
> index e06c3cc..e82e9cf 100644
> --- a/arch/arm/cpu/armv8/cpu.c
> +++ b/arch/arm/cpu/armv8/cpu.c
> @@ -16,6 +16,19 @@
>  #include <asm/system.h>
>  #include <linux/compiler.h>
>
> +/************************************************************
> + * sdelay() - simple spin loop.  Will be constant time as
> + *  its generally used in bypass conditions only.  This
> + *  is necessary until timers are accessible.
> + *
> + *  not inline to increase chances its in cache when called
> + *************************************************************/
> +void sdelay(unsigned long loops)
> +{
> +	__asm__ volatile ("1:\n" "subs %0, %1, #1\n"
> +			  "b.ne 1b":"=r" (loops):"0"(loops));
> +}
> +
>  int cleanup_before_linux(void)
>  {
>  	/*
>


More information about the U-Boot mailing list