Commit 1f544f65 authored by Simon Guinot's avatar Simon Guinot Committed by Kamal Mostafa

net: mvneta: fix DMA buffer unmapping in mvneta_rx()

commit daf158d0 upstream.

This patch fixes a regression introduced by the commit a84e3289
("net: mvneta: fix refilling for Rx DMA buffers"). Due to this commit
the newly allocated Rx buffers are DMA-unmapped in place of those passed
to the networking stack. Obviously, this causes data corruptions.

This patch fixes the issue by ensuring that the right Rx buffers are
DMA-unmapped.
Reported-by: default avatarOren Laskin <oren@igneous.io>
Signed-off-by: default avatarSimon Guinot <simon.guinot@sequanux.org>
Fixes: a84e3289 ("net: mvneta: fix refilling for Rx DMA buffers")
Tested-by: default avatarOren Laskin <oren@igneous.io>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 905db2ff
...@@ -1452,6 +1452,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo, ...@@ -1452,6 +1452,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq); struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq);
struct sk_buff *skb; struct sk_buff *skb;
unsigned char *data; unsigned char *data;
dma_addr_t phys_addr;
u32 rx_status; u32 rx_status;
int rx_bytes, err; int rx_bytes, err;
...@@ -1459,6 +1460,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo, ...@@ -1459,6 +1460,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
rx_status = rx_desc->status; rx_status = rx_desc->status;
rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE); rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
data = (unsigned char *)rx_desc->buf_cookie; data = (unsigned char *)rx_desc->buf_cookie;
phys_addr = rx_desc->buf_phys_addr;
if (!mvneta_rxq_desc_is_first_last(rx_status) || if (!mvneta_rxq_desc_is_first_last(rx_status) ||
(rx_status & MVNETA_RXD_ERR_SUMMARY)) { (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
...@@ -1507,7 +1509,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo, ...@@ -1507,7 +1509,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
if (!skb) if (!skb)
goto err_drop_frame; goto err_drop_frame;
dma_unmap_single(dev->dev.parent, rx_desc->buf_phys_addr, dma_unmap_single(dev->dev.parent, phys_addr,
MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE); MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
rcvd_pkts++; rcvd_pkts++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment