All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3] zynq-gem: Use appropriate cache flush/invalidate for RX and TX
       [not found] <[U-Boot] [PATCH v2] zynq-gem: Flush cache before handing RX packet to receive handler>
@ 2018-12-13 14:37 ` Stefan Theil
  2018-12-13 15:31   ` Bin Meng
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Theil @ 2018-12-13 14:37 UTC (permalink / raw)
  To: u-boot

The cache was only flushed before *transmitting* packets, but not
when receiving them, leading to an issue where new packets were
handed to the receive handler with old contents in cache. This
only happens when a lot of packets are received without sending
packages every now and then. Also flushing the receive buffers
in the transmit function makes no sense and can be removed.

Signed-off-by: Stefan Theil <stefan.theil@mixed-mode.de>

---
Changes for v2:
	- Use invalidate_dcache_range instead of
	  flush_dcache_range
Changes for v3:
	- Remove unnecessary flushing of all RX
	  buffers in zynq_gem_send
---
 drivers/net/zynq_gem.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index 9bd79b198a..4f7d945562 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -570,11 +570,6 @@ static int zynq_gem_send(struct udevice *dev, void *ptr, int len)
 	addr &= ~(ARCH_DMA_MINALIGN - 1);
 	size = roundup(len, ARCH_DMA_MINALIGN);
 	flush_dcache_range(addr, addr + size);
-
-	addr = (ulong)priv->rxbuffers;
-	addr &= ~(ARCH_DMA_MINALIGN - 1);
-	size = roundup((RX_BUF * PKTSIZE_ALIGN), ARCH_DMA_MINALIGN);
-	flush_dcache_range(addr, addr + size);
 	barrier();
 
 	/* Start transmit */
@@ -621,6 +616,9 @@ static int zynq_gem_recv(struct udevice *dev, int flags, uchar **packetp)
 
 	*packetp = (uchar *)(uintptr_t)addr;
 
+	invalidate_dcache_range(addr, addr + roundup(PKTSIZE_ALIGN, ARCH_DMA_MINALIGN));
+	barrier();
+
 	return frame_len;
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH v3] zynq-gem: Use appropriate cache flush/invalidate for RX and TX
  2018-12-13 14:37 ` [U-Boot] [PATCH v3] zynq-gem: Use appropriate cache flush/invalidate for RX and TX Stefan Theil
@ 2018-12-13 15:31   ` Bin Meng
  0 siblings, 0 replies; 2+ messages in thread
From: Bin Meng @ 2018-12-13 15:31 UTC (permalink / raw)
  To: u-boot

On Thu, Dec 13, 2018 at 10:39 PM Stefan Theil
<stefan.theil@mixed-mode.de> wrote:
>
> The cache was only flushed before *transmitting* packets, but not

nits: but not invalidated

> when receiving them, leading to an issue where new packets were
> handed to the receive handler with old contents in cache. This
> only happens when a lot of packets are received without sending
> packages every now and then. Also flushing the receive buffers
> in the transmit function makes no sense and can be removed.
>
> Signed-off-by: Stefan Theil <stefan.theil@mixed-mode.de>
>
> ---
> Changes for v2:
>         - Use invalidate_dcache_range instead of
>           flush_dcache_range
> Changes for v3:
>         - Remove unnecessary flushing of all RX
>           buffers in zynq_gem_send
> ---
>  drivers/net/zynq_gem.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-13 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <[U-Boot] [PATCH v2] zynq-gem: Flush cache before handing RX packet to receive handler>
2018-12-13 14:37 ` [U-Boot] [PATCH v3] zynq-gem: Use appropriate cache flush/invalidate for RX and TX Stefan Theil
2018-12-13 15:31   ` Bin Meng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.