Page MenuHomeFreeBSD

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

Authored by saper_saper.info on Aug 20 2025, 5:04 PM.
Tags
None
Referenced Files
F146970523: D52050.id160687.diff
Sat, Mar 7, 6:20 AM
Unknown Object (File)
Tue, Mar 3, 6:14 PM
Unknown Object (File)
Tue, Mar 3, 2:27 PM
Unknown Object (File)
Tue, Mar 3, 12:52 AM
Unknown Object (File)
Fri, Feb 27, 10:14 PM
Unknown Object (File)
Wed, Feb 11, 1:56 AM
Unknown Object (File)
Wed, Feb 11, 1:56 AM
Unknown Object (File)
Sun, Feb 8, 8:45 AM

Details

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 Not Applicable
Unit
Tests Not Applicable

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–5976

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–5976

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.Jan 28 2026, 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?

Ping, is "Marcin Cieslak <saper@saper.info>" the right author attribution?

Yes, I can provide you with a signed commit if this is needed.

This revision was not accepted when it landed; it landed in state Needs Review.Wed, Feb 25, 2:21 AM
This revision was automatically updated to reflect the committed changes.