DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] i40e: fix the issue of not freeing memzone
@ 2015-11-06  3:26 Helin Zhang
  2015-11-06  5:39 ` Wu, Jingjing
  2015-11-06  7:57 ` [dpdk-dev] [PATCH v2] " Helin Zhang
  0 siblings, 2 replies; 11+ messages in thread
From: Helin Zhang @ 2015-11-06  3:26 UTC (permalink / raw)
  To: dev

This fixes the issue of not freeing memzone in a call to free the
memory for adminq DMA.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 doc/guides/rel_notes/release_2_2.rst |  5 +++++
 drivers/net/i40e/base/i40e_osdep.h   |  2 +-
 drivers/net/i40e/i40e_ethdev.c       | 12 +++++++-----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst
index 59dda59..eaa906c 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -150,6 +150,11 @@ Drivers
 
   Added discarding packets on VSI to the stats and rectify the old statistics.
 
+* **i40e: Fixed issue of not freeing memzone.**
+
+  Fixed the issue of not freeing memzone in the call to free the memory for
+  adminq DMA.
+
 * **vhost: Fixed Qemu shutdown.**
 
   Fixed issue with libvirt ``virsh destroy`` not killing the VM.
diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h
index 70d2721..71077f0 100644
--- a/drivers/net/i40e/base/i40e_osdep.h
+++ b/drivers/net/i40e/base/i40e_osdep.h
@@ -146,7 +146,7 @@ struct i40e_dma_mem {
 	void *va;
 	u64 pa;
 	u32 size;
-	u64 id;
+	const void *zone;
 } __attribute__((packed));
 
 #define i40e_allocate_dma_mem(h, m, unused, s, a) \
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index ddf3d38..8d6c0fa 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2910,15 +2910,13 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,
 			u64 size,
 			u32 alignment)
 {
-	static uint64_t id = 0;
 	const struct rte_memzone *mz = NULL;
 	char z_name[RTE_MEMZONE_NAMESIZE];
 
 	if (!mem)
 		return I40E_ERR_PARAM;
 
-	id++;
-	snprintf(z_name, sizeof(z_name), "i40e_dma_%"PRIu64, id);
+	snprintf(z_name, sizeof(z_name), "i40e_dma_%"PRIu64, rte_rand());
 #ifdef RTE_LIBRTE_XEN_DOM0
 	mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY, 0,
 					 alignment, RTE_PGSIZE_2M);
@@ -2929,7 +2927,6 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,
 	if (!mz)
 		return I40E_ERR_NO_MEMORY;
 
-	mem->id = id;
 	mem->size = size;
 	mem->va = mz->addr;
 #ifdef RTE_LIBRTE_XEN_DOM0
@@ -2937,6 +2934,8 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,
 #else
 	mem->pa = mz->phys_addr;
 #endif
+	mem->zone = (const void *)mz;
+	PMD_DRV_LOG(DEBUG, "memzone allocated: %p", mem->zone);
 
 	return I40E_SUCCESS;
 }
@@ -2950,9 +2949,12 @@ enum i40e_status_code
 i40e_free_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,
 		    struct i40e_dma_mem *mem)
 {
-	if (!mem || !mem->va)
+	if (!mem)
 		return I40E_ERR_PARAM;
 
+	PMD_DRV_LOG(DEBUG, "memzone to be freed: %p", mem->zone);
+	rte_memzone_free((const struct rte_memzone *)mem->zone);
+	mem->zone = NULL;
 	mem->va = NULL;
 	mem->pa = (u64)0;
 
-- 
1.9.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-11-11 18:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-06  3:26 [dpdk-dev] [PATCH] i40e: fix the issue of not freeing memzone Helin Zhang
2015-11-06  5:39 ` Wu, Jingjing
2015-11-06  6:00   ` Zhang, Helin
2015-11-06  7:57 ` [dpdk-dev] [PATCH v2] " Helin Zhang
2015-11-06  8:32   ` Wu, Jingjing
2015-11-06 10:19   ` Thomas Monjalon
2015-11-09  1:20     ` Zhang, Helin
2015-11-09  1:20   ` [dpdk-dev] [PATCH v3] " Helin Zhang
2015-11-10 15:53     ` Thomas Monjalon
2015-11-11  5:28     ` [dpdk-dev] [PATCH v4] " Helin Zhang
2015-11-11 18:10       ` Thomas Monjalon

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).