Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/nvme/nvme_ctrlr.c
Show First 20 Lines • Show All 509 Lines • ▼ Show 20 Lines | if (nvme_completion_is_error(&status.cpl)) { | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
nvme_ctrlr_destroy_qpair(struct nvme_controller *ctrlr, struct nvme_qpair *qpair) | nvme_ctrlr_destroy_qpairs(struct nvme_controller *ctrlr) | ||||
{ | { | ||||
struct nvme_completion_poll_status status; | struct nvme_completion_poll_status status; | ||||
struct nvme_qpair *qpair; | |||||
for (int i = 0; i < ctrlr->num_io_queues; i++) { | |||||
qpair = &ctrlr->ioq[i]; | |||||
status.done = 0; | status.done = 0; | ||||
nvme_ctrlr_cmd_delete_io_sq(ctrlr, qpair, | nvme_ctrlr_cmd_delete_io_sq(ctrlr, qpair, | ||||
nvme_completion_poll_cb, &status); | nvme_completion_poll_cb, &status); | ||||
while (!atomic_load_acq_int(&status.done)) | while (!atomic_load_acq_int(&status.done)) | ||||
pause("nvme", 1); | pause("nvme", 1); | ||||
if (nvme_completion_is_error(&status.cpl)) { | if (nvme_completion_is_error(&status.cpl)) { | ||||
nvme_printf(ctrlr, "nvme_destroy_io_sq failed!\n"); | nvme_printf(ctrlr, "nvme_destroy_io_sq failed!\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
status.done = 0; | status.done = 0; | ||||
nvme_ctrlr_cmd_delete_io_cq(ctrlr, qpair, | nvme_ctrlr_cmd_delete_io_cq(ctrlr, qpair, | ||||
nvme_completion_poll_cb, &status); | nvme_completion_poll_cb, &status); | ||||
while (!atomic_load_acq_int(&status.done)) | while (!atomic_load_acq_int(&status.done)) | ||||
pause("nvme", 1); | pause("nvme", 1); | ||||
if (nvme_completion_is_error(&status.cpl)) { | if (nvme_completion_is_error(&status.cpl)) { | ||||
nvme_printf(ctrlr, "nvme_destroy_io_cq failed!\n"); | nvme_printf(ctrlr, "nvme_destroy_io_cq failed!\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
} | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
nvme_ctrlr_construct_namespaces(struct nvme_controller *ctrlr) | nvme_ctrlr_construct_namespaces(struct nvme_controller *ctrlr) | ||||
{ | { | ||||
struct nvme_namespace *ns; | struct nvme_namespace *ns; | ||||
▲ Show 20 Lines • Show All 760 Lines • ▼ Show 20 Lines | nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev) | ||||
nvme_notify_fail_consumers(ctrlr); | nvme_notify_fail_consumers(ctrlr); | ||||
for (i = 0; i < NVME_MAX_NAMESPACES; i++) | for (i = 0; i < NVME_MAX_NAMESPACES; i++) | ||||
nvme_ns_destruct(&ctrlr->ns[i]); | nvme_ns_destruct(&ctrlr->ns[i]); | ||||
if (ctrlr->cdev) | if (ctrlr->cdev) | ||||
destroy_dev(ctrlr->cdev); | destroy_dev(ctrlr->cdev); | ||||
nvme_ctrlr_destroy_qpairs(ctrlr); | |||||
for (i = 0; i < ctrlr->num_io_queues; i++) { | for (i = 0; i < ctrlr->num_io_queues; i++) { | ||||
nvme_ctrlr_destroy_qpair(ctrlr, &ctrlr->ioq[i]); | |||||
nvme_io_qpair_destroy(&ctrlr->ioq[i]); | nvme_io_qpair_destroy(&ctrlr->ioq[i]); | ||||
} | } | ||||
free(ctrlr->ioq, M_NVME); | free(ctrlr->ioq, M_NVME); | ||||
nvme_admin_qpair_destroy(&ctrlr->adminq); | nvme_admin_qpair_destroy(&ctrlr->adminq); | ||||
/* | /* | ||||
* Notify the controller of a shutdown, even though this is due to | * Notify the controller of a shutdown, even though this is due to | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |