From b71ee92e3b925a9a6c442f2604aab583a7b25824 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Thu, 2 Apr 2020 14:57:40 +0200 Subject: [PATCH] Revert "pci: fix the hotplug issue" This reverts commit 301c5aeec9f1ef3bed61c55502385d08565acdb1. The patch doesn't fix anything as the hotremoval could be still called twice and the second call would do use-after-free. Change-Id: I78a1120707dbdf36c871ec378a312c4a058fc76b Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1729 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/env_dpdk/pci.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index f43e5272b..844647cb5 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -179,12 +179,6 @@ pci_driver_register(struct spdk_pci_driver *driver) } #if RTE_VERSION >= RTE_VERSION_NUM(18, 5, 0, 0) -static void -pci_device_rte_hotremove_cb(void *dev) -{ - detach_rte((struct spdk_pci_device *)dev); -} - static void pci_device_rte_hotremove(const char *device_name, enum rte_dev_event_type event, @@ -200,6 +194,7 @@ pci_device_rte_hotremove(const char *device_name, pthread_mutex_lock(&g_pci_mutex); TAILQ_FOREACH(dev, &g_pci_devices, internal.tailq) { struct rte_pci_device *rte_dev = dev->dev_handle; + if (strcmp(rte_dev->name, device_name) == 0 && !dev->internal.pending_removal) { can_detach = !dev->internal.attached; @@ -211,17 +206,8 @@ pci_device_rte_hotremove(const char *device_name, pthread_mutex_unlock(&g_pci_mutex); if (dev != NULL && can_detach) { - /* If device is not attached, we can remove it right away. - * - * Because the user's callback is invoked in eal interrupt - * callback, the interrupt callback need to be finished before - * it can be unregistered when detaching device. So finish - * callback soon and use a deferred removal to detach device - * is need. It is a workaround, once the device detaching be - * moved into the eal in the future, the deferred removal could - * be deleted. - */ - rte_eal_alarm_set(1, pci_device_rte_hotremove_cb, dev); + /* if device is not attached, we can remove it right away. */ + detach_rte(dev); } } #endif