DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wei Huang <wei.huang@intel.com>
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 <wei.huang@intel.com>
Subject: [PATCH v1] raw/ifpga: check afu device before unplug
Date: Sun, 26 Mar 2023 17:41:34 -0400	[thread overview]
Message-ID: <20230326214134.782428-1-wei.huang@intel.com> (raw)

AFU device may be already unplugged in IFPGA bus cleanup process,
unplug AFU device only when it exists.

Signed-off-by: Wei Huang <wei.huang@intel.com>
---
 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 <bus_vdev_driver.h>
 #include <rte_string_fns.h>
 #include <rte_pmd_i40e.h>
+#include <bus_driver.h>
 
 #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


             reply	other threads:[~2023-03-27  2:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-26 21:41 Wei Huang [this message]
2023-03-30  9:06 ` Zhang, Tianfei
2023-06-12 20:30   ` Thomas Monjalon
2023-05-03  5:19 ` Xu, Rosen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230326214134.782428-1-wei.huang@intel.com \
    --to=wei.huang@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=rosen.xu@intel.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=tianfei.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).