Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e3173a3 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by David S. Miller
Browse files

net: mvneta: Avoid unmapping the TSO header buffers



The buffers for the TSO headers belong to a DMA coherent region which is
allocated at ndo_open() time, and released at ndo_stop() time.

Therefore, and contrary to the TSO payload descriptor buffers, the TSO header
buffers don't need to be unmapped. This commit adds a check to detect a
TSO header buffer and explicitly prevent the unmap.

Signed-off-by: default avatarEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ba7e46ef
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -264,6 +264,10 @@
	      ETH_HLEN + ETH_FCS_LEN,			     \
	      MVNETA_CPU_D_CACHE_LINE_SIZE)

#define IS_TSO_HEADER(txq, addr) \
	((addr >= txq->tso_hdrs_phys) && \
	 (addr < txq->tso_hdrs_phys + txq->size * TSO_HEADER_SIZE))

#define MVNETA_RX_BUF_SIZE(pkt_size)   ((pkt_size) + NET_SKB_PAD)

struct mvneta_pcpu_stats {
@@ -1291,7 +1295,9 @@ static void mvneta_txq_bufs_free(struct mvneta_port *pp,

		mvneta_txq_inc_get(txq);

		dma_unmap_single(pp->dev->dev.parent, tx_desc->buf_phys_addr,
		if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr))
			dma_unmap_single(pp->dev->dev.parent,
					 tx_desc->buf_phys_addr,
					 tx_desc->data_size, DMA_TO_DEVICE);
		if (!skb)
			continue;
@@ -1642,7 +1648,7 @@ static int mvneta_tx_tso(struct sk_buff *skb, struct net_device *dev,
	 */
	for (i = desc_count - 1; i >= 0; i--) {
		struct mvneta_tx_desc *tx_desc = txq->descs + i;
		if (!(tx_desc->command & MVNETA_TXD_F_DESC))
		if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr))
			dma_unmap_single(pp->dev->dev.parent,
					 tx_desc->buf_phys_addr,
					 tx_desc->data_size,