diff mbox series

[4/6] net: dwc_eth_qos: Invalidate RX descriptor before reading

Message ID 20200323014526.3340884-4-marex@denx.de
State Accepted
Commit 738ee270fe17ea9e48fee8823eb356ed03656e7c
Headers show
Series [1/6] net: dwc_eth_qos: Fully rewrite RX descriptor field 3 | expand

Commit Message

Marek Vasut March 23, 2020, 1:45 a.m. UTC
The current code polls the RX desciptor ring for new packets by reading
the RX descriptor status. This works by accident, as the RX descriptors
are often in non-cacheable memory. However, the driver does support use
of RX descriptors in cacheable memory.

This patch adds a missing RX descriptor invalidation, which assures the
CPU will read a fresh copy of the RX descriptor instead of a cached one.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Patrice Chotard <patrice.chotard at st.com>
Cc: Patrick Delaunay <patrick.delaunay at st.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Stephen Warren <swarren at nvidia.com>
---
 drivers/net/dwc_eth_qos.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ramon Fried March 23, 2020, 7:07 a.m. UTC | #1
On Mon, Mar 23, 2020 at 3:45 AM Marek Vasut <marex at denx.de> wrote:
>
> The current code polls the RX desciptor ring for new packets by reading
> the RX descriptor status. This works by accident, as the RX descriptors
> are often in non-cacheable memory. However, the driver does support use
> of RX descriptors in cacheable memory.
>
> This patch adds a missing RX descriptor invalidation, which assures the
> CPU will read a fresh copy of the RX descriptor instead of a cached one.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Patrice Chotard <patrice.chotard at st.com>
> Cc: Patrick Delaunay <patrick.delaunay at st.com>
> Cc: Ramon Fried <rfried.dev at gmail.com>
> Cc: Stephen Warren <swarren at nvidia.com>
> ---
>  drivers/net/dwc_eth_qos.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
> index 66cc301c8c..e40c461278 100644
> --- a/drivers/net/dwc_eth_qos.c
> +++ b/drivers/net/dwc_eth_qos.c
> @@ -1397,6 +1397,7 @@ static int eqos_recv(struct udevice *dev, int flags, uchar **packetp)
>         debug("%s(dev=%p, flags=%x):\n", __func__, dev, flags);
>
>         rx_desc = &(eqos->rx_descs[eqos->rx_desc_idx]);
> +       eqos->config->ops->eqos_inval_desc(rx_desc);
>         if (rx_desc->des3 & EQOS_DESC3_OWN) {
>                 debug("%s: RX packet not available\n", __func__);
>                 return -EAGAIN;
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev at gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 66cc301c8c..e40c461278 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -1397,6 +1397,7 @@  static int eqos_recv(struct udevice *dev, int flags, uchar **packetp)
 	debug("%s(dev=%p, flags=%x):\n", __func__, dev, flags);
 
 	rx_desc = &(eqos->rx_descs[eqos->rx_desc_idx]);
+	eqos->config->ops->eqos_inval_desc(rx_desc);
 	if (rx_desc->des3 & EQOS_DESC3_OWN) {
 		debug("%s: RX packet not available\n", __func__);
 		return -EAGAIN;