From 17a286baff5ab1b066149a12c4cefae62670b880 Mon Sep 17 00:00:00 2001 From: Jin Yu Date: Fri, 26 Feb 2021 00:56:34 +0800 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6553 Reviewed-by: Vasuki Manikarnike Reviewed-by: Changpeng Liu Reviewed-by: Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- lib/env_dpdk/pci.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 22977b679..6eabdb917 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -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; }