aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2025-12-10 22:52:17 +0000
committerWarner Losh <imp@FreeBSD.org>2025-12-10 22:52:17 +0000
commit743fbb549b17c1288306cd3fffdf139137268f61 (patch)
tree4c194c9b701b313c4210b6fef4b3f2dd7f011c56
parente5c770dc7ff3fa71189addcafd30c333ff496de1 (diff)
nvme: Add child device for each controller
Step 1 in the move from registering consumers for NVMe drives to newbus nvme drives: Add a child device and attach them for each controller that we initialize. Detach them when we detach the main device. Sponsored by: Netflix Reviewed by: dab Differential Revision: https://reviews.freebsd.org/D51383
-rw-r--r--sys/dev/nvme/nvme.c5
-rw-r--r--sys/dev/nvme/nvme_ctrlr.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c
index d119f9877aaa..7788889ae591 100644
--- a/sys/dev/nvme/nvme.c
+++ b/sys/dev/nvme/nvme.c
@@ -104,9 +104,14 @@ int
nvme_detach(device_t dev)
{
struct nvme_controller *ctrlr = DEVICE2SOFTC(dev);
+ int error;
config_intrhook_drain(&ctrlr->config_hook);
+ error = bus_generic_detach(dev);
+ if (error)
+ return (error);
+
nvme_ctrlr_destruct(ctrlr, dev);
return (0);
}
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 3d8b26d2004c..50753f06c4e2 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1079,8 +1079,13 @@ nvme_ctrlr_start_config_hook(void *arg)
config_intrhook_disestablish(&ctrlr->config_hook);
if (!ctrlr->is_failed) {
+ 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);
}
TSEXIT();
}