summaryrefslogtreecommitdiff
path: root/drivers/net/fec_mxc.c
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-08-26 10:19:21 +0000
committerJoe Hershberger <joe.hershberger@ni.com>2012-09-27 12:22:09 -0500
commitefe24d2e17996f00b8803623c53cfe4baede9349 (patch)
tree4919bd04d9eb46e27ce49b7f2faa23d4a16f5fe8 /drivers/net/fec_mxc.c
parente2a66e609745470b1157fe6b6663c804ee44b0b9 (diff)
downloadu-boot-imx-efe24d2e17996f00b8803623c53cfe4baede9349.zip
u-boot-imx-efe24d2e17996f00b8803623c53cfe4baede9349.tar.gz
u-boot-imx-efe24d2e17996f00b8803623c53cfe4baede9349.tar.bz2
FEC: Properly align address over the buffers for cache ops
Align the address that's to be invalidated/flushed properly. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Benoit Thebaudeau <benoit.thebaudeau@advans> Cc: Eric Nelson <eric.nelson@boundarydevices.com> Cc: Fabio Estevam <festevam@gmail.com> Cc: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/net/fec_mxc.c')
-rw-r--r--drivers/net/fec_mxc.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 7b6a997..bc44d38 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -695,7 +695,7 @@ static void fec_halt(struct eth_device *dev)
static int fec_send(struct eth_device *dev, void *packet, int length)
{
unsigned int status;
- uint32_t size;
+ uint32_t size, end;
uint32_t addr;
/*
@@ -722,8 +722,9 @@ static int fec_send(struct eth_device *dev, void *packet, int length)
#endif
addr = (uint32_t)packet;
- size = roundup(length, ARCH_DMA_MINALIGN);
- flush_dcache_range(addr, addr + size);
+ end = roundup(addr + length, ARCH_DMA_MINALIGN);
+ addr &= ~(ARCH_DMA_MINALIGN - 1);
+ flush_dcache_range(addr, end);
writew(length, &fec->tbd_base[fec->tbd_index].data_length);
writel(addr, &fec->tbd_base[fec->tbd_index].data_pointer);
@@ -790,7 +791,7 @@ static int fec_recv(struct eth_device *dev)
int frame_length, len = 0;
struct nbuf *frame;
uint16_t bd_status;
- uint32_t addr, size;
+ uint32_t addr, size, end;
int i;
uchar buff[FEC_MAX_PKT_SIZE] __aligned(ARCH_DMA_MINALIGN);
@@ -854,8 +855,9 @@ static int fec_recv(struct eth_device *dev)
* Invalidate data cache over the buffer
*/
addr = (uint32_t)frame;
- size = roundup(frame_length, ARCH_DMA_MINALIGN);
- invalidate_dcache_range(addr, addr + size);
+ end = roundup(addr + frame_length, ARCH_DMA_MINALIGN);
+ addr &= ~(ARCH_DMA_MINALIGN - 1);
+ invalidate_dcache_range(addr, end);
/*
* Fill the buffer and pass it to upper layers