Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Dec 2022 20:22:15 +0100
From:      =?UTF-8?Q?Fernando_Apestegu=C3=ADa?= <fernape@freebsd.org>
To:        Warner Losh <imp@bsdimp.com>
Cc:        freebsd-usb@freebsd.org, Hans Petter Selasky <hps@selasky.org>
Subject:   Re: autoloading module when matching device
Message-ID:  <CAGwOe2YSSrdsUgm-XUwU9-Gey%2BPpeG9q9A0h7EBXPcUKz_dvfQ@mail.gmail.com>
In-Reply-To: <CANCZdfoOrUr3usmHSwXhJ0CpPQZEct2nUguCVzKV_0ut6PYiqw@mail.gmail.com>
References:  <CAGwOe2bYAFW-Dwy34g6QuB1JEJjMqgoA-gsJByBqTjHLgFczNA@mail.gmail.com> <75ddc208-5bf1-7c9c-4d57-057a2058cc26@selasky.org> <CAGwOe2bA6kYs3dDR7y-3M5xooswLz_vbqe%2BzcyKjiSd6Et1bkA@mail.gmail.com> <CANCZdfoOrUr3usmHSwXhJ0CpPQZEct2nUguCVzKV_0ut6PYiqw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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=C3=ADa <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 loa=
ded
> 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=3D0

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=3D3 hubaddr=3D1 port=3D2 devaddr=3D2
interface=3D2 ugen=3Dugen3.2 vendor=3D0x1357 product=3D0x1001 devclass=3D0x=
00
devsubclass=3D0x00 devproto=3D0x00
sernum=3D"" release=3D0x0100 mode=3Dhost intclass=3D0x03 intsubclass=3D0x00
intprotocol=3D0x00 on uhub4'
Pushing table
setting *=3D+uhid0 at bus=3D3 hubaddr=3D1 port=3D2 devaddr=3D2 interface=3D=
2
ugen=3Dugen3.2 vendor=3D0x1357 product=3D0x1001 devclass=3D0x00
devsubclass=3D0x00 devproto=3D0x00 sernum=3D"
" release=3D0x0100 mode=3Dhost intclass=3D0x03 intsubclass=3D0x00
intprotocol=3D0x00 on uhub4
setting _=3Duhid0 at bus=3D3 hubaddr=3D1 port=3D2 devaddr=3D2 interface=3D2
ugen=3Dugen3.2 vendor=3D0x1357 product=3D0x1001 devclass=3D0x00
devsubclass=3D0x00 devproto=3D0x00 sernum=3D""
 release=3D0x0100 mode=3Dhost intclass=3D0x03 intsubclass=3D0x00
intprotocol=3D0x00 on uhub4
setting timestamp=3D1670691286.796388
setting device-name=3Duhid0
setting bus=3D3
setting hubaddr=3D1
setting port=3D2
setting devaddr=3D2
setting interface=3D2
setting ugen=3Dugen3.2
setting vendor=3D0x1357
setting product=3D0x1001
setting devclass=3D0x00
setting devsubclass=3D0x00
setting devproto=3D0x00
setting sernum=3D
setting release=3D0x0100
setting mode=3Dhost
setting intclass=3D0x03
setting intsubclass=3D0x00
setting intprotocol=3D0x00
setting bus=3Duhub4
Processing attach event
Testing device-name=3Duhid0 against ^ed50$, invert=3D0
Testing device-name=3Duhid0 against ^ubt[0-9]+$, invert=3D0
Testing device-name=3Duhid0 against ^ukbd0$, invert=3D0
Testing device-name=3Duhid0 against
^(ath|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rtw|rtwn|rum|ru=
n|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+$,
invert=3D
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=3D3 hubaddr=3D1 port=3D2 devaddr=3D2
interface=3D2 ugen=3Dugen3.2 vendor=3D0x1357 product=3D0x1001 devclass=3D0x=
00
devsubclass=3D0x00 devproto=3D0x00 sernum=3D"" release=3D0x0100 mode=3Dhost
intclass=3D0x03 intsubclass=3D0x00 intprotocol=3D0x00 on uhub4'
Pushing table
setting *=3D+uhid1 at bus=3D3 hubaddr=3D1 port=3D2 devaddr=3D2 interface=3D=
2
ugen=3Dugen3.2 vendor=3D0x1357 product=3D0x1001 devclass=3D0x00
devsubclass=3D0x00 devproto=3D0x00 sernum=3D"" release=3D0x0100 mode=3Dhost
intclass=3D0x03 intsubclass=3D0x00 intprotocol=3D0x00 on uhub4
setting _=3Duhid1 at bus=3D3 hubaddr=3D1 port=3D2 devaddr=3D2 interface=3D2
ugen=3Dugen3.2 vendor=3D0x1357 product=3D0x1001 devclass=3D0x00
devsubclass=3D0x00 devproto=3D0x00 sernum=3D"" release=3D0x0100 mode=3Dhost
intclass=3D0x03 intsubclass=3D0x00 intprotocol=3D0x00 on uhub4
setting timestamp=3D1670691805.346820
setting device-name=3Duhid1
setting bus=3D3
setting hubaddr=3D1
setting port=3D2
setting devaddr=3D2
setting interface=3D2
setting ugen=3Dugen3.2
setting vendor=3D0x1357
setting product=3D0x1001
setting devclass=3D0x00
setting devsubclass=3D0x00
setting devproto=3D0x00
setting sernum=3D
setting release=3D0x0100
setting mode=3Dhost
setting intclass=3D0x03
setting intsubclass=3D0x00
setting intprotocol=3D0x00
setting bus=3Duhub4
Processing attach event
Testing device-name=3Duhid1 against ^ed50$, invert=3D0
Testing device-name=3Duhid1 against ^ubt[0-9]+$, invert=3D0
Testing device-name=3Duhid1 against ^ukbd0$, invert=3D0
Testing device-name=3Duhid1 against
^(ath|bwi|bwn|ipw|iwlwifi|iwi|iwm|iwn|malo|mwl|otus|ral|rsu|rtw|rtwn|rum|ru=
n|uath|upgt|ural|urtw|wpi|wtap|zyd)[0-9]+$,
invert=3D0
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=3Dppx_yo_dt_b_asin_titl=
e_o00_s00?ie=3DUTF8&psc=3D1
>
> 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=C3=ADa <fernape@freebsd.org>, developers
>> <developers@freebsd.org>
>>
>>
>> On 12/9/22 19:57, Fernando Apestegu=C3=ADa 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
>>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGwOe2YSSrdsUgm-XUwU9-Gey%2BPpeG9q9A0h7EBXPcUKz_dvfQ>