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 31A734284A for ; Mon, 27 Mar 2023 04:40:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28A914161A; Mon, 27 Mar 2023 04:40:50 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id BE89D40ED5; Mon, 27 Mar 2023 04:40:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679884848; x=1711420848; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=iBNMmsDXsEsYx+d1PFfs7LtccoGi/EfdTChuSP7DJ10=; b=WOT81Dx8GvMqZRk/EyBYJ3OIW3yhpjGFxMXhuUtCiZPBL7lHLbAE+13E cEP3iJpBmVyvowhvaaUtDQhFhc9b+kQlKXZMt+OvdibeUk4wOKPsnKq12 BqerbMNRNqrc9015898IelsRDloXQ9tcj2gIpVV/4EEHTyIdzrThuEj+c 4+tYIHWXV5TuydHkest1L1+t1N4dxNo8EQPOnDovuh5LG9vhl95dFP35X 63qxSdcPz/aptZQhcuaXurklIQ97NkuPI+MpmWwOL10ZeSHlG8QuIDMEz LlyFS5ZSd5OnEcVFrv8A4ERPrIsk938g4UnVCPdS+MNzoi0a0EoRb7LnQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="324048458" X-IronPort-AV: E=Sophos;i="5.98,293,1673942400"; d="scan'208";a="324048458" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2023 19:40:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="772527570" X-IronPort-AV: E=Sophos;i="5.98,293,1673942400"; d="scan'208";a="772527570" Received: from unknown (HELO ocsbesrhlrepo01.sh.intel.com) ([10.238.175.110]) by FMSMGA003.fm.intel.com with ESMTP; 26 Mar 2023 19:40:44 -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] raw/ifpga: check afu device before unplug Date: Sun, 26 Mar 2023 17:41:34 -0400 Message-Id: <20230326214134.782428-1-wei.huang@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org AFU device may be already unplugged in IFPGA bus cleanup process, unplug AFU device only when it exists. Signed-off-by: Wei Huang --- drivers/raw/ifpga/ifpga_rawdev.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 1020adc..0d43c87 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "base/opae_hw_api.h" #include "base/opae_ifpga_hw_api.h" @@ -1832,12 +1833,19 @@ static int ifpga_rawdev_get_string_arg(const char *key __rte_unused, return ret; } +static int cmp_dev_name(const struct rte_device *dev, const void *_name) +{ + const char *name = _name; + return strcmp(dev->name, name); +} + static int ifpga_cfg_remove(struct rte_vdev_device *vdev) { struct rte_rawdev *rawdev = NULL; struct ifpga_rawdev *ifpga_dev; struct ifpga_vdev_args args; + struct rte_bus *bus; char dev_name[RTE_RAWDEV_NAME_MAX_LEN]; const char *vdev_name = NULL; char *tmp_vdev = NULL; @@ -1864,7 +1872,13 @@ static int ifpga_rawdev_get_string_arg(const char *key __rte_unused, snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "%d|%s", args.port, args.bdf); - ret = rte_eal_hotplug_remove(RTE_STR(IFPGA_BUS_NAME), dev_name); + bus = rte_bus_find_by_name(RTE_STR(IFPGA_BUS_NAME)); + if (bus) { + if (bus->find_device(NULL, cmp_dev_name, dev_name)) { + ret = rte_eal_hotplug_remove(RTE_STR(IFPGA_BUS_NAME), + dev_name); + } + } for (i = 0; i < IFPGA_MAX_VDEV; i++) { tmp_vdev = ifpga_dev->vdev_name[i]; -- 1.8.3.1