All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hao <haokexin@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Sunil Goutham <sgoutham@marvell.com>,
	Geetha sowjanya <gakula@marvell.com>,
	Subbaraya Sundeep <sbhatta@marvell.com>,
	hariprasad <hkelam@marvell.com>,
	davem@davemloft.net, Sunil Kovvuri <sunil.kovvuri@gmail.com>
Subject: Re: [PATCH v2] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers
Date: Sat, 9 May 2020 08:53:32 +0800	[thread overview]
Message-ID: <20200509005332.GK3222151@pek-khao-d2.corp.ad.wrs.com> (raw)
In-Reply-To: <20200508173833.0f48cccc@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

[-- Attachment #1: Type: text/plain, Size: 2238 bytes --]

On Fri, May 08, 2020 at 05:38:33PM -0700, Jakub Kicinski wrote:
> On Fri,  8 May 2020 19:49:53 +0800 Kevin Hao wrote:
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > index f1d2dea90a8c..612d33207326 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> > @@ -379,40 +379,33 @@ void otx2_config_irq_coalescing(struct otx2_nic *pfvf, int qidx)
> >  		     (pfvf->hw.cq_ecount_wait - 1));
> >  }
> >  
> > -dma_addr_t otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool,
> > -			   gfp_t gfp)
> > +dma_addr_t _otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool)
> 
> If you need to respin please use double underscore as a prefix, it's
> a far more common style in the kernel.

Sure.

> 
> >  {
> >  	dma_addr_t iova;
> > +	u8 *buf;
> >  
> > -	/* Check if request can be accommodated in previous allocated page */
> > -	if (pool->page && ((pool->page_offset + pool->rbsize) <=
> > -	    (PAGE_SIZE << pool->rbpage_order))) {
> > -		pool->pageref++;
> > -		goto ret;
> > -	}
> > -
> > -	otx2_get_page(pool);
> > -
> > -	/* Allocate a new page */
> > -	pool->page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN,
> > -				 pool->rbpage_order);
> > -	if (unlikely(!pool->page))
> > +	buf = napi_alloc_frag(pool->rbsize);
> > +	if (unlikely(!buf))
> >  		return -ENOMEM;
> >  
> > -	pool->page_offset = 0;
> > -ret:
> > -	iova = (u64)otx2_dma_map_page(pfvf, pool->page, pool->page_offset,
> > -				      pool->rbsize, DMA_FROM_DEVICE);
> > -	if (!iova) {
> > -		if (!pool->page_offset)
> > -			__free_pages(pool->page, pool->rbpage_order);
> > -		pool->page = NULL;
> > +	iova = dma_map_single_attrs(pfvf->dev, buf, pool->rbsize,
> > +				    DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
> > +	if (unlikely(dma_mapping_error(pfvf->dev, iova)))
> 
> Thanks for doing this, but aren't you leaking the buf on DMA mapping
> error?

Ouch, I missed that. Will fix.

Thanks,
Kevin

> 
> >  		return -ENOMEM;
> > -	}
> > -	pool->page_offset += pool->rbsize;
> > +
> >  	return iova;
> >  }

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2020-05-09  0:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 11:49 [PATCH v2] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers Kevin Hao
2020-05-09  0:38 ` Jakub Kicinski
2020-05-09  0:53   ` Kevin Hao [this message]

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=20200509005332.GK3222151@pek-khao-d2.corp.ad.wrs.com \
    --to=haokexin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=sunil.kovvuri@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.