The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=743fbb549b17c1288306cd3fffdf139137268f61

commit 743fbb549b17c1288306cd3fffdf139137268f61
Author:     Warner Losh <[email protected]>
AuthorDate: 2025-12-10 22:52:17 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2025-12-10 22:52:17 +0000

    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
---
 sys/dev/nvme/nvme.c       | 5 +++++
 sys/dev/nvme/nvme_ctrlr.c | 5 +++++
 2 files changed, 10 insertions(+)

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();
 }

Reply via email to