* [PATCH] Input: goodix - disable IRQs while suspended
@ 2018-01-10 11:34 Hans de Goede
2018-01-10 14:14 ` Bastien Nocera
0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2018-01-10 11:34 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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
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] 3+ messages in thread
* Re: [PATCH] Input: goodix - disable IRQs while suspended
2018-01-10 11:34 [PATCH] Input: goodix - disable IRQs while suspended Hans de Goede
@ 2018-01-10 14:14 ` Bastien Nocera
2018-01-11 14:08 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: Bastien Nocera @ 2018-01-10 14:14 UTC (permalink / raw)
To: Hans de Goede, Dmitry Torokhov, Benjamin Tissoires; +Cc: linux-input
On Wed, 2018-01-10 at 12:34 +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.
Do disable_irq() and enable_irq() require to be paired, and if so, are
goodix_suspend() and goodix_resume() guaranteed to be paired?
Other than that, looks good to me. Please add the name of the device(s)
you tested this on in the changelog and add your tested-by, to show
it's not a "compile-only check" kind of commit.
Cheers
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: goodix - disable IRQs while suspended
2018-01-10 14:14 ` Bastien Nocera
@ 2018-01-11 14:08 ` Hans de Goede
0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2018-01-11 14:08 UTC (permalink / raw)
To: Bastien Nocera, Dmitry Torokhov, Benjamin Tissoires; +Cc: linux-input
Hi,
On 10-01-18 15:14, Bastien Nocera wrote:
> On Wed, 2018-01-10 at 12:34 +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.
>
> Do disable_irq() and enable_irq() require to be paired,
Yes.
> and if so, are
> goodix_suspend() and goodix_resume() guaranteed to be paired?
Yes I believe they are, many i2c drivers call disable / enable_irq
from there suspend/resume handler.
> Other than that, looks good to me. Please add the name of the device(s)
> you tested this on in the changelog and add your tested-by, to show
> it's not a "compile-only check" kind of commit.
Ok, v2 with amended commit messages coming up.
Regards,
Hans
>
> Cheers
>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-11 14:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-10 11:34 [PATCH] Input: goodix - disable IRQs while suspended Hans de Goede
2018-01-10 14:14 ` Bastien Nocera
2018-01-11 14:08 ` Hans de Goede
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).