Linux Input Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] Add an I2C HID quirk for incorrect input length.
@ 2019-11-27  3:23 admin
  2019-12-01  3:12 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: admin @ 2019-11-27  3:23 UTC (permalink / raw)
  To: Linux-input, Dmitry.torokhov; +Cc: Pavel Balan

From: Pavel Balan <admin@kryma.net>

Apply it to the Lenovo Y720 gaming laptop I2C peripheral then.

This fixes dmesg being flooded with errors visible on un-suspend
in Linux Mint 19 Cinnamon.

Example of error log:

<...>
[    4.326588] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
[    4.326845] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
[    4.327095] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
[    4.327341] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
[    4.327609] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
<...>

Example of fixed log (debug on)

<...>
[ 3731.333183] i2c_hid i2c-ITE33D1:00: input: 02 00
[ 3731.333581] i2c_hid i2c-ITE33D1:00: input: 02 00
[ 3731.333842] i2c_hid i2c-ITE33D1:00: input: 02 00
[ 3731.334107] i2c_hid i2c-ITE33D1:00: input: 02 00
[ 3731.334367] i2c_hid i2c-ITE33D1:00: input: 02 00
<...>

Signed-off-by: Pavel Balan <admin@kryma.net>
---
 drivers/hid/hid-ids.h              |  1 +
 drivers/hid/i2c-hid/i2c-hid-core.c | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 76969a22b0f2..ea518daf7435 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -628,6 +628,7 @@
 #define USB_VENDOR_ID_ITE               0x048d
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA   0x8386
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA2  0x8350
+#define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720	0x837a
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA900	0x8396
 #define USB_DEVICE_ID_ITE8595		0x8595
 
diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 2a7c6e33bb1c..14d964700a7c 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -51,6 +51,7 @@
 #define I2C_HID_QUIRK_NO_RUNTIME_PM		BIT(2)
 #define I2C_HID_QUIRK_DELAY_AFTER_SLEEP		BIT(3)
 #define I2C_HID_QUIRK_BOGUS_IRQ			BIT(4)
+#define I2C_HID_QUIRK_BAD_INPUT_SIZE		BIT(5)
 
 /* flags */
 #define I2C_HID_STARTED		0
@@ -182,6 +183,8 @@ static const struct i2c_hid_quirks {
 		I2C_HID_QUIRK_NO_RUNTIME_PM },
 	{ USB_VENDOR_ID_ELAN, HID_ANY_ID,
 		 I2C_HID_QUIRK_BOGUS_IRQ },
+	{ USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720,
+		I2C_HID_QUIRK_BAD_INPUT_SIZE },
 	{ 0, 0 }
 };
 
@@ -513,9 +516,15 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)
 	}
 
 	if ((ret_size > size) || (ret_size < 2)) {
-		dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
-			__func__, size, ret_size);
-		return;
+		if (ihid->quirks & I2C_HID_QUIRK_BAD_INPUT_SIZE) {
+			ihid->inbuf[0] = size & 0xff;
+			ihid->inbuf[1] = size >> 8;
+			ret_size = size;
+		} else {
+			dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
+				__func__, size, ret_size);
+			return;
+		}
 	}
 
 	i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf);
-- 
2.17.1


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

* Re: [PATCH] Add an I2C HID quirk for incorrect input length.
  2019-11-27  3:23 [PATCH] Add an I2C HID quirk for incorrect input length admin
@ 2019-12-01  3:12 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2019-12-01  3:12 UTC (permalink / raw)
  To: admin; +Cc: Linux-input, Benjamin Tissoires, Jiri Kosina

On Wed, Nov 27, 2019 at 03:23:29AM +0000, admin@kryma.net wrote:
> From: Pavel Balan <admin@kryma.net>
> 
> Apply it to the Lenovo Y720 gaming laptop I2C peripheral then.
> 
> This fixes dmesg being flooded with errors visible on un-suspend
> in Linux Mint 19 Cinnamon.
> 
> Example of error log:
> 
> <...>
> [    4.326588] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
> [    4.326845] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
> [    4.327095] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
> [    4.327341] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
> [    4.327609] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4)
> <...>
> 
> Example of fixed log (debug on)
> 
> <...>
> [ 3731.333183] i2c_hid i2c-ITE33D1:00: input: 02 00
> [ 3731.333581] i2c_hid i2c-ITE33D1:00: input: 02 00
> [ 3731.333842] i2c_hid i2c-ITE33D1:00: input: 02 00
> [ 3731.334107] i2c_hid i2c-ITE33D1:00: input: 02 00
> [ 3731.334367] i2c_hid i2c-ITE33D1:00: input: 02 00
> <...>

This should go to Jiri/Benjamin (CCed).

> 
> Signed-off-by: Pavel Balan <admin@kryma.net>
> ---
>  drivers/hid/hid-ids.h              |  1 +
>  drivers/hid/i2c-hid/i2c-hid-core.c | 15 ++++++++++++---
>  2 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index 76969a22b0f2..ea518daf7435 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -628,6 +628,7 @@
>  #define USB_VENDOR_ID_ITE               0x048d
>  #define USB_DEVICE_ID_ITE_LENOVO_YOGA   0x8386
>  #define USB_DEVICE_ID_ITE_LENOVO_YOGA2  0x8350
> +#define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720	0x837a
>  #define USB_DEVICE_ID_ITE_LENOVO_YOGA900	0x8396
>  #define USB_DEVICE_ID_ITE8595		0x8595
>  
> diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
> index 2a7c6e33bb1c..14d964700a7c 100644
> --- a/drivers/hid/i2c-hid/i2c-hid-core.c
> +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
> @@ -51,6 +51,7 @@
>  #define I2C_HID_QUIRK_NO_RUNTIME_PM		BIT(2)
>  #define I2C_HID_QUIRK_DELAY_AFTER_SLEEP		BIT(3)
>  #define I2C_HID_QUIRK_BOGUS_IRQ			BIT(4)
> +#define I2C_HID_QUIRK_BAD_INPUT_SIZE		BIT(5)
>  
>  /* flags */
>  #define I2C_HID_STARTED		0
> @@ -182,6 +183,8 @@ static const struct i2c_hid_quirks {
>  		I2C_HID_QUIRK_NO_RUNTIME_PM },
>  	{ USB_VENDOR_ID_ELAN, HID_ANY_ID,
>  		 I2C_HID_QUIRK_BOGUS_IRQ },
> +	{ USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720,
> +		I2C_HID_QUIRK_BAD_INPUT_SIZE },
>  	{ 0, 0 }
>  };
>  
> @@ -513,9 +516,15 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)
>  	}
>  
>  	if ((ret_size > size) || (ret_size < 2)) {
> -		dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
> -			__func__, size, ret_size);
> -		return;
> +		if (ihid->quirks & I2C_HID_QUIRK_BAD_INPUT_SIZE) {
> +			ihid->inbuf[0] = size & 0xff;
> +			ihid->inbuf[1] = size >> 8;
> +			ret_size = size;
> +		} else {
> +			dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
> +				__func__, size, ret_size);
> +			return;
> +		}
>  	}
>  
>  	i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf);
> -- 
> 2.17.1
> 

-- 
Dmitry

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27  3:23 [PATCH] Add an I2C HID quirk for incorrect input length admin
2019-12-01  3:12 ` Dmitry Torokhov

Linux Input Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-input/0 linux-input/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-input linux-input/ https://lore.kernel.org/linux-input \
		linux-input@vger.kernel.org
	public-inbox-index linux-input

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-input


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git