From: Wang ShougangX <shougangx.wang@intel.com>
To: dev@dpdk.org
Cc: qiming.yang@intel.com, beilei.xing@intel.com,
Wang ShougangX <shougangx.wang@intel.com>
Subject: [dpdk-dev] [PATCH v3 1/4] net/ice: fix memzone reserve and release in FDIR
Date: Tue, 12 Nov 2019 00:50:53 +0000 [thread overview]
Message-ID: <20191112005056.30805-2-shougangx.wang@intel.com> (raw)
In-Reply-To: <20191112005056.30805-1-shougangx.wang@intel.com>
To avoid memzone reserve failure and memory leak, following
resources management should be added.
- Check if the FDIR Memzone already exists before reserving.
- Free FDIR memzone when teardown and other failure scenarios.
Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
drivers/net/ice/ice_ethdev.h | 1 +
drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index c55713cc1..d4ab18436 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -334,6 +334,7 @@ struct ice_fdir_info {
struct ice_rx_queue *rxq;
void *prg_pkt; /* memory for fdir program packet */
uint64_t dma_addr; /* physic address of packet memory*/
+ const struct rte_memzone *mz;
struct ice_fdir_filter_conf conf;
struct ice_fdir_filter_conf **hash_map;
diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index afab5af7f..a89c506c0 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -127,6 +127,12 @@ static struct ice_flow_parser ice_fdir_parser_comms;
static const struct rte_memzone *
ice_memzone_reserve(const char *name, uint32_t len, int socket_id)
{
+ const struct rte_memzone *mz;
+
+ mz = rte_memzone_lookup(name);
+ if (mz)
+ return mz;
+
return rte_memzone_reserve_aligned(name, len, socket_id,
RTE_MEMZONE_IOVA_CONTIG,
ICE_RING_BASE_ALIGN);
@@ -481,19 +487,23 @@ ice_fdir_setup(struct ice_pf *pf)
}
pf->fdir.prg_pkt = mz->addr;
pf->fdir.dma_addr = mz->iova;
+ pf->fdir.mz = mz;
err = ice_fdir_prof_alloc(hw);
if (err) {
PMD_DRV_LOG(ERR, "Cannot allocate memory for "
"flow director profile.");
err = -ENOMEM;
- goto fail_mem;
+ goto fail_prof;
}
PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming queue %u.",
vsi->base_queue);
return ICE_SUCCESS;
+fail_prof:
+ rte_memzone_free(pf->fdir.mz);
+ pf->fdir.mz = NULL;
fail_mem:
ice_rx_queue_release(pf->fdir.rxq);
pf->fdir.rxq = NULL;
@@ -607,6 +617,13 @@ ice_fdir_teardown(struct ice_pf *pf)
ice_fdir_prof_free(hw);
ice_release_vsi(vsi);
pf->fdir.fdir_vsi = NULL;
+
+ if (pf->fdir.mz) {
+ err = rte_memzone_free(pf->fdir.mz);
+ pf->fdir.mz = NULL;
+ if (err)
+ PMD_DRV_LOG(ERR, "Failed to free FDIR memezone.");
+ }
}
static int
--
2.17.1
next prev parent reply other threads:[~2019-11-12 7:10 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-05 3:38 [dpdk-dev] [PATCH] net/ice: fix wild pointer Wang ShougangX
2019-11-07 2:22 ` [dpdk-dev] [PATCH v2 0/4] net/ice: fix memory release in FDIR Wang ShougangX
2019-11-07 2:22 ` [dpdk-dev] [PATCH v2 1/4] net/ice: fix memzone reserve and " Wang ShougangX
2019-11-11 8:09 ` Ye Xiaolong
2019-11-11 8:39 ` Wang, ShougangX
2019-11-07 2:22 ` [dpdk-dev] [PATCH v2 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-07 2:22 ` [dpdk-dev] [PATCH v2 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-07 2:22 ` [dpdk-dev] [PATCH v2 4/4] net/ice: fix wild pointer Wang ShougangX
2019-11-12 0:00 ` [dpdk-dev] [PATCH v3 0/4] net/ice: fix memory release in FDIR Wang ShougangX
2019-11-12 0:10 ` Wang ShougangX
2019-11-12 0:10 ` [dpdk-dev] [PATCH v3 1/4] net/ice: fix memzone reserve and " Wang ShougangX
2019-11-12 0:10 ` [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-12 0:10 ` [dpdk-dev] [PATCH v3 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-12 0:10 ` [dpdk-dev] [PATCH v3 4/4] net/ice: fix wild pointer Wang ShougangX
2019-11-12 0:26 ` [dpdk-dev] [PATCH v3 0/4] net/ice: fix memory release in FDIR Wang ShougangX
2019-11-12 0:26 ` [dpdk-dev] [PATCH v3 1/4] net/ice: fix memzone reserve and " Wang ShougangX
2019-11-12 0:26 ` [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-12 0:27 ` [dpdk-dev] [PATCH v3 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-12 7:42 ` Zhang, Qi Z
2019-11-12 0:27 ` [dpdk-dev] [PATCH v3 4/4] net/ice: fix wild pointer Wang ShougangX
2019-11-12 7:39 ` Zhang, Qi Z
2019-11-12 0:50 ` [dpdk-dev] [PATCH v3 0/4] net/ice: fix memory release in FDIR Wang ShougangX
2019-11-12 0:50 ` Wang ShougangX [this message]
2019-11-12 7:45 ` [dpdk-dev] [PATCH v3 1/4] net/ice: fix memzone reserve and " Zhang, Qi Z
2019-11-12 0:50 ` [dpdk-dev] [PATCH v3 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-12 7:50 ` Zhang, Qi Z
2019-11-12 8:03 ` Wang, ShougangX
2019-11-12 0:50 ` [dpdk-dev] [PATCH v3 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-12 0:50 ` [dpdk-dev] [PATCH v3 4/4] net/ice: fix wild pointer Wang ShougangX
2019-11-07 3:19 ` [dpdk-dev] [PATCH] " Ye Xiaolong
2019-11-07 3:30 ` Ye Xiaolong
2019-11-07 5:44 ` Wang, ShougangX
2019-11-12 3:50 ` [dpdk-dev] [PATCH v4 0/4] net/ice: fix memory release in FDIR Wang ShougangX
2019-11-12 3:50 ` [dpdk-dev] [PATCH v4 1/4] net/ice: fix memzone reserve and " Wang ShougangX
2019-11-12 3:50 ` [dpdk-dev] [PATCH v4 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-12 10:36 ` Yang, Qiming
2019-11-13 6:21 ` Wang, ShougangX
2019-11-12 3:50 ` [dpdk-dev] [PATCH v4 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-12 3:50 ` [dpdk-dev] [PATCH v4 4/4] net/ice: fix wild pointer Wang ShougangX
2019-11-13 1:37 ` [dpdk-dev] [PATCH v5 0/4] net/ice: fix memory release in FDIR Wang ShougangX
2019-11-13 1:37 ` [dpdk-dev] [PATCH v5 1/4] net/ice: fix memzone reserve and " Wang ShougangX
2019-11-13 1:37 ` [dpdk-dev] [PATCH v5 2/4] net/ice: fix removal of FDIR profile Wang ShougangX
2019-11-13 8:44 ` Yang, Qiming
2019-11-13 1:37 ` [dpdk-dev] [PATCH v5 3/4] net/ice: fix FDIR counter resource release Wang ShougangX
2019-11-13 1:37 ` [dpdk-dev] [PATCH v5 4/4] net/ice: fix wild pointer Wang ShougangX
2019-11-13 8:44 ` Yang, Qiming
2019-11-13 8:54 ` [dpdk-dev] [PATCH v5 0/4] net/ice: fix memory release in FDIR Ye Xiaolong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191112005056.30805-2-shougangx.wang@intel.com \
--to=shougangx.wang@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=qiming.yang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).