[Devel] [PATCH 8/8] bnx2: use kvzalloc() to allocate certain internal data
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Fri May 21 19:26:52 MSK 2021
From: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
These structures are not disigned for DMA'ing and don't require
physically contiguous memory.
https://jira.sw.ru/browse/HCI-140
Signed-off-by: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
Acked-by: Denis V. Lunev <den at openvz.org>
(cherry-picked from 66e75bd04dabf65c2ca65e63b76125b484b577fd)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 11 +++++------
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 +-
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 2b91e9c..f684d68 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4566,9 +4566,8 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
"allocating tx memory of fp %d cos %d\n",
index, cos);
- txdata->tx_buf_ring = kcalloc(NUM_TX_BD,
- sizeof(struct sw_tx_bd),
- GFP_KERNEL);
+ txdata->tx_buf_ring = kvzalloc(sizeof(struct sw_tx_bd) * NUM_TX_BD,
+ GFP_KERNEL);
if (!txdata->tx_buf_ring)
goto alloc_mem_err;
txdata->tx_desc_ring = BNX2X_PCI_ALLOC(&txdata->tx_desc_mapping,
@@ -4582,7 +4581,7 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
if (!skip_rx_queue(bp, index)) {
/* fastpath rx rings: rx_buf rx_desc rx_comp */
bnx2x_fp(bp, index, rx_buf_ring) =
- kcalloc(NUM_RX_BD, sizeof(struct sw_rx_bd), GFP_KERNEL);
+ kvzalloc(sizeof(struct sw_rx_bd) * NUM_RX_BD, GFP_KERNEL);
if (!bnx2x_fp(bp, index, rx_buf_ring))
goto alloc_mem_err;
bnx2x_fp(bp, index, rx_desc_ring) =
@@ -4600,8 +4599,8 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
/* SGE ring */
bnx2x_fp(bp, index, rx_page_ring) =
- kcalloc(NUM_RX_SGE, sizeof(struct sw_rx_page),
- GFP_KERNEL);
+ kvzalloc(sizeof(struct sw_rx_page) * NUM_RX_SGE,
+ GFP_KERNEL);
if (!bnx2x_fp(bp, index, rx_page_ring))
goto alloc_mem_err;
bnx2x_fp(bp, index, rx_sge_ring) =
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 76ff0a8..53a4c2a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -45,7 +45,7 @@
#define BNX2X_FREE(x) \
do { \
if (x) { \
- kfree((void *)x); \
+ kvfree((void *)x); \
x = NULL; \
} \
} while (0)
--
1.8.3.1
More information about the Devel
mailing list