diff mbox series

HID: i2c-hid: Reset ALPS touchpads on resume

Message ID 20200224192315.24427-2-alex.hung@canonical.com
State New
Headers show
Series HID: i2c-hid: Reset ALPS touchpads on resume | expand

Commit Message

Alex Hung Feb. 24, 2020, 7:23 p.m. UTC
From: Kai-Heng Feng <kai.heng.feng@canonical.com>

Commit 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system
resume") fixes many touchpads and touchscreens, however ALPS touchpads
start to trigger IRQ storm after system resume.

Since it's total silence from ALPS, let's bring the old behavior back
to ALPS touchpads.

BugLink: http://bugs.launchpad.net/bugs/1864527

Fixes: 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system resume")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
(cherry picked from commit fd70466d37bf3fe0118d18c56ddde85b428f86cf)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 drivers/hid/i2c-hid/i2c-hid-core.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Kleber Sacilotto de Souza Feb. 25, 2020, 4:52 p.m. UTC | #1
On 24.02.20 20:23, Alex Hung wrote:
> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> Commit 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system
> resume") fixes many touchpads and touchscreens, however ALPS touchpads
> start to trigger IRQ storm after system resume.
> 
> Since it's total silence from ALPS, let's bring the old behavior back
> to ALPS touchpads.
> 
> BugLink: http://bugs.launchpad.net/bugs/1864527
> 
> Fixes: 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system resume")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> (cherry picked from commit fd70466d37bf3fe0118d18c56ddde85b428f86cf)
> Signed-off-by: Alex Hung <alex.hung@canonical.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>


Alex, can you please set the series nomination on the bug report?

Thanks,
Kleber

> ---
>  drivers/hid/i2c-hid/i2c-hid-core.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
> index 400e2cd..9510a72 100644
> --- a/drivers/hid/i2c-hid/i2c-hid-core.c
> +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
> @@ -48,6 +48,7 @@
>  #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV	BIT(0)
>  #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET	BIT(1)
>  #define I2C_HID_QUIRK_BOGUS_IRQ			BIT(4)
> +#define I2C_HID_QUIRK_RESET_ON_RESUME		BIT(5)
>  
>  /* flags */
>  #define I2C_HID_STARTED		0
> @@ -176,6 +177,8 @@ static const struct i2c_hid_quirks {
>  		I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
>  	{ USB_VENDOR_ID_ELAN, HID_ANY_ID,
>  		 I2C_HID_QUIRK_BOGUS_IRQ },
> +	{ USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
> +		 I2C_HID_QUIRK_RESET_ON_RESUME },
>  	{ 0, 0 }
>  };
>  
> @@ -1216,8 +1219,15 @@ static int i2c_hid_resume(struct device *dev)
>  	 * solves "incomplete reports" on Raydium devices 2386:3118 and
>  	 * 2386:4B33 and fixes various SIS touchscreens no longer sending
>  	 * data after a suspend/resume.
> +	 *
> +	 * However some ALPS touchpads generate IRQ storm without reset, so
> +	 * let's still reset them here.
>  	 */
> -	ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
> +	if (ihid->quirks & I2C_HID_QUIRK_RESET_ON_RESUME)
> +		ret = i2c_hid_hwreset(client);
> +	else
> +		ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
> +
>  	if (ret)
>  		return ret;
>  
>
Stefan Bader March 12, 2020, 1:46 p.m. UTC | #2
On 24.02.20 20:23, Alex Hung wrote:
> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> Commit 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system
> resume") fixes many touchpads and touchscreens, however ALPS touchpads
> start to trigger IRQ storm after system resume.
> 
> Since it's total silence from ALPS, let's bring the old behavior back
> to ALPS touchpads.
> 
> BugLink: http://bugs.launchpad.net/bugs/1864527
> 
> Fixes: 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system resume")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> (cherry picked from commit fd70466d37bf3fe0118d18c56ddde85b428f86cf)
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  drivers/hid/i2c-hid/i2c-hid-core.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
> index 400e2cd..9510a72 100644
> --- a/drivers/hid/i2c-hid/i2c-hid-core.c
> +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
> @@ -48,6 +48,7 @@
>  #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV	BIT(0)
>  #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET	BIT(1)
>  #define I2C_HID_QUIRK_BOGUS_IRQ			BIT(4)
> +#define I2C_HID_QUIRK_RESET_ON_RESUME		BIT(5)
>  
>  /* flags */
>  #define I2C_HID_STARTED		0
> @@ -176,6 +177,8 @@ static const struct i2c_hid_quirks {
>  		I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
>  	{ USB_VENDOR_ID_ELAN, HID_ANY_ID,
>  		 I2C_HID_QUIRK_BOGUS_IRQ },
> +	{ USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
> +		 I2C_HID_QUIRK_RESET_ON_RESUME },
>  	{ 0, 0 }
>  };
>  
> @@ -1216,8 +1219,15 @@ static int i2c_hid_resume(struct device *dev)
>  	 * solves "incomplete reports" on Raydium devices 2386:3118 and
>  	 * 2386:4B33 and fixes various SIS touchscreens no longer sending
>  	 * data after a suspend/resume.
> +	 *
> +	 * However some ALPS touchpads generate IRQ storm without reset, so
> +	 * let's still reset them here.
>  	 */
> -	ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
> +	if (ihid->quirks & I2C_HID_QUIRK_RESET_ON_RESUME)
> +		ret = i2c_hid_hwreset(client);
> +	else
> +		ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
> +
>  	if (ret)
>  		return ret;
>  
>
diff mbox series

Patch

diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 400e2cd..9510a72 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -48,6 +48,7 @@ 
 #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV	BIT(0)
 #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET	BIT(1)
 #define I2C_HID_QUIRK_BOGUS_IRQ			BIT(4)
+#define I2C_HID_QUIRK_RESET_ON_RESUME		BIT(5)
 
 /* flags */
 #define I2C_HID_STARTED		0
@@ -176,6 +177,8 @@  static const struct i2c_hid_quirks {
 		I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
 	{ USB_VENDOR_ID_ELAN, HID_ANY_ID,
 		 I2C_HID_QUIRK_BOGUS_IRQ },
+	{ USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
+		 I2C_HID_QUIRK_RESET_ON_RESUME },
 	{ 0, 0 }
 };
 
@@ -1216,8 +1219,15 @@  static int i2c_hid_resume(struct device *dev)
 	 * solves "incomplete reports" on Raydium devices 2386:3118 and
 	 * 2386:4B33 and fixes various SIS touchscreens no longer sending
 	 * data after a suspend/resume.
+	 *
+	 * However some ALPS touchpads generate IRQ storm without reset, so
+	 * let's still reset them here.
 	 */
-	ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
+	if (ihid->quirks & I2C_HID_QUIRK_RESET_ON_RESUME)
+		ret = i2c_hid_hwreset(client);
+	else
+		ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
+
 	if (ret)
 		return ret;