From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-8.cisco.com (alln-iport-8.cisco.com [173.37.142.95]) by dpdk.org (Postfix) with ESMTP id C5D98292D for ; Thu, 22 Sep 2016 19:02:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2785; q=dns/txt; s=iport; t=1474563768; x=1475773368; h=from:to:cc:subject:date:message-id; bh=0NVbgTvElXKhf+UCqAAPS39tTF0R5itUB/4bzqrDGR0=; b=A9Fxuy1OnwK5shUH05rssF747y6PcO7qBr9NrHxei3FXd5xPNMf6WHqm F61TkAPE00C1ESAvMU2iJa3IkNFSuMJjwLYMBWiizOx75o8gyvnhJoYWI 1cwpFyzQMM6pZjx0StcLawpvJz7dh27A+C7Do9PN2Nsum5Ix+Z9F70sl0 0=; X-IronPort-AV: E=Sophos;i="5.30,379,1470700800"; d="scan'208";a="326740635" Received: from alln-core-2.cisco.com ([173.36.13.135]) by alln-iport-8.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 Sep 2016 17:02:48 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-2.cisco.com (8.14.5/8.14.5) with ESMTP id u8MH2lRr000854; Thu, 22 Sep 2016 17:02:48 GMT Received: by cisco.com (Postfix, from userid 392789) id B6A9B3FAAE0F; Thu, 22 Sep 2016 10:02:47 -0700 (PDT) From: John Daley To: bruce.richardson@intel.com Cc: dev@dpdk.org, Nelson Escobar Date: Thu, 22 Sep 2016 10:02:45 -0700 Message-Id: <20160922170246.15061-1-johndale@cisco.com> X-Mailer: git-send-email 2.10.0 Subject: [dpdk-dev] [PATCH] net/enic: fix another case of memory not being freed 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: Thu, 22 Sep 2016 17:02:49 -0000 From: Nelson Escobar The function vnic_dev_free_desc_ring() didn't actually free memory. Fix this by first changing vnic_dev_alloc_desc_ring() to use the common allocation function, then in vnic_dev_free_desc_ring call the common free function. Fixes: fefed3d1e62c ("enic: new driver") Signed-off-by: Nelson Escobar --- drivers/net/enic/base/vnic_dev.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/enic/base/vnic_dev.c b/drivers/net/enic/base/vnic_dev.c index fc2e4cc..4db21a4 100644 --- a/drivers/net/enic/base/vnic_dev.c +++ b/drivers/net/enic/base/vnic_dev.c @@ -266,32 +266,35 @@ void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring) memset(ring->descs, 0, ring->size); } -int vnic_dev_alloc_desc_ring(__attribute__((unused)) struct vnic_dev *vdev, +int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, - unsigned int desc_count, unsigned int desc_size, unsigned int socket_id, + unsigned int desc_count, unsigned int desc_size, + __attribute__((unused)) unsigned int socket_id, char *z_name) { - const struct rte_memzone *rz; + void *alloc_addr = NULL; + dma_addr_t alloc_pa = 0; vnic_dev_desc_ring_size(ring, desc_count, desc_size); - - rz = rte_memzone_reserve_aligned(z_name, - ring->size_unaligned, socket_id, - 0, ENIC_ALIGN); - if (!rz) { + alloc_addr = vdev->alloc_consistent(vdev->priv, + ring->size_unaligned, + &alloc_pa, (u8 *)z_name); + if (!alloc_addr) { pr_err("Failed to allocate ring (size=%d), aborting\n", (int)ring->size); return -ENOMEM; } - - ring->descs_unaligned = rz->addr; - if (!ring->descs_unaligned) { + ring->descs_unaligned = alloc_addr; + if (!alloc_pa) { pr_err("Failed to map allocated ring (size=%d), aborting\n", (int)ring->size); + vdev->free_consistent(vdev->priv, + ring->size_unaligned, + alloc_addr, + alloc_pa); return -ENOMEM; } - - ring->base_addr_unaligned = (dma_addr_t)rz->phys_addr; + ring->base_addr_unaligned = alloc_pa; ring->base_addr = VNIC_ALIGN(ring->base_addr_unaligned, ring->base_align); @@ -308,8 +311,13 @@ int vnic_dev_alloc_desc_ring(__attribute__((unused)) struct vnic_dev *vdev, void vnic_dev_free_desc_ring(__attribute__((unused)) struct vnic_dev *vdev, struct vnic_dev_ring *ring) { - if (ring->descs) + if (ring->descs) { + vdev->free_consistent(vdev->priv, + ring->size_unaligned, + ring->descs_unaligned, + ring->base_addr_unaligned); ring->descs = NULL; + } } static int _vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, -- 2.10.0