linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Benjamin Tissoires <bentiss@kernel.org>
Cc: "Filipe Laíns" <lains@riseup.net>,
	"Bastien Nocera" <hadess@hadess.net>,
	"Jiri Kosina" <jikos@kernel.org>,
	"Benjamin Tissoires" <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH v2 00/14] HID: logitech-hidpp: Avoid hidpp_connect_event() running while probe() restarts IO
Date: Tue, 10 Oct 2023 11:40:03 +0200	[thread overview]
Message-ID: <73344c94-a36a-258e-4225-061da8e8e06b@redhat.com> (raw)
In-Reply-To: <hjcpffahcxfqxfzyd7as2v75wpqbta2arj7dy3d2xwg7pz7q4g@4lv2dry2gcp7>

Hi,

On 10/10/23 11:36, Benjamin Tissoires wrote:
> On Oct 09 2023, Hans de Goede wrote:

<snip>

>>> However, the thing I am afraid is that commit 498ba2069035 ("HID:
>>> logitech-hidpp: Don't restart communication if not necessary") was
>>> fixing devices that did not like the hid_hw_stop/start. I can't find the
>>> bug numbers however... So with your series, we might breaking those
>>> once again.
>>>
>>> How about we do the following (in pseudo code):
>>> probe():
>>>   hidpp_connect_and_start(connect_mask = 0)
>>>   // retrieve name and serial
>>>   hid_connect(connect_mask) // with connect_mask ensuring we don't
>>>                             // create inputs if HIDPP_QUIRK_DELAYED_INIT
>>>                             // is set, instead of stop/start
>>>   hid_hw_close(hdev); // to balance hidpp_connect_and_start()
>>>
>>> I think the above should even remove the need for the
>>> enable_connect_event atomic_t given that now we are not restarting the
>>> devices at all.
>>
>> Interesting yes that looks good, any idea why this was not done
>> in commit 91cf9a98ae41 ("HID: logitech-hidpp: make .probe usbhid capable")
>> right away ?
> 
> I tried to do a little bit of digging. Initially I thought that's
> because I was always doing that stop/start dance, and so I continued
> with that.
> 
> But looking slightly more carefully, I think I understand why:
> - calling twice hid_connect should fail, because it'll create twice the
>   sysfs nodes for the HID device itself
> - so we need to call hid_disconnect() first
> - this was done through hid_hw_stop() and given that the dj driver has
>   empty stubs for start/stop, this was semantically the same.
> 
> So using hid_hw_stop/start was a shortcut because DJ had empty stubs.
> But when I enabled direct use of hidpp from other transport layers, I
> did not realized that there was this glitch.
> 
> And then I completely forgot to clean up that because "at the end of a
> HID driver we are supposed to call hid_hw_start()".
> 
>>
>> Let me rework the series to use that tomorrow. This will probably also
>> allow dropping a bunch of the patches.
> 
> Yeah, I think we should be able to remove the sync mechanism.
> And be careful to call hid_disconnect() before
> hid_connect(connect_mask), or you'll probably have errors if not when
> plugging the device, but when unplugging it for sure.

Note that hid_hw_start() never calls hid_connect() when called with
a connect_mask of 0, so just simply calling hid_connect() later should
be fine without needing to do a hid_disconnect() before:

int hid_hw_start(struct hid_device *hdev, unsigned int connect_mask)
{
        int error;

        error = hdev->ll_driver->start(hdev);
        if (error)
                return error;

        if (connect_mask) {
                error = hid_connect(hdev, connect_mask);
                if (error) {
                        hdev->ll_driver->stop(hdev);
                        return error;
                }
        }

        return 0;
}
EXPORT_SYMBOL_GPL(hid_hw_start);

Regards,

Hans



      reply	other threads:[~2023-10-10  9:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-08  9:54 [PATCH v2 00/14] HID: logitech-hidpp: Avoid hidpp_connect_event() running while probe() restarts IO Hans de Goede
2023-10-08  9:54 ` [PATCH v2 01/14] HID: logitech-hidpp: Revert "Don't restart communication if not necessary" Hans de Goede
2023-10-08  9:54 ` [PATCH v2 02/14] HID: logitech-hidpp: Move hidpp_overwrite_name() to before connect check Hans de Goede
2023-10-08  9:54 ` [PATCH v2 03/14] HID: logitech-hidpp: Add hidpp_non_unifying_init() helper Hans de Goede
2023-10-08  9:54 ` [PATCH v2 04/14] HID: logitech-hidpp: Remove connected check for non-unifying devices Hans de Goede
2023-10-08  9:54 ` [PATCH v2 05/14] HID: logitech-hidpp: Move get_wireless_feature_index() check to hidpp_connect_event() Hans de Goede
2023-10-08  9:54 ` [PATCH v2 06/14] HID: logitech-hidpp: Remove wtp_get_config() call from probe() Hans de Goede
2023-10-08  9:54 ` [PATCH v2 07/14] HID: logitech-hidpp: Remove connected check for g920_get_config() call Hans de Goede
2023-10-08  9:54 ` [PATCH v2 08/14] HID: logitech-hidpp: Add a hidpp_connect_and_start() helper Hans de Goede
2023-10-08  9:54 ` [PATCH v2 09/14] HID: logitech-hidpp: Move the connected check to after restarting IO Hans de Goede
2023-10-08  9:54 ` [PATCH v2 10/14] HID: logitech-hidpp: Move g920_get_config() to just before hidpp_ff_init() Hans de Goede
2023-10-08  9:54 ` [PATCH v2 11/14] HID: logitech-hidpp: Remove unused connected param from *_connect() Hans de Goede
2023-10-08  9:54 ` [PATCH v2 12/14] HID: logitech-hidpp: Fix connect event race Hans de Goede
2023-10-08  9:54 ` [PATCH v2 13/14] HID: logitech-hidpp: Avoid hidpp_connect_event() running while probe() restarts IO Hans de Goede
2023-10-08  9:54 ` [PATCH v2 14/14] HID: logitech-hidpp: Drop delayed_work_cb() Hans de Goede
2023-10-08 10:30 ` [PATCH v2 00/14] HID: logitech-hidpp: Avoid hidpp_connect_event() running while probe() restarts IO Hans de Goede
2023-10-09  8:13   ` Benjamin Tissoires
2023-10-09 15:00     ` Hans de Goede
2023-10-10  9:36       ` Benjamin Tissoires
2023-10-10  9:40         ` Hans de Goede [this message]

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=73344c94-a36a-258e-4225-061da8e8e06b@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=bentiss@kernel.org \
    --cc=hadess@hadess.net \
    --cc=jikos@kernel.org \
    --cc=lains@riseup.net \
    --cc=linux-input@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
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).