public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* question on memory barrier
@ 2005-08-24 12:43 moreau francis
  2005-08-24 13:04 ` linux-os (Dick Johnson)
  2005-08-24 21:57 ` Alan Cox
  0 siblings, 2 replies; 22+ messages in thread
From: moreau francis @ 2005-08-24 12:43 UTC (permalink / raw)
  To: linux-kernel

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, here is a bit of driver's code:

"""
#include <asm/io.h>

static inline void dev_out(u32 *reg, u32 value)
{
        writel(value, regs);
}

void config_dev(void)
{
        dev_out(reg_a, 0x0); /* first io */
        dev_out(reg_a, 0xA); /* second io */
}

void config_dev_fixed(void)
{
        dev_out(reg_a, 0x0); /* first io */
        wmb();
        dev_out(reg_a, 0xA); /* second io */
        wmb();
}
"""

In this case, am I sure that the order will be respected ? can gcc remove
the first io while optimizing...If so, does "config_dev_fixed" fix it ?

thanks for your answers,

            Francis


	

	
		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2005-08-26 10:45 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-24 12:43 question on memory barrier moreau francis
2005-08-24 13:04 ` linux-os (Dick Johnson)
2005-08-24 17:31   ` moreau francis
2005-08-24 18:22     ` linux-os (Dick Johnson)
2005-08-24 19:32       ` Oliver Neukum
2005-08-24 19:47         ` linux-os (Dick Johnson)
2005-08-24 19:55           ` Oliver Neukum
2005-08-24 19:48     ` Andy Isaacson
2005-08-24 19:53       ` Jesse Barnes
2005-08-24 21:45         ` Alan Cox
2005-08-24 21:22           ` Jesse Barnes
2005-08-24 20:03       ` linux-os (Dick Johnson)
2005-08-24 20:21         ` Oliver Neukum
2005-08-25  2:25         ` David Schwartz
2005-08-25  8:49       ` Denis Vlasenko
2005-08-25  9:14       ` moreau francis
2005-08-25 10:07         ` Alan Cox
2005-08-25 14:54         ` Andy Isaacson
2005-08-26  7:21           ` moreau francis
2005-08-26 10:37             ` Maciej W. Rozycki
2005-08-25 10:32       ` Maciej W. Rozycki
2005-08-24 21:57 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox