linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Hutterer <peter.hutterer@redhat.com>
To: "Benjamin Tissoires" <btissoir@redhat.com>,
	"Filipe Laíns" <lains@archlinux.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	linux-input <linux-input@vger.kernel.org>,
	Nestor Lopez Casado <nlopezcasad@logitech.com>,
	Jiri Kosina <jikos@kernel.org>,
	Bastien Nocera <hadess@hadess.net>,
	Julien Hartmann <juli1.hartmann@gmail.com>
Subject: Re: Make the hid-logitech-dj driver remove the HID++ nodes when the device disconnects
Date: Fri, 7 Feb 2020 10:03:25 +1000	[thread overview]
Message-ID: <b867da88-991d-4a9b-7640-4a7994b7112a@redhat.com> (raw)
In-Reply-To: <CAO-hwJLKrY6vJ-95+A-w3BdGXLVQDsX73VkgqjGCFOztTVRa9w@mail.gmail.com>

On 7/2/20 3:01 am, Benjamin Tissoires wrote:
> On Thu, Feb 6, 2020 at 4:42 PM Filipe Laíns <lains@archlinux.org> wrote:
>>
>> On Thu, 2020-02-06 at 13:13 +0100, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 2/6/20 12:51 PM, Filipe Laíns wrote:
>>>> On Thu, 2020-02-06 at 12:30 +0100, Hans de Goede wrote:
>>>>> HI,
>>>>>
>>>>> On 2/6/20 12:14 PM, Filipe Laíns wrote:
>>>>>> Hello,
>>>>>>
>>>>>> Right now the hid-logitech-dj driver will export one node for each
>>>>>> connected device, even when the device is not connected. That causes
>>>>>> some trouble because in userspace we don't have have any way to know if
>>>>>> the device is connected or not, so when we try to communicate, if the
>>>>>> device is disconnected it will fail.
>>>>>
>>>>> I'm a bit reluctant to make significant changes to how the
>>>>> hid-logitech-dj driver works. We have seen a number of regressions
>>>>> when it was changed to handle the non unifying receivers and I would
>>>>> like to avoid more regressions.
>>>>>
>>>>> Some questions:
>>>>> 1. What is the specific use case where you are hitting this?
>>>>
>>>> For example, in libratbag we enumerate the devices and then probe them.
>>>> Currently if the device is not connected, the communication fails. To
>>>> get the device to show up we need to replug it, so it it triggers udev,
>>>> or restart the daemon.
>>>
>>> Thanks, that is exactly the sort of context to your suggested changes
>>> which I need.
>>>
>>>>> 2. Can't the userspace tools involved by modified to handle the errors
>>>>> they are getting gracefully?
>>>>
>>>> They can, but the approaches I see are not optimal:
>>>>     - Wait for HID events coming from the device, which could never
>>>> happen.
>>>>     - Poll the device until it wakes up.
>>>
>>> I guess we do get some (other or repeated?) event when the device does
>>> actually connect, otherwise your suggested changes would not be possible.
>>
>> No, I was thinking to just send the HID++ version identification
>> routine and see if the device replies.
> 
> Hmm, to continue on these questions:
> - yes, the current approach is to have the users of the HID++ device
> try to contact the device, get an error from the receiver, then keep
> the hidraw node open until we get something out of it, and then we can
> start talking to it
> - to your question Hans, when a device connects, it emits a HID++
> notification, which we should be relaying in the hidraw node. If not,
> well then starting to receive a key or abs event on the input node is
> a pretty good hint that the device connected.
> 
> So at any time, the kernel knows which devices are connected among
> those that are paired, so the kernel knows a lot more than user space.
> 
> The main problem Filipe is facing here is that we specifically
> designed libratbag to *not* keep the device nodes opened, and to not
> poll on the input events. The reason being... we do not want libratbag
> to be considered as a keylogger.

I'm wondering - can we really get around this long-term? Even if we have 
a separate HID++ node and/or udev change events and/or some other 
notification, in the end you still have some time T between that event 
and userspace opening the actual event node. Where the first key event 
wakes up the physical keyboard, you're now racing.

So the separate HID++ node works as long as libratbag *only* listens to 
that node, as soon as we need to start caring about a normal event it 
won't work any longer.

Cheers,
   Peter


  parent reply	other threads:[~2020-02-07  0:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 11:14 Make the hid-logitech-dj driver remove the HID++ nodes when the device disconnects Filipe Laíns
2020-02-06 11:30 ` Hans de Goede
2020-02-06 11:51   ` Filipe Laíns
2020-02-06 12:13     ` Hans de Goede
2020-02-06 15:42       ` Filipe Laíns
2020-02-06 17:01         ` Benjamin Tissoires
2020-02-06 17:45           ` Hans de Goede
2020-02-06 18:43             ` Filipe Laíns
2020-02-06 19:02               ` Hans de Goede
2020-02-06 19:43                 ` Filipe Laíns
2020-02-13 15:07                 ` Benjamin Tissoires
2020-02-13 15:52                   ` Hans de Goede
2020-02-07  0:03           ` Peter Hutterer [this message]
2020-02-07  0:36             ` Filipe Laíns
2020-02-13 15:12               ` Benjamin Tissoires
2020-02-13 15:24                 ` Filipe Laíns
2020-02-13 16:10                   ` Benjamin Tissoires

Reply instructions:

You may reply publicly 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=b867da88-991d-4a9b-7640-4a7994b7112a@redhat.com \
    --to=peter.hutterer@redhat.com \
    --cc=btissoir@redhat.com \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=jikos@kernel.org \
    --cc=juli1.hartmann@gmail.com \
    --cc=lains@archlinux.org \
    --cc=linux-input@vger.kernel.org \
    --cc=nlopezcasad@logitech.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).