For cache-incoherent DMA, dma_sync_single_for_cpu with DMA_FROM_DEVICE
invalidates the cache, so no stale lines in the cache hide what the
hardware had written to RAM.

On the same systems, dma_sync_single_for_device with DMA_FROM_DEVICE also
invalidates the cache, so no dirty lines from the CPU are evicted
clobbering what the hardware had written to RAM.

In rx_descs_init, the RX buffers need to be invalidated before transferring
ownership to the network controller, therefore we should use
dma_sync_single_for_device for clarity, even if it doesn't change behavior.

Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
---
 drivers/net/designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 183feba2ea5a..66f28b429dea 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -156,7 +156,7 @@ static void rx_descs_init(struct eth_device *dev)
                else
                        desc_p->dmamac_cntl |= DESC_RXCTRL_RXCHAIN;
 
-               dma_sync_single_for_cpu(dev->parent, desc_p->dmamac_addr,
+               dma_sync_single_for_device(dev->parent, desc_p->dmamac_addr,
                                        CONFIG_ETH_BUFSIZE, DMA_FROM_DEVICE);
                desc_p->txrx_status = DESC_RXSTS_OWNBYDMA;
        }
-- 
2.39.2


Reply via email to