linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: logitech-hidpp: Stop IO before calling hid_connect()
@ 2023-10-25 19:01 Hans de Goede
  2023-10-26 10:04 ` Benjamin Tissoires
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2023-10-25 19:01 UTC (permalink / raw)
  To: Filipe Laíns, Bastien Nocera, Jiri Kosina,
	Benjamin Tissoires
  Cc: Hans de Goede, linux-input

hid_connect() will call hid_pidff_init() which does
hid_device_io_start() leading to an "io already started" warning.

To fix this call hid_device_io_stop() before calling hid_connect(),
stopping IO means that connect events may be lost while hid_connect()
runs, re-enable IO and move the hidpp_connect_event() work queuing
after the hid_connect().

Note re-enabling IO is also necessary for the g920_get_config()
call later during hidpp_probe().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/hid/hid-logitech-hidpp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index c1bc89560612..fd6d8f1d9b8f 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -4461,19 +4461,22 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	else
 		hidpp_non_unifying_init(hidpp);
 
-	schedule_work(&hidpp->work);
-	flush_work(&hidpp->work);
-
 	if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT)
 		connect_mask &= ~HID_CONNECT_HIDINPUT;
 
 	/* Now export the actual inputs and hidraw nodes to the world */
+	hid_device_io_stop(hdev);
 	ret = hid_connect(hdev, connect_mask);
 	if (ret) {
 		hid_err(hdev, "%s:hid_connect returned error %d\n", __func__, ret);
 		goto hid_hw_init_fail;
 	}
 
+	/* Check for connected devices now that incoming packets will not be disabled again */
+	hid_device_io_start(hdev);
+	schedule_work(&hidpp->work);
+	flush_work(&hidpp->work);
+
 	if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {
 		struct hidpp_ff_private_data data;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] HID: logitech-hidpp: Stop IO before calling hid_connect()
  2023-10-25 19:01 [PATCH] HID: logitech-hidpp: Stop IO before calling hid_connect() Hans de Goede
@ 2023-10-26 10:04 ` Benjamin Tissoires
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Tissoires @ 2023-10-26 10:04 UTC (permalink / raw)
  To: Filipe Laíns, Bastien Nocera, Jiri Kosina,
	Benjamin Tissoires, Hans de Goede
  Cc: linux-input

On Wed, 25 Oct 2023 21:01:51 +0200, Hans de Goede wrote:
> hid_connect() will call hid_pidff_init() which does
> hid_device_io_start() leading to an "io already started" warning.
> 
> To fix this call hid_device_io_stop() before calling hid_connect(),
> stopping IO means that connect events may be lost while hid_connect()
> runs, re-enable IO and move the hidpp_connect_event() work queuing
> after the hid_connect().
> 
> [...]

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git (for-6.7/logitech), thanks!

[1/1] HID: logitech-hidpp: Stop IO before calling hid_connect()
      https://git.kernel.org/hid/hid/c/3e6b0bb22a80

Cheers,
-- 
Benjamin Tissoires <bentiss@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-26 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 19:01 [PATCH] HID: logitech-hidpp: Stop IO before calling hid_connect() Hans de Goede
2023-10-26 10:04 ` Benjamin Tissoires

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).