Commit 8c71c208 authored by Liang Yan's avatar Liang Yan Committed by Daniel Verkamp
Browse files

nvme: check ctrlr process while get ctrlr data in hotplug function.



Fix issue #313.
For multi-process test scenarios, the secondary process may access
controller’s CSTS register in the shared ctrlr list. For this situation,
all the controllers are already in the primary shared ctrlr list, but
then each controller is added one by one in the secondary process, so the
secondary process may access CSTS before it is remapped for the BAR space.

In the rpc_config.sh test case, the spdk_nvme_ctrlr_get_regs_csts function
will be called in _nvme_pcie_hotplug_monitor function before calling
spdk_pci_nvme_device_attach. This step caused the secondary process iSCSI
Target access CSTS before it is remapped for the BAR space.

Change-Id: Ifd62c38adf8624f9877a9a2f965ca4db28839d99
Signed-off-by: default avatarLiang Yan <liang.z.yan@intel.com>
Reviewed-on: https://review.gerrithub.io/412594


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent ff4f94dc
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -254,6 +254,7 @@ _nvme_pcie_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb,
	struct spdk_uevent event;
	struct spdk_pci_addr pci_addr;
	union spdk_nvme_csts_register csts;
	struct spdk_nvme_ctrlr_process *proc;

	while (spdk_get_uevent(hotplug_fd, &event) > 0) {
		if (event.subsystem == SPDK_NVME_UEVENT_SUBSYSTEM_UIO ||
@@ -294,6 +295,9 @@ _nvme_pcie_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb,

	/* This is a work around for vfio-attached device hot remove detection. */
	TAILQ_FOREACH_SAFE(ctrlr, &g_spdk_nvme_driver->shared_attached_ctrlrs, tailq, tmp) {
		/* NVMe controller BAR must be mapped to secondary process space before any access. */
		proc = spdk_nvme_ctrlr_get_current_process(ctrlr);
		if (proc) {
			csts = spdk_nvme_ctrlr_get_regs_csts(ctrlr);
			if (csts.raw == 0xffffffffU) {
				nvme_ctrlr_fail(ctrlr, true);
@@ -304,6 +308,7 @@ _nvme_pcie_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb,
				}
			}
		}
	}
	return 0;
}