env/pci: cleanup spdk_detach_rte by moving code

Change-Id: I1dee015e44ecfbd7fcb1680cce0e6d527d083c99
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1728
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2020-04-02 12:42:14 +02:00 committed by Tomasz Zawadzki
parent 9db8040738
commit 23a7e4b94f

View File

@ -131,7 +131,11 @@ spdk_detach_rte(struct spdk_pci_device *dev)
* again while we go asynchronous, so we explicitly forbid that. * again while we go asynchronous, so we explicitly forbid that.
*/ */
dev->internal.pending_removal = true; dev->internal.pending_removal = true;
if (spdk_process_is_primary() && !pthread_equal(g_dpdk_tid, pthread_self())) { if (!spdk_process_is_primary() || pthread_equal(g_dpdk_tid, pthread_self())) {
spdk_detach_rte_cb(rte_dev);
return;
}
rte_eal_alarm_set(1, spdk_detach_rte_cb, rte_dev); rte_eal_alarm_set(1, spdk_detach_rte_cb, rte_dev);
/* wait up to 2s for the cb to finish executing */ /* wait up to 2s for the cb to finish executing */
for (i = 2000; i > 0; i--) { for (i = 2000; i > 0; i--) {
@ -166,9 +170,6 @@ spdk_detach_rte(struct spdk_pci_device *dev)
/* If we reach this state, then the device couldn't be removed and most likely /* If we reach this state, then the device couldn't be removed and most likely
a subsequent hot add of a device in the same BDF will fail */ a subsequent hot add of a device in the same BDF will fail */
} }
} else {
spdk_detach_rte_cb(rte_dev);
}
} }
void void