[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<PAXPR04MB8510E1BAD3FDB59268138682881B2@PAXPR04MB8510.eurprd04.prod.outlook.com>
Date: Fri, 17 Jan 2025 02:47:33 +0000
From: Wei Fang <wei.fang@....com>
To: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>, Shenwei Wang
<shenwei.wang@....com>, Clark Wang <xiaoning.wang@....com>
CC: "andrew+netdev@...n.ch" <andrew+netdev@...n.ch>, "davem@...emloft.net"
<davem@...emloft.net>, "edumazet@...gle.com" <edumazet@...gle.com>,
"kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>,
"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "netdev@...r.kernel.org"
<netdev@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH net-next] net: fec: implement TSO descriptor cleanup
> Implement the TODO in fec_enet_txq_submit_tso() error path to properly
> release buffer descriptors that were allocated during a failed TSO
> operation. This prevents descriptor leaks when TSO operations fail
> partway through.
>
> The cleanup iterates from the starting descriptor to where the error
> occurred, resetting the status and buffer address fields of each
> descriptor.
>
> Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@...il.com>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index b2daed55bf6c..eff065010c9e 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -913,7 +913,18 @@ static int fec_enet_txq_submit_tso(struct
> fec_enet_priv_tx_q *txq,
> return 0;
>
> err_release:
> - /* TODO: Release all used data descriptors for TSO */
> + /* Release all used data descriptors for TSO */
> + struct bufdesc *tmp_bdp = txq->bd.cur;
> +
> + while (tmp_bdp != bdp) {
> + tmp_bdp->cbd_sc = 0;
> + tmp_bdp->cbd_bufaddr = 0;
> + tmp_bdp->cbd_datlen = 0;
> + tmp_bdp = fec_enet_get_nextdesc(tmp_bdp, &txq->bd);
> + }
There is still some cleanup to do.
1. If bufdesc_ex is used, we also need to clear it, such as ebdp->cbd_esc.
2. The data buffers have been mapped in fec_enet_txq_put_data_tso(),
I think we need to unmap them in the error path. But do not unmap
the TSO header buff, which is a DMA memory. Actually it is not necessary
for fec_enet_txq_put_hdr_tso() to call dma_map_single(). If you are
interested, you can add a separate patch to remove dma_map_single()
in fec_enet_txq_put_hdr_tso().
> +
> + dev_kfree_skb_any(skb);
> +
> return ret;
> }
>
> --
> 2.34.1
Powered by blists - more mailing lists