Loading lib/nvme/nvme_ctrlr.c +24 −0 Original line number Diff line number Diff line Loading @@ -1106,6 +1106,30 @@ nvme_ctrlr_get_ref_count(struct spdk_nvme_ctrlr *ctrlr) return ref; } /** * Get the PCI device handle which is only visible to its associated process. */ struct spdk_pci_device * nvme_ctrlr_proc_get_devhandle(struct spdk_nvme_ctrlr *ctrlr) { struct spdk_nvme_ctrlr_process *active_proc; pid_t pid = getpid(); struct spdk_pci_device *devhandle = NULL; nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); TAILQ_FOREACH(active_proc, &ctrlr->active_procs, tailq) { if (active_proc->pid == pid) { devhandle = active_proc->devhandle; break; } } nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); return devhandle; } /** * This function will be called repeatedly during initialization until the controller is ready. */ Loading lib/nvme/nvme_internal.h +1 −0 Original line number Diff line number Diff line Loading @@ -524,6 +524,7 @@ void nvme_completion_poll_cb(void *arg, const struct spdk_nvme_cpl *cpl); int nvme_ctrlr_add_process(struct spdk_nvme_ctrlr *ctrlr, void *devhandle); void nvme_ctrlr_free_processes(struct spdk_nvme_ctrlr *ctrlr); struct spdk_pci_device *nvme_ctrlr_proc_get_devhandle(struct spdk_nvme_ctrlr *ctrlr); int nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid, void *devhandle, spdk_nvme_probe_cb probe_cb, void *cb_ctx); Loading lib/nvme/nvme_pcie.c +6 −1 Original line number Diff line number Diff line Loading @@ -775,6 +775,7 @@ int nvme_pcie_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr) { struct nvme_pcie_ctrlr *pctrlr = nvme_pcie_ctrlr(ctrlr); struct spdk_pci_device *devhandle = nvme_ctrlr_proc_get_devhandle(ctrlr); if (ctrlr->adminq) { nvme_pcie_qpair_destroy(ctrlr->adminq); Loading @@ -783,7 +784,11 @@ nvme_pcie_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr) nvme_ctrlr_free_processes(ctrlr); nvme_pcie_ctrlr_free_bars(pctrlr); spdk_pci_device_detach(pctrlr->devhandle); if (devhandle) { spdk_pci_device_detach(devhandle); } spdk_free(pctrlr); return 0; Loading test/lib/nvme/nvmemp.sh +4 −2 Original line number Diff line number Diff line Loading @@ -19,10 +19,12 @@ if [ $(uname -s) = Linux ]; then timing_enter mp_fault_test timing_enter mp_fault_test_1 $rootdir/examples/nvme/arbitration/arbitration -i 0 -s 4096 -t 5 -c 0xf & pid=$! sleep 3 $rootdir/examples/nvme/perf/perf -i 0 -q 128 -w read -s 4096 -t 3 -c 0x10 $rootdir/examples/nvme/perf/perf -i 0 -q 128 -w read -s 4096 -t 5 -c 0x10 & sleep 1 kill -9 $! kill -9 $pid wait $! timing_exit mp_fault_test_1 timing_enter mp_fault_test_2 Loading test/lib/nvme/unit/nvme_pcie_c/nvme_pcie_ut.c +6 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,12 @@ nvme_ctrlr_free_processes(struct spdk_nvme_ctrlr *ctrlr) abort(); } struct spdk_pci_device * nvme_ctrlr_proc_get_devhandle(struct spdk_nvme_ctrlr *ctrlr) { abort(); } int nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid, void *devhandle, spdk_nvme_probe_cb probe_cb, void *cb_ctx) Loading Loading
lib/nvme/nvme_ctrlr.c +24 −0 Original line number Diff line number Diff line Loading @@ -1106,6 +1106,30 @@ nvme_ctrlr_get_ref_count(struct spdk_nvme_ctrlr *ctrlr) return ref; } /** * Get the PCI device handle which is only visible to its associated process. */ struct spdk_pci_device * nvme_ctrlr_proc_get_devhandle(struct spdk_nvme_ctrlr *ctrlr) { struct spdk_nvme_ctrlr_process *active_proc; pid_t pid = getpid(); struct spdk_pci_device *devhandle = NULL; nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); TAILQ_FOREACH(active_proc, &ctrlr->active_procs, tailq) { if (active_proc->pid == pid) { devhandle = active_proc->devhandle; break; } } nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); return devhandle; } /** * This function will be called repeatedly during initialization until the controller is ready. */ Loading
lib/nvme/nvme_internal.h +1 −0 Original line number Diff line number Diff line Loading @@ -524,6 +524,7 @@ void nvme_completion_poll_cb(void *arg, const struct spdk_nvme_cpl *cpl); int nvme_ctrlr_add_process(struct spdk_nvme_ctrlr *ctrlr, void *devhandle); void nvme_ctrlr_free_processes(struct spdk_nvme_ctrlr *ctrlr); struct spdk_pci_device *nvme_ctrlr_proc_get_devhandle(struct spdk_nvme_ctrlr *ctrlr); int nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid, void *devhandle, spdk_nvme_probe_cb probe_cb, void *cb_ctx); Loading
lib/nvme/nvme_pcie.c +6 −1 Original line number Diff line number Diff line Loading @@ -775,6 +775,7 @@ int nvme_pcie_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr) { struct nvme_pcie_ctrlr *pctrlr = nvme_pcie_ctrlr(ctrlr); struct spdk_pci_device *devhandle = nvme_ctrlr_proc_get_devhandle(ctrlr); if (ctrlr->adminq) { nvme_pcie_qpair_destroy(ctrlr->adminq); Loading @@ -783,7 +784,11 @@ nvme_pcie_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr) nvme_ctrlr_free_processes(ctrlr); nvme_pcie_ctrlr_free_bars(pctrlr); spdk_pci_device_detach(pctrlr->devhandle); if (devhandle) { spdk_pci_device_detach(devhandle); } spdk_free(pctrlr); return 0; Loading
test/lib/nvme/nvmemp.sh +4 −2 Original line number Diff line number Diff line Loading @@ -19,10 +19,12 @@ if [ $(uname -s) = Linux ]; then timing_enter mp_fault_test timing_enter mp_fault_test_1 $rootdir/examples/nvme/arbitration/arbitration -i 0 -s 4096 -t 5 -c 0xf & pid=$! sleep 3 $rootdir/examples/nvme/perf/perf -i 0 -q 128 -w read -s 4096 -t 3 -c 0x10 $rootdir/examples/nvme/perf/perf -i 0 -q 128 -w read -s 4096 -t 5 -c 0x10 & sleep 1 kill -9 $! kill -9 $pid wait $! timing_exit mp_fault_test_1 timing_enter mp_fault_test_2 Loading
test/lib/nvme/unit/nvme_pcie_c/nvme_pcie_ut.c +6 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,12 @@ nvme_ctrlr_free_processes(struct spdk_nvme_ctrlr *ctrlr) abort(); } struct spdk_pci_device * nvme_ctrlr_proc_get_devhandle(struct spdk_nvme_ctrlr *ctrlr) { abort(); } int nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid, void *devhandle, spdk_nvme_probe_cb probe_cb, void *cb_ctx) Loading