Skip to contentSkip to conversation

spontaneous disconnect with "usb-storage: implement autosuspend"

DISCUSSION Paolo Ornati 4 participants 12 messages Aug 14, 2007 – Sep 13, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

with "CONFIG_USB_SUSPEND=y", since commit:

8dfe4b14869fd185ca25ee88b02ada58a3005eaf
usb-storage: implement autosuspend

This patch (as930) implements autosuspend for usb-storage. It is adapted from a patch by Oliver Neukum. Autosuspend is allowed except during LUN scanning, resets, and command execution.

my USB photo-camera gets automagically disconnected before I can do anything with it ;)

Relevant dmesg (what I get by just attaching it):

[   70.722898] scsi 8:0:0:0: Direct-Access     HP       PHOTOSMART E317  A001 PQ: 0 ANSI: 0 CCS
[   70.727880] sd 8:0:0:0: [sdb] 488448 512-byte hardware sectors (250 MB)
[   70.730876] sd 8:0:0:0: [sdb] Write Protect is off
[   70.730879] sd 8:0:0:0: [sdb] Mode Sense: 00 46 00 00
[   70.730882] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[   70.742874] sd 8:0:0:0: [sdb] 488448 512-byte hardware sectors (250 MB)
[   70.745873] sd 8:0:0:0: [sdb] Write Protect is off
[   70.745876] sd 8:0:0:0: [sdb] Mode Sense: 00 46 00 00
[   70.745878] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[   70.745882]  sdb: sdb1
[   70.755192] sd 8:0:0:0: [sdb] Attached SCSI removable disk
[   70.755446] sd 8:0:0:0: Attached scsi generic sg3 type 0
[   70.755657] usb-storage: device scan complete
[   73.071490] usb 6-2: usb auto-suspend
[   73.321445] hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
[   73.321453] uhci_hcd 0000:00:1d.1: port 2 portsc 108a,00
[   73.321462] hub 6-0:1.0: port 2, status 0100, change 0003, 12 Mb/s
[   73.321465] usb 6-2: USB disconnect, address 2
[   73.321467] usb 6-2: unregistering device

The relevant differences of dmesg between pre and post "autosuspend" patch:

@@ -1,4 +1,4 @@
- Linux version 2.6.22-gb0e2a705 ...
+ Linux version 2.6.22-g8dfe4b14 ...
@@ -606,6 +606,12 @@
hub 1-0:1.0: hub_suspend
usb usb1: bus auto-suspend
ehci_hcd 0000:00:1a.7: suspend root hub
+ hub 4-0:1.0: hub_suspend
+ usb usb4: bus auto-suspend
+ usb usb4: suspend_rh
+ hub 5-0:1.0: hub_suspend
+ usb usb5: bus auto-suspend
+ usb usb5: suspend_rh
hub 6-0:1.0: hub_suspend
usb usb6: bus auto-suspend
usb usb6: suspend_rh
@@ -618,12 +624,6 @@
hub 3-0:1.0: hub_suspend
usb usb3: bus auto-suspend
usb usb3: suspend_rh
- hub 4-0:1.0: hub_suspend
- usb usb4: bus auto-suspend
- usb usb4: suspend_rh
- hub 5-0:1.0: hub_suspend
- usb usb5: bus auto-suspend
- usb usb5: suspend_rh
usb usb3: uevent
usb 3-0:1.0: uevent
usb 3-0:1.0: uevent
@@ -686,6 +686,7 @@
usb-storage 6-2:1.0: usb_probe_interface - got id
scsi8 : SCSI emulation for USB Mass Storage devices drivers/usb/core/inode.c: creating file '002'
+ hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning hub 2-0:1.0: hub_suspend
@@ -704,3 +705,22 @@
sd 8:0:0:0: [sdb] Attached SCSI removable disk
sd 8:0:0:0: Attached scsi generic sg3 type 0
usb-storage: device scan complete
+ usb 6-2: usb auto-suspend
+ hub 6-0:1.0: state 7 ports 2 chg 0000 evt 0004
+ uhci_hcd 0000:00:1d.1: port 2 portsc 108a,00
+ hub 6-0:1.0: port 2, status 0100, change 0003, 12 Mb/s
+ usb 6-2: USB disconnect, address 2
+ usb 6-2: unregistering device
+ usb 6-2: usb_disable_device nuking all URBs
+ usb 6-2: unregistering interface 6-2:1.0
+ usb_endpoint usbdev6.2_ep82: ep_device_release called for usbdev6.2_ep82
+ usb_endpoint usbdev6.2_ep03: ep_device_release called for usbdev6.2_ep03
+ usb 6-2:1.0: uevent
+ usb 6-2:1.0: uevent
+ usb_endpoint usbdev6.2_ep00: ep_device_release called for usbdev6.2_ep00
+ usb 6-2: uevent
+ hub 6-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x100
+ usb usb6: suspend_rh (auto-stop)
+ hub 6-0:1.0: hub_suspend
+ usb usb6: bus auto-suspend
+ usb usb6: suspend_rh

config for 2.6.22-gb0e2a705 attached

Signature · 2 lines
	Paolo Ornati
	Linux 2.6.23-rc3 on x86_64
#1 lore raw

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 12 lines

Hi,

with "CONFIG_USB_SUSPEND=y", since commit:

8dfe4b14869fd185ca25ee88b02ada58a3005eaf
    usb-storage: implement autosuspend

    This patch (as930) implements autosuspend for usb-storage.  It is adapted from a patch by Oliver Neukum.  Autosuspend is allowed except during LUN scanning, resets, and command execution.

Quoted 3 lines

my USB photo-camera gets automagically disconnected before I can do anything with it ;)

hi,

I need vendor:product. Please provide "lsusb".
Generally a bug report for a specific usb device without vendor:product is a bad idea.

Regards
Oliver

#2 lore raw
Quoted 9 lines · On Tue, 14 Aug 2007 15:30:27 +0200 Oliver Neukum <[email protected]> wrote:
Quoted 3 lines

my USB photo-camera gets automagically disconnected before I can do anything with it ;)

hi,

I need vendor:product. Please provide "lsusb".
Generally a bug report for a specific usb device without vendor:product is a bad idea.

oopss :)

HP PHOTOSMART E317

tux ~ # lsusb
Bus 007 Device 001: ID 0000:0000
Bus 006 Device 002: ID 03f0:4002 Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage)
...

Signature · 2 lines
	Paolo Ornati
	Linux 2.6.23-rc3 on x86_64
#3 lore raw

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 1 line

Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage)

Please try this patch.

Regards
Oliver

-----

drivers/usb/core/quirks.c +2 -0
@@ -30,6 +30,8 @@
 static const struct usb_device_id usb_quirk_list[] = {
 	/* HP 5300/5370C scanner */
 	{ USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
+	/* Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage) */
+	{ USB_DEVICE(0x03f0, 0x4002), .driver_info = USB_QUIRK_RESET_RESUME },
 	/* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
 	{ USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
 	/* Benq S2W 3300U */
#4 lore raw
Quoted 4 lines · On Tue, 14 Aug 2007 17:46:16 +0200 Oliver Neukum <[email protected]> wrote:

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 1 line

Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage)

Please try this patch.

Tried on -rc3 but it doesn't work, dmesg attached.

However I've found that if "hald" is running the problems doesn't happen (I think it's just hidden by the fact that hald do some polling on it preventing autosuspend to trigger).

Signature · 2 lines
	Paolo Ornati
	Linux 2.6.23-rc3 on x86_64
#5 lore raw

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 6 lines
Quoted 3 lines · On Tue, 14 Aug 2007 17:46:16 +0200 Oliver Neukum <[email protected]> wrote:

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 1 line

Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage)

Quoted 7 lines
Quoted 1 line

Please try this patch.

Tried on -rc3 but it doesn't work, dmesg attached.

However I've found that if "hald" is running the problems doesn't happen (I think it's just hidden by the fact that hald do some polling on it preventing autosuspend to trigger).

Exactly. This is not reliable. It needs to be done in kernel. This patch should do it.

Regards
Oliver

---

drivers/usb/core/quirks.c +2 -0
@@ -30,6 +30,8 @@
 static const struct usb_device_id usb_quirk_list[] = {
 	/* HP 5300/5370C scanner */
 	{ USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
+	/* Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage) */
+	{ USB_DEVICE(0x03f0, 0x4002), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
 	/* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
 	{ USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
 	/* Benq S2W 3300U */
#6 lore raw
Quoted 2 lines · On Tue, 14 Aug 2007 20:33:22 +0200 Oliver Neukum <[email protected]> wrote:

Exactly. This is not reliable. It needs to be done in kernel. This patch should do it.

ok, this one works :)

I suspect that there are many more broken devices out there ;)

thanks,

Signature · 2 lines
	Paolo Ornati
	Linux 2.6.23-rc3-gbfefa254 on x86_64
#7 lore raw
In reply to Oliver Neukum
Quoted 24 lines · Oliver Neukum

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 11 lines
Quoted 3 lines · On Tue, 14 Aug 2007 17:46:16 +0200 Oliver Neukum <[email protected]> wrote:

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 1 line

Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage)

Please try this patch.

Tried on -rc3 but it doesn't work, dmesg attached.

However I've found that if "hald" is running the problems doesn't happen (I think it's just hidden by the fact that hald do some polling on it preventing autosuspend to trigger).

Exactly. This is not reliable. It needs to be done in kernel. This patch should do it.

Regards
Oliver

---

drivers/usb/core/quirks.c

Quoted 9 lines
drivers/usb/core/quirks.c +2 -1
@@ -30,6 +30,8 @@
 static const struct usb_device_id usb_quirk_list[] = {
 	/* HP 5300/5370C scanner */
 	{ USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
+	/* Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage) */
+	{ USB_DEVICE(0x03f0, 0x4002), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
 	/* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
 	{ USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
 	/* Benq S2W 3300U */
-

I believe the offending commit needs to be reverted. It just breaks too much stuff, including my Sandisk USB sticks.

Quoted 11 lines

with "CONFIG_USB_SUSPEND=y", since commit:

8dfe4b14869fd185ca25ee88b02ada58a3005eaf
usb-storage: implement autosuspend

This patch (as930) implements autosuspend for usb-storage. It is adapted from a patch by Oliver Neukum. Autosuspend is allowed except during LUN scanning, resets, and command execution.

my USB photo-camera gets automagically disconnected before I can do anything with it ;)

Ditto for several other devices that are being slowly special-cased, and many that have yet to be tested. This commit is (unfortunately) a disaster with many regressions.

Andrew, Linus?

#8 lore raw
Quoted 44 lines · Mark Lord
Quoted 28 lines · Oliver Neukum

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 11 lines
Quoted 3 lines · On Tue, 14 Aug 2007 17:46:16 +0200 Oliver Neukum <[email protected]> wrote:

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 1 line

Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage)

Please try this patch.

Tried on -rc3 but it doesn't work, dmesg attached.

However I've found that if "hald" is running the problems doesn't happen (I think it's just hidden by the fact that hald do some polling on it preventing autosuspend to trigger).

Exactly. This is not reliable. It needs to be done in kernel. This patch should do it.
Regards
Oliver
---

drivers/usb/core/quirks.c +2 -0
@@ -30,6 +30,8 @@
 static const struct usb_device_id usb_quirk_list[] = {
 	/* HP 5300/5370C scanner */
 	{ USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 
 },
+	/* Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage) */
+	{ USB_DEVICE(0x03f0, 0x4002), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
 	/* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
 	{ USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },

drivers/usb/core/quirks.c

Quoted 2 lines
drivers/usb/core/quirks.c +0 -1
 	/* Benq S2W 3300U */
-

I believe the offending commit needs to be reverted. It just breaks too much stuff, including my Sandisk USB sticks.

Quoted 8 lines

with "CONFIG_USB_SUSPEND=y", since commit:
8dfe4b14869fd185ca25ee88b02ada58a3005eaf
usb-storage: implement autosuspend
This patch (as930) implements autosuspend for usb-storage. It is
adapted from a patch by Oliver Neukum. Autosuspend is allowed except during LUN scanning, resets, and command execution.
my USB photo-camera gets automagically disconnected before I can do anything with it ;)

Quoted 3 lines

Ditto for several other devices that are being slowly special-cased, and many that have yet to be tested. This commit is (unfortunately) a disaster with many regressions.

There are many regressions right now, _ONLY_ if you enable CONFIG_USB_SUSPEND. If you disable that, your problems will go away, right?

This option is a new option, and we have found out the hard way that a very large class of hardware really does not like working with usb suspend at all.

Because of this, we have a patch queued up for 2.6.24 that will disable suspend for devices, and have to be enabled from a white-list that we will put in userspace based on the history of what other operating systems have determined are devices that can sleep properly.

I can send this patch in now to Linus, but as it changes functionality from previous -rc patches, I've been hesitant to do so. Especially when a mere config option change will solve your problem.

Oh, and currently no distro will enable this option due to the hardware problems, so the only people that could get hit by this are those who build their own kernels, and they can easily disable the option.

Does this help explain things?

thanks,

greg k-h

#9 lore raw
Quoted 47 lines · Greg KH
Quoted 42 lines · Mark Lord
Quoted 28 lines · Oliver Neukum

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 11 lines
Quoted 3 lines · On Tue, 14 Aug 2007 17:46:16 +0200 Oliver Neukum <[email protected]> wrote:

Am Dienstag 14 August 2007 schrieb Paolo Ornati:

Quoted 1 line

Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage)

Please try this patch.

Tried on -rc3 but it doesn't work, dmesg attached.

However I've found that if "hald" is running the problems doesn't happen (I think it's just hidden by the fact that hald do some polling on it preventing autosuspend to trigger).

Exactly. This is not reliable. It needs to be done in kernel. This patch should do it.
Regards
Oliver
---

drivers/usb/core/quirks.c +2 -0
@@ -30,6 +30,8 @@
 static const struct usb_device_id usb_quirk_list[] = {
 	/* HP 5300/5370C scanner */
 	{ USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 
 },
+	/* Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage) */
+	{ USB_DEVICE(0x03f0, 0x4002), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
 	/* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
 	{ USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },

drivers/usb/core/quirks.c

Quoted 2 lines
drivers/usb/core/quirks.c +0 -1
 	/* Benq S2W 3300U */
-

I believe the offending commit needs to be reverted. It just breaks too much stuff, including my Sandisk USB sticks.

Quoted 8 lines

with "CONFIG_USB_SUSPEND=y", since commit:
8dfe4b14869fd185ca25ee88b02ada58a3005eaf
usb-storage: implement autosuspend
This patch (as930) implements autosuspend for usb-storage. It is
adapted from a patch by Oliver Neukum. Autosuspend is allowed except during LUN scanning, resets, and command execution.
my USB photo-camera gets automagically disconnected before I can do anything with it ;)

Quoted 3 lines

Ditto for several other devices that are being slowly special-cased, and many that have yet to be tested. This commit is (unfortunately) a disaster with many regressions.

Quoted 7 lines

There are many regressions right now, _ONLY_ if you enable CONFIG_USB_SUSPEND. If you disable that, your problems will go away, right?

This option is a new option, and we have found out the hard way that a very large class of hardware really does not like working with usb suspend at all.

CONFIG_USB_SUSPEND is *not* a new config option.
It's been around for quite some time now, and I also had it enabled in 2.6.22 without any troubles. Definite regression here, folks!

Cheers

#10 lore raw
In reply to Greg KH
Quoted 4 lines · Greg KH

There are many regressions right now, _ONLY_ if you enable CONFIG_USB_SUSPEND. If you disable that, your problems will go away, right?

..

Quoted 3 lines

Oh, and currently no distro will enable this option due to the hardware problems, so the only people that could get hit by this are those who build their own kernels, and they can easily disable the option.

Ubuntu has CONFIG_USB_SUSPEND=y

There are probably lots of other distros that use it as well.

This new behaviour (failed operation of USB flash keys) is a *new* regression in 2.6.23, and we still have time to fix it by either reverting the changed functionality, or by changing the code to default OFF.

Here's my patch for 2.6.23-rc6+ :

Fix USB Storage failures.

---

drivers/usb/storage/usb.c renamed from drivers/usb/storage/usb.c.orig +0 -0
@@ -1065,7 +1065,7 @@

.pre_reset = storage_pre_reset,
.post_reset = storage_post_reset,
.id_table = storage_usb_ids,
- .supports_autosuspend = 1,
+ .supports_autosuspend = 0,
};

static int __init usb_stor_init(void)

#11 lore raw
Quoted 11 lines · Mark Lord
Quoted 4 lines · Greg KH

There are many regressions right now, _ONLY_ if you enable CONFIG_USB_SUSPEND. If you disable that, your problems will go away, right?

..

Quoted 3 lines

Oh, and currently no distro will enable this option due to the hardware problems, so the only people that could get hit by this are those who build their own kernels, and they can easily disable the option.

Ubuntu has CONFIG_USB_SUSPEND=y

They also have a patch that disables suspend automatically for all devices except USB hubs. Same goes for Red Hat's rawhide kernel.

Quoted 1 line

There are probably lots of other distros that use it as well.

Not without the above mentioned patch they do not :)

Quoted 4 lines

This new behaviour (failed operation of USB flash keys) is a *new* regression
in 2.6.23, and we still have time to fix it by either reverting the changed functionality, or by changing the code to default OFF.

I now agree.

Quoted 5 lines

Here's my patch for 2.6.23-rc6+ :

Fix USB Storage failures.

That's way too simple, I want to revert the whole usb-storage suspend logic as Oliver has found some core problems with it working properly, even with devices that have no problems.

Is that ok for you?

thanks,

greg k-h