netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
To: Wei Fang <wei.fang@nxp.com>
Cc: Shenwei Wang <shenwei.wang@nxp.com>,
	Clark Wang <xiaoning.wang@nxp.com>,
	"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] net: fec: implement TSO descriptor cleanup
Date: Sat, 18 Jan 2025 09:53:20 +0530	[thread overview]
Message-ID: <Z4ssuJQc0SClS5uF@HOME-PC> (raw)
In-Reply-To: <PAXPR04MB8510E1BAD3FDB59268138682881B2@PAXPR04MB8510.eurprd04.prod.outlook.com>

On Fri, Jan 17, 2025 at 02:47:33AM +0000, Wei Fang wrote:
> > 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@gmail.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
> 
Hello Simon and Fang,

Thank you you valuable feedback. I will incorporate the suggestions and 
send the updated patch.

-Dheeraj

  reply	other threads:[~2025-01-18  4:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 13:09 [PATCH net-next] net: fec: implement TSO descriptor cleanup Dheeraj Reddy Jonnalagadda
2025-01-16 18:24 ` Simon Horman
2025-01-17  2:47 ` Wei Fang
2025-01-18  4:23   ` Dheeraj Reddy Jonnalagadda [this message]
2025-01-17 15:30 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z4ssuJQc0SClS5uF@HOME-PC \
    --to=dheeraj.linuxdev@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imx@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shenwei.wang@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).