Re: [PATCH] IBM Lanstreamer bugfixes

Alan Cox (alan@lxorguk.ukuu.org.uk)
Fri, 1 Feb 2002 23:38:38 +0000 (GMT)


> what purpose does the volatile below serve?
>
> io.h:122:#define writew(b,addr) (*(volatile unsigned short *)
> __io_virt(addr) = (b))X
>
> Is this a sort of "go do this now" command to flush it from the CPU to the
> PCI bus, while the readw() makes sure its flushed out of the PCI cache?

The compiler isnt obliged to actually generate the assignment in order
otherwise, so given

writew(1, foo+2);
writew(2, foo);

it might have the urge to reverse them - perhaps to optimise in using
postincrement modes

volatile says "stuff happens here beyond the compilers direct knowledge of
events".

Simple example

i=0;
while(i<100000) i++;

can be optimised to i=100000 if i is not volatile

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