public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexander Holler <holler@ahsoftware.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] oamp3: bug in clock.c with gcc 4.5.1?
Date: Fri, 17 Dec 2010 21:33:08 +0100	[thread overview]
Message-ID: <4D0BC904.3050009@ahsoftware.de> (raw)
In-Reply-To: <20101217142055.35FE0D31260@gemini.denx.de>

Hello,

Am 17.12.2010 15:20, schrieb Wolfgang Denk:

>> I think I've nailed down, why an u-boot compiled with gcc 4.5.1 fails
>> here. Compiling arch/arm/cpu/armv7/omap3/clock.c with
>> ...
>> That means get_sys_clk_speed() will allways return S12M, at least that
>> is what I'm reading here. And I don't see why gcc should be allowed to
>> optimize that cdiff to a fixed value and therefor returning only S12M.
>
> Well, if you look at the code after preprocessing it looks like this:
>
> struct gptimer *gpt1_base = (struct gptimer *)0x48318000;
> ...
> cstart = (*(volatile unsigned int *)(&gpt1_base->tcrr));
> ...
> cend = (*(volatile unsigned int *)(&gpt1_base->tcrr));
> cdiff = cend - cstart;
>
>
> Eventually that simple definition of readl() is no longer good enough
> for recent compilers.  There is probably a very good reason that Linux
> uses a "__iormb();" memory barrier in the definition of readl() and
> similar macros.
>
> We should probably update "arch/arm/include/asm/io.h" ...

I was unsure if that volatile is enough, therefor I've asked here. 
Looking at the kernel would have been my next step, but I thought it 
would be good to inform other ARM-users here early. In things belonging 
to lowlevel ARM I'm no expert too.

Anyway a memory barrier seems to be a very good idea in readl, even when 
ignoring the volatile should be considered as a bug of gcc.

Linux has a paper on that topic in 
Documentation/volatile-considered-harmful.txt.

I will modify readl here, check what happens, and will post a patch if 
that fixes the problem.

Regards,

Alexander

      reply	other threads:[~2010-12-17 20:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-17 14:01 [U-Boot] oamp3: bug in clock.c with gcc 4.5.1? Alexander Holler
2010-12-17 14:20 ` Wolfgang Denk
2010-12-17 20:33   ` Alexander Holler [this message]

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=4D0BC904.3050009@ahsoftware.de \
    --to=holler@ahsoftware.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