From b7349216b909e071459f2196a7bad5b41b70b996 Mon Sep 17 00:00:00 2001 From: Cunyin Chang Date: Wed, 8 Mar 2017 09:54:19 +0800 Subject: [PATCH] nvme: optimization for nvme probe and detachment. remove the unnecessary rte_eal_pci_probe_one() in function spdk_pci_device_detach(), this could cause error message when we terminate the application, it will also not make sense try to probe one device after we detach it, we could call spdk_pci_nvme_device_attach() instead of spdk_pci_nvme_enumerate() when we have one given device address, dpdk will try to scan the device and add it back to pci device list then. Change-Id: I35f5bb412249bb20da57394f0531c10a49691906 Signed-off-by: Cunyin Chang --- lib/env_dpdk/pci.c | 5 ----- lib/nvme/nvme_pcie.c | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index c99a5be2ac..b7db73ba53 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -87,11 +87,6 @@ spdk_pci_device_detach(struct spdk_pci_device *device) rte_eal_device_remove(&device->device); #endif rte_eal_pci_detach(&addr); - /* This will not actually load any drivers because our - * callback isn't set, but it will re-add the device - * to DPDK's internal list. - */ - rte_eal_pci_probe_one(&addr); } int diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 1230d4d9d4..80bb027a2a 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -644,7 +644,11 @@ nvme_pcie_ctrlr_scan(const struct spdk_nvme_transport_id *trid, _nvme_pcie_hotplug_monitor(cb_ctx, probe_cb, remove_cb); } - return spdk_pci_nvme_enumerate(pcie_nvme_enum_cb, &enum_ctx); + if (enum_ctx.has_pci_addr == false) { + return spdk_pci_nvme_enumerate(pcie_nvme_enum_cb, &enum_ctx); + } else { + return spdk_pci_nvme_device_attach(pcie_nvme_enum_cb, &enum_ctx, &enum_ctx.pci_addr); + } } static int