From patchwork Fri Apr 8 14:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 109530 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D407AA050B; Fri, 8 Apr 2022 16:15:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31BF8427EA; Fri, 8 Apr 2022 16:15:02 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 07A904003F; Fri, 8 Apr 2022 16:14:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649427299; x=1680963299; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uVW7l9Hti0x477ny1oP/osJwac2bpvw6pWUr4JFaQlE=; b=Uj2Q0sijKq1Vff7MI6Xf04o/WwcBRymwCb8zEpxddFxGtWX4uHPEpYeh dKh0c5TY2AvJ/Z2mcVIj2HkPRMMcaDXhdbIpEelKeF1QLc8mi1lY4n4Yo u1xnwzQNEePYx3yvWrp9tibhdRqFXIuisXWJWfq0yZqTq71srHmmeOe8P VxRlXK/5Rm/M1lu78+x5QSJWKvP8OQ4oOXDnmNTuwy+8xLk+qXH3ExBVp prGYIJULqvMHlwTsIVwTi5y17G5km81Owf8mcoNljOKkZhTMmPk7FU5KP vZ3ygm4LSmeGVQTNyRWDALqeBdPRxb/Od5QLKdzfHga66px6Ps6grEflC g==; X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="324762466" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="324762466" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 07:14:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="852083812" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by fmsmga005.fm.intel.com with ESMTP; 08 Apr 2022 07:14:56 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz , stable@dpdk.org, bruce.richardson@intel.com, Xingguang He , Conor Walsh Subject: [PATCH 1/5] dma/idxd: fix memory leak in pci close Date: Fri, 8 Apr 2022 15:15:00 +0100 Message-Id: <20220408141504.1319913-2-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220408141504.1319913-1-kevin.laatz@intel.com> References: <20220408141504.1319913-1-kevin.laatz@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org ASAN reports a memory leak for the 'pci' pointer in the 'idxd_dmadev' struct. This is fixed by free'ing the struct when the last queue on the PCI device is being closed. Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe") Cc: stable@dpdk.org Cc: bruce.richardson@intel.com Reported-by: Xingguang He Signed-off-by: Kevin Laatz Acked-by: Bruce Richardson --- drivers/dma/idxd/idxd_common.c | 1 + drivers/dma/idxd/idxd_internal.h | 2 ++ drivers/dma/idxd/idxd_pci.c | 34 +++++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/dma/idxd/idxd_common.c b/drivers/dma/idxd/idxd_common.c index ea6413cc7a..57c4c1655d 100644 --- a/drivers/dma/idxd/idxd_common.c +++ b/drivers/dma/idxd/idxd_common.c @@ -597,6 +597,7 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, dmadev->fp_obj->dev_private = idxd; idxd->dmadev->state = RTE_DMA_DEV_READY; + rte_atomic16_inc(&idxd->u.pci->ref_count); return 0; diff --git a/drivers/dma/idxd/idxd_internal.h b/drivers/dma/idxd/idxd_internal.h index 3375600217..180a8587c6 100644 --- a/drivers/dma/idxd/idxd_internal.h +++ b/drivers/dma/idxd/idxd_internal.h @@ -7,6 +7,7 @@ #include #include +#include #include "idxd_hw_defs.h" @@ -33,6 +34,7 @@ struct idxd_pci_common { rte_spinlock_t lk; uint8_t wq_cfg_sz; + rte_atomic16_t ref_count; volatile struct rte_idxd_bar0 *regs; volatile uint32_t *wq_regs_base; volatile struct rte_idxd_grpcfg *grp_regs; diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c index 9ca1ec64e9..7036eb938d 100644 --- a/drivers/dma/idxd/idxd_pci.c +++ b/drivers/dma/idxd/idxd_pci.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "idxd_internal.h" @@ -115,20 +116,38 @@ idxd_pci_dev_close(struct rte_dma_dev *dev) { struct idxd_dmadev *idxd = dev->fp_obj->dev_private; uint8_t err_code; + int is_last_wq; - /* disable the device */ - err_code = idxd_pci_dev_command(idxd, idxd_disable_dev); - if (err_code) { - IDXD_PMD_ERR("Error disabling device: code %#x", err_code); - return err_code; + if (idxd_is_wq_enabled(idxd)) { + /* disable the wq */ + err_code = idxd_pci_dev_command(idxd, idxd_disable_wq); + if (err_code) { + IDXD_PMD_ERR("Error disabling wq: code %#x", err_code); + return err_code; + } + IDXD_PMD_DEBUG("IDXD WQ disabled OK"); } - IDXD_PMD_DEBUG("IDXD Device disabled OK"); /* free device memory */ IDXD_PMD_DEBUG("Freeing device driver memory"); rte_free(idxd->batch_idx_ring); rte_free(idxd->desc_ring); + /* if this is the last WQ on the device, disable the device and free + * the PCI struct + */ + is_last_wq = rte_atomic16_dec_and_test(&idxd->u.pci->ref_count); + if (is_last_wq) { + /* disable the device */ + err_code = idxd_pci_dev_command(idxd, idxd_disable_dev); + if (err_code) { + IDXD_PMD_ERR("Error disabling device: code %#x", err_code); + return err_code; + } + IDXD_PMD_DEBUG("IDXD device disabled OK"); + rte_free(idxd->u.pci); + } + return 0; } @@ -159,12 +178,13 @@ init_pci_device(struct rte_pci_device *dev, struct idxd_dmadev *idxd, uint8_t lg2_max_batch, lg2_max_copy_size; unsigned int i, err_code; - pci = malloc(sizeof(*pci)); + pci = rte_malloc(NULL, sizeof(*pci), 0); if (pci == NULL) { IDXD_PMD_ERR("%s: Can't allocate memory", __func__); err_code = -1; goto err; } + memset(pci, 0, sizeof(*pci)); rte_spinlock_init(&pci->lk); /* assign the bar registers, and then configure device */ From patchwork Fri Apr 8 14:15:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 109531 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0C881A050B; Fri, 8 Apr 2022 16:15:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F9AD427F3; Fri, 8 Apr 2022 16:15:03 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 65CD04003F; Fri, 8 Apr 2022 16:15:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649427300; x=1680963300; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v7rIibFWCp95otrtAI1lbOqedk/aGJhQcoWpfRV5R1Q=; b=R+9D7zMCxIg3El8duQOMy7GTfXZE3M9lYYUJOWCl/FuZyQxtCt6cIKlU vlb4eJ7Mj6WP3XPCaT5amDPrYUZ6MCfARWyr3imqzQfy5Zt01R8ydK3jS Eb8iW33EXrruaRem0KD+UUW9OfxlvcH4hAARYYwmihCKJ6j7sG3mAQQEf b8XbQJO5bv0jMEbKGX4SrWuKMcGIGaYfX2gI75AdQPKuLEdgNtPwrjR81 YQyWBG/GQpLT1toyqNNlYZil0X0X/4xaYVdTfuVUtEoKNl74zBlVokE/F t4zTEX+JIr//12jLMerc4IXpGYCOFD77n1BGpqhrhrYIVH/0Wkp0BEFsR w==; X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="324762470" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="324762470" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 07:14:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="852083825" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by fmsmga005.fm.intel.com with ESMTP; 08 Apr 2022 07:14:58 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz , stable@dpdk.org, bruce.richardson@intel.com, Conor Walsh Subject: [PATCH 2/5] dma/idxd: fix memory leak due to free on incorrect pointer Date: Fri, 8 Apr 2022 15:15:01 +0100 Message-Id: <20220408141504.1319913-3-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220408141504.1319913-1-kevin.laatz@intel.com> References: <20220408141504.1319913-1-kevin.laatz@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org During PCI device close, any allocated memory needs to be free'd. Currently, one of the free's is being called on an incorrect idxd_dmadev struct member, namely 'batch_idx_ring', causing a memleak from the pointer that should have been free'd. This patch fixes this memleak by calling free on the correct pointer. Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe") Cc: stable@dpdk.org Cc: bruce.richardson@intel.com Signed-off-by: Kevin Laatz --- drivers/dma/idxd/idxd_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c index 7036eb938d..fdb1f15750 100644 --- a/drivers/dma/idxd/idxd_pci.c +++ b/drivers/dma/idxd/idxd_pci.c @@ -130,7 +130,7 @@ idxd_pci_dev_close(struct rte_dma_dev *dev) /* free device memory */ IDXD_PMD_DEBUG("Freeing device driver memory"); - rte_free(idxd->batch_idx_ring); + rte_free(idxd->batch_comp_ring); rte_free(idxd->desc_ring); /* if this is the last WQ on the device, disable the device and free From patchwork Fri Apr 8 14:15:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 109532 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0A7DA050B; Fri, 8 Apr 2022 16:15:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5143842858; Fri, 8 Apr 2022 16:15:04 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id DD9F2410EC for ; Fri, 8 Apr 2022 16:15:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649427301; x=1680963301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ODbjNIwS560D8/uBxgIDJwDE/Deh40bk7iPxnNWARJA=; b=ZKdm9xJMEkmS/d8DN4QC+uWaUqAgcFCMGHS9RIWJ+DWALGNs6zo+bem/ c/Z+08bkXe1IiNZtUPjJmooKCzfolgI+O4o4y6cz/qfYLMH+uLbowDjwz 61PJitvJNH4gxMI7C9Vr2yDPfIQZnQrWTqTOpyPwe4c+pyRbOXNW4koTW cAbwd4fbgn5URPjcH3OsJWEzKKFATHspDGMboxMmgg8QWWlZIzXYxG28Y OWIDHhifu6Qx/xxWDcP7ExU8gwknu1QSbx23ujLT4t/Tf4hqWbykNoEOh X0X1i49rDKeoI0x1dhXaErhF9AYJkm/HHZJAdwmsmrZsADxTtZAJ9UKZ3 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="324762475" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="324762475" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 07:15:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="852083828" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by fmsmga005.fm.intel.com with ESMTP; 08 Apr 2022 07:14:59 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz Subject: [PATCH 3/5] app/test: close dma devices during cleanup Date: Fri, 8 Apr 2022 15:15:02 +0100 Message-Id: <20220408141504.1319913-4-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220408141504.1319913-1-kevin.laatz@intel.com> References: <20220408141504.1319913-1-kevin.laatz@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org DMA devices are created during PCI probe of EAL init. These devices need to be closed in order to perform necessary cleanup for those devices. This patch adds the call to close() for all DMA devices. Signed-off-by: Kevin Laatz --- app/test/test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/test/test.c b/app/test/test.c index e69cae3eea..cc986e5cc9 100644 --- a/app/test/test.c +++ b/app/test/test.c @@ -24,6 +24,7 @@ extern cmdline_parse_ctx_t main_ctx[]; #include #include #include +#include #ifdef RTE_LIB_TIMER #include #endif @@ -244,6 +245,11 @@ main(int argc, char **argv) #ifdef RTE_LIB_TIMER rte_timer_subsystem_finalize(); #endif + + /* close all dmadevs */ + RTE_DMA_FOREACH_DEV(i) + rte_dma_close(i); + rte_eal_cleanup(); return ret; } From patchwork Fri Apr 8 14:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 109533 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 69743A050B; Fri, 8 Apr 2022 16:15:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 311F94285C; Fri, 8 Apr 2022 16:15:05 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 90592427ED for ; Fri, 8 Apr 2022 16:15:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649427302; x=1680963302; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PHnc3GbCRUH745Q35nDfCg8gw2GUuNVurY7Aymebtrk=; b=noEWmYji+5yrndBhkdn32fGJIWtd/2tGk2LSpEMMj5Xpw+bUPKJCLu5g 54GWogbqO8umpTBHiqaztohAOWPxLEu93dlwT9F7DLPZ9lRsAJ1r+YrZc sqf8IsBnaalvpdz9nUWcFvpQizNj3P5n65lPPKoOvi9gTjOns0eNr+0qF TQWyBhRtKt+cJp4KF+J1mISG8msMZugyE+083aY9/LwKzE3lgRFvwZQhT BknAwS1PDNdGO1soMEOQMBfUw4WICQdVUT8BmKXiGj2vop3y4cIJRFFu4 3iVC9QJh2D3qAV+RyAiJa8XEoT4TL+wgkjUtjt+JpYdylmz1uWokDwkpo Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="324762479" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="324762479" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 07:15:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="852083835" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by fmsmga005.fm.intel.com with ESMTP; 08 Apr 2022 07:15:00 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz , Xiaoyun Li , Aman Singh , Yuying Zhang Subject: [PATCH 4/5] app/testpmd: stop and close dmadevs at exit Date: Fri, 8 Apr 2022 15:15:03 +0100 Message-Id: <20220408141504.1319913-5-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220408141504.1319913-1-kevin.laatz@intel.com> References: <20220408141504.1319913-1-kevin.laatz@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org DMA devices are created during PCI probe in EAL init. In order to perform cleanup for those devices, they need to be stopped and closed. This patch adds the necessary cleanup to ensure clean exit. Signed-off-by: Kevin Laatz --- app/test-pmd/testpmd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..438749c5b8 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #ifdef RTE_NET_IXGBE @@ -3402,6 +3403,14 @@ pmd_test_exit(void) } } + /* stop and close all dmadevs */ + RTE_DMA_FOREACH_DEV(i) { + printf("\nStopping and closing dmadev %d...\n", i); + fflush(stdout); + rte_dma_stop(i); + rte_dma_close(i); + } + if (hot_plug) { ret = rte_dev_event_monitor_stop(); if (ret) { From patchwork Fri Apr 8 14:15:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 109534 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 92682A050B; Fri, 8 Apr 2022 16:15:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 208E842864; Fri, 8 Apr 2022 16:15:06 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id B9FBF42800; Fri, 8 Apr 2022 16:15:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649427304; x=1680963304; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oIRrUefB/hIBj+IVHApcl59CJd8D6+zjE+ettjyiymg=; b=GMPkpAd5d6RcNhasvgvIEeCHGB9zkBSgsvlTsnWGEFLqeSPAHyqpIFHP HdtF5uwoemriK0Lr1q+S4UipS0TlCocXgs//3foNZgegQwxSQ05xCAaRO Do8RhR73NqqLHzn9DwMIqMZ7pTWGCavlaHjCsCDU7V/6h65R/0KgiQvlN fIf2epCCFzJDYUysuFD8fQsrgnE55jiT3t4o97yeoihx4r5FMfgPYLtby juBzrem6ZB8ezwUVbeqCYKVUZc29UPtDWWuT+jzlHMMn5f3tT7myRM4we 1FzMwGH83nfAC+xq+2kB0JDMgPXdElAXLF9+F7zM+AH6a713sTaUzS0aQ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="324762490" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="324762490" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 07:15:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="852083853" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by fmsmga005.fm.intel.com with ESMTP; 08 Apr 2022 07:15:01 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz , stable@dpdk.org, bruce.richardson@intel.com, Chengwen Feng , Conor Walsh Subject: [PATCH 5/5] examples/dma: fix missing dma close Date: Fri, 8 Apr 2022 15:15:04 +0100 Message-Id: <20220408141504.1319913-6-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220408141504.1319913-1-kevin.laatz@intel.com> References: <20220408141504.1319913-1-kevin.laatz@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The application stops all dmadevs that it used but never closed any, meaning device cleanup was not done. This patch adds device cleanup for all dmadevs. All devices need to be closed for completeness, since devices not used by the application may also have been created during PCI probe of EAL init. Fixes: d047310407a3 ("examples/ioat: port application to dmadev API") Cc: stable@dpdk.org Cc: bruce.richardson@intel.com Signed-off-by: Kevin Laatz --- examples/dma/dmafwd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c index 608487e35c..4c612a0e0b 100644 --- a/examples/dma/dmafwd.c +++ b/examples/dma/dmafwd.c @@ -1097,6 +1097,12 @@ main(int argc, char **argv) rte_ring_free(cfg.ports[i].rx_to_tx_ring); } + /* close all dmadevs */ + RTE_DMA_FOREACH_DEV(i) { + printf("Closing dmadev %d\n", i); + rte_dma_close(i); + } + /* clean up the EAL */ rte_eal_cleanup();