Re: [PATCH net] net: fec: remove unnecessary DMA mapping of TSO header

From: Dheeraj Reddy Jonnalagadda
Date: Thu Jan 23 2025 - 05:34:24 EST


On Thu, Jan 23, 2025 at 02:58:32AM +0000, Wei Fang wrote:
>
> Hi Dheeraj,
>
> I must admit that I misread it too. There is another case in the TSO
> header where txq->tx_bounce may be used in some cases. I think
> the most correct fix is to make txq->tso_hdrs aligned to 32/64 bytes
> when allocating tso_hdrs, then we do not need to use txq->tx_bounce
> in fec_enet_txq_put_hdr_tso(), because (bufaddr) & fep->tx_align)
> will not be true. This way we can safely remove dma_map_single()
> from fec_enet_txq_put_hdr_tso().

Hi Fang, Simon,

Thank you for the feedback. I have a clarification question regarding
the alignment of txq->tso_hdrs.

In the current code, txq->tso_hdrs is allocated using fec_dma_alloc(),
which internally calls dma_alloc_coherent(). As I understand it,
dma_alloc_coherent() guarantees that the allocated buffer is properly aligned.

Given this, should we remove the alignment check
((unsigned long)bufaddr) & fep->tx_align and the associated dma_map_single()
logic entirely from fec_enet_txq_put_hdr_tso() as you have suggested?

-Dheeraj