Re: question on memory barrier

From: Alan Cox
Date: Thu Aug 25 2005 - 04:39:26 EST


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;
>
> __mem = (void *)((unsigned long)(mem));
> __val = val;
>
> *__mem = __val;
> }
>
> I don't see the magic in it since "volatile" keyword do not handle memory
> ordering constraints...Linus wrote on volatile keyword, see

For the case and the platform the volatile is sufficient to force
ordering. That or the arch code author made a mistake. But I think its
sufifcient for MIPS. The volatile prevents

*foo = 1;
*foo = 2;

or even

*foo;

from being collapsed together or eliminated

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/