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: signature.asc
Description: PGP signature

Reply via email to