diff options
| author | Andy Fiddaman <omnios@citrus-it.co.uk> | 2022-07-14 18:35:54 +0000 |
|---|---|---|
| committer | Andy Fiddaman <illumos@fiddaman.net> | 2022-08-12 08:56:37 +0000 |
| commit | 30a4bccb45421aa759c9731e9094f2fa13f321c7 (patch) | |
| tree | 3336667d0896abba1b9a5280202c1495421ecd49 /usr | |
| parent | 64121b135066abca1808f49288c947e236922532 (diff) | |
| download | illumos-joyent-30a4bccb45421aa759c9731e9094f2fa13f321c7.tar.gz | |
14816 Boot from NVMe scans all devices after 14688
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Robert Mustacchi <rm@fingolfin.org>
Diffstat (limited to 'usr')
| -rw-r--r-- | usr/src/uts/common/io/nvme/nvme.c | 58 | ||||
| -rw-r--r-- | usr/src/uts/common/io/nvme/nvme_var.h | 2 |
2 files changed, 24 insertions, 36 deletions
diff --git a/usr/src/uts/common/io/nvme/nvme.c b/usr/src/uts/common/io/nvme/nvme.c index 00ed176144..6ce0b3dcf9 100644 --- a/usr/src/uts/common/io/nvme/nvme.c +++ b/usr/src/uts/common/io/nvme/nvme.c @@ -3817,27 +3817,6 @@ nvme_remove_callback(dev_info_t *dip, ddi_eventcookie_t cookie, void *a, } } -static void -nvme_attach_children(void *arg) -{ - nvme_t *nvme = arg; - int i; - - mutex_enter(&nvme->n_mgmt_mutex); - - for (i = 1; i <= nvme->n_namespace_count; i++) { - int rv; - - rv = nvme_attach_ns(nvme, i); - if (rv != 0 && rv != ENOTSUP) { - dev_err(nvme->n_dip, CE_WARN, - "!failed to attach namespace %d: %d", i, rv); - } - } - - mutex_exit(&nvme->n_mgmt_mutex); -} - static int nvme_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) { @@ -3847,6 +3826,7 @@ nvme_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) off_t regsize; int i; char name[32]; + boolean_t attached_ns; if (cmd != DDI_ATTACH) return (DDI_FAILURE); @@ -4053,26 +4033,39 @@ nvme_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) } } - mutex_exit(&nvme->n_mgmt_mutex); - if (ddi_create_minor_node(dip, "devctl", S_IFCHR, NVME_MINOR(ddi_get_instance(dip), 0), DDI_NT_NVME_NEXUS, 0) != DDI_SUCCESS) { + mutex_exit(&nvme->n_mgmt_mutex); dev_err(dip, CE_WARN, "nvme_attach: " "cannot create devctl minor node"); goto fail; } - nvme->n_tq = ddi_taskq_create(dip, "attach_children", 1, - TASKQ_DEFAULTPRI, 0); - if (nvme->n_tq == NULL) { - dev_err(dip, CE_WARN, - "!failed to create attach_children taskq"); - goto fail; + attached_ns = B_FALSE; + for (i = 1; i <= nvme->n_namespace_count; i++) { + int rv; + + rv = nvme_attach_ns(nvme, i); + if (rv == 0) { + attached_ns = B_TRUE; + } else if (rv != ENOTSUP) { + dev_err(nvme->n_dip, CE_WARN, + "!failed to attach namespace %d: %d", i, rv); + /* + * Once we have successfully attached a namespace we + * can no longer fail the driver attach as there is now + * a blkdev child node linked to this device, and + * our node is not yet in the attached state. + */ + if (!attached_ns) { + mutex_exit(&nvme->n_mgmt_mutex); + goto fail; + } + } } - (void) ddi_taskq_dispatch(nvme->n_tq, nvme_attach_children, nvme, - DDI_SLEEP); + mutex_exit(&nvme->n_mgmt_mutex); return (DDI_SUCCESS); @@ -4102,9 +4095,6 @@ nvme_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) if (nvme == NULL) return (DDI_FAILURE); - if (nvme->n_tq != NULL) - ddi_taskq_destroy(nvme->n_tq); - ddi_remove_minor_node(dip, "devctl"); if (nvme->n_ns) { diff --git a/usr/src/uts/common/io/nvme/nvme_var.h b/usr/src/uts/common/io/nvme/nvme_var.h index 4d06e618f8..10cc529fd9 100644 --- a/usr/src/uts/common/io/nvme/nvme_var.h +++ b/usr/src/uts/common/io/nvme/nvme_var.h @@ -273,8 +273,6 @@ struct nvme { nvme_fwslot_log_t *n_fwslot; /* Lock protecting the cached firmware slot info */ kmutex_t n_fwslot_mutex; - - ddi_taskq_t *n_tq; }; struct nvme_namespace { |
