diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 844647cb51..f90ef946f9 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -47,7 +47,6 @@ #define DPDK_HOTPLUG_RETRY_COUNT 4 /* DPDK alarm/interrupt thread */ -static pthread_t g_dpdk_tid; static pthread_mutex_t g_pci_mutex = PTHREAD_MUTEX_INITIALIZER; static TAILQ_HEAD(, spdk_pci_device) g_pci_devices = TAILQ_HEAD_INITIALIZER(g_pci_devices); /* devices hotplugged on a dpdk thread */ @@ -103,10 +102,8 @@ cfg_write_rte(struct spdk_pci_device *dev, void *value, uint32_t len, uint32_t o } static void -detach_rte_cb(void *_dev) +remove_rte_dev(struct rte_pci_device *rte_dev) { - struct rte_pci_device *rte_dev = _dev; - #if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0) char bdf[32]; int i = 0, rc; @@ -120,6 +117,12 @@ detach_rte_cb(void *_dev) #endif } +static void +detach_rte_cb(void *_dev) +{ + remove_rte_dev(_dev); +} + static void detach_rte(struct spdk_pci_device *dev) { @@ -131,8 +134,8 @@ detach_rte(struct spdk_pci_device *dev) * again while we go asynchronous, so we explicitly forbid that. */ dev->internal.pending_removal = true; - if (!spdk_process_is_primary() || pthread_equal(g_dpdk_tid, pthread_self())) { - detach_rte_cb(rte_dev); + if (!spdk_process_is_primary()) { + remove_rte_dev(rte_dev); return; } @@ -206,8 +209,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. */ - detach_rte(dev); + /* if device is not attached we can remove it right away. */ + remove_rte_dev(dev->dev_handle); } } #endif @@ -238,12 +241,6 @@ cleanup_pci_devices(void) pthread_mutex_unlock(&g_pci_mutex); } -static void -_get_alarm_thread_cb(void *unused) -{ - g_dpdk_tid = pthread_self(); -} - void pci_env_init(void) { @@ -276,11 +273,6 @@ pci_env_init(void) rte_dev_event_callback_register(NULL, pci_device_rte_hotremove, NULL); } #endif - - rte_eal_alarm_set(1, _get_alarm_thread_cb, NULL); - /* alarms are executed in order, so this one will be always executed - * before any real hotremove alarms and we don't need to wait for it. - */ } void