From 4409b3959edf7fd41707f773640e74fdef096383 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Thu, 29 Sep 2016 23:08:31 +0100 Subject: sunxi: fix udelay() implementation Nah, compilers are way too clever these days to fall for those simple delay loops, in fact the function resulted into a single "ret" to be generated. Use an inline assembly loop instead. --- plat/sun50iw1p1/sunxi_cpu_ops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plat/sun50iw1p1/sunxi_cpu_ops.c b/plat/sun50iw1p1/sunxi_cpu_ops.c index 1fcff13..9db3a9e 100644 --- a/plat/sun50iw1p1/sunxi_cpu_ops.c +++ b/plat/sun50iw1p1/sunxi_cpu_ops.c @@ -61,18 +61,18 @@ static unsigned int sun50i_prcm_base = SUN50I_PRCM_PBASE; static unsigned int sun50i_r_cpucfg_base = SUN50I_RCPUCFG_PBASE; extern bakery_lock_t plat_console_lock; - void udelay(unsigned int delay) - { - unsigned int i, j; +void udelay(unsigned int delay) +{ if (!delay) return; - for (i=0; i<1000*delay; i++) - { - j+=i; - } - } + __asm__ volatile ( + "1:\tsubs %0, %0, #1\n" + "\tb.ne 1b" + :: "r" (delay * 1000UL) + ); +} #ifdef SUNXI_CPUOPS_REAL_DELAY #define CPU_DELAY_SHORT 10 -- cgit v1.2.3