diff --git a/sys/dev/nvd/nvd.c b/sys/dev/nvd/nvd.c --- a/sys/dev/nvd/nvd.c +++ b/sys/dev/nvd/nvd.c @@ -524,14 +524,6 @@ TAILQ_INSERT_TAIL(&ctrlr_head, nvd_ctrlr, tailq); mtx_unlock(&nvd_lock); - for (int i = 0; i < min(ctrlr->cdata.nn, NVME_MAX_NAMESPACES); i++) { - struct nvme_namespace *ns = &ctrlr->ns[i]; - - if (ns->data.nsze == 0) - continue; - nvd_new_disk(ns, nvd_ctrlr); - } - return (0); } diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c --- a/sys/dev/nvme/nvme.c +++ b/sys/dev/nvme/nvme.c @@ -170,18 +170,6 @@ } } -void -nvme_notify_new_controller(struct nvme_controller *ctrlr) -{ - int i; - - for (i = 0; i < NVME_MAX_CONSUMERS; i++) { - if (nvme_consumer[i].id != INVALID_CONSUMER_ID) { - nvme_notify(&nvme_consumer[i], ctrlr); - } - } -} - static void nvme_notify_new_consumer(struct nvme_consumer *cons) { diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -45,6 +45,8 @@ #include "nvme_private.h" #include "nvme_linux.h" +#include "nvmec_if.h" + #define B4_CHK_RDY_DELAY_MS 2300 /* work around controller bug */ static void nvme_ctrlr_construct_and_submit_aer(struct nvme_controller *ctrlr, @@ -1181,10 +1183,20 @@ device_t child; ctrlr->is_initialized = true; - nvme_notify_new_controller(ctrlr); child = device_add_child(ctrlr->dev, NULL, DEVICE_UNIT_ANY); device_set_ivars(child, ctrlr); bus_attach_children(ctrlr->dev); + + /* + * Now notify the child of all the known namepsaces + */ + for (int i = 0; i < min(ctrlr->cdata.nn, NVME_MAX_NAMESPACES); i++) { + struct nvme_namespace *ns = &ctrlr->ns[i]; + + if (ns->data.nsze == 0) + continue; + NVMEC_NEW_NS(child, ns); + } } TSEXIT(); } diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -560,7 +560,6 @@ uint32_t log_page_id, void *log_page_buffer, uint32_t log_page_size); void nvme_notify_fail_consumers(struct nvme_controller *ctrlr); -void nvme_notify_new_controller(struct nvme_controller *ctrlr); void nvme_notify_ns(struct nvme_controller *ctrlr, int nsid); void nvme_ctrlr_shared_handler(void *arg); diff --git a/sys/dev/nvme/nvme_sim.c b/sys/dev/nvme/nvme_sim.c --- a/sys/dev/nvme/nvme_sim.c +++ b/sys/dev/nvme/nvme_sim.c @@ -371,14 +371,6 @@ goto err3; } - for (int i = 0; i < min(ctrlr->cdata.nn, NVME_MAX_NAMESPACES); i++) { - struct nvme_namespace *ns = &ctrlr->ns[i]; - - if (ns->data.nsze == 0) - continue; - nvme_sim_ns_change(ns, sc); - } - return (0); err3: xpt_bus_deregister(cam_sim_path(sc->s_sim));