DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] bus/vdev: reduce scope of device list lock
@ 2018-05-21 16:11 Thomas Monjalon
  2018-05-21 16:45 ` [dpdk-dev] [PATCH v2] bus/vdev: fix " Thomas Monjalon
  2018-05-22  9:05 ` [dpdk-dev] [PATCH] bus/vdev: reduce " Burakov, Anatoly
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Monjalon @ 2018-05-21 16:11 UTC (permalink / raw)
  To: dev; +Cc: matan, ferruh.yigit

The lock vdev_device_list_lock was taken before calling
"remove" function for the device.
So it prevents to remove sub-devices (as in failsafe) inside
its own "remove" function, because of a deadlock.

The lock is now only protecting the device list inside
the bus driver.

Fixes: 35f462839b69 ("bus/vdev: add lock on device list")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/bus/vdev/vdev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 099b9ff85..2fbc86806 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -293,25 +293,23 @@ rte_vdev_uninit(const char *name)
 	if (name == NULL)
 		return -EINVAL;
 
-	rte_spinlock_lock(&vdev_device_list_lock);
-
 	dev = find_vdev(name);
 	if (!dev) {
 		ret = -ENOENT;
-		goto unlock;
+		return ret;
 	}
 
 	ret = vdev_remove_driver(dev);
 	if (ret)
-		goto unlock;
+		return ret;
 
+	rte_spinlock_lock(&vdev_device_list_lock);
 	TAILQ_REMOVE(&vdev_device_list, dev, next);
 	devargs = dev->device.devargs;
 	rte_devargs_remove(devargs->bus->name, devargs->name);
 	free(dev);
-
-unlock:
 	rte_spinlock_unlock(&vdev_device_list_lock);
+
 	return ret;
 }
 
-- 
2.16.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-05-22 14:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21 16:11 [dpdk-dev] [PATCH] bus/vdev: reduce scope of device list lock Thomas Monjalon
2018-05-21 16:45 ` [dpdk-dev] [PATCH v2] bus/vdev: fix " Thomas Monjalon
2018-05-21 17:28   ` Matan Azrad
2018-05-22  9:11     ` Gaëtan Rivet
2018-05-22  9:05 ` [dpdk-dev] [PATCH] bus/vdev: reduce " Burakov, Anatoly
2018-05-22  9:20   ` Thomas Monjalon
2018-05-22 11:37     ` [dpdk-dev] [PATCH v3] bus/vdev: replace device list lock by a recursive one Thomas Monjalon
2018-05-22 12:08       ` Matan Azrad
2018-05-22 13:34       ` Burakov, Anatoly
2018-05-22 14:38         ` Thomas Monjalon

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).