From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 504F641E77; Fri, 17 Mar 2023 02:43:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F64F42DCC; Fri, 17 Mar 2023 02:43:48 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id C990040A79; Fri, 17 Mar 2023 02:43:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679017427; x=1710553427; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5PB0j5opY3batMaMKKsb1eYIfxE+r+xFEWfUFi0lKIs=; b=MV8OEqtv7beBUW6TeeV/nkMB4bbzqeTtcSkvjhO7pVqro8H0ZEcIYn5A g2YsZO3Fye3Q7dfuuCI/fdF2wa6Cj6QMxqzuTwr5H9vgU+3m+fE8+ELrc 42Ey/Fh9H1gHKx+XEMtxd9azjGwMBpTvnADGMva1N84M0QNeMHryO8GP3 eQAWgvqwsihuMHPWQYY25D8dSqCm3jWBPyjUN2NEGzmGejpU/xV2D3d/M i5keujeRFFjYjwZ9fGPvGXjS9FBQwDthJMf8zTsA82Yu/bAskAVnwP/of /+Iir7854Uqh4qXsOlqR1PMqKwycXOcyBSTglQ/xbKj8yY/XDhAsW5Www w==; X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="338172993" X-IronPort-AV: E=Sophos;i="5.98,267,1673942400"; d="scan'208";a="338172993" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2023 18:43:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="925979042" X-IronPort-AV: E=Sophos;i="5.98,267,1673942400"; d="scan'208";a="925979042" Received: from sh_lab5_1.sh.intel.com (HELO ocsbesrhlrepo01.sh.intel.com) ([10.238.175.110]) by fmsmga006.fm.intel.com with ESMTP; 16 Mar 2023 18:43:34 -0700 From: Wei Huang To: dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com Cc: stable@dpdk.org, rosen.xu@intel.com, tianfei.zhang@intel.com, qi.z.zhang@intel.com, Wei Huang Subject: [PATCH v1] bus/ifpga: add fpga bus cleanup Date: Thu, 16 Mar 2023 16:44:34 -0400 Message-Id: <20230316204434.360283-1-wei.huang@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 In this patch, cleanup method is implemented for FPGA bus which will be called during eal_bus_cleanup(). Signed-off-by: Wei Huang --- drivers/bus/ifpga/ifpga_bus.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index 07e316b..ffb0c61 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -360,6 +360,41 @@ struct rte_afu_device * return ret; } +/* + * Cleanup the content of the Intel FPGA bus, and call the remove() function + * for all registered devices. + */ +static int +ifpga_cleanup(void) +{ + struct rte_afu_device *afu_dev, *tmp_dev; + int error = 0; + + RTE_TAILQ_FOREACH_SAFE(afu_dev, &ifpga_afu_dev_list, next, tmp_dev) { + struct rte_afu_driver *drv = afu_dev->driver; + int ret = 0; + + if (drv == NULL || drv->remove == NULL) + goto free; + + ret = drv->remove(afu_dev); + if (ret < 0) { + rte_errno = errno; + error = -1; + } + afu_dev->driver = NULL; + afu_dev->device.driver = NULL; + +free: + TAILQ_REMOVE(&ifpga_afu_dev_list, afu_dev, next); + rte_devargs_remove(afu_dev->device.devargs); + rte_intr_instance_free(afu_dev->intr_handle); + free(afu_dev); + } + + return error; +} + static int ifpga_plug(struct rte_device *dev) { @@ -470,6 +505,7 @@ struct rte_afu_device * static struct rte_bus rte_ifpga_bus = { .scan = ifpga_scan, .probe = ifpga_probe, + .cleanup = ifpga_cleanup, .find_device = ifpga_find_device, .plug = ifpga_plug, .unplug = ifpga_unplug, -- 1.8.3.1