All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
To: gupt21@gmail.com, jikos@kernel.org,
	benjamin.tissoires@redhat.com, Enrik.Berkhan@inka.de,
	sven.zuehlsdorf@vigem.de
Cc: linux-i2c@vger.kernel.org, linux-input@vger.kernel.org,
	Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Subject: [PATCH 2/5] HID: mcp2221: Allow IO to start during probe
Date: Wed, 25 Oct 2023 16:55:11 +1300	[thread overview]
Message-ID: <20231025035514.3450123-3-hamish.martin@alliedtelesis.co.nz> (raw)
In-Reply-To: <20231025035514.3450123-1-hamish.martin@alliedtelesis.co.nz>

During the probe we add an I2C adapter and as soon as we add that adapter
it may be used for a transfer (e.g via the code in i2cdetect()).
Those transfers are not able to complete and time out. This is because the
HID raw_event callback (mcp2221_raw_event) will not be invoked until the
HID device's 'driver_input_lock' is marked up at the completion of the
probe in hid_device_probe(). This starves the driver of the responses it
is waiting for.
In order to allow the I2C transfers to complete while we are still in the
probe, start the IO once we have completed init of the HID device.

This issue seems to have been seen before and a patch was submitted but
it seems it was never accepted. See:
https://lore.kernel.org/all/20221103222714.21566-3-Enrik.Berkhan@inka.de/

Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
---
 drivers/hid/hid-mcp2221.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index b95f31cf0fa2..aef0785c91cc 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -1142,6 +1142,8 @@ static int mcp2221_probe(struct hid_device *hdev,
 	if (ret)
 		return ret;
 
+	hid_device_io_start(hdev);
+
 	/* Set I2C bus clock diviser */
 	if (i2c_clk_freq > 400)
 		i2c_clk_freq = 400;
-- 
2.42.0


  parent reply	other threads:[~2023-10-25  3:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25  3:55 [PATCH 0/5] MCP2221 Improvements Hamish Martin
2023-10-25  3:55 ` [PATCH 1/5] HID: mcp2221: Set driver data before I2C adapter add Hamish Martin
2023-10-25  3:55 ` Hamish Martin [this message]
2023-10-25  3:55 ` [PATCH 3/5] HID: mcp2221: Set ACPI companion Hamish Martin
2023-10-25  3:55 ` [PATCH 4/5] HID: mcp2221: Don't set bus speed on every transfer Hamish Martin
2023-10-25  3:55 ` [PATCH 5/5] HID: mcp2221: Handle reads greater than 60 bytes Hamish Martin
2023-11-21  8:31 ` [PATCH 0/5] MCP2221 Improvements Jiri Kosina

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=20231025035514.3450123-3-hamish.martin@alliedtelesis.co.nz \
    --to=hamish.martin@alliedtelesis.co.nz \
    --cc=Enrik.Berkhan@inka.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=gupt21@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=sven.zuehlsdorf@vigem.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.