[U-Boot-Users] cfi_flash.c and lost volatile qualifier

Haavard Skinnemoen haavard.skinnemoen at atmel.com
Thu May 8 13:17:45 CEST 2008


Adrian Filipi <adrian.filipi at eurotech.com> wrote:
> diff -u -r1.1.1.2.2.2 cfi_flash.c
> --- cfi_flash.c	23 Apr 2008 17:02:47 -0000	1.1.1.2.2.2
> +++ cfi_flash.c	29 Apr 2008 18:55:47 -0000
> @@ -464,7 +464,7 @@
>   			     uint offset, uchar cmd)
>   {
> 
> -	void *addr;
> +	void *volatile addr;

That looks bogus. It makes the pointer itself volatile, not whatever it
points to. All accesses through addr is performed by appropriate I/O
accessors, so no volatile should be needed, and certainly not one that
affects the pointer itself.

I suspect the change adds a few extra memory accesses (probably to the
stack) so that any memory ordering problems just happen to go away.

flash_write_cmd() calls sync() after writing the command to the flash,
so any memory ordering issues should have been taken care of. However,
sync() does nothing on ARM. Maybe it should do something?

Haavard




More information about the U-Boot mailing list