[U-Boot] [PATCH 01/10] Fix IP alignement problem

Haavard Skinnemoen haavard.skinnemoen at atmel.com
Fri Oct 10 16:42:33 CEST 2008


[Cc'ing the networking maintainer]

Olav Morken <olavmrk at gmail.com> wrote:
> This patch removes volatile from:
> volatile IP_t *ip = (IP_t *)xip;
> 
> Due to a bug, avr32-gcc will assume that ip is aligned on a word boundary when
> using volatile, which causes an exception since xip isn't aligned on a word
> boundary.

Note that this bug has been reported internally, and will hopefully get
fixed soon.

That said, I feel somewhat suspicious about the rather liberal use of
volatile in the networking code. Is that really necessary? It looks to
me that in many cases, volatile does nothing apart from hurting
performance.

Looking at the assembly code, gcc does some really stupid things in
there. Maybe that's an avr32-specific problem, but gcc has been known
to generate crappy code on other architectures as well when volatile is
involved...

> Signed-off-by: Gunnar Rangoy <gunnar at rangoy.com>
> Signed-off-by: Paul Driveklepp <pauldriveklepp at gmail.com>
> Signed-off-by: Olav Morken <olavmrk at gmail.com>
> ---
>  net/net.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/net/net.c b/net/net.c
> index 313d5d8..405ca6e 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1685,7 +1685,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
>  void
>  NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
>  {
> -	volatile IP_t *ip = (IP_t *)xip;
> +	IP_t *ip = (IP_t *)xip;
>  
>  	/*
>  	 *	If the data is an odd number of bytes, zero the
> -- 
> 1.6.0.2

Haavard


More information about the U-Boot mailing list