Skip to contentSkip to conversation

Input: goodix - disable IRQs while suspended

PATCH Superseded Hans de Goede 2 participants 3 messages Jan 10, 2018 – Jan 11, 2018

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: goodix - disable IRQs while suspended

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.

---
 drivers/input/touchscreen/goodix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/input/touchscreen/goodix.c +6 -2
index 69d0b8cbc71f..ecec8eb17f28 100644
@@ -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
Signature · 1 line
2.14.3
#1 lore raw
Quoted 9 lines · Hans de Goede

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

Quoted 36 lines
---
 drivers/input/touchscreen/goodix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/input/touchscreen/goodix.c +6 -2
index 69d0b8cbc71f..ecec8eb17f28 100644
@@ -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 lore raw

Hi,

Quoted 4 lines · Bastien Nocera
Quoted 3 lines · Hans de Goede

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

Quoted 8 lines
Quoted 6 lines

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.

Quoted 2 lines

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.

Quoted 3 lines

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

Quoted 39 lines

Cheers

Quoted 36 lines
---
  drivers/input/touchscreen/goodix.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
drivers/input/touchscreen/goodix.c +6 -2
index 69d0b8cbc71f..ecec8eb17f28 100644
@@ -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