Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions drivers/net/ethernet/spacemit/k1_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@

struct desc_buf {
u64 dma_addr;
void *buff_addr;
u16 dma_len;
u8 map_as_page;
};
Expand All @@ -70,7 +69,6 @@ struct emac_tx_desc_buffer {
struct emac_rx_desc_buffer {
struct sk_buff *skb;
u64 dma_addr;
void *buff_addr;
u16 dma_len;
u8 map_as_page;
};
Expand Down Expand Up @@ -340,7 +338,6 @@ static void emac_free_tx_buf(struct emac_priv *priv, int i)

buf->dma_addr = 0;
buf->map_as_page = false;
buf->buff_addr = NULL;
}

if (tx_buf->skb) {
Expand Down Expand Up @@ -451,12 +448,12 @@ static void emac_free_tx_resources(struct emac_priv *priv)

emac_clean_tx_desc_ring(priv);

kfree(tr->tx_desc_buf);
tr->tx_desc_buf = NULL;

dma_free_coherent(dev, tr->total_size, tr->desc_addr,
tr->desc_dma_addr);
tr->desc_addr = NULL;

kfree(tr->tx_desc_buf);
tr->tx_desc_buf = NULL;
}

static void emac_free_rx_resources(struct emac_priv *priv)
Expand All @@ -466,12 +463,12 @@ static void emac_free_rx_resources(struct emac_priv *priv)

emac_clean_rx_desc_ring(priv);

kfree(rr->rx_desc_buf);
rr->rx_desc_buf = NULL;

dma_free_coherent(dev, rr->total_size, rr->desc_addr,
rr->desc_dma_addr);
rr->desc_addr = NULL;

kfree(rr->rx_desc_buf);
rr->rx_desc_buf = NULL;
}

static int emac_tx_clean_desc(struct emac_priv *priv)
Expand Down Expand Up @@ -567,7 +564,9 @@ static void emac_alloc_rx_desc_buffers(struct emac_priv *priv)
DMA_FROM_DEVICE);
if (dma_mapping_error(&priv->pdev->dev, rx_buf->dma_addr)) {
dev_err_ratelimited(&ndev->dev, "Mapping skb failed\n");
goto err_free_skb;
dev_kfree_skb_any(skb);
rx_buf->skb = NULL;
break;
}

rx_desc_addr = &((struct emac_desc *)rx_ring->desc_addr)[i];
Expand All @@ -592,10 +591,6 @@ static void emac_alloc_rx_desc_buffers(struct emac_priv *priv)

rx_ring->head = i;
return;

err_free_skb:
dev_kfree_skb_any(skb);
rx_buf->skb = NULL;
}

/* Returns number of packets received */
Expand Down Expand Up @@ -737,7 +732,7 @@ static void emac_tx_mem_map(struct emac_priv *priv, struct sk_buff *skb)
struct emac_desc tx_desc, *tx_desc_addr;
struct device *dev = &priv->pdev->dev;
struct emac_tx_desc_buffer *tx_buf;
u32 head, old_head, frag_num, f;
u32 head, old_head, frag_num, f, i;
bool buf_idx;

frag_num = skb_shinfo(skb)->nr_frags;
Expand Down Expand Up @@ -805,6 +800,15 @@ static void emac_tx_mem_map(struct emac_priv *priv, struct sk_buff *skb)

err_free_skb:
dev_dstats_tx_dropped(priv->ndev);

i = old_head;
while (i != head) {
emac_free_tx_buf(priv, i);

if (++i == tx_ring->total_cnt)
i = 0;
}

dev_kfree_skb_any(skb);
}

Expand Down