Commit db280515 authored by Kevin Hao's avatar Kevin Hao Committed by Jakub Kicinski

net: octeontx2: Make sure the buffer is 128 byte aligned

The octeontx2 hardware needs the buffer to be 128 byte aligned.
But in the current implementation of napi_alloc_frag(), it can't
guarantee the return address is 128 byte aligned even the request size
is a multiple of 128 bytes, so we have to request an extra 128 bytes and
use the PTR_ALIGN() to make sure that the buffer is aligned correctly.

Fixes: 7a36e491 ("octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers")
Reported-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
Tested-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
Link: https://lore.kernel.org/r/20210121070906.25380-1-haokexin@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7e0e63d0
...@@ -478,10 +478,11 @@ dma_addr_t __otx2_alloc_rbuf(struct otx2_nic *pfvf, struct otx2_pool *pool) ...@@ -478,10 +478,11 @@ 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); buf = napi_alloc_frag(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