Skip to content

Commit

Permalink
net: octeontx2: Use napi_alloc_frag_align() to avoid the memory waste
Browse files Browse the repository at this point in the history
The napi_alloc_frag_align() will guarantee that a correctly align
buffer address is returned. So use this function to simplify the buffer
alloc and avoid the unnecessary memory waste.

Signed-off-by: Kevin Hao <[email protected]>
Tested-by: Subbaraya Sundeep <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
haokexin authored and kuba-moo committed Feb 6, 2021
1 parent 3f6e687 commit 1b04160
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,10 @@ dma_addr_t __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool)
dma_addr_t iova;
u8 *buf;

buf = napi_alloc_frag(pool->rbsize + OTX2_ALIGN);
buf = napi_alloc_frag_align(pool->rbsize, OTX2_ALIGN);
if (unlikely(!buf))
return -ENOMEM;

buf = PTR_ALIGN(buf, OTX2_ALIGN);
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))) {
Expand Down

0 comments on commit 1b04160

Please sign in to comment.