From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 4355B1B20E for ; Mon, 21 May 2018 18:45:59 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BBCF122189; Mon, 21 May 2018 12:45:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 21 May 2018 12:45:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=sMYT4iFw1dbhfK swElfqV7UaX2vRpSb7hMfJnKMhbGw=; b=Fs2qTqr2uC1F4i7rpb7Q7yfWxFMeSQ Jrr1L6OyPlNN0A2LgC5YRrLHUMdO1WxcWP1Xpv+Dybgaolh6t7PPCFiUrhajajoe i90vRuaShwiR/POHzdgtx8Bc9eKUuqkUkQ5Ga1GpVRGZnvF8dXkdqbffYhZGL6DA 07HeNMJLVruGI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=sMYT4iFw1dbhfKswElfqV7UaX2vRpSb7hMfJnKMhbGw=; b=Z4Kz4mf7 HNk4l6vwx3LtRCQQxrPqWRo7RIDyQZzNqX8dXADFfQBVQ75ei36XY64NpsmC0w22 4vg91Nl+Wt+5qBLpy5MfW14nhS9a3f1PAcOergmvaLXCMvV8uf7A2fU7ZysJm7zO PyrrDJcKK+ns9FfHe7zj8eS9KEk/Pfli6ikP3tqbqb1blEBNdudAPFrl7bepMosx d1XktC5PTpETcccdvpnfw6UkeZOPdCIoV7feK7Li0wOoC4S0nOwMZm+gKw+okmLZ uYTaf07q0/AETz5Bnh5J5EYdK+Xi9/P6n71aTI/qI8Jj9W88f7T+CUe1js7Ap6PI 3RQgdsd4Y0ikOg== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from xps.monjalon.net (236.204.154.77.rev.sfr.net [77.154.204.236]) by mail.messagingengine.com (Postfix) with ESMTPA id 68191E4115; Mon, 21 May 2018 12:45:57 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: matan@mellanox.com, ferruh.yigit@intel.com Date: Mon, 21 May 2018 18:45:44 +0200 Message-Id: <20180521164544.26421-1-thomas@monjalon.net> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180521161156.25724-1-thomas@monjalon.net> References: <20180521161156.25724-1-thomas@monjalon.net> Subject: [dpdk-dev] [PATCH v2] bus/vdev: fix scope of device list lock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 16:45:59 -0000 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 --- v2: reduce scope more by moving unlock --- drivers/bus/vdev/vdev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 099b9ff85..470cff46c 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -293,25 +293,24 @@ 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); + rte_spinlock_unlock(&vdev_device_list_lock); + 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