Subject: Re: [PATCH net-next v11 5/7] net: tn40xx: add basic Rx handling

From: Jakub Kicinski <[email-masked]>
Date: Tue, 18 Jun 2024 18:52:47 -0700

On Tue, 18 Jun 2024 14:16:06 +0900 FUJITA Tomonori wrote:
> +	netif_tx_lock(priv->ndev);
> +	while (f->m.wptr != f->m.rptr) {
> +		f->m.rptr += TN40_TXF_DESC_SZ;
> +		f->m.rptr &= f->m.size_mask;
> +		/* Unmap all fragments */
> +		/* First has to come tx_maps containing DMA */
> +		do {
> +			dma_unmap_page(&priv->pdev->dev, db->rptr->addr.dma,
> +				       db->rptr->len, DMA_TO_DEVICE);
> +			tn40_tx_db_inc_rptr(db);
> +		} while (db->rptr->len > 0);
> +		tx_level -= db->rptr->len; /* '-' Because the len is negative */
> +
> +		/* Now should come skb pointer - free it */
> +		dev_kfree_skb_any(db->rptr->addr.skb);
> +		netdev_dbg(priv->ndev, "dev_kfree_skb_any %p %d\n",
> +			   db->rptr->addr.skb, -db->rptr->len);
> +		tn40_tx_db_inc_rptr(db);
> +	}

Do you have to hold the Tx lock while unmapping the previous skbs?
That's the most expensive part of the function, would be good to let
other CPUs queue new packets at the same time.