Re: autoloading module when matching device
- Reply: Hans Petter Selasky : "Re: autoloading module when matching device"
- In reply to: Warner Losh : "Re: autoloading module when matching device"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 10 Dec 2022 19:22:15 UTC
On Sat, Dec 10, 2022 at 6:32 AM Warner Losh <imp@bsdimp.com> wrote: > > > > On Fri, Dec 9, 2022 at 12:50 PM Fernando Apesteguía <fernape@freebsd.org> wrote: >> >> Forwarding from developers@ by indication of Hans, >> >> Maybe a devd(8) can do this? >> >> Just to be clear, the keyboard works nicely, but it would be better if >> it was detected during the hotplug :-) > > > Usually the USB devices that are keyboards autoload the right driver(s). > > So, sure, you could use a hack in devd to do this (it was how we did all > the matching before devmatch harvested the matches from the .ko files), > but maybe a better question is why aren't the driver(s) automatically loaded > when the NOMATCH event gets generated when the device is plugged in? OK, I did some digging. First some info. This[1] is the keyboard I'm using. It is one of those to be used with a media center. It is smaller than usual and it incorporates a touchpad. The media center (an old Zotac Nvidia Ion) is running FreeBSD 13.1 (FreeBSD zbox 13.1-RELEASE-p3 FreeBSD 13.1-RELEASE-p3 GENERIC amd64) If I force ums(4) in kld_list, this is what I get in dmesg after booting: ukbd0 on uhub4 ukbd0: <HL 0000 00 00 00-01 USB Device, class 0/0, rev 1.10/1.00, addr 2> on usbus3 kbd2 at ukbd0 nvidia0: <ION> on vgapci0 vgapci0: child nvidia0 requested pci_enable_io vgapci0: child nvidia0 requested pci_enable_io ums0 on uhub4 ums0: <HL 0000 00 00 00-01 USB Device, class 0/0, rev 1.10/1.00, addr 2> on usbus3 ums0: 5 buttons and [XYZT] coordinates ID=0 and both keyboard and touchpad work nicely. However if I remove ums(4) from kld_list, the keyboard works, but the touchpad doesn't. Now, if I boot with ums(4) loaded and then I stop devd(8) and restart it in debug mode after unplugging the usb dongle of the keyboard: service devd stop; sleep 5; (here I unplug the dongle); devd -d When I plug it in, this is what devd(8) says: Processing event '+uhid0 at bus=3 hubaddr=1 port=2 devaddr=2 interface=2 ugen=ugen3.2 vendor=0x1357 product=0x1001 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="" release=0x0100 mode=host intclass=0x03 intsubclass=0x00 intprotocol=0x00 on uhub4' Pushing table setting *=+uhid0 at bus=3 hubaddr=1 port=2 devaddr=2 interface=2 ugen=ugen3.2 vendor=0x1357 product=0x1001 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum=" " release=0x0100 mode=host intclass=0x03 intsubclass=0x00 intprotocol=0x00 on uhub4 setting _=uhid0 at bus=3 hubaddr=1 port=2 devaddr=2 interface=2 ugen=ugen3.2 vendor=0x1357 product=0x1001 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="" release=0x0100 mode=host intclass=0x03 intsubclass=0x00 intprotocol=0x00 on uhub4 setting timestamp=1670691286.796388 setting device-name=uhid0 setting bus=3 setting hubaddr=1 setting port=2 setting devaddr=2 setting interface=2 setting ugen=ugen3.2 setting vendor=0x1357 setting product=0x1001 setting devclass=0x00 setting devsubclass=0x00 setting devproto=0x00 setting sernum= setting release=0x0100 setting mode=host setting intclass=0x03 setting intsubclass=0x00 setting intprotocol=0x00 setting bus=uhub4 Processing attach event Testing device-name=uhid0 against ^ed50$, invert=0 Testing device-name=uhid0 against ^ubt[0-9]+$, invert=0 Testing device-name=uhid0 against ^ukbd0$, invert=0 Testing device-name=uhid0 against ^(ath|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rtw|rtwn|rum|run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+$, invert= 0 and both keyboard and touchpad work (remember the ums(4) is still loaded). However, if I do the same *and* unload ums(4): kldunload ums;sleep 5;(unplug dongle); devd -d The touchpad does not work when the dongle is plugged again. This is the output of devd(8) the second time: Processing event '+uhid1 at bus=3 hubaddr=1 port=2 devaddr=2 interface=2 ugen=ugen3.2 vendor=0x1357 product=0x1001 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="" release=0x0100 mode=host intclass=0x03 intsubclass=0x00 intprotocol=0x00 on uhub4' Pushing table setting *=+uhid1 at bus=3 hubaddr=1 port=2 devaddr=2 interface=2 ugen=ugen3.2 vendor=0x1357 product=0x1001 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="" release=0x0100 mode=host intclass=0x03 intsubclass=0x00 intprotocol=0x00 on uhub4 setting _=uhid1 at bus=3 hubaddr=1 port=2 devaddr=2 interface=2 ugen=ugen3.2 vendor=0x1357 product=0x1001 devclass=0x00 devsubclass=0x00 devproto=0x00 sernum="" release=0x0100 mode=host intclass=0x03 intsubclass=0x00 intprotocol=0x00 on uhub4 setting timestamp=1670691805.346820 setting device-name=uhid1 setting bus=3 setting hubaddr=1 setting port=2 setting devaddr=2 setting interface=2 setting ugen=ugen3.2 setting vendor=0x1357 setting product=0x1001 setting devclass=0x00 setting devsubclass=0x00 setting devproto=0x00 setting sernum= setting release=0x0100 setting mode=host setting intclass=0x03 setting intsubclass=0x00 setting intprotocol=0x00 setting bus=uhub4 Processing attach event Testing device-name=uhid1 against ^ed50$, invert=0 Testing device-name=uhid1 against ^ubt[0-9]+$, invert=0 Testing device-name=uhid1 against ^ukbd0$, invert=0 Testing device-name=uhid1 against ^(ath|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rtw|rtwn|rum|run|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+$, invert=0 Popping table and this is what dmesg says: ukbd0 on uhub4 ukbd0: <HL 0000 00 00 00-01 USB Device, class 0/0, rev 1.10/1.00, addr 2> on usbus3 kbd2 at ukbd0 uhid0 on uhub4 uhid0: <HL 0000 00 00 00-01 USB Device, class 0/0, rev 1.10/1.00, addr 2> on usbus3 uhid1 on uhub4 uhid1: <HL 0000 00 00 00-01 USB Device, class 0/0, rev 1.10/1.00, addr 2> on usbus3 If I try to load ums(4) now by hand, the driver is loaded, no messages are in dmesg and the touchpad still doesn't work. The only difference I see when I vimdiff both devd(8) outputs is that one uses "uhid0" and the other one "uhid1". The rest seems identical. Any ideas? [1] https://www.amazon.es/gp/product/B07X4ZWJT2/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1 > > Warner > >> >> Thanks! >> ---------- Forwarded message --------- >> From: Hans Petter Selasky <hps@selasky.org> >> Date: Fri, Dec 9, 2022 at 8:34 PM >> Subject: Re: autoloading module when matching device >> To: Fernando Apesteguía <fernape@freebsd.org>, developers >> <developers@freebsd.org> >> >> >> On 12/9/22 19:57, Fernando Apesteguía wrote: >> > Hi all, >> > >> > I have a new usb keyboard that uses the ums(4) driver. However I need >> > to add it to kld_list to preload it since the module is not autoloaded >> > when the keyboard is plugged in. The keyboard I want to replace is >> > properly detected when plugged in, though. I thought there would be >> > some place where I could add some device id and map it to ums(4), but >> > I can't find it. I've had a look at devmatch(8) but I can't find any >> > related config files. >> > >> > Where do I need to look? >> > >> > Thanks! >> >> Hi Fernando, >> >> There is no such quirk yet. There are only quirks via usbconfig to >> prevent attach of ums or ukbd. >> >> However, this is a perfect question for freebsd-usb@freebsd.org . Let's >> continue there! >> >> --HPS >>