Commit 1b041601 authored by Kevin Hao's avatar Kevin Hao Committed by Jakub Kicinski

net: octeontx2: Use napi_alloc_frag_align() to avoid the memory waste

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: default avatarKevin Hao <haokexin@gmail.com>
Tested-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 3f6e687d
...@@ -488,11 +488,10 @@ dma_addr_t __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool) ...@@ -488,11 +488,10 @@ dma_addr_t __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool)
dma_addr_t iova; dma_addr_t iova;
u8 *buf; u8 *buf;
buf = napi_alloc_frag(pool->rbsize + OTX2_ALIGN); buf = napi_alloc_frag_align(pool->rbsize, OTX2_ALIGN);
if (unlikely(!buf)) if (unlikely(!buf))
return -ENOMEM; return -ENOMEM;
buf = PTR_ALIGN(buf, OTX2_ALIGN);
iova = dma_map_single_attrs(pfvf->dev, buf, pool->rbsize, iova = dma_map_single_attrs(pfvf->dev, buf, pool->rbsize,
DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
if (unlikely(dma_mapping_error(pfvf->dev, iova))) { if (unlikely(dma_mapping_error(pfvf->dev, iova))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment