git: b6b52a9b8011 - main - nvme: Notify failure with newbus call
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 10 Dec 2025 22:53:57 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=b6b52a9b8011d9893899ecad87948ef346858960
commit b6b52a9b8011d9893899ecad87948ef346858960
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-12-10 22:52:53 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-12-10 22:52:53 +0000
nvme: Notify failure with newbus call
Sponsored by: Netflix
Reviewed by: dab
Differential Revision: https://reviews.freebsd.org/D51391
---
sys/dev/nvme/nvme.c | 23 ++++++++++-------------
sys/dev/nvme/nvme_ctrlr.c | 4 ++--
sys/dev/nvme/nvme_private.h | 2 +-
3 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c
index dcd0851dd56a..2571c6fe2973 100644
--- a/sys/dev/nvme/nvme.c
+++ b/sys/dev/nvme/nvme.c
@@ -208,11 +208,10 @@ nvme_notify_async(struct nvme_controller *ctrlr,
}
void
-nvme_notify_fail_consumers(struct nvme_controller *ctrlr)
+nvme_notify_fail(struct nvme_controller *ctrlr)
{
- struct nvme_consumer *cons;
- void *ctrlr_cookie;
- uint32_t i;
+ device_t *children;
+ int n_children;
/*
* This controller failed during initialization (i.e. IDENTIFY
@@ -223,15 +222,13 @@ nvme_notify_fail_consumers(struct nvme_controller *ctrlr)
if (!ctrlr->is_initialized)
return;
- for (i = 0; i < NVME_MAX_CONSUMERS; i++) {
- cons = &nvme_consumer[i];
- if (cons->id != INVALID_CONSUMER_ID &&
- (ctrlr_cookie = ctrlr->cons_cookie[i]) != NULL) {
- ctrlr->cons_cookie[i] = NULL;
- if (cons->fail_fn != NULL)
- cons->fail_fn(ctrlr_cookie);
- }
- }
+ if (device_get_children(ctrlr->dev, &children, &n_children) != 0)
+ return;
+
+ for (int i = 0; i < n_children; i++)
+ NVME_CONTROLLER_FAILED(children[i]);
+
+ free(children, M_TEMP);
}
struct nvme_consumer *
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 2f28d8f5cb7f..6b875060d4b1 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -256,7 +256,7 @@ nvme_ctrlr_fail(struct nvme_controller *ctrlr, bool admin_also)
nvme_qpair_fail(&ctrlr->ioq[i]);
}
}
- nvme_notify_fail_consumers(ctrlr);
+ nvme_notify_fail(ctrlr);
}
/*
@@ -1723,7 +1723,7 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev)
if (gone)
nvme_ctrlr_fail(ctrlr, true);
else
- nvme_notify_fail_consumers(ctrlr);
+ nvme_notify_fail(ctrlr);
for (i = 0; i < NVME_MAX_NAMESPACES; i++)
nvme_ns_destruct(&ctrlr->ns[i]);
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index 27d70d120307..04756c6c74a7 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -560,7 +560,7 @@ void nvme_notify_async(struct nvme_controller *ctrlr,
const struct nvme_completion *async_cpl,
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_fail(struct nvme_controller *ctrlr);
void nvme_ctrlr_shared_handler(void *arg);
void nvme_ctrlr_poll(struct nvme_controller *ctrlr);