[PATCH] net: zynq_gem: Add cache flush to zynq_gem_free_pkt

Michal Simek monstr at monstr.eu
Mon Apr 6 12:59:38 CEST 2020


út 25. 2. 2020 v 12:42 odesílatel Michal Simek <michal.simek at xilinx.com> napsal:
>
> From: Ashok Reddy Soma <ashok.reddy.soma at xilinx.com>
>
> Add cache flush to zynq_gem_free_pkt. This is necessary
> because some net routines would modify this buffer in place.
> The cache_invalidate in the zynq_gem_recv function would cause
> the modifications to the buffer to overwrite the DMA from the GEM,
> if cache coherency is not enabled in the GEM, the next time the
> buffer is in use.
>
> Flushing the cache when the buffer is no longer in use by the
> net functions ensures that the GEM DMA is going to take place
> into a clean buffer.
>
> Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma at xilinx.com>
> Signed-off-by: Michal Simek <michal.simek at xilinx.com>
> ---
>
>  drivers/net/zynq_gem.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
> index 5f2f87d352c4..cfd14665a70d 100644
> --- a/drivers/net/zynq_gem.c
> +++ b/drivers/net/zynq_gem.c
> @@ -578,6 +578,7 @@ static int zynq_gem_free_pkt(struct udevice *dev, uchar *packet, int length)
>         struct zynq_gem_priv *priv = dev_get_priv(dev);
>         struct emac_bd *current_bd = &priv->rx_bd[priv->rxbd_current];
>         struct emac_bd *first_bd;
> +       dma_addr_t addr;
>
>         if (current_bd->status & ZYNQ_GEM_RXBUF_SOF_MASK) {
>                 priv->rx_first_buf = priv->rxbd_current;
> @@ -592,6 +593,17 @@ static int zynq_gem_free_pkt(struct udevice *dev, uchar *packet, int length)
>                 first_bd->status = 0xF0000000;
>         }
>
> +       /* Flush the cache for the packet as well */
> +#if defined(CONFIG_PHYS_64BIT)
> +       addr = (dma_addr_t)((current_bd->addr & ZYNQ_GEM_RXBUF_ADD_MASK)
> +               | ((dma_addr_t)current_bd->addr_hi << 32));
> +#else
> +       addr = current_bd->addr & ZYNQ_GEM_RXBUF_ADD_MASK;
> +#endif
> +       flush_dcache_range(addr, addr + roundup(PKTSIZE_ALIGN,
> +                                               ARCH_DMA_MINALIGN));
> +       barrier();
> +
>         if ((++priv->rxbd_current) >= RX_BUF)
>                 priv->rxbd_current = 0;
>
> --
> 2.25.1
>

Applied.
M

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


More information about the U-Boot mailing list