Page MenuHomeFreeBSD

'devctl clear driver' shall not fail if no driver has been found
Needs ReviewPublic

Authored by saper_saper.info on Aug 20 2025, 5:04 PM.
Tags
None
Referenced Files
F144211821: D52050.id.diff
Fri, Feb 6, 1:31 PM
Unknown Object (File)
Mon, Feb 2, 12:14 PM
Unknown Object (File)
Sat, Jan 31, 7:48 AM
Unknown Object (File)
Thu, Jan 29, 1:17 PM
Unknown Object (File)
Thu, Jan 29, 9:43 AM
Unknown Object (File)
Wed, Jan 21, 8:11 AM
Unknown Object (File)
Mon, Jan 12, 5:45 PM
Unknown Object (File)
Dec 12 2025, 5:40 AM

Details

Reviewers
jhb
imp
Group Reviewers
bhyve
Summary

Detaching bhyve(4) ppt driver from the unsupported PCI device shall
not cause "Device not configured" error. We do not expect
that a new driver must take the device over in this case.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 70195
Build 67078: arc lint + arc unit

Event Timeline

I was really confused by the wifibox messages like this

2025-08-04T11:35:14+0200 WARN  PPT device pci2:0:0 could not be destroyed
2025-08-04T11:35:20+0200 WARN  PPT device pci2:0:0 could not be destroyed
2025-08-04T11:35:27+0200 WARN  PPT device pci2:0:0 could not be destroyed
2025-08-04T11:35:34+0200 WARN  PPT device pci2:0:0 could not be destroyed
2025-08-04T11:35:40+0200 WARN  PPT device pci2:0:0 could not be destroyed
2025-08-04T11:35:47+0200 WARN  PPT device pci2:0:0 could not be destroyed
2025-08-04T11:35:54+0200 WARN  PPT device pci2:0:0 could not be destroyed
2025-08-04T11:36:00+0200 WARN  PPT device pci2:0:0 could not be destroyed

https://lists.freebsd.org/archives/freebsd-current/2025-August/008456.html

imp added inline comments.
sys/kern/subr_bus.c
5964–5975

yea, device_probe() is weird. It returns -1 in two cases, only one of which is relevant here (the DS_ALIVE one). I guess neither could happen getting here though, assuming that device_detach does the right thing.

This revision is now accepted and ready to land.Aug 20 2025, 5:48 PM

Silence ENXIO from device_probe()

device_probe() will return ENXIO when no driver could be found.

This revision now requires review to proceed.Aug 20 2025, 6:47 PM

As it turns out, we get ENXIO from device_probe() when no driver has been found.

With this change wifibox does not report any error anymore and it can be stopped and started multiple times.

I wonder how to test this with some other device, or whether devmatch works/does not work with this

jhb added inline comments.
lib/libdevctl/devctl.3
381

This I think already covers the behavior you are fixing as it says the error is only if attach fails, not if probe doesn't find a driver, so I would probably leave off the manpage update.

sys/kern/subr_bus.c
5964–5975

I think this needs a comment, something like:

devclass_delete_device(...);

/*
  * 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);
This revision is now accepted and ready to land.Aug 21 2025, 4:42 PM

Added the comment code, updated the function description in the manpage
instead of an error code.

This revision now requires review to proceed.Wed, Jan 28, 8:45 PM
saper_saper.info added inline comments.
lib/libdevctl/devctl.3
381

you are right, I have moved it to the function description instead. The reason I'd like to update it is that I was trying to deduct if that behaviour is correct from the manpage, but I wasn't sure.

saper_saper.info marked an inline comment as done.

Whitespace fix

This looks good to me modulo one style nit I can fix while merging. Is "Marcin Cieslak <saper@saper.info>" the right way to credit you as the author of the commit?