Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
From: "Tod E. Kurt" <tod@todbot.com>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: "open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	Linux USB Mailing List <linux-usb@vger.kernel.org>
Subject: Re: Linux "hid_led" vs "hidraw" USB HID question 
Date: Sun, 10 Nov 2019 15:07:22 -0800
Message-ID: <B63E1B37-D7A3-4A71-A3F1-73C5952B2653@todbot.com> (raw)
In-Reply-To: <ab4e0840-72ee-4e65-db17-083c187b03ec@gmail.com>

Hi Heiner,

Yes, that was what I was starting from. I was hoping there was now an in-situ way of replacing kernel modules without a full kernel recompile.

I have tried this patch on Raspian 4.19.81 and Ubuntu 19 kernel 5.0.0-32 with no config changes.  I believe it solves the main issue.  However, I'm seeing another problem that I can't explain.

Specifically:
- On reboot, device shows up in /sys/class/hidraw/
- Opening with hidapi and (mis)using hidapi functions works, but,
- Device is then removed from /sys/class/hidraw/

Under what circumstances can a device be removed from /sys/class/hidraw? 

If you'd like to trigger this yourself, run "blink1-tool --list" and see the blink(1) disappear. And yet "blink1-tool" can subsequently still communicate with the blink(1). Which I don't quite understand yet either.

Cheers,
-=Tod

> On Nov 10, 2019, at 9:25 a, Heiner Kallweit <hkallweit1@gmail.com> wrote:
> 
> On 10.11.2019 17:59, Tod E. Kurt wrote:
>> Hi Heiner, (and others on the list)
>> 
>> Thanks for your quick and detailed response. 
>> 
>> I am endeavoring to try the patch out now.  But I've not built a desktop Linux kernel or kernel modules in about 15 years.  Do you have a preferred recipe for applying this patch to an existing distro?  Since 'hid-quirks' isn't a module, this means recompiling the entire HID driver, correct?  I mostly test against various modern Ubuntu or Raspian flavors of Debian, if that matters.
>> 
> See e.g. here: https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
> 
>> Also, is there a mitigation for users running production distros that doesn't involve a recompile? 
>> 
> I don't think so (at least from kernel perspective). What you could do is adding an integration with
> the /sys/class/led interface in your library (if it should be suitable for your use cases) and
> auto-detect which interface to use.
> 
>> Thanks,
>> -=Tod
>> 
> Heiner
> 
>>> On Nov 10, 2019, at 2:44 a, Heiner Kallweit <hkallweit1@gmail.com> wrote:
>>> 
>>> On 10.11.2019 04:26, Tod E. Kurt wrote:
>>>> HiI
>>>> 
>>> Hi Tod,
>>> 
>>>> Since you are listed as author of "hid-led.c": 
>>>>  https://github.com/torvalds/linux/blob/master/drivers/hid/hid-led.c, 
>>>> I was wondering if you could offer some insight on an issue I'm seeing.
>>>> I'm a maintainer of "hidapi" and "node-hid", cross-platform C and NodeJs libraries for accessing HID devices, and I'm the creator of the ThingM blink(1) USB LED that "hid-led" controls.
>>>> 
>>>> On the distros I've seen (Ubuntu, Raspian) where "hid-led" is enabled, when inserting a blink(1) device, the "hid-led" driver appears to grab the device and remove it from available "hidraw" devices.  This makes generic hidraw-based systems (like "hidapi" and the upcoming Chrome WebHID) unable to see the blink(1)
>>>> 
>>>> I have tried blacklisting the "hid-led" module but the problem persist. Ffrom dmesg and lsmod the module does appear to not be loaded on reboot.
>>>> 
>>>> Any insights on what's going on?  Any tips on how to debug this or how to prevent this from occurring?
>>>> 
>>> When hid-led was written it was needed to add the LED devices to hid_have_special_driver list.
>>> Else the driver can't take control over the device. Side effect is that even if hid-led
>>> isn't loaded hid-generic can't take control.
>>> I think since e04a0442d33b ("HID: core: remove the absolute need of hid_have_special_driver[]")
>>> it's no longer needed to have the LED devices in hid_have_special_driver.
>>> Could you please test the following patch? If hid-led is loaded is should control the
>>> device, if it's blacklisted hid-generic should have the control.
>>> 
>>> 
>>> diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
>>> index c50bcd967..bdaab79f7 100644
>>> --- a/drivers/hid/hid-quirks.c
>>> +++ b/drivers/hid/hid-quirks.c
>>> @@ -419,13 +419,6 @@ static const struct hid_device_id hid_have_special_driver[] = {
>>> #if IS_ENABLED(CONFIG_HID_LCPOWER)
>>> 	{ HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000) },
>>> #endif
>>> -#if IS_ENABLED(CONFIG_HID_LED)
>>> -	{ HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) },
>>> -	{ HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) },
>>> -	{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_LUXAFOR) },
>>> -	{ HID_USB_DEVICE(USB_VENDOR_ID_RISO_KAGAKU, USB_DEVICE_ID_RI_KA_WEBMAIL) },
>>> -	{ HID_USB_DEVICE(USB_VENDOR_ID_THINGM, USB_DEVICE_ID_BLINK1) },
>>> -#endif
>>> #if IS_ENABLED(CONFIG_HID_LENOVO)
>>> 	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) },
>>> 	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) },
>>> -- 
>>> 2.24.0
>>> 
>>>> I can send you blink(1) devices and "hidapi" test programs if you'd like to try to replicate this.
>>>> 
>>> Thanks for the offer, I've got a blink(1) already. Just tested the patch with this device
>>> and it worked properly like described above.
>>> 
>>>> Thanks!
>>>> -=Tod
>>> 
>>> Heiner
>> 
>> 
> 


  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6A37A3D7-96A6-49A4-83E5-ABE5DB417E8B@todbot.com>
2019-11-10 10:44 ` Heiner Kallweit
2019-11-10 16:59   ` Tod E. Kurt
2019-11-10 17:25     ` Heiner Kallweit
2019-11-10 23:07       ` Tod E. Kurt [this message]
2019-11-11 21:31         ` Heiner Kallweit

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B63E1B37-D7A3-4A71-A3F1-73C5952B2653@todbot.com \
    --to=tod@todbot.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git