From: Stefan Theil Date: Thu, 13 Dec 2018 13:25:53 +0000 Subject: [U-Boot] [PATCH] zynq-gem: Flush cache before handing RX packet to receive handler Message-ID: <22bfd13652dc41acb1e9d65f6cf61e1c@Neckar.pixel-group.local> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hmm good question. I went with flush because that's what's done in the tran= smit function: addr =3D (ulong) ptr; addr &=3D ~(ARCH_DMA_MINALIGN - 1); size =3D roundup(len, ARCH_DMA_MINALIGN); flush_dcache_range(addr, addr + size); addr =3D (ulong)priv->rxbuffers; addr &=3D ~(ARCH_DMA_MINALIGN - 1); size =3D roundup((RX_BUF * PKTSIZE_ALIGN), ARCH_DMA_MINALIGN); flush_dcache_range(addr, addr + size); barrier(); But since we actually want the uncached data invalidation seems logical. I = have to admit though, I don't have much experience with caches. This patch = completely fixed my problem... Maybe somebody with a bit more expertise can= add their opinion? Regards, Stefan > -----Urspr=C3=BCngliche Nachricht----- > Von: Bin Meng [mailto:bmeng.cn at gmail.com] > Gesendet: Donnerstag, 13. Dezember 2018 14:13 > An: Stefan Theil > Cc: U-Boot Mailing List > Betreff: Re: [U-Boot] [PATCH] zynq-gem: Flush cache before handing RX > packet to receive handler >=20 > On Thu, Dec 13, 2018 at 6:18 PM Stefan Theil > wrote: > > > > 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. > > > > Signed-off-by: Stefan Theil > > --- > > drivers/net/zynq_gem.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index > > 9bd79b198a..5825b6dd99 100644 > > --- a/drivers/net/zynq_gem.c > > +++ b/drivers/net/zynq_gem.c > > @@ -621,6 +621,9 @@ static int zynq_gem_recv(struct udevice *dev, int > > flags, uchar **packetp) > > > > *packetp =3D (uchar *)(uintptr_t)addr; > > > > + flush_dcache_range(addr, addr + roundup(PKTSIZE_ALIGN, > > + ARCH_DMA_MINALIGN)); >=20 > Shouldn't it be invalidate_dcache_range()? >=20 > > + barrier(); > > + > > return frame_len; > > } > > >=20 > Regards, > Bin