summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2019-05-30 14:28:15 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-06-04 08:48:30 +0200
commit67881bf78aae3a354475c84e32c51df584a0d615 (patch)
treee54cb890b38bc16946ff4efd17c41ead88462e3b /drivers/net
parentdc8d91d76a7594dccee3efb49ea65a10e15d01cb (diff)
downloadbarebox-67881bf78aae3a354475c84e32c51df584a0d615.tar.gz
net: macb: dma_sync_* receive buffers
Receive buffers are properly synchronized only if Cadence is GEM. Fix it for MACB as well. Fixes: 86dc5259e25d (net: macb: no need for coherent memory for receive buffer) Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/macb.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 0c0d17e..a0411d6 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -209,9 +209,11 @@ static int macb_recv(struct eth_device *edev)
dev_dbg(macb->dev, "%s\n", __func__);
for (;;) {
+ barrier();
if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED)))
return -1;
+ barrier();
status = macb->rx_ring[rx_tail].ctrl;
if (status & MACB_BIT(RX_SOF)) {
if (rx_tail != macb->rx_tail)
@@ -228,14 +230,26 @@ static int macb_recv(struct eth_device *edev)
headlen = macb->rx_buffer_size * (macb->rx_ring_size
- macb->rx_tail);
taillen = length - headlen;
- memcpy((void *)NetRxPackets[0],
- buffer, headlen);
+ dma_sync_single_for_cpu((unsigned long)buffer,
+ headlen, DMA_FROM_DEVICE);
+ memcpy((void *)NetRxPackets[0], buffer, headlen);
+ dma_sync_single_for_cpu((unsigned long)macb->rx_buffer,
+ taillen, DMA_FROM_DEVICE);
memcpy((void *)NetRxPackets[0] + headlen,
- macb->rx_buffer, taillen);
- buffer = (void *)NetRxPackets[0];
+ macb->rx_buffer, taillen);
+ dma_sync_single_for_device((unsigned long)buffer,
+ headlen, DMA_FROM_DEVICE);
+ dma_sync_single_for_device((unsigned long)macb->rx_buffer,
+ taillen, DMA_FROM_DEVICE);
+ net_receive(edev, NetRxPackets[0], length);
+ } else {
+ dma_sync_single_for_cpu((unsigned long)buffer, length,
+ DMA_FROM_DEVICE);
+ net_receive(edev, buffer, length);
+ dma_sync_single_for_device((unsigned long)buffer, length,
+ DMA_FROM_DEVICE);
}
-
- net_receive(edev, buffer, length);
+ barrier();
if (++rx_tail >= macb->rx_ring_size)
rx_tail = 0;
reclaim_rx_buffers(macb, rx_tail);
@@ -245,7 +259,6 @@ static int macb_recv(struct eth_device *edev)
rx_tail = 0;
}
}
- barrier();
}
return 0;