mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-10 22:54:11 +08:00
net: dpaa2: 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: Kevin Hao <haokexin@gmail.com> Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
1b041601c7
commit
d0dfbb9912
@ -764,12 +764,11 @@ static int dpaa2_eth_build_sg_fd(struct dpaa2_eth_priv *priv,
|
||||
/* Prepare the HW SGT structure */
|
||||
sgt_buf_size = priv->tx_data_offset +
|
||||
sizeof(struct dpaa2_sg_entry) * num_dma_bufs;
|
||||
sgt_buf = napi_alloc_frag(sgt_buf_size + DPAA2_ETH_TX_BUF_ALIGN);
|
||||
sgt_buf = napi_alloc_frag_align(sgt_buf_size, DPAA2_ETH_TX_BUF_ALIGN);
|
||||
if (unlikely(!sgt_buf)) {
|
||||
err = -ENOMEM;
|
||||
goto sgt_buf_alloc_failed;
|
||||
}
|
||||
sgt_buf = PTR_ALIGN(sgt_buf, DPAA2_ETH_TX_BUF_ALIGN);
|
||||
memset(sgt_buf, 0, sgt_buf_size);
|
||||
|
||||
sgt = (struct dpaa2_sg_entry *)(sgt_buf + priv->tx_data_offset);
|
||||
|
Loading…
Reference in New Issue
Block a user