In some configurations it is necessary to manually load a driver to make other devices visible, which then in turn can be detected by devmatch. For example (amd64 stable/13-n244484-154207a59bd VM under Virtualbox, MINIMAL kernel plus kld_list="virtio_pci snd_ich aesni fusefs"): Enter full pathname of shell or RETURN for /bin/sh: root@ / # service devmatch start Autoloading module: intpm.ko intsmb0: <Intel PIIX4 SMBUS Interface> irq 23 at device 7.0 on pci0 intsmb0: intr IRQ 9 enabled revision 0 smbus0: <System Management Bus> on intsmb0 root@ / # service kld start Loading kernel modules: virtio_pci0: <VirtIO PCI (legacy) Network adapter> port 0xd020-0xd03f irq 19 at device 3.0 on pci0 virtio_pci1: <VirtIO PCI (legacy) Network adapter> port 0xd240-0xd25f irq 16 at device 8.0 on pci0 pcm0: <Intel ICH (82801AA)> port 0xd100-0xd1ff,0xd200-0xd23f irq 21 at device 5.0 on pci0 pcm0: <SigmaTel STAC9700/83/84 AC97 Codec> cryptosoft0: <software crypto> aesni0: <AES-CBC,AES-CCM,AES-GCM,AES-ICM,AES-XTS> root@ / # service devmatch start Autoloading module: if_vtnet.ko vtnet0: <VirtIO Networking Adapter> on virtio_pci0 vtnet0: Ethernet address: 08:00:27:6a:04:1c vtnet1: <VirtIO Networking Adapter> on virtio_pci1 vtnet1: Ethernet address: 08:00:27:6a:59:37 root@ / # When devmatch is run before kld, it won't detect virtio_pci and therefore no if_vtnet devices as well. Only if we load virtio_pci through kld, if_vtnet becomes detectable for devmatch. So we need to ensure that kld is run before devmatch.
Created attachment 222200 [details] proposed patch kld quite obviously requires kldxref, so shortcut to just kld
Warner, can you take a look at this?
devd should be running the newly visible devices through devmatch after things load. The fact that's not happening is the bug, not the order of the devmatch script in rc. This suggests the real bug is in virtio_pci doesn't generage NOMATCH events that devd will use to drive devmatch to load drivers for them. We need to see why that isn't happening.
I've thought about this some more. And I think the patch is good. The problem isn't normal boot, but instead when we are booting in a maybe cross-built system.
I'm honestly still a little worried for possible NOMATCH events not being generated for some reason, but I this won't hurt and it could help some configurations.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f68e3ea831b76a8927eed7f7abfea55ee5a193c4 commit f68e3ea831b76a8927eed7f7abfea55ee5a193c4 Author: Helge Oldach <freebsd@oldach.net> AuthorDate: 2021-07-07 20:43:35 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-07-07 20:48:40 +0000 devmatch: defer until after kld devmatch loads a number of things automatically. Allow the list of things to load to happen first in case those drivers affect what would be loaded. Normally, this will produce the same results, but there's some special cases that may not when drivers are loaded that report other drivers missing, like virtio_pci. PR: 253287 Reviewed by: imp MFC After: 2 weeks libexec/rc/rc.d/devmatch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=bd14c0c6cdaf14fdebdf517bf161d60b3b43fa21 commit bd14c0c6cdaf14fdebdf517bf161d60b3b43fa21 Author: Helge Oldach <freebsd@oldach.net> AuthorDate: 2021-07-07 20:43:35 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-07-16 17:45:11 +0000 devmatch: defer until after kld devmatch loads a number of things automatically. Allow the list of things to load to happen first in case those drivers affect what would be loaded. Normally, this will produce the same results, but there's some special cases that may not when drivers are loaded that report other drivers missing, like virtio_pci. PR: 253287 Reviewed by: imp MFC After: 2 weeks libexec/rc/rc.d/devmatch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1466c6253e559ae615446c3f0b27ef9d0ada4209 commit 1466c6253e559ae615446c3f0b27ef9d0ada4209 Author: Helge Oldach <freebsd@oldach.net> AuthorDate: 2021-07-07 20:43:35 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-07-16 18:28:43 +0000 devmatch: defer until after kld devmatch loads a number of things automatically. Allow the list of things to load to happen first in case those drivers affect what would be loaded. Normally, this will produce the same results, but there's some special cases that may not when drivers are loaded that report other drivers missing, like virtio_pci. PR: 253287 Reviewed by: imp MFC After: 2 weeks (cherry picked from commit f68e3ea831b76a8927eed7f7abfea55ee5a193c4) libexec/rc/rc.d/devmatch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)