Commit 76e1ac04 authored by Changpeng Liu's avatar Changpeng Liu Committed by Jim Harris
Browse files

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: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7944


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarDong Yi <dongx.yi@intel.com>
parent 1aa72efa
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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();