From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C0E3E8D96 for ; Wed, 11 Nov 2015 06:28:43 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 10 Nov 2015 21:28:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,274,1444719600"; d="scan'208";a="833828800" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 10 Nov 2015 21:28:41 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tAB5SeDA031555; Wed, 11 Nov 2015 13:28:40 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tAB5SaMB031494; Wed, 11 Nov 2015 13:28:38 +0800 Received: (from hzhan75@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tAB5SaB2031490; Wed, 11 Nov 2015 13:28:36 +0800 From: Helin Zhang To: dev@dpdk.org Date: Wed, 11 Nov 2015 13:28:34 +0800 Message-Id: <1447219714-31459-1-git-send-email-helin.zhang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1447032022-7805-1-git-send-email-helin.zhang@intel.com> References: <1447032022-7805-1-git-send-email-helin.zhang@intel.com> Subject: [dpdk-dev] [PATCH v4] i40e: fix the issue of not freeing memzone X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Nov 2015 05:28:44 -0000 This fixes the issue of not freeing memzone in a call to free the memory for adminq DMA. Fixes: 4861cde46116 ("i40e: new poll mode driver") Signed-off-by: Helin Zhang --- doc/guides/rel_notes/release_2_2.rst | 5 +++++ drivers/net/i40e/base/i40e_osdep.h | 2 +- drivers/net/i40e/i40e_ethdev.c | 15 ++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) v2 changes: Reworked the debug logs. v3 changes: Added more info into the commit logs. v4 changes: Fixed the compile issues in debug mode. 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..c156665 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,9 @@ 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 %s allocated with physical address: " + "%"PRIu64, mz->name, mem->pa); return I40E_SUCCESS; } @@ -2950,9 +2950,14 @@ 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 %s to be freed with physical address: " + "%"PRIu64, ((const struct rte_memzone *)mem->zone)->name, + mem->pa); + rte_memzone_free((const struct rte_memzone *)mem->zone); + mem->zone = NULL; mem->va = NULL; mem->pa = (u64)0; -- 1.9.3