linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] Input: goodix - disable IRQs while suspended
@ 2018-01-11 17:24 Hans de Goede
  2018-01-12  8:37 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2018-01-11 17:24 UTC (permalink / raw)
  To: Dmitry Torokhov, Bastien Nocera, Benjamin Tissoires
  Cc: Hans de Goede, linux-input

We should not try to do any i2c transfers before the controller is
resumed (which happens before our resume method gets called).

So we need to disable our IRQ while suspended to enforce this. The
code paths for devices with GPIOs for the int and reset pins already
disable the IRQ the through goodix_free_irq().

This commit also disables the IRQ while suspended for devices without
GPIOs for the int and reset pins.

This fixes the i2c bus sometimes getting stuck after a suspend/resume
causing the touchscreen to sometimes not work after a suspend/resume.
This has been tested on a GPD pocked device.

BugLink: https://github.com/nexus511/gpd-ubuntu-packages/issues/10
BugLink: https://www.reddit.com/r/GPDPocket/comments/7niut2/fix_for_broken_touch_after_resume_all_linux/
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Bastien Nocera <hadess@hadess.net>
---
Changes in v2:
-Mention the problems this fix + devices tested on in commit msg
-Add BugLinks and Tested-by to commit msg

Changes in v3:
-Fix typo in commit msg
-Add Bastien's Reviewed-by
---
 drivers/input/touchscreen/goodix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 69d0b8cbc71f..ecec8eb17f28 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -878,8 +878,10 @@ static int __maybe_unused goodix_suspend(struct device *dev)
 	int error;
 
 	/* We need gpio pins to suspend/resume */
-	if (!ts->gpiod_int || !ts->gpiod_rst)
+	if (!ts->gpiod_int || !ts->gpiod_rst) {
+		disable_irq(client->irq);
 		return 0;
+	}
 
 	wait_for_completion(&ts->firmware_loading_complete);
 
@@ -919,8 +921,10 @@ static int __maybe_unused goodix_resume(struct device *dev)
 	struct goodix_ts_data *ts = i2c_get_clientdata(client);
 	int error;
 
-	if (!ts->gpiod_int || !ts->gpiod_rst)
+	if (!ts->gpiod_int || !ts->gpiod_rst) {
+		enable_irq(client->irq);
 		return 0;
+	}
 
 	/*
 	 * Exit sleep mode by outputting HIGH level to INT pin
-- 
2.14.3


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

* Re: [PATCH v3] Input: goodix - disable IRQs while suspended
  2018-01-11 17:24 [PATCH v3] Input: goodix - disable IRQs while suspended Hans de Goede
@ 2018-01-12  8:37 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2018-01-12  8:37 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Bastien Nocera, Benjamin Tissoires, linux-input

On Thu, Jan 11, 2018 at 06:24:07PM +0100, Hans de Goede wrote:
> We should not try to do any i2c transfers before the controller is
> resumed (which happens before our resume method gets called).
> 
> So we need to disable our IRQ while suspended to enforce this. The
> code paths for devices with GPIOs for the int and reset pins already
> disable the IRQ the through goodix_free_irq().
> 
> This commit also disables the IRQ while suspended for devices without
> GPIOs for the int and reset pins.
> 
> This fixes the i2c bus sometimes getting stuck after a suspend/resume
> causing the touchscreen to sometimes not work after a suspend/resume.
> This has been tested on a GPD pocked device.
> 
> BugLink: https://github.com/nexus511/gpd-ubuntu-packages/issues/10
> BugLink: https://www.reddit.com/r/GPDPocket/comments/7niut2/fix_for_broken_touch_after_resume_all_linux/
> Tested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Bastien Nocera <hadess@hadess.net>

Applied, thank you.

> ---
> Changes in v2:
> -Mention the problems this fix + devices tested on in commit msg
> -Add BugLinks and Tested-by to commit msg
> 
> Changes in v3:
> -Fix typo in commit msg
> -Add Bastien's Reviewed-by
> ---
>  drivers/input/touchscreen/goodix.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> index 69d0b8cbc71f..ecec8eb17f28 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -878,8 +878,10 @@ static int __maybe_unused goodix_suspend(struct device *dev)
>  	int error;
>  
>  	/* We need gpio pins to suspend/resume */
> -	if (!ts->gpiod_int || !ts->gpiod_rst)
> +	if (!ts->gpiod_int || !ts->gpiod_rst) {
> +		disable_irq(client->irq);
>  		return 0;
> +	}
>  
>  	wait_for_completion(&ts->firmware_loading_complete);
>  
> @@ -919,8 +921,10 @@ static int __maybe_unused goodix_resume(struct device *dev)
>  	struct goodix_ts_data *ts = i2c_get_clientdata(client);
>  	int error;
>  
> -	if (!ts->gpiod_int || !ts->gpiod_rst)
> +	if (!ts->gpiod_int || !ts->gpiod_rst) {
> +		enable_irq(client->irq);
>  		return 0;
> +	}
>  
>  	/*
>  	 * Exit sleep mode by outputting HIGH level to INT pin
> -- 
> 2.14.3
> 

-- 
Dmitry

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

end of thread, other threads:[~2018-01-12  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-11 17:24 [PATCH v3] Input: goodix - disable IRQs while suspended Hans de Goede
2018-01-12  8:37 ` Dmitry Torokhov

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