[U-Boot] [linux-sunxi] Uboot error: address not aligned in v7_dcache_inval_range

Ian Campbell ijc at hellion.org.uk
Sat Apr 19 15:30:14 CEST 2014


On Sun, 2014-04-13 at 23:45 -0400, Shixin Zeng wrote:
> Hi,
> 
> I compiled the current u-boot from
> https://github.com/jwrdegoede/u-boot-sunxi.git for cubieboard2, and
> wrote it to the SD card. I was trying to boot the kernel on my
> computer over network by tftp, however it failed when I ran "dhcp" or
> "tftp" command in uboot with a tons of:
> 
> 
> ERROR: v7_dcache_inval_range - start address is not aligned - 0x7fb677e0
> ERROR: v7_dcache_inval_range - stop address is not aligned - 0x7fb67820

I'm seeing this on Cubieboard2 and Cubietruck. It appears to be down to
a change to the upstream designware driver:

commit 50b0df814b0f75c08a3d45a017016a75af3edb5d
Author: Alexey Brodkin <Alexey.Brodkin at synopsys.com>
Date:   Wed Jan 22 20:49:09 2014 +0400

    net/designware: make driver compatible with data cache
    
    Up until now this driver only worked with data cache disabled.
    To make it work with enabled data cache following changes were required:
    
     * Flush Tx/Rx buffer descriptors their modification
     * Invalidate Tx/Rx buffer descriptors before reading its values
     * Flush cache for data passed from CPU to GMAC
     * Invalidate cache for data passed from GMAC to CPU

http://git.denx.de/?p=u-boot.git;a=commit;h=50b0df814b0f75c08a3d45a017016a75af3edb5d

I suppose this was only tested on some architecture which allows DMA
flush/invaidation at a fairly fine granularity (at least down to 4 byte
boundaries)
 
Making sure that struct dw_eth_dev is DMA aligned helps with the
invalidate of the descriptors in dw_eth_recv (see below) but with that
the invalidate of the txrx_status field in dw_eth_send is still
problematic -- the field is only 4 bytes, so although the descriptor is
aligned the end is not.

Ian.


commit 8878d858ede12584b885fa9439f9093bf2186a90
Author: Ian Campbell <ijc at hellion.org.uk>
Date:   Sat Apr 19 14:16:04 2014 +0100

    net/designware: ensure device private data is DMA aligned.
    
    struct dw_eth_dev contains fields which are accessed via DMA, so make sure it
    is aligned to a dma boundary. Without this I see:
        ERROR: v7_dcache_inval_range - start address is not aligned - 0x7fb677e0
    
    Signed-off-by: Ian Campbell <ian.campbell at citrix.com>

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 6ece479..1120f70 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -412,7 +412,8 @@ int designware_initialize(ulong base_addr, u32 interface)
 	 * Since the priv structure contains the descriptors which need a strict
 	 * buswidth alignment, memalign is used to allocate memory
 	 */
-	priv = (struct dw_eth_dev *) memalign(16, sizeof(struct dw_eth_dev));
+	priv = (struct dw_eth_dev *) memalign(ARCH_DMA_MINALIGN,
+					      sizeof(struct dw_eth_dev));
 	if (!priv) {
 		free(dev);
 		return -ENOMEM;




More information about the U-Boot mailing list