aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2025-12-10 22:52:45 +0000
committerWarner Losh <imp@FreeBSD.org>2025-12-10 22:52:45 +0000
commit9b170dc457a46d3ec3b329116fcd6851fe9b63a0 (patch)
treeb4cf26869c3956dd5caf0347f6e7ed413c998c39
parentaed44717a1606e4c5c79f7c8831de49cba64d7e6 (diff)
nvme: Use new method to do async notifications
Nothing uses these at the moment, but it would be useful to use in the future so convert this functionality to an newbus function dispatch. Sponsored by: Netflix Reviewed by: dab Differential Revision: https://reviews.freebsd.org/D51390
-rw-r--r--sys/dev/nvme/nvme.c29
-rw-r--r--sys/dev/nvme/nvme_ctrlr.c11
-rw-r--r--sys/dev/nvme/nvme_private.h8
3 files changed, 23 insertions, 25 deletions
diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c
index 3ff64c781884..dcd0851dd56a 100644
--- a/sys/dev/nvme/nvme.c
+++ b/sys/dev/nvme/nvme.c
@@ -34,6 +34,7 @@
#include <vm/uma.h>
#include "nvme_private.h"
+#include "nvme_if.h"
struct nvme_consumer {
uint32_t id;
@@ -189,23 +190,21 @@ nvme_notify_new_consumer(struct nvme_consumer *cons)
}
void
-nvme_notify_async_consumers(struct nvme_controller *ctrlr,
- const struct nvme_completion *async_cpl,
- uint32_t log_page_id, void *log_page_buffer,
- uint32_t log_page_size)
+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)
{
- struct nvme_consumer *cons;
- void *ctrlr_cookie;
- uint32_t i;
+ device_t *children;
+ int n_children;
- for (i = 0; i < NVME_MAX_CONSUMERS; i++) {
- cons = &nvme_consumer[i];
- if (cons->id != INVALID_CONSUMER_ID && cons->async_fn != NULL &&
- (ctrlr_cookie = ctrlr->cons_cookie[i]) != NULL) {
- (*cons->async_fn)(ctrlr_cookie, async_cpl,
- log_page_id, log_page_buffer, log_page_size);
- }
- }
+ if (device_get_children(ctrlr->dev, &children, &n_children) != 0)
+ return;
+
+ for (int i = 0; i < n_children; i++)
+ NVME_HANDLE_AEN(children[i], async_cpl, log_page_id,
+ log_page_buffer, log_page_size);
+
+ free(children, M_TEMP);
}
void
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 7a449fdc4727..2f28d8f5cb7f 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1154,8 +1154,7 @@ nvme_ctrlr_aer_task(void *arg, int pending)
* Repost another asynchronous event request to replace the one
* that just completed.
*/
- nvme_notify_async_consumers(ctrlr, &aer->cpl, aer->log_page_id,
- NULL, 0);
+ nvme_notify_async(ctrlr, &aer->cpl, aer->log_page_id, NULL, 0);
nvme_ctrlr_construct_and_submit_aer(ctrlr, aer);
goto out;
}
@@ -1180,8 +1179,8 @@ nvme_ctrlr_aer_task(void *arg, int pending)
* error, don't pass log page data to the consumers. In
* practice, this case should never happen.
*/
- nvme_notify_async_consumers(aer->ctrlr, &aer->cpl,
- aer->log_page_id, NULL, 0);
+ nvme_notify_async(aer->ctrlr, &aer->cpl, aer->log_page_id,
+ NULL, 0);
goto out;
}
@@ -1261,8 +1260,8 @@ nvme_ctrlr_aer_task(void *arg, int pending)
* Pass the cpl data from the original async event completion, not the
* log page fetch.
*/
- nvme_notify_async_consumers(aer->ctrlr, &aer->cpl,
- aer->log_page_id, aer->log_page_buffer, aer->log_page_size);
+ nvme_notify_async(aer->ctrlr, &aer->cpl, aer->log_page_id,
+ aer->log_page_buffer, aer->log_page_size);
/*
* Repost another asynchronous event request to replace the one
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index cd0ef444150f..27d70d120307 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -556,10 +556,10 @@ nvme_allocate_request_ccb(union ccb *ccb, const int how, nvme_cb_fn_t cb_fn,
#define nvme_free_request(req) free(req, M_NVME)
-void nvme_notify_async_consumers(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_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_ctrlr_shared_handler(void *arg);