pci: fix rte dev remove handling

Can not remove device in the remove event
callback as we can not unregister the remove
callback. So use the alarm_set to fix this issue.

Fixes #1809

Change-Id: Ib86bc4eeecc0fe2bc51538e28684d015405e8835
Signed-off-by: Jin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6553
Reviewed-by: Vasuki Manikarnike <vasuki.manikarnike@hpe.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Jin Yu 2021-02-26 00:56:34 +08:00 committed by Tomasz Zawadzki
parent 6de10dfc01
commit 17a286baff

View File

@ -246,8 +246,17 @@ pci_device_rte_dev_event(const char *device_name,
if (dev != NULL && can_detach) {
/* if device is not attached we can remove it right away.
* Otherwise it will be removed at detach. */
remove_rte_dev(dev->dev_handle);
* Otherwise it will be removed at detach.
*
* 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, detach_rte_cb, dev->dev_handle);
}
break;
}