From nobody Sat Dec 10 19:22:15 2022 X-Original-To: freebsd-usb@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NTyYN459Pz4kFxs for ; Sat, 10 Dec 2022 19:26:16 +0000 (UTC) (envelope-from fernando.apesteguia@gmail.com) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NTyYM6TC7z3jB8 for ; Sat, 10 Dec 2022 19:26:15 +0000 (UTC) (envelope-from fernando.apesteguia@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lf1-f43.google.com with SMTP id x28so12155290lfn.6 for ; Sat, 10 Dec 2022 11:26:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y3eGNiAdju0SDojw57DniIBIegV3qjUz+hSK2SfybNA=; b=NRxsuWifvT9oKjTAU9OsuCPGqY4nR2LOgJo4ObBxnep07Kn3GTuwidC9AU5uv9aobp 9MYKgiBoLcvKsZK+1AxJeB+NTsjvQ3FCGjBYWOWOYp+ybAzbU5aNeTrt8W9FdawFCNvG BW93LIGedQ3S86SGJrDksy1kapL59N6NQTzfkKHKfsT6ZaOd8EReJUhsZbTgIKwKDQ9L KgNW8tlFl4miJ6HOUf+5ZLgpQNsubenX+YlEtC56pedE4nP+KEBIwnKuROR450z4wNnJ 7B3hUeJE56C9JletaQXW0SqWpIXHqIGVfnAnizVJ7TXOA0CLKan2qBpYlJNEEdiBXAmz KkNQ== X-Gm-Message-State: ANoB5pm57Cfg6dm8ur7CMRmGxC/7wVtLYYVKaa719k4Jgnbo6rA1do2S 7XTXg+O7zdyoO6tzZHGwJ7xmRDB6e1Pydg== X-Google-Smtp-Source: AA0mqf5sH1nbPzmbW9GnXuPKtNebnRjijLbMgTeqOJw5xficyZpvm3NRSR1cHfaToWafCBgWT5/wFQ== X-Received: by 2002:a05:6512:90c:b0:4b5:2cf4:cc1d with SMTP id e12-20020a056512090c00b004b52cf4cc1dmr2263818lft.68.1670700373554; Sat, 10 Dec 2022 11:26:13 -0800 (PST) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id s14-20020a056512202e00b004b5284a92f9sm830652lfs.208.2022.12.10.11.26.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Dec 2022 11:26:12 -0800 (PST) Received: by mail-lj1-f177.google.com with SMTP id f20so8429608lja.4 for ; Sat, 10 Dec 2022 11:26:12 -0800 (PST) X-Received: by 2002:a2e:b5a1:0:b0:27a:4173:8abc with SMTP id f1-20020a2eb5a1000000b0027a41738abcmr76675ljn.224.1670700372138; Sat, 10 Dec 2022 11:26:12 -0800 (PST) List-Id: FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-usb List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org MIME-Version: 1.0 References: <75ddc208-5bf1-7c9c-4d57-057a2058cc26@selasky.org> In-Reply-To: From: =?UTF-8?Q?Fernando_Apestegu=C3=ADa?= Date: Sat, 10 Dec 2022 20:22:15 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: autoloading module when matching device To: Warner Losh Cc: freebsd-usb@freebsd.org, Hans Petter Selasky Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4NTyYM6TC7z3jB8 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Sat, Dec 10, 2022 at 6:32 AM Warner Losh wrote: > > > > On Fri, Dec 9, 2022 at 12:50 PM Fernando Apestegu=C3=ADa 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: on usbus3 kbd2 at ukbd0 nvidia0: on vgapci0 vgapci0: child nvidia0 requested pci_enable_io vgapci0: child nvidia0 requested pci_enable_io ums0 on uhub4 ums0: 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: on usbus3 kbd2 at ukbd0 uhid0 on uhub4 uhid0: on usbus3 uhid1 on uhub4 uhid1: 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 >> Date: Fri, Dec 9, 2022 at 8:34 PM >> Subject: Re: autoloading module when matching device >> To: Fernando Apestegu=C3=ADa , developers >> >> >> >> 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 >>