All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-02-17 17:59 ` Karoly Pados
  0 siblings, 0 replies; 18+ messages in thread
From: Karoly Pados @ 2019-02-17 17:59 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman, linux-usb, linux-kernel, Loic Poulain
  Cc: Karoly Pados

Current GPIO code in cp210x fails to take USB autosuspend into account,
making it practically impossible to use GPIOs with autosuspend enabled
without user configuration. Fix this like for ftdi_sio in a previous patch.
Tested on a CP2102N.

Signed-off-by: Karoly Pados <pados@pados.hu>
---
Changelog:
- v2: Restrict new autopm calls to GPIO paths.
      Always check result of usb_autopm_get.
      Rebased to current usb_serial upstream.

 drivers/usb/serial/cp210x.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index fac7a4547523..f7aaecad6e21 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1370,8 +1370,13 @@ static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 	if (priv->partnum == CP210X_PARTNUM_CP2105)
 		req_type = REQTYPE_INTERFACE_TO_HOST;
 
+	result = usb_autopm_get_interface(serial->interface);
+	if (result)
+		return result;
+
 	result = cp210x_read_vendor_block(serial, req_type,
 					  CP210X_READ_LATCH, &buf, sizeof(buf));
+	usb_autopm_put_interface(serial->interface);
 	if (result < 0)
 		return result;
 
@@ -1392,6 +1397,10 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
 
 	buf.mask = BIT(gpio);
 
+	result = usb_autopm_get_interface(serial->interface);
+	if (result)
+		goto out;
+
 	if (priv->partnum == CP210X_PARTNUM_CP2105) {
 		result = cp210x_write_vendor_block(serial,
 						   REQTYPE_HOST_TO_INTERFACE,
@@ -1399,7 +1408,6 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
 						   sizeof(buf));
 	} else {
 		u16 wIndex = buf.state << 8 | buf.mask;
-
 		result = usb_control_msg(serial->dev,
 					 usb_sndctrlpipe(serial->dev, 0),
 					 CP210X_VENDOR_SPECIFIC,
@@ -1409,6 +1417,9 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
 					 NULL, 0, USB_CTRL_SET_TIMEOUT);
 	}
 
+	usb_autopm_put_interface(serial->interface);
+
+out:
 	if (result < 0) {
 		dev_err(&serial->interface->dev, "failed to set GPIO value: %d\n",
 				result);
-- 
2.20.1


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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-02-17 17:59 ` Karoly Pados
  0 siblings, 0 replies; 18+ messages in thread
From: Karoly Pados @ 2019-02-17 17:59 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman, linux-usb, linux-kernel, Loic Poulain
  Cc: Karoly Pados

Current GPIO code in cp210x fails to take USB autosuspend into account,
making it practically impossible to use GPIOs with autosuspend enabled
without user configuration. Fix this like for ftdi_sio in a previous patch.
Tested on a CP2102N.

Signed-off-by: Karoly Pados <pados@pados.hu>
---
Changelog:
- v2: Restrict new autopm calls to GPIO paths.
      Always check result of usb_autopm_get.
      Rebased to current usb_serial upstream.

 drivers/usb/serial/cp210x.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index fac7a4547523..f7aaecad6e21 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -1370,8 +1370,13 @@ static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 	if (priv->partnum == CP210X_PARTNUM_CP2105)
 		req_type = REQTYPE_INTERFACE_TO_HOST;
 
+	result = usb_autopm_get_interface(serial->interface);
+	if (result)
+		return result;
+
 	result = cp210x_read_vendor_block(serial, req_type,
 					  CP210X_READ_LATCH, &buf, sizeof(buf));
+	usb_autopm_put_interface(serial->interface);
 	if (result < 0)
 		return result;
 
@@ -1392,6 +1397,10 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
 
 	buf.mask = BIT(gpio);
 
+	result = usb_autopm_get_interface(serial->interface);
+	if (result)
+		goto out;
+
 	if (priv->partnum == CP210X_PARTNUM_CP2105) {
 		result = cp210x_write_vendor_block(serial,
 						   REQTYPE_HOST_TO_INTERFACE,
@@ -1399,7 +1408,6 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
 						   sizeof(buf));
 	} else {
 		u16 wIndex = buf.state << 8 | buf.mask;
-
 		result = usb_control_msg(serial->dev,
 					 usb_sndctrlpipe(serial->dev, 0),
 					 CP210X_VENDOR_SPECIFIC,
@@ -1409,6 +1417,9 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
 					 NULL, 0, USB_CTRL_SET_TIMEOUT);
 	}
 
+	usb_autopm_put_interface(serial->interface);
+
+out:
 	if (result < 0) {
 		dev_err(&serial->interface->dev, "failed to set GPIO value: %d\n",
 				result);

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-02-18  9:17   ` Oliver Neukum
  0 siblings, 0 replies; 18+ messages in thread
From: Oliver Neukum @ 2019-02-18  9:17 UTC (permalink / raw)
  To: Karoly Pados, Johan Hovold, Loic Poulain, Greg Kroah-Hartman,
	linux-kernel, linux-usb

On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> Current GPIO code in cp210x fails to take USB autosuspend into account,
> making it practically impossible to use GPIOs with autosuspend enabled
> without user configuration. Fix this like for ftdi_sio in a previous patch.
> Tested on a CP2102N.

Hi,

your patch is looking good to me, but I am afraid there are issues.
How do the GPIO lines on the device interact with USB reset and system
suspend?

	Regards
		Oliver


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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-02-18  9:17   ` Oliver Neukum
  0 siblings, 0 replies; 18+ messages in thread
From: Oliver Neukum @ 2019-02-18  9:17 UTC (permalink / raw)
  To: Karoly Pados, Johan Hovold, Loic Poulain, Greg Kroah-Hartman,
	linux-kernel, linux-usb

On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> Current GPIO code in cp210x fails to take USB autosuspend into account,
> making it practically impossible to use GPIOs with autosuspend enabled
> without user configuration. Fix this like for ftdi_sio in a previous patch.
> Tested on a CP2102N.

Hi,

your patch is looking good to me, but I am afraid there are issues.
How do the GPIO lines on the device interact with USB reset and system
suspend?

	Regards
		Oliver

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-02-20  9:23   ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-02-20  9:23 UTC (permalink / raw)
  To: Karoly Pados
  Cc: Johan Hovold, Greg Kroah-Hartman, linux-usb, linux-kernel, Loic Poulain

On Sun, Feb 17, 2019 at 06:59:01PM +0100, Karoly Pados wrote:
> Current GPIO code in cp210x fails to take USB autosuspend into account,
> making it practically impossible to use GPIOs with autosuspend enabled
> without user configuration. Fix this like for ftdi_sio in a previous patch.
> Tested on a CP2102N.
> 
> Signed-off-by: Karoly Pados <pados@pados.hu>
> ---
> Changelog:
> - v2: Restrict new autopm calls to GPIO paths.
>       Always check result of usb_autopm_get.
>       Rebased to current usb_serial upstream.

Thanks for the v2. Now applied after removing the unmotivated white
space change.

I also added a Fixes and CC-stable tag as this seems annoying enough to
warrant a backport even if autosuspend was never actually supported.

Johan

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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-02-20  9:23   ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-02-20  9:23 UTC (permalink / raw)
  To: Karoly Pados
  Cc: Johan Hovold, Greg Kroah-Hartman, linux-usb, linux-kernel, Loic Poulain

On Sun, Feb 17, 2019 at 06:59:01PM +0100, Karoly Pados wrote:
> Current GPIO code in cp210x fails to take USB autosuspend into account,
> making it practically impossible to use GPIOs with autosuspend enabled
> without user configuration. Fix this like for ftdi_sio in a previous patch.
> Tested on a CP2102N.
> 
> Signed-off-by: Karoly Pados <pados@pados.hu>
> ---
> Changelog:
> - v2: Restrict new autopm calls to GPIO paths.
>       Always check result of usb_autopm_get.
>       Rebased to current usb_serial upstream.

Thanks for the v2. Now applied after removing the unmotivated white
space change.

I also added a Fixes and CC-stable tag as this seems annoying enough to
warrant a backport even if autosuspend was never actually supported.

Johan

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 10:36     ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-03-19 10:36 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Karoly Pados, Johan Hovold, Loic Poulain, Greg Kroah-Hartman,
	linux-kernel, linux-usb

On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
> On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> > Current GPIO code in cp210x fails to take USB autosuspend into account,
> > making it practically impossible to use GPIOs with autosuspend enabled
> > without user configuration. Fix this like for ftdi_sio in a previous patch.
> > Tested on a CP2102N.

> your patch is looking good to me, but I am afraid there are issues.
> How do the GPIO lines on the device interact with USB reset and system
> suspend?

What was your concern here, Oliver?

Johan

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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 10:36     ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-03-19 10:36 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Karoly Pados, Johan Hovold, Loic Poulain, Greg Kroah-Hartman,
	linux-kernel, linux-usb

On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
> On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> > Current GPIO code in cp210x fails to take USB autosuspend into account,
> > making it practically impossible to use GPIOs with autosuspend enabled
> > without user configuration. Fix this like for ftdi_sio in a previous patch.
> > Tested on a CP2102N.

> your patch is looking good to me, but I am afraid there are issues.
> How do the GPIO lines on the device interact with USB reset and system
> suspend?

What was your concern here, Oliver?

Johan

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 11:15       ` Oliver Neukum
  0 siblings, 0 replies; 18+ messages in thread
From: Oliver Neukum @ 2019-03-19 11:15 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Loic Poulain, Greg Kroah-Hartman, Karoly Pados, linux-kernel, linux-usb

On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
> On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
> > On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> > > Current GPIO code in cp210x fails to take USB autosuspend into account,
> > > making it practically impossible to use GPIOs with autosuspend enabled
> > > without user configuration. Fix this like for ftdi_sio in a previous patch.
> > > Tested on a CP2102N.
> > your patch is looking good to me, but I am afraid there are issues.
> > How do the GPIO lines on the device interact with USB reset and system
> > suspend?
> 
> What was your concern here, Oliver?

If you have a device resetting or losing power (for reset_resume) the
GPIO lines will revert to the default. But that change is not reported
to user space, is it?
So the original patch is correct, but there are more situations rather
than suspend which could trigger the problem.

	Regards
		Oliver


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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 11:15       ` Oliver Neukum
  0 siblings, 0 replies; 18+ messages in thread
From: Oliver Neukum @ 2019-03-19 11:15 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Loic Poulain, Greg Kroah-Hartman, Karoly Pados, linux-kernel, linux-usb

On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
> On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
> > On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> > > Current GPIO code in cp210x fails to take USB autosuspend into account,
> > > making it practically impossible to use GPIOs with autosuspend enabled
> > > without user configuration. Fix this like for ftdi_sio in a previous patch.
> > > Tested on a CP2102N.
> > your patch is looking good to me, but I am afraid there are issues.
> > How do the GPIO lines on the device interact with USB reset and system
> > suspend?
> 
> What was your concern here, Oliver?

If you have a device resetting or losing power (for reset_resume) the
GPIO lines will revert to the default. But that change is not reported
to user space, is it?
So the original patch is correct, but there are more situations rather
than suspend which could trigger the problem.

	Regards
		Oliver

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 13:14         ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-03-19 13:14 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Johan Hovold, Loic Poulain, Greg Kroah-Hartman, Karoly Pados,
	linux-kernel, linux-usb

On Tue, Mar 19, 2019 at 12:15:06PM +0100, Oliver Neukum wrote:
> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
> > On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
> > > On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> > > > Current GPIO code in cp210x fails to take USB autosuspend into account,
> > > > making it practically impossible to use GPIOs with autosuspend enabled
> > > > without user configuration. Fix this like for ftdi_sio in a previous patch.
> > > > Tested on a CP2102N.
> > > your patch is looking good to me, but I am afraid there are issues.
> > > How do the GPIO lines on the device interact with USB reset and system
> > > suspend?
> > 
> > What was your concern here, Oliver?
> 
> If you have a device resetting or losing power (for reset_resume) the
> GPIO lines will revert to the default. But that change is not reported
> to user space, is it?

This driver doesn't support reset_resume() so that shouldn't be an
issue, right? We'd disconnect (deregister the gpiochip) and re-probe
instead.

> So the original patch is correct, but there are more situations rather
> than suspend which could trigger the problem.

This patch just added the missing auto-resume handling, but, yeah,
there may be devices out there for which things may get out of sync if
they lose state over suspend. I think Karoly confirmed this wasn't the
case with cp210x.

Johan

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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 13:14         ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-03-19 13:14 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Johan Hovold, Loic Poulain, Greg Kroah-Hartman, Karoly Pados,
	linux-kernel, linux-usb

On Tue, Mar 19, 2019 at 12:15:06PM +0100, Oliver Neukum wrote:
> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
> > On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
> > > On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
> > > > Current GPIO code in cp210x fails to take USB autosuspend into account,
> > > > making it practically impossible to use GPIOs with autosuspend enabled
> > > > without user configuration. Fix this like for ftdi_sio in a previous patch.
> > > > Tested on a CP2102N.
> > > your patch is looking good to me, but I am afraid there are issues.
> > > How do the GPIO lines on the device interact with USB reset and system
> > > suspend?
> > 
> > What was your concern here, Oliver?
> 
> If you have a device resetting or losing power (for reset_resume) the
> GPIO lines will revert to the default. But that change is not reported
> to user space, is it?

This driver doesn't support reset_resume() so that shouldn't be an
issue, right? We'd disconnect (deregister the gpiochip) and re-probe
instead.

> So the original patch is correct, but there are more situations rather
> than suspend which could trigger the problem.

This patch just added the missing auto-resume handling, but, yeah,
there may be devices out there for which things may get out of sync if
they lose state over suspend. I think Karoly confirmed this wasn't the
case with cp210x.

Johan

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 17:12       ` Karoly Pados
  0 siblings, 0 replies; 18+ messages in thread
From: Karoly Pados @ 2019-03-19 17:12 UTC (permalink / raw)
  To: Oliver Neukum, Johan Hovold
  Cc: Loic Poulain, Greg Kroah-Hartman, linux-kernel, linux-usb

Hi Oliver,

USB suspend does not turn off power. Your concerns about the situations you list
are valid, but my patch is for another problem. Not for what happens
when power is lost, but because the user couldn't use the GPIO lines even if
power was on and continous, due to the kernel automatically putting the device into
suspend and then all usb messages failed in this case.

Karoly

March 19, 2019 12:26 PM, "Oliver Neukum" <oneukum@suse.com> wrote:

> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
> 
>> On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
>> On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
>>> Current GPIO code in cp210x fails to take USB autosuspend into account,
>>> making it practically impossible to use GPIOs with autosuspend enabled
>>> without user configuration. Fix this like for ftdi_sio in a previous patch.
>>> Tested on a CP2102N.
>> your patch is looking good to me, but I am afraid there are issues.
>> How do the GPIO lines on the device interact with USB reset and system
>> suspend?
>> 
>> What was your concern here, Oliver?
> 
> If you have a device resetting or losing power (for reset_resume) the
> GPIO lines will revert to the default. But that change is not reported
> to user space, is it?
> So the original patch is correct, but there are more situations rather
> than suspend which could trigger the problem.
> 
> Regards
> Oliver

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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 17:12       ` Karoly Pados
  0 siblings, 0 replies; 18+ messages in thread
From: Karoly Pados @ 2019-03-19 17:12 UTC (permalink / raw)
  To: Oliver Neukum, Johan Hovold
  Cc: Loic Poulain, Greg Kroah-Hartman, linux-kernel, linux-usb

Hi Oliver,

USB suspend does not turn off power. Your concerns about the situations you list
are valid, but my patch is for another problem. Not for what happens
when power is lost, but because the user couldn't use the GPIO lines even if
power was on and continous, due to the kernel automatically putting the device into
suspend and then all usb messages failed in this case.

Karoly

March 19, 2019 12:26 PM, "Oliver Neukum" <oneukum@suse.com> wrote:

> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
> 
>> On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
>> On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
>>> Current GPIO code in cp210x fails to take USB autosuspend into account,
>>> making it practically impossible to use GPIOs with autosuspend enabled
>>> without user configuration. Fix this like for ftdi_sio in a previous patch.
>>> Tested on a CP2102N.
>> your patch is looking good to me, but I am afraid there are issues.
>> How do the GPIO lines on the device interact with USB reset and system
>> suspend?
>> 
>> What was your concern here, Oliver?
> 
> If you have a device resetting or losing power (for reset_resume) the
> GPIO lines will revert to the default. But that change is not reported
> to user space, is it?
> So the original patch is correct, but there are more situations rather
> than suspend which could trigger the problem.
> 
> Regards
> Oliver

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 17:19         ` Karoly Pados
  0 siblings, 0 replies; 18+ messages in thread
From: Karoly Pados @ 2019-03-19 17:19 UTC (permalink / raw)
  To: Johan Hovold, Oliver Neukum
  Cc: Loic Poulain, Greg Kroah-Hartman, linux-kernel, linux-usb

>> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
>> On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
>>> On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
>>>> Current GPIO code in cp210x fails to take USB autosuspend into account,
>>>> making it practically impossible to use GPIOs with autosuspend enabled
>>>> without user configuration. Fix this like for ftdi_sio in a previous patch.
>>>> Tested on a CP2102N.
>>> your patch is looking good to me, but I am afraid there are issues.
>>> How do the GPIO lines on the device interact with USB reset and system
>>> suspend?
>> 
>> What was your concern here, Oliver?
>> 
>> If you have a device resetting or losing power (for reset_resume) the
>> GPIO lines will revert to the default. But that change is not reported
>> to user space, is it?
> 
> This driver doesn't support reset_resume() so that shouldn't be an
> issue, right? We'd disconnect (deregister the gpiochip) and re-probe
> instead.
> 
>> So the original patch is correct, but there are more situations rather
>> than suspend which could trigger the problem.
> 
> This patch just added the missing auto-resume handling, but, yeah,
> there may be devices out there for which things may get out of sync if
> they lose state over suspend. I think Karoly confirmed this wasn't the
> case with cp210x.
> 

The way I tested this is very simple: I just toggled an output pin. If the device
would lose its state during suspend, then the pin state would return to its factory
default as soon the it went into suspend. Since the LED stayed stable over suspend
(I connected an LED), it seems these devices don't lose state. I did not, however,
test all device state in detail to see if every setting remained. I cannot vouch for
whether *all* state is retained.

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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-19 17:19         ` Karoly Pados
  0 siblings, 0 replies; 18+ messages in thread
From: Karoly Pados @ 2019-03-19 17:19 UTC (permalink / raw)
  To: Johan Hovold, Oliver Neukum
  Cc: Loic Poulain, Greg Kroah-Hartman, linux-kernel, linux-usb

>> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:
>> On Mon, Feb 18, 2019 at 10:17:12AM +0100, Oliver Neukum wrote:
>>> On So, 2019-02-17 at 18:59 +0100, Karoly Pados wrote:
>>>> Current GPIO code in cp210x fails to take USB autosuspend into account,
>>>> making it practically impossible to use GPIOs with autosuspend enabled
>>>> without user configuration. Fix this like for ftdi_sio in a previous patch.
>>>> Tested on a CP2102N.
>>> your patch is looking good to me, but I am afraid there are issues.
>>> How do the GPIO lines on the device interact with USB reset and system
>>> suspend?
>> 
>> What was your concern here, Oliver?
>> 
>> If you have a device resetting or losing power (for reset_resume) the
>> GPIO lines will revert to the default. But that change is not reported
>> to user space, is it?
> 
> This driver doesn't support reset_resume() so that shouldn't be an
> issue, right? We'd disconnect (deregister the gpiochip) and re-probe
> instead.
> 
>> So the original patch is correct, but there are more situations rather
>> than suspend which could trigger the problem.
> 
> This patch just added the missing auto-resume handling, but, yeah,
> there may be devices out there for which things may get out of sync if
> they lose state over suspend. I think Karoly confirmed this wasn't the
> case with cp210x.
> 

The way I tested this is very simple: I just toggled an output pin. If the device
would lose its state during suspend, then the pin state would return to its factory
default as soon the it went into suspend. Since the LED stayed stable over suspend
(I connected an LED), it seems these devices don't lose state. I did not, however,
test all device state in detail to see if every setting remained. I cannot vouch for
whether *all* state is retained.

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

* Re: [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-20  9:11           ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-03-20  9:11 UTC (permalink / raw)
  To: Karoly Pados
  Cc: Johan Hovold, Oliver Neukum, Loic Poulain, Greg Kroah-Hartman,
	linux-kernel, linux-usb

On Tue, Mar 19, 2019 at 05:19:24PM +0000, Karoly Pados wrote:
> >> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:

> > This patch just added the missing auto-resume handling, but, yeah,
> > there may be devices out there for which things may get out of sync if
> > they lose state over suspend. I think Karoly confirmed this wasn't the
> > case with cp210x.
> 
> The way I tested this is very simple: I just toggled an output pin. If
> the device would lose its state during suspend, then the pin state
> would return to its factory default as soon the it went into suspend.
> Since the LED stayed stable over suspend (I connected an LED), it
> seems these devices don't lose state. I did not, however, test all
> device state in detail to see if every setting remained. I cannot
> vouch for whether *all* state is retained.

I think your test should be sufficient.

Thanks,
Johan

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

* [v2] USB: serial: cp210x: Fix GPIO in autosuspend
@ 2019-03-20  9:11           ` Johan Hovold
  0 siblings, 0 replies; 18+ messages in thread
From: Johan Hovold @ 2019-03-20  9:11 UTC (permalink / raw)
  To: Karoly Pados
  Cc: Johan Hovold, Oliver Neukum, Loic Poulain, Greg Kroah-Hartman,
	linux-kernel, linux-usb

On Tue, Mar 19, 2019 at 05:19:24PM +0000, Karoly Pados wrote:
> >> On Di, 2019-03-19 at 11:36 +0100, Johan Hovold wrote:

> > This patch just added the missing auto-resume handling, but, yeah,
> > there may be devices out there for which things may get out of sync if
> > they lose state over suspend. I think Karoly confirmed this wasn't the
> > case with cp210x.
> 
> The way I tested this is very simple: I just toggled an output pin. If
> the device would lose its state during suspend, then the pin state
> would return to its factory default as soon the it went into suspend.
> Since the LED stayed stable over suspend (I connected an LED), it
> seems these devices don't lose state. I did not, however, test all
> device state in detail to see if every setting remained. I cannot
> vouch for whether *all* state is retained.

I think your test should be sufficient.

Thanks,
Johan

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

end of thread, other threads:[~2019-03-20  9:11 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-17 17:59 [PATCH v2] USB: serial: cp210x: Fix GPIO in autosuspend Karoly Pados
2019-02-17 17:59 ` [v2] " Karoly Pados
2019-02-18  9:17 ` [PATCH v2] " Oliver Neukum
2019-02-18  9:17   ` [v2] " Oliver Neukum
2019-03-19 10:36   ` [PATCH v2] " Johan Hovold
2019-03-19 10:36     ` [v2] " Johan Hovold
2019-03-19 11:15     ` [PATCH v2] " Oliver Neukum
2019-03-19 11:15       ` [v2] " Oliver Neukum
2019-03-19 13:14       ` [PATCH v2] " Johan Hovold
2019-03-19 13:14         ` [v2] " Johan Hovold
2019-03-19 17:19       ` [PATCH v2] " Karoly Pados
2019-03-19 17:19         ` [v2] " Karoly Pados
2019-03-20  9:11         ` [PATCH v2] " Johan Hovold
2019-03-20  9:11           ` [v2] " Johan Hovold
2019-03-19 17:12     ` [PATCH v2] " Karoly Pados
2019-03-19 17:12       ` [v2] " Karoly Pados
2019-02-20  9:23 ` [PATCH v2] " Johan Hovold
2019-02-20  9:23   ` [v2] " Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.