Patch "HID: logitech-hidpp: Don't restart IO, instead defer hid_connect() only" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    HID: logitech-hidpp: Don't restart IO, instead defer hid_connect() only

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     hid-logitech-hidpp-don-t-restart-io-instead-defer-hi.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f24bbf0ca82813db0828949d2cce131afb1f305a
Author: Hans de Goede <hdegoede@xxxxxxxxxx>
Date:   Tue Oct 10 12:20:18 2023 +0200

    HID: logitech-hidpp: Don't restart IO, instead defer hid_connect() only
    
    [ Upstream commit 11ca0322a41920df2b462d2e45b0731e47ff475b ]
    
    Restarting IO causes 2 problems:
    
    1. Some devices do not like IO being restarted this was addressed in
       commit 498ba2069035 ("HID: logitech-hidpp: Don't restart communication
       if not necessary"), but that change has issues of its own and needs to
       be reverted.
    
    2. Restarting IO and specifically calling hid_device_io_stop() causes
       received packets to be missed, which may cause connect-events to
       get missed.
    
    Restarting IO was introduced in commit 91cf9a98ae41 ("HID: logitech-hidpp:
    make .probe usbhid capable") to allow to retrieve the device's name and
    serial number and store these in hdev->name and hdev->uniq before
    connecting any hid subdrivers (hid-input, hidraw) exporting this info
    to userspace.
    
    But this does not require restarting IO, this merely requires deferring
    calling hid_connect(). Calling hid_hw_start() with a connect-mask of
    0 makes it skip calling hid_connect(), so hidpp_probe() can simply call
    hid_connect() later without needing to restart IO.
    
    Remove the stop + restart of IO and instead just call hid_connect() later
    to avoid the issues caused by restarting IO.
    
    Now that IO is no longer stopped, hid_hw_close() must be called at the end
    of probe() to balance the hid_hw_open() done at the beginning probe().
    
    This series has been tested on the following devices:
    Logitech Bluetooth Laser Travel Mouse (bluetooth, HID++ 1.0)
    Logitech M720 Triathlon (bluetooth, HID++ 4.5)
    Logitech M720 Triathlon (unifying, HID++ 4.5)
    Logitech K400 Pro (unifying, HID++ 4.1)
    Logitech K270 (eQUAD nano Lite, HID++ 2.0)
    Logitech M185 (eQUAD nano Lite, HID++ 4.5)
    Logitech LX501 keyboard (27 Mhz, HID++ builtin scroll-wheel, HID++ 1.0)
    Logitech M-RAZ105 mouse (27 Mhz, HID++ extra mouse buttons, HID++ 1.0)
    
    And by bentiss:
    Logitech Touchpad T650 (unifying)
    Logitech Touchpad T651 (bluetooth)
    Logitech MX Master 3B (BLE)
    Logitech G403 (plain USB / Gaming receiver)
    
    Fixes: 498ba2069035 ("HID: logitech-hidpp: Don't restart communication if not necessary")
    Suggested-by: Benjamin Tissoires <bentiss@xxxxxxxxxx>
    Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231010102029.111003-2-hdegoede@xxxxxxxxxx
    Signed-off-by: Benjamin Tissoires <bentiss@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index e012d2d1a644f..5755b3e63c338 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -3869,8 +3869,10 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 			 hdev->name);
 
 	/*
-	 * Plain USB connections need to actually call start and open
-	 * on the transport driver to allow incoming data.
+	 * First call hid_hw_start(hdev, 0) to allow IO without connecting any
+	 * hid subdrivers (hid-input, hidraw). This allows retrieving the dev's
+	 * name and serial number and store these in hdev->name and hdev->uniq,
+	 * before the hid-input and hidraw drivers expose these to userspace.
 	 */
 	ret = hid_hw_start(hdev, will_restart ? 0 : connect_mask);
 	if (ret) {
@@ -3928,19 +3930,14 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	flush_work(&hidpp->work);
 
 	if (will_restart) {
-		/* Reset the HID node state */
-		hid_device_io_stop(hdev);
-		hid_hw_close(hdev);
-		hid_hw_stop(hdev);
-
 		if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT)
 			connect_mask &= ~HID_CONNECT_HIDINPUT;
 
 		/* Now export the actual inputs and hidraw nodes to the world */
-		ret = hid_hw_start(hdev, connect_mask);
+		ret = hid_connect(hdev, connect_mask);
 		if (ret) {
-			hid_err(hdev, "%s:hid_hw_start returned error\n", __func__);
-			goto hid_hw_start_fail;
+			hid_err(hdev, "%s:hid_connect returned error %d\n", __func__, ret);
+			goto hid_hw_init_fail;
 		}
 	}
 
@@ -3952,6 +3949,11 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 				 ret);
 	}
 
+	/*
+	 * This relies on logi_dj_ll_close() being a no-op so that DJ connection
+	 * events will still be received.
+	 */
+	hid_hw_close(hdev);
 	return ret;
 
 hid_hw_init_fail:



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux