patch 'net/nfp: fix resource leak for exit of CoreNIC firmware' has been queued to stable release 23.11.1
Xueming Li
xuemingl at nvidia.com
Tue Mar 5 10:46:58 CET 2024
Hi,
FYI, your patch has been queued to stable release 23.11.1
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/31/24. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging
This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=e65a677895f1bd39b984971021ded9264874992d
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From e65a677895f1bd39b984971021ded9264874992d Mon Sep 17 00:00:00 2001
From: Chaoyong He <chaoyong.he at corigine.com>
Date: Mon, 4 Dec 2023 09:57:16 +0800
Subject: [PATCH] net/nfp: fix resource leak for exit of CoreNIC firmware
Cc: Xueming Li <xuemingl at nvidia.com>
[ upstream commit 66d5f53d3e1beebf31de3b3b2e15371ffe322866 ]
Fix the resource leak problem in the exit logic of CoreNIC firmware.
Fixes: 646ea79ce481 ("net/nfp: move PF functions into its own file")
Signed-off-by: Chaoyong He <chaoyong.he at corigine.com>
Reviewed-by: Long Wu <long.wu at corigine.com>
Reviewed-by: Peng Zhang <peng.zhang at corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 91 +++++++++++++++++++++++++-------
drivers/net/nfp/nfp_net_common.h | 1 +
2 files changed, 72 insertions(+), 20 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index bb0ddf3d54..5e473d9c16 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -322,6 +322,55 @@ nfp_net_uninit(struct rte_eth_dev *eth_dev)
nfp_cpp_area_release_free(net_hw->mac_stats_area);
}
+static void
+nfp_cleanup_port_app_fw_nic(struct nfp_pf_dev *pf_dev,
+ uint8_t id)
+{
+ struct rte_eth_dev *eth_dev;
+ struct nfp_app_fw_nic *app_fw_nic;
+
+ app_fw_nic = pf_dev->app_fw_priv;
+ if (app_fw_nic->ports[id] != NULL) {
+ eth_dev = app_fw_nic->ports[id]->eth_dev;
+ if (eth_dev != NULL)
+ nfp_net_uninit(eth_dev);
+
+ app_fw_nic->ports[id] = NULL;
+ }
+}
+
+static void
+nfp_uninit_app_fw_nic(struct nfp_pf_dev *pf_dev)
+{
+ nfp_cpp_area_release_free(pf_dev->ctrl_area);
+ rte_free(pf_dev->app_fw_priv);
+}
+
+void
+nfp_pf_uninit(struct nfp_pf_dev *pf_dev)
+{
+ nfp_cpp_area_release_free(pf_dev->qc_area);
+ free(pf_dev->sym_tbl);
+ if (pf_dev->multi_pf.enabled) {
+ nfp_net_keepalive_stop(&pf_dev->multi_pf);
+ nfp_net_keepalive_uninit(&pf_dev->multi_pf);
+ }
+ free(pf_dev->nfp_eth_table);
+ free(pf_dev->hwinfo);
+ nfp_cpp_free(pf_dev->cpp);
+ rte_free(pf_dev);
+}
+
+static int
+nfp_pf_secondary_uninit(struct nfp_pf_dev *pf_dev)
+{
+ free(pf_dev->sym_tbl);
+ nfp_cpp_free(pf_dev->cpp);
+ rte_free(pf_dev);
+
+ return 0;
+}
+
/* Reset and stop device. The device can not be restarted. */
static int
nfp_net_close(struct rte_eth_dev *dev)
@@ -333,8 +382,19 @@ nfp_net_close(struct rte_eth_dev *dev)
struct rte_pci_device *pci_dev;
struct nfp_app_fw_nic *app_fw_nic;
- if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ /*
+ * In secondary process, a released eth device can be found by its name
+ * in shared memory.
+ * If the state of the eth device is RTE_ETH_DEV_UNUSED, it means the
+ * eth device has been released.
+ */
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ if (dev->state == RTE_ETH_DEV_UNUSED)
+ return 0;
+
+ nfp_pf_secondary_uninit(dev->process_private);
return 0;
+ }
hw = dev->data->dev_private;
pf_dev = hw->pf_dev;
@@ -351,16 +411,17 @@ nfp_net_close(struct rte_eth_dev *dev)
nfp_net_close_tx_queue(dev);
nfp_net_close_rx_queue(dev);
- /* Clear ipsec */
- nfp_ipsec_uninit(dev);
-
/* Cancel possible impending LSC work here before releasing the port */
rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev);
/* Only free PF resources after all physical ports have been closed */
/* Mark this port as unused and free device priv resources */
nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
- app_fw_nic->ports[hw->idx] = NULL;
+
+ if (pf_dev->app_fw_id != NFP_APP_FW_CORE_NIC)
+ return -EINVAL;
+
+ nfp_cleanup_port_app_fw_nic(pf_dev, hw->idx);
for (i = 0; i < app_fw_nic->total_phyports; i++) {
id = nfp_function_id_get(pf_dev, i);
@@ -370,26 +431,16 @@ nfp_net_close(struct rte_eth_dev *dev)
return 0;
}
- /* Now it is safe to free all PF resources */
- PMD_INIT_LOG(INFO, "Freeing PF resources");
- if (pf_dev->multi_pf.enabled) {
- nfp_net_keepalive_stop(&pf_dev->multi_pf);
- nfp_net_keepalive_uninit(&pf_dev->multi_pf);
- }
- nfp_cpp_area_free(pf_dev->ctrl_area);
- nfp_cpp_area_free(pf_dev->qc_area);
- free(pf_dev->hwinfo);
- free(pf_dev->sym_tbl);
- nfp_cpp_free(pf_dev->cpp);
- rte_free(app_fw_nic);
- rte_free(pf_dev);
-
+ /* Enable in nfp_net_start() */
rte_intr_disable(pci_dev->intr_handle);
- /* Unregister callback func from eal lib */
+ /* Register in nfp_net_init() */
rte_intr_callback_unregister(pci_dev->intr_handle,
nfp_net_dev_interrupt_handler, (void *)dev);
+ nfp_uninit_app_fw_nic(pf_dev);
+ nfp_pf_uninit(pf_dev);
+
return 0;
}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 30fea7ae02..ded491cbdc 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -272,6 +272,7 @@ int nfp_net_flow_ctrl_get(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
int nfp_net_flow_ctrl_set(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
+void nfp_pf_uninit(struct nfp_pf_dev *pf_dev);
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
((struct nfp_app_fw_nic *)app_fw_priv)
--
2.34.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2024-03-05 17:39:33.334851778 +0800
+++ 0077-net-nfp-fix-resource-leak-for-exit-of-CoreNIC-firmwa.patch 2024-03-05 17:39:30.813566494 +0800
@@ -1 +1 @@
-From 66d5f53d3e1beebf31de3b3b2e15371ffe322866 Mon Sep 17 00:00:00 2001
+From e65a677895f1bd39b984971021ded9264874992d Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 66d5f53d3e1beebf31de3b3b2e15371ffe322866 ]
@@ -9 +11,0 @@
-Cc: stable at dpdk.org
@@ -20 +22 @@
-index 6fdde105ba..537b4fe792 100644
+index bb0ddf3d54..5e473d9c16 100644
@@ -23 +25 @@
-@@ -329,6 +329,55 @@ nfp_net_uninit(struct rte_eth_dev *eth_dev)
+@@ -322,6 +322,55 @@ nfp_net_uninit(struct rte_eth_dev *eth_dev)
@@ -79 +81 @@
-@@ -340,8 +389,19 @@ nfp_net_close(struct rte_eth_dev *dev)
+@@ -333,8 +382,19 @@ nfp_net_close(struct rte_eth_dev *dev)
@@ -100 +102 @@
-@@ -358,16 +418,17 @@ nfp_net_close(struct rte_eth_dev *dev)
+@@ -351,16 +411,17 @@ nfp_net_close(struct rte_eth_dev *dev)
@@ -122 +124 @@
-@@ -377,26 +438,16 @@ nfp_net_close(struct rte_eth_dev *dev)
+@@ -370,26 +431,16 @@ nfp_net_close(struct rte_eth_dev *dev)
More information about the stable
mailing list