From 720e7bb69c26b445287b7dd12d2f1e709b227953 Mon Sep 17 00:00:00 2001
From: John Baldwin <jhb@FreeBSD.org>
Date: Tue, 16 May 2017 23:18:50 +0000
Subject: [PATCH] Add support for child devices that aren't ports.

Invoke any identify routines of child drivers during attach before attaching
children, and delete any remaining devices after deleting ports.

MFC after:	1 month
Sponsored by:	Chelsio Communications
---
 sys/dev/cxgbe/t4_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 9b5e4ff09a11..cbc8e8c6a27f 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -1186,6 +1186,12 @@ t4_attach(device_t dev)
 		goto done;
 	}
 
+	rc = bus_generic_probe(dev);
+	if (rc != 0) {
+		device_printf(dev, "failed to probe child drivers: %d\n", rc);
+		goto done;
+	}
+
 	rc = bus_generic_attach(dev);
 	if (rc != 0) {
 		device_printf(dev,
@@ -1339,6 +1345,8 @@ t4_detach_common(device_t dev)
 		}
 	}
 
+	device_delete_children(dev);
+
 	if (sc->flags & FULL_INIT_DONE)
 		adapter_full_uninit(sc);