public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] imx: get_ticks in syscounter.c get miscompiled by GCC 6
Date: Tue, 6 Mar 2018 13:31:10 +0100	[thread overview]
Message-ID: <20180306133110.00e9fd33@karo-electronics.de> (raw)
In-Reply-To: <CAELBRWJje2JapKVdECxwMu8LCwVnVPd2qyb+ZL79Gjk-ZQJN6w@mail.gmail.com>

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

  reply	other threads:[~2018-03-06 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06  6:06 [U-Boot] imx: get_ticks in syscounter.c get miscompiled by GCC 6 Yasushi SHOJI
2018-03-06 12:31 ` Lothar Waßmann [this message]
2018-03-06 13:11   ` Fabio Estevam
2018-03-07  5:57     ` Yasushi SHOJI
2018-03-07 13:42       ` Fabio Estevam
2018-03-07 14:27         ` Tom Rini
2018-03-09  9:56           ` Yasushi SHOJI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180306133110.00e9fd33@karo-electronics.de \
    --to=lw@karo-electronics.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox