aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Cieslak <saper@saper.info>2026-02-25 01:58:59 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2026-02-25 01:58:59 +0000
commitfba56be09f1c344cc5805b898fbfef6066950942 (patch)
tree1c9ea9c86aa2142fe3efb2f632660b24f40d3f03
parentef1218add1d3d2baca9d3b8bcfb57e05ef6fc503 (diff)
Do not fail 'devctl clear driver' if another driver is not found
Detaching the bhyve(4) ppt driver from an unsupported PCI device should not raise a "Device not configured" error. We do not expect that a new driver must take over the device in this case. Reviewed by: imp, jhb Differential Revision: https://reviews.freebsd.org/D52050
-rw-r--r--lib/libdevctl/devctl.33
-rw-r--r--sys/kern/subr_bus.c14
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/libdevctl/devctl.3 b/lib/libdevctl/devctl.3
index c8a4704825c2..94fe350e524b 100644
--- a/lib/libdevctl/devctl.3
+++ b/lib/libdevctl/devctl.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 4, 2019
+.Dd February 24, 2026
.Dt DEVCTL 3
.Os
.Sh NAME
@@ -193,6 +193,7 @@ is true,
the device will be detached from its current device driver.
After the device's name is reset,
it is reprobed and attached to a suitable device driver if one is found.
+If no suitable device driver is found, no error is reported.
.Pp
The
.Fn devctl_rescan
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index c9d64e3674c6..b5c1c5b61f60 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -5961,7 +5961,19 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
dev->flags &= ~DF_FIXEDCLASS;
dev->flags |= DF_WILDCARD;
devclass_delete_device(dev->devclass, dev);
- error = device_probe_and_attach(dev);
+
+ /*
+ * Don't use device_probe_and_attach so that failing
+ * to find a new driver isn't reported as an error.
+ */
+ error = device_probe(dev);
+ if (error == ENXIO) {
+ error = 0;
+ break;
+ }
+ if (error == 0) {
+ error = device_attach(dev);
+ }
break;
case DEV_RESCAN:
if (!device_is_attached(dev)) {