Re: question on memory barrier

2005-08-26 Thread Maciej W. Rozycki
On Fri, 26 Aug 2005, moreau francis wrote: > I don't think that MIPS cpu reorder memory access, but gcc can ! And I > don't think that the use of 'volatile' can prevent it to do that. Well, certain MIPS implementations may merge multiple uncached writes in the writeback buffer, e.g. writes to d

Re: question on memory barrier

2005-08-26 Thread moreau francis
--- Andy Isaacson <[EMAIL PROTECTED]> a écrit : > > Did you *read* the post? > > # The _only_ acceptable use of "volatile" is basically: > # > # - in _code_ (not data structures), where we might mark a place as making > # a special type of access. For example, in the PCI MMIO read functions,

Re: question on memory barrier

2005-08-25 Thread Andy Isaacson
On Thu, Aug 25, 2005 at 11:14:03AM +0200, moreau francis wrote: > --- Andy Isaacson <[EMAIL PROTECTED]> a écrit : > > The first register write will be completed before the second register > > write because you use writel, which is defined to have the semantics you > > want. (It uses a platform-spe

Re: question on memory barrier

2005-08-25 Thread Maciej W. Rozycki
On Wed, 24 Aug 2005, Andy Isaacson wrote: > You might benefit by running your source code through gcc -E and seeing > what the writel() expands to. (I do something like "rm drivers/mydev.o; > make V=1" and then copy-n-paste the gcc line, replacing the "-c -o mydev.o" > options with -E.) Well, `

Re: question on memory barrier

2005-08-25 Thread Alan Cox
On Iau, 2005-08-25 at 11:14 +0200, moreau francis wrote: > I'm compiling Linux kernel for a MIPS32 cpu. On my platform, writel seems > expand to: > > static inline writel(u32 val, volatile void __iomem *mem) > { > volatile u32 *__mem; > u32 __val; > > _

Re: question on memory barrier

2005-08-25 Thread moreau francis
--- Andy Isaacson <[EMAIL PROTECTED]> a écrit : > > The first register write will be completed before the second register > write because you use writel, which is defined to have the semantics you > want. (It uses a platform-specific method to guarantee this, possibly > "volatile" or "asm("eiei

RE: question on memory barrier

2005-08-24 Thread David Schwartz
> Wrong. Reference: > > http://www.phy.duke.edu/~rgb/General/c_book/c_book/chapter8/sequen > ce_points.html > > Cheers, > Dick Johnson That discussion is wrong. The form of the argument is simply invalid. Just because an optimization could break things in some cases doesn’t mean

Re: question on memory barrier

2005-08-24 Thread Alan Cox
On Mer, 2005-08-24 at 14:43 +0200, moreau francis wrote: > I'm currently trying to write a USB driver for Linux. The device must be > configured by writing some values into the same register but I want to be > sure that the writing order is respected by either the compiler and the cpu. The Linux k

Re: question on memory barrier

2005-08-24 Thread Jesse Barnes
On Wednesday, August 24, 2005 2:45 pm, Alan Cox wrote: > And in more detail from the deviceiobook.. > > > In addition to write posting, on some large multiprocessing > systems > (e.g. SGI Challenge, Origin and Altix machines) posted writes > won't > be strongly ordere

Re: question on memory barrier

2005-08-24 Thread Alan Cox
On Mer, 2005-08-24 at 12:53 -0700, Jesse Barnes wrote: > writel() ensures ordering? Only from one CPU, another CPU issuing a > write at some later time may have its write arrive first. See > Documentation/io_ordering.txt for some documentation I put together on > this issue. And in more detai

Re: question on memory barrier

2005-08-24 Thread Oliver Neukum
> > The sequence point argument is obviously wrong, BTW - if it were the > > case that a mere sequence point required the compiler to have completed > > all externally-visible side effects, then almost every optimization that > > gcc does with -O2 would be impossible. CSE, loop splitting, etc. >

Re: question on memory barrier

2005-08-24 Thread linux-os \(Dick Johnson\)
On Wed, 24 Aug 2005, Andy Isaacson wrote: > On Wed, Aug 24, 2005 at 07:31:31PM +0200, moreau francis wrote: >> --- "linux-os (Dick Johnson)" <[EMAIL PROTECTED]> a écrit : >>> On Wed, 24 Aug 2005, moreau francis wrote: I'm currently trying to write a USB driver for Linux. The device must be >

Re: question on memory barrier

2005-08-24 Thread Oliver Neukum
> And you never even bothered to read what I said about that??? > The write ORDER will NOT change. Period. It's a FIFO. Writes On current implementations of i386. That is not good enough. We want code that works everywhere. You are wrong. If you need to have ordered writes to a bus, use wmb().

Re: question on memory barrier

2005-08-24 Thread Jesse Barnes
On Wednesday, August 24, 2005 12:48 pm, Andy Isaacson wrote: > The first register write will be completed before the second register > write because you use writel, which is defined to have the semantics > you want. (It uses a platform-specific method to guarantee this, > possibly "volatile" or "a

Re: question on memory barrier

2005-08-24 Thread linux-os \(Dick Johnson\)
On Wed, 24 Aug 2005, Oliver Neukum wrote: > Am Mittwoch, 24. August 2005 20:22 schrieb linux-os (Dick Johnson): >>> sorry but I'm not sure to understand you...Do you mean that the first write >>> into reg_a pointer will be completed before the second write because they're >>> separated by a (;) ?

Re: question on memory barrier

2005-08-24 Thread Andy Isaacson
On Wed, Aug 24, 2005 at 07:31:31PM +0200, moreau francis wrote: > --- "linux-os (Dick Johnson)" <[EMAIL PROTECTED]> a écrit : > > On Wed, 24 Aug 2005, moreau francis wrote: > > > I'm currently trying to write a USB driver for Linux. The device must be > > > configured by writing some values into th

Re: question on memory barrier

2005-08-24 Thread Oliver Neukum
Am Mittwoch, 24. August 2005 20:22 schrieb linux-os (Dick Johnson): > > sorry but I'm not sure to understand you...Do you mean that the first write > > into reg_a pointer will be completed before the second write because they're > > separated by a (;) ? > > Yes. The compiler must make sure that ev

Re: question on memory barrier

2005-08-24 Thread linux-os \(Dick Johnson\)
On Wed, 24 Aug 2005, moreau francis wrote: > > --- "linux-os (Dick Johnson)" <[EMAIL PROTECTED]> a écrit : > >> >> On Wed, 24 Aug 2005, moreau francis wrote: >> >>> Hi, >>> >>> I'm currently trying to write a USB driver for Linux. The device must be >>> configured by writing some values into the

Re: question on memory barrier

2005-08-24 Thread moreau francis
--- "linux-os (Dick Johnson)" <[EMAIL PROTECTED]> a écrit : > > On Wed, 24 Aug 2005, moreau francis wrote: > > > Hi, > > > > I'm currently trying to write a USB driver for Linux. The device must be > > configured by writing some values into the same register but I want to be > > sure that the w

Re: question on memory barrier

2005-08-24 Thread linux-os \(Dick Johnson\)
On Wed, 24 Aug 2005, moreau francis wrote: > Hi, > > I'm currently trying to write a USB driver for Linux. The device must be > configured by writing some values into the same register but I want to be > sure that the writing order is respected by either the compiler and the cpu. > > For example,