]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: dwc_eth_qos: Prevent DMA from writing updated RX DMA descriptor
authorMarek Vasut <marex@denx.de>
Mon, 23 Mar 2020 01:11:46 +0000 (02:11 +0100)
committermarex <marex@desktop.lan>
Fri, 1 May 2020 10:35:21 +0000 (12:35 +0200)
The DMA may attempt to write a DMA descriptor in the ring while it is
being updated. By writing the DMA descriptor buffer address to 0, it
is assured the DMA will not use such a buffer and the buffer can be
updated without any interference.

Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
drivers/net/dwc_eth_qos.c

index a195fe5c2753b7a153806670c0f1671aff699a0d..60dfd17a74d31d55c9f4a4bd3d1f687d970ed3f9 100644 (file)
@@ -1477,8 +1477,10 @@ static int eqos_free_pkt(struct udevice *dev, uchar *packet, int length)
 
        rx_desc = &(eqos->rx_descs[eqos->rx_desc_idx]);
 
+       rx_desc->des0 = 0;
+       mb();
+       eqos->config->ops->eqos_flush_desc(rx_desc);
        eqos->config->ops->eqos_inval_buffer(packet, length);
-
        rx_desc->des0 = (u32)(ulong)packet;
        rx_desc->des1 = 0;
        rx_desc->des2 = 0;