question on memory barrier
From: moreau francis
Date: Wed Aug 24 2005 - 07:47:07 EST
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
-
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/