public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] cfi_flash.c and lost volatile qualifier
Date: Wed, 30 Apr 2008 10:43:16 -0400	[thread overview]
Message-ID: <48188584.3060109@ge.com> (raw)
In-Reply-To: <alpine.DEB.1.10.0804300949360.13610@pmy.adscville>

Adrian Filipi wrote:
> On Tue, 29 Apr 2008, Jerry Van Baren wrote:
> 
>> Adrian Filipi wrote:
>>> On Tue, 29 Apr 2008, Wolfgang Denk wrote:
>>>
>>>> In message <alpine.DEB.1.10.0804291604250.32753@pmy.adscville> you 
>>>> wrote:
>>>>>      I narrowed down the source of the problem to the loss of the
>>>>> volatile qualifier on the addr pointer in flash_write_cmd().  
>>>>> Adding the
>>>>> qualifier gets rid of the corruption.  In the older 1.2.0 sources, 
>>>>> addr was
>>>>> declared as "volatile cfiptr_t addr;".
>>>> The volatile should not be needed - the CFI driver should use correct
>>>> accessor macros instead. See
>>>> Documentation/volatile-considered-harmful.txt in your Linux kernel
>>>> source tree...
>>>>
>>>> Best regards,
>>>>
>>>> Wolfgang Denk
>>>
>>>      Sure, reducing the reliance on volatile is a good idea, but I'm 
>>> at a loss for anything better to do.
>>>
>>>      I'm seeing a real problem that is only fixed by qualifying the 
>>> container of the pointer as volatile, i.e. "void *volatile".  
>>> "volatile void *" has no effect as expected given that the read/write 
>>> accessors are used now.
>>>
>>>      The old data type was essentially "volatile void *volatile addr" 
>>> and the new type is simply "void *addr".  I seem to need at least 
>>> "void *volatile addr" for things to work.
>>>
>>>      Note, I'm only seeing this problem on our PXA250 boards.
>>>
>>>      Adrian
>>
>> Hi Adrian,
>>
>> Please bottom post.
>>
>> It may be useful to disassemble cfi_flash.o file (objdump -S) and see 
>> what the two different configurations of flash_write_cmd() get turned 
>> into in assembly.
>>
>> Best regards,
>> gvb
>>
> 
>     I've attached the assembler output as well as the diff to the 
> version with volatile added.  I don't see anything incriminating.
> Instead of using a register, the variable is read from its location on 
> the stack.
> 
>     I'm having a hard time seeing how flash could get corrupted by this 
> code.  It's happening during initialization.
> 
>     Adrian

I'm not an ARMexpert, but if that were a PowerPC CPU, I would *strongly* 
suspect that the bus interface unit is rearranging the bus operations 
going to memory (e.g. moving a read ahead of a write or re-ordering the 
writes).  The result is that the write command/data sequence to the 
flash gets buggered by the re-ordering.

Per my theory, by putting in the "volatile", you force extra reads on 
the bus which forces the bus interface unit to flush out the flash write 
sequence in the right order.  The fix is totally unrelated the the 
problem, other than as an unrecognized side effect it "fixes" the problem.

The solution in the PowerPC world is to add a "eieio" or "sync" 
instruction[1] appropriately[2], which prevents the bus interface unit 
from reordering the memory operations.

Your task is to dig into the PXA250 manual to (a) figure out what syncs 
you need and (b) figure out why the bus interface is doing you in. 
Alternatively, (c) show that I don't know what I'm talking about. 
Obviously, (a) gets you the best results, so lets root for that. ;-)

HTH,
gvb

[1] Sync is a big hammer, eieio is a medium size hammer.  Don't use 
both, PPC people will know you don't know what you are doing.  ;-)

[2] The flash command sequence order is critical (e.g. the 55s and AAs). 
  The actual data sequence is not critical.  The observed problem is in 
flash_write_cmd() that is writing the command sequence.  Hmmmmm.

  parent reply	other threads:[~2008-04-30 14:43 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-08 14:32 [U-Boot-Users] drivers MMCplus for at91sam9x Pierre Savary
2008-04-09 17:49 ` Jean-Christophe PLAGNIOL-VILLARD
2008-04-10 10:32   ` Pierre Savary
2008-04-10 22:31 ` Ken.Fuchs at bench.com
2008-04-11  8:26   ` Pierre Savary
2008-04-11 15:48   ` Pierre Ossman
2008-04-11 18:54     ` Ken.Fuchs at bench.com
2008-04-12  9:28       ` Pierre Ossman
2008-04-15 10:18         ` Pierre Savary
2008-04-15 16:51           ` Ken.Fuchs at bench.com
     [not found]         ` <-6021840981243159212@unknownmsgid>
2008-04-15 19:25           ` Andy Fleming
2008-04-16  8:55             ` Pierre Savary
2008-04-16 23:30             ` Ken.Fuchs at bench.com
2008-04-22 11:55             ` Pierre Savary
2008-04-22 15:07               ` [U-Boot-Users] [PATCH] Add eSDHC driver Andy Fleming
2008-04-22 16:53                 ` Anton Vorontsov
2008-04-23 19:23                 ` Ken.Fuchs at bench.com
2008-04-24  6:24                   ` Pierre Savary
2008-04-29 19:45                     ` [U-Boot-Users] drivers MMCplus for at91sam9x Ken.Fuchs at bench.com
2008-04-29 20:20                       ` [U-Boot-Users] cfi_flash.c and lost volatile qualifier Adrian Filipi
2008-04-29 20:43                         ` Wolfgang Denk
2008-04-29 21:10                           ` Adrian Filipi
2008-04-29 21:16                             ` Jerry Van Baren
     [not found]                               ` <alpine.DEB.1.10.0804300949360.13610@pmy.adscville>
2008-04-30 14:43                                 ` Jerry Van Baren [this message]
2008-04-30 15:11                                   ` Joakim Tjernlund
2008-04-30 15:21                                     ` Scott Wood
2008-04-30 15:34                                       ` Joakim Tjernlund
2008-04-30 15:41                                         ` Wolfgang Denk
2008-04-30 16:02                                         ` Scott Wood
2008-04-30 16:11                                           ` Joakim Tjernlund
2008-04-30 15:35                                     ` [U-Boot-Users] PPC sync/eieio (was cfi_flash.c and lost volatile qualifier) Jerry Van Baren
2008-04-30 15:38                                   ` [U-Boot-Users] cfi_flash.c and lost volatile qualifier Wolfgang Denk
2008-04-30 15:51                                     ` Jerry Van Baren
2008-05-08 11:17                         ` Haavard Skinnemoen
2008-05-08 14:05                           ` Adrian Filipi
2008-05-08 16:27                             ` Haavard Skinnemoen
2008-04-30 14:20                       ` [U-Boot-Users] drivers MMCplus for at91sam9x Pierre Savary
2008-04-30 16:25                         ` Ken.Fuchs at bench.com
2008-04-30 20:31                         ` Ken.Fuchs at bench.com

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=48188584.3060109@ge.com \
    --to=gerald.vanbaren@ge.com \
    --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