From 76e1ac04c744231c44620de02f05d8ac89a1dce2 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Wed, 19 May 2021 20:32:55 +0800 Subject: [PATCH] env/dpdk: fix the PCI detach error in secondary process DPDK will report error when detaching the PCI device in secondary process, because SPDK will return -1 in `pci_device_fini`, so here we will reset the `attached` flag before that. Also return the errno instead of -1. Change-Id: I3efa4d97ceab504215faeb9d3d80a694bdd6014c Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7944 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Ben Walker Reviewed-by: Dong Yi --- lib/env_dpdk/pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 84bc3b85a..b0a2fc8ec 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -528,7 +528,7 @@ pci_device_fini(struct rte_pci_device *_dev) if (dev == NULL || dev->internal.attached) { /* The device might be still referenced somewhere in SPDK. */ pthread_mutex_unlock(&g_pci_mutex); - return -1; + return -EBUSY; } /* remove our allowed_at option */ @@ -552,6 +552,7 @@ spdk_pci_device_detach(struct spdk_pci_device *dev) spdk_pci_device_unclaim(dev); } + dev->internal.attached = false; if (strcmp(dev->type, "pci") == 0) { /* if it's a physical device we need to deal with DPDK on * a different process and we can't just unset one flag @@ -561,8 +562,6 @@ spdk_pci_device_detach(struct spdk_pci_device *dev) * to a different process, or to a kernel driver like nvme. */ detach_rte(dev); - } else { - dev->internal.attached = false; } cleanup_pci_devices();