* (unknown),
@ 2013-03-07 16:07 Ming Lei
2013-03-07 16:07 ` [PATCH v2 1/7] USB: adds comment on suspend callback Ming Lei
2013-03-07 16:07 ` [PATCH v2 2/7] USB: serial: handle suspend failure path correctly Ming Lei
0 siblings, 2 replies; 6+ messages in thread
From: Ming Lei @ 2013-03-07 16:07 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input
Hi,
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case, otherwise the recovery things may confuse
resume().
Also fixes the USB serial, HID and several usbnet drivers
which may recover device in suspend failure path of system sleep.
v2:
- improve comments on suspend callback as suggested by Alan
- update kerneldoc for usb_suspend_both as suggested by Alan
- remove previous check of PMSG_IS_AUTO(message) in cdc_mbim/
qmi_wwan and add comments on suspend failure case, since Bjørn
doesn't like the check.
- add comments on smsc95xx/smsc75xx
v1:
- fix compile failure
- add comments about handling suspend failure in resume()
drivers/hid/usbhid/hid-core.c | 14 +++++---------
drivers/net/usb/cdc_mbim.c | 5 +++++
drivers/net/usb/qmi_wwan.c | 5 +++++
drivers/net/usb/smsc75xx.c | 6 +++++-
drivers/net/usb/smsc95xx.c | 6 +++++-
drivers/usb/core/driver.c | 11 ++++++++---
drivers/usb/serial/usb-serial.c | 3 ++-
include/linux/usb.h | 7 ++++++-
8 files changed, 41 insertions(+), 16 deletions(-)
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/7] USB: adds comment on suspend callback
2013-03-07 16:07 (unknown), Ming Lei
@ 2013-03-07 16:07 ` Ming Lei
2013-03-07 16:07 ` [PATCH v2 2/7] USB: serial: handle suspend failure path correctly Ming Lei
1 sibling, 0 replies; 6+ messages in thread
From: Ming Lei @ 2013-03-07 16:07 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case and let resume/reset_resume callback
handle the suspend failure if needed.
Also kerneldoc for usb_suspend_both() is updated with the
fact.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/usb/core/driver.c | 11 ++++++++---
include/linux/usb.h | 7 ++++++-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d938b2b..eb1d00a 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1196,9 +1196,14 @@ done:
*
* This is the central routine for suspending USB devices. It calls the
* suspend methods for all the interface drivers in @udev and then calls
- * the suspend method for @udev itself. If an error occurs at any stage,
- * all the interfaces which were suspended are resumed so that they remain
- * in the same state as the device.
+ * the suspend method for @udev itself. When the routine is called in
+ * autosuspend, if an error occurs at any stage, all the interfaces
+ * which were suspended are resumed so that they remain in the same
+ * state as the device, but when called from system sleep, all error
+ * from suspend methods of interfaces and the non-root-hub device itself
+ * are simply ignored, so all suspended interfaces are only resumed
+ * to the device's state when @udev is root-hub and its suspend method
+ * returns failure.
*
* Autosuspend requests originating from a child device or an interface
* driver may be made without the protection of @udev's device lock, but
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 4d22d0f..f82ce57 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -978,7 +978,12 @@ struct usbdrv_wrap {
* the "usbfs" filesystem. This lets devices provide ways to
* expose information to user space regardless of where they
* do (or don't) show up otherwise in the filesystem.
- * @suspend: Called when the device is going to be suspended by the system.
+ * @suspend: Called when the device is going to be suspended by the
+ * system either from system sleep or runtime suspend context. The
+ * return value will be ignored in system sleep context, so do NOT
+ * try to continue using the device if suspend fails in this case.
+ * Instead, let the resume or reset-resume routine recover from
+ * the failure.
* @resume: Called when the device is being resumed by the system.
* @reset_resume: Called when the suspended device has been reset instead
* of being resumed.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/7] USB: serial: handle suspend failure path correctly
2013-03-07 16:07 (unknown), Ming Lei
2013-03-07 16:07 ` [PATCH v2 1/7] USB: adds comment on suspend callback Ming Lei
@ 2013-03-07 16:07 ` Ming Lei
1 sibling, 0 replies; 6+ messages in thread
From: Ming Lei @ 2013-03-07 16:07 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei, Johan Hovold
This patch kills traffic even though type->suspend returns
failure inside usb_serial_suspend from system sleep context
because USB core ignores the failiure and lets system sleep
go ahread, so the serial URB traffic need to be killed
in this case.
Cc: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/usb/serial/usb-serial.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a19ed74..9d0b9c8 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1142,10 +1142,11 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
if (serial->type->suspend) {
r = serial->type->suspend(serial, message);
- if (r < 0) {
+ if (r < 0 && PMSG_IS_AUTO(message)) {
serial->suspending = 0;
goto err_out;
}
+ /* TODO: resume() might need to handle suspend failure */
}
for (i = 0; i < serial->num_ports; ++i) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 0/7] USB: don't recover device if suspend fails in system sleep
@ 2013-03-07 16:15 Ming Lei
2013-03-07 16:15 ` [PATCH v2 2/7] USB: serial: handle suspend failure path correctly Ming Lei
0 siblings, 1 reply; 6+ messages in thread
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input
Hi,
Sorry for my broken email client just now.
This patch adds comments on interface driver suspend callback
to emphasize that the failure return value is ignored by
USB core in system sleep context, so do not try to recover
device for this case, otherwise the recovery things may confuse
resume().
Also fixes the USB serial, HID and several usbnet drivers
which may recover device in suspend failure path of system sleep.
v2:
- improve comments on suspend callback as suggested by Alan
- update kerneldoc for usb_suspend_both as suggested by Alan
- remove previous check of PMSG_IS_AUTO(message) in cdc_mbim/
qmi_wwan and add comments on suspend failure case, since Bjørn
doesn't like the check.
- add comments on smsc95xx/smsc75xx
v1:
- fix compile failure
- add comments about handling suspend failure in resume()
drivers/hid/usbhid/hid-core.c | 14 +++++---------
drivers/net/usb/cdc_mbim.c | 5 +++++
drivers/net/usb/qmi_wwan.c | 5 +++++
drivers/net/usb/smsc75xx.c | 6 +++++-
drivers/net/usb/smsc95xx.c | 6 +++++-
drivers/usb/core/driver.c | 11 ++++++++---
drivers/usb/serial/usb-serial.c | 3 ++-
include/linux/usb.h | 7 ++++++-
8 files changed, 41 insertions(+), 16 deletions(-)
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/7] USB: serial: handle suspend failure path correctly
2013-03-07 16:15 [PATCH v2 0/7] USB: don't recover device if suspend fails in system sleep Ming Lei
@ 2013-03-07 16:15 ` Ming Lei
2013-03-14 11:10 ` Johan Hovold
0 siblings, 1 reply; 6+ messages in thread
From: Ming Lei @ 2013-03-07 16:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Kosina
Cc: Alan Stern, Oliver Neukum, netdev, linux-usb, linux-input,
Ming Lei, Johan Hovold
This patch kills traffic even though type->suspend returns
failure inside usb_serial_suspend from system sleep context
because USB core ignores the failiure and lets system sleep
go ahread, so the serial URB traffic need to be killed
in this case.
Cc: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/usb/serial/usb-serial.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a19ed74..9d0b9c8 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1142,10 +1142,11 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
if (serial->type->suspend) {
r = serial->type->suspend(serial, message);
- if (r < 0) {
+ if (r < 0 && PMSG_IS_AUTO(message)) {
serial->suspending = 0;
goto err_out;
}
+ /* TODO: resume() might need to handle suspend failure */
}
for (i = 0; i < serial->num_ports; ++i) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/7] USB: serial: handle suspend failure path correctly
2013-03-07 16:15 ` [PATCH v2 2/7] USB: serial: handle suspend failure path correctly Ming Lei
@ 2013-03-14 11:10 ` Johan Hovold
2013-03-15 3:04 ` Ming Lei
0 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2013-03-14 11:10 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Jiri Kosina, Alan Stern,
Oliver Neukum, netdev, linux-usb, linux-input, Johan Hovold
On Fri, Mar 08, 2013 at 12:15:19AM +0800, Ming Lei wrote:
> This patch kills traffic even though type->suspend returns
> failure inside usb_serial_suspend from system sleep context
> because USB core ignores the failiure and lets system sleep
> go ahread, so the serial URB traffic need to be killed
> in this case.
>
> Cc: Johan Hovold <jhovold@gmail.com>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> ---
> drivers/usb/serial/usb-serial.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> index a19ed74..9d0b9c8 100644
> --- a/drivers/usb/serial/usb-serial.c
> +++ b/drivers/usb/serial/usb-serial.c
> @@ -1142,10 +1142,11 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
>
> if (serial->type->suspend) {
> r = serial->type->suspend(serial, message);
> - if (r < 0) {
> + if (r < 0 && PMSG_IS_AUTO(message)) {
> serial->suspending = 0;
> goto err_out;
> }
> + /* TODO: resume() might need to handle suspend failure */
> }
>
> for (i = 0; i < serial->num_ports; ++i) {
Sorry for the late reply.
The usb-serial subdriver suspend callbacks do not and must not return
non-zero if !PMSG_IS_AUTO(message) so adding code to handle that case
merely obfuscates this fact.
I'd rather see this documented with a comment just as Bjørn suggested
for cdc_mbim and qmi_wwan.
Thanks,
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/7] USB: serial: handle suspend failure path correctly
2013-03-14 11:10 ` Johan Hovold
@ 2013-03-15 3:04 ` Ming Lei
0 siblings, 0 replies; 6+ messages in thread
From: Ming Lei @ 2013-03-15 3:04 UTC (permalink / raw)
To: Johan Hovold
Cc: David S. Miller, Greg Kroah-Hartman, Jiri Kosina, Alan Stern,
Oliver Neukum, netdev, linux-usb, linux-input
On Thu, Mar 14, 2013 at 7:10 PM, Johan Hovold <jhovold@gmail.com> wrote:
> On Fri, Mar 08, 2013 at 12:15:19AM +0800, Ming Lei wrote:
>> This patch kills traffic even though type->suspend returns
>> failure inside usb_serial_suspend from system sleep context
>> because USB core ignores the failiure and lets system sleep
>> go ahread, so the serial URB traffic need to be killed
>> in this case.
>>
>> Cc: Johan Hovold <jhovold@gmail.com>
>> Signed-off-by: Ming Lei <ming.lei@canonical.com>
>> ---
>> drivers/usb/serial/usb-serial.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
>> index a19ed74..9d0b9c8 100644
>> --- a/drivers/usb/serial/usb-serial.c
>> +++ b/drivers/usb/serial/usb-serial.c
>> @@ -1142,10 +1142,11 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
>>
>> if (serial->type->suspend) {
>> r = serial->type->suspend(serial, message);
>> - if (r < 0) {
>> + if (r < 0 && PMSG_IS_AUTO(message)) {
>> serial->suspending = 0;
>> goto err_out;
>> }
>> + /* TODO: resume() might need to handle suspend failure */
>> }
>>
>> for (i = 0; i < serial->num_ports; ++i) {
>
> Sorry for the late reply.
>
> The usb-serial subdriver suspend callbacks do not and must not return
> non-zero if !PMSG_IS_AUTO(message) so adding code to handle that case
> merely obfuscates this fact.
>
> I'd rather see this documented with a comment just as Bjørn suggested
> for cdc_mbim and qmi_wwan.
No problem, will do it in v3.
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-03-15 3:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-07 16:07 (unknown), Ming Lei
2013-03-07 16:07 ` [PATCH v2 1/7] USB: adds comment on suspend callback Ming Lei
2013-03-07 16:07 ` [PATCH v2 2/7] USB: serial: handle suspend failure path correctly Ming Lei
-- strict thread matches above, loose matches on Subject: below --
2013-03-07 16:15 [PATCH v2 0/7] USB: don't recover device if suspend fails in system sleep Ming Lei
2013-03-07 16:15 ` [PATCH v2 2/7] USB: serial: handle suspend failure path correctly Ming Lei
2013-03-14 11:10 ` Johan Hovold
2013-03-15 3:04 ` Ming Lei
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).