[PATCH 19/24] net: xgmac: convert to streaming DMA ops
Lucas Stach
dev at lynxeye.de
Sun Mar 1 05:17:17 PST 2015
Move to the common streaming DMA ops in order to get rid of
the direct usage of the ARM MMU functions for the cache
maintenance.
Signed-off-by: Lucas Stach <dev at lynxeye.de>
---
drivers/net/xgmac.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index c1e4da8..f39dc4c 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -25,7 +25,6 @@
#include <errno.h>
#include <io.h>
#include <linux/err.h>
-#include <asm/mmu.h>
#define TX_NUM_DESC 1
#define RX_NUM_DESC 32
@@ -587,7 +586,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length)
struct xgmac_dma_desc *txdesc = &priv->tx_chain[currdesc];
int ret;
- dma_flush_range((ulong) packet, (ulong)packet + length);
+ dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
desc_set_buf_addr_and_size(txdesc, packet, length);
desc_set_tx_owner(txdesc, TXDESC_FIRST_SEG |
TXDESC_LAST_SEG | TXDESC_CRC_EN_APPEND);
@@ -596,6 +595,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length)
writel(1, priv->base + XGMAC_DMA_TX_POLL);
ret = wait_on_timeout(1 * SECOND, !desc_get_owner(txdesc));
+ dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
if (ret) {
dev_err(priv->dev, "TX timeout\n");
return ret;
@@ -611,14 +611,19 @@ static int xgmac_recv(struct eth_device *edev)
u32 currdesc = priv->rx_currdesc;
struct xgmac_dma_desc *rxdesc = &priv->rx_chain[currdesc];
int length = 0;
+ void *buf_addr;
/* check if the host has the desc */
if (desc_get_owner(rxdesc))
return -1; /* something bad happened */
length = desc_get_rx_frame_len(rxdesc);
+ buf_addr = desc_get_buf_addr(rxdesc);
- net_receive(edev, desc_get_buf_addr(rxdesc), length);
+ dma_sync_single_for_cpu((unsigned long)buf_addr, length, DMA_FROM_DEVICE);
+ net_receive(edev, buf_addr, length);
+ dma_sync_single_for_device((unsigned long)buf_addr, length,
+ DMA_FROM_DEVICE);
/* set descriptor back to owned by XGMAC */
desc_set_rx_owner(rxdesc);
--
2.1.0
More information about the barebox
mailing list