[U-Boot] imx: get_ticks in syscounter.c get miscompiled by GCC 6
Lothar Waßmann
LW at KARO-electronics.de
Tue Mar 6 12:31:10 UTC 2018
Hi,
On Tue, 6 Mar 2018 15:06:08 +0900 Yasushi SHOJI wrote:
> Hi,
>
> It seems to me that both GCC 6.3 and 6.4 mis-compiles
>
s/mis-compiles/optimizes/
Without the 'volatile' attribute the compiler is entitled to move the
asm code around or optimize it out.
So, your patch is the correct fix independent from the gcc version
used.
> arch/arm/mach-imx/syscounter.c.
>
> I'm attaching two files, bad.txt is the original syscounter.c and
> good.txt is the one
> with the following patch.
>
> diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c
> index 9290918dca..30ed0109a2 100644
> --- a/arch/arm/mach-imx/syscounter.c
> +++ b/arch/arm/mach-imx/syscounter.c
> @@ -82,7 +82,7 @@ unsigned long long get_ticks(void)
> {
> unsigned long long now;
>
> - asm("mrrc p15, 0, %Q0, %R0, c14" : "=r" (now));
> + asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (now));
>
> gd->arch.tbl = (unsigned long)(now & 0xffffffff);
> gd->arch.tbu = (unsigned long)(now >> 32);
>
Lothar Waßmann
More information about the U-Boot
mailing list