On Mon, 3 Jan 2005 11:02:22 -0500 (EST), Alan Stern <[EMAIL PROTECTED]> wrote:

> This patch adds "volatile" to a couple of declarations for fields in the 
> UHCI driver that are susceptible to outside change by DMA.  Without this 
> or some similar approach to defeat gcc's optimizer, the compiler will 
> generate incorrect references to these fields.

>  struct uhci_qh {
>       /* Hardware fields */
>       __le32 link;                    /* Next queue */
> -     __le32 element;                 /* Queue element pointer */
> +     __le32 volatile element;        /* Queue element pointer */

This is not a good idea, at least not typically. This was extensively
discussed before, and although I cannot repeat all arguments precisely,
I remember that I found them convincing. It boils down to two things.
Fist is SMP: volatile does nothing to help serialize accesses, although
I can see that in perhaps in this case it's not an issue. The second
is portability: on a few CPUs special instructions are necessary for
serializations, which are provided by memory barriers. I would suggest
adding barriers explicitly.

Greetings,
-- Pete


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to