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: Liang Yan <liang.z.yan@intel.com> Reviewed-on: https://review.gerrithub.io/412594 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: GangCao <gang.cao@intel.com> Reviewed-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
ff4f94dc5f
commit
8c71c208a2
@ -254,6 +254,7 @@ _nvme_pcie_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb,
|
|||||||
struct spdk_uevent event;
|
struct spdk_uevent event;
|
||||||
struct spdk_pci_addr pci_addr;
|
struct spdk_pci_addr pci_addr;
|
||||||
union spdk_nvme_csts_register csts;
|
union spdk_nvme_csts_register csts;
|
||||||
|
struct spdk_nvme_ctrlr_process *proc;
|
||||||
|
|
||||||
while (spdk_get_uevent(hotplug_fd, &event) > 0) {
|
while (spdk_get_uevent(hotplug_fd, &event) > 0) {
|
||||||
if (event.subsystem == SPDK_NVME_UEVENT_SUBSYSTEM_UIO ||
|
if (event.subsystem == SPDK_NVME_UEVENT_SUBSYSTEM_UIO ||
|
||||||
@ -294,13 +295,17 @@ _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. */
|
/* 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) {
|
TAILQ_FOREACH_SAFE(ctrlr, &g_spdk_nvme_driver->shared_attached_ctrlrs, tailq, tmp) {
|
||||||
csts = spdk_nvme_ctrlr_get_regs_csts(ctrlr);
|
/* NVMe controller BAR must be mapped to secondary process space before any access. */
|
||||||
if (csts.raw == 0xffffffffU) {
|
proc = spdk_nvme_ctrlr_get_current_process(ctrlr);
|
||||||
nvme_ctrlr_fail(ctrlr, true);
|
if (proc) {
|
||||||
if (remove_cb) {
|
csts = spdk_nvme_ctrlr_get_regs_csts(ctrlr);
|
||||||
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
|
if (csts.raw == 0xffffffffU) {
|
||||||
remove_cb(cb_ctx, ctrlr);
|
nvme_ctrlr_fail(ctrlr, true);
|
||||||
nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
|
if (remove_cb) {
|
||||||
|
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||||
|
remove_cb(cb_ctx, ctrlr);
|
||||||
|
nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user