linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
@ 2009-01-01 16:03 Yan Li
  2009-01-01 16:07 ` [PATCH] enable CONFIG_USB_SUSPEND by default Yan Li
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Yan Li @ 2009-01-01 16:03 UTC (permalink / raw)
  To: gregkh, linux-usb; +Cc: linux-kernel

Hello List,

By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
this when I got a new WDC My Book hard drive. I have no way to unplug
it safely, according to it's manual, with a kernel that doesn't have
CONFIG_USB_SUSPEND=y.

On it's manual read "you should unplug and remove the device only when
the light is off." On Linux unmounting it won't turn it's light off
and I can feel it's motor is still running.  The only way to unplug it
properly on a Linux system, as to my knowledge, is to echo `suspend'
to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
CONFIG_USB_SUSPEND=y to do this.

On Windows and Mac OS, `safely remove this device' function effectly
turns it into `suspend' mode, and it's light off.

I'm new in this field and I understood people's concern on enabling
autosuspend.  As to my understanding, `enabling suspend' and `enabling
autosuspend' should be controlled by two different knobs.  I did a
quick search in LKML and haven't found specific oppose to enable USB
suspend by default, and Debian has started shipping a kernel with
it turned on since 2.6.26.

Perhaps we should consider turning it on by default?  Thanks!

-- 
Li, Yan

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

* [PATCH] enable CONFIG_USB_SUSPEND by default
  2009-01-01 16:03 Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Yan Li
@ 2009-01-01 16:07 ` Yan Li
  2009-01-01 17:29 ` Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Alan Stern
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 19+ messages in thread
From: Yan Li @ 2009-01-01 16:07 UTC (permalink / raw)
  To: gregkh, linux-usb; +Cc: linux-kernel

Some USB devices need to be put into suspend mode before
unplugging. Without CONFIG_USB_SUSPEND we have no way to unplug them
safely.

Signed-off-by: Yan Li <elliot.li.tech@gmail.com>
---
 drivers/usb/core/Kconfig |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index e1759d1..457ee9d 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -89,18 +89,20 @@ config USB_DYNAMIC_MINORS
 config USB_SUSPEND
 	bool "USB selective suspend/resume and wakeup"
 	depends on USB && PM
+	default y
 	help
 	  If you say Y here, you can use driver calls or the sysfs
 	  "power/level" file to suspend or resume individual USB
-	  peripherals and to enable or disable autosuspend (see
-	  Documentation/usb/power-management.txt for more details).
+	  peripherals and to enable or disable autosuspend. Some USB
+	  devices need to be put into suspend mode before unplugging
+	  (see Documentation/usb/power-management.txt for more details).
 
 	  Also, USB "remote wakeup" signaling is supported, whereby some
 	  USB devices (like keyboards and network adapters) can wake up
 	  their parent hub.  That wakeup cascades up the USB tree, and
 	  could wake the system from states like suspend-to-RAM.
 
-	  If you are unsure about this, say N here.
+	  If you are unsure about this, say Y here.
 
 config USB_OTG
 	bool
-- 
1.5.6.5


-- 
Li, Yan

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-01 16:03 Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Yan Li
  2009-01-01 16:07 ` [PATCH] enable CONFIG_USB_SUSPEND by default Yan Li
@ 2009-01-01 17:29 ` Alan Stern
  2009-01-02 13:23   ` Yan Li
  2009-01-01 17:32 ` Alexander E. Patrakov
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 19+ messages in thread
From: Alan Stern @ 2009-01-01 17:29 UTC (permalink / raw)
  To: Yan Li; +Cc: gregkh, linux-usb, linux-kernel

On Fri, 2 Jan 2009, Yan Li wrote:

> Hello List,
> 
> By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
> this when I got a new WDC My Book hard drive. I have no way to unplug
> it safely, according to it's manual, with a kernel that doesn't have
> CONFIG_USB_SUSPEND=y.
> 
> On it's manual read "you should unplug and remove the device only when
> the light is off."

It's not clear whether you should believe this.  The manual may have 
overstated things.  Still, better to be safe.

>  On Linux unmounting it won't turn it's light off
> and I can feel it's motor is still running.  The only way to unplug it
> properly on a Linux system, as to my knowledge, is to echo `suspend'
> to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
> CONFIG_USB_SUSPEND=y to do this.
> 
> On Windows and Mac OS, `safely remove this device' function effectly
> turns it into `suspend' mode, and it's light off.

Yes -- but they don't suspend the device; instead they disable its 
upstream port.  As far as the device is concerned, there's no 
difference.  However the Linux API doesn't include any way to disable a 
USB port.  Maybe we should add one...

> I'm new in this field and I understood people's concern on enabling
> autosuspend.  As to my understanding, `enabling suspend' and `enabling
> autosuspend' should be controlled by two different knobs.

They are.

>  I did a
> quick search in LKML and haven't found specific oppose to enable USB
> suspend by default, and Debian has started shipping a kernel with
> it turned on since 2.6.26.
> 
> Perhaps we should consider turning it on by default?  Thanks!

That is indeed the next step to take.

Alan Stern


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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be   unplugged safely
  2009-01-01 16:03 Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Yan Li
  2009-01-01 16:07 ` [PATCH] enable CONFIG_USB_SUSPEND by default Yan Li
  2009-01-01 17:29 ` Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Alan Stern
@ 2009-01-01 17:32 ` Alexander E. Patrakov
  2009-01-01 17:45   ` Alan Stern
  2009-01-02 13:37   ` Yan Li
  2009-01-01 19:09 ` Robert Hancock
  2009-01-02  9:56 ` Tino Keitel
  4 siblings, 2 replies; 19+ messages in thread
From: Alexander E. Patrakov @ 2009-01-01 17:32 UTC (permalink / raw)
  To: public-gregkh-l3A5Bk7waGM,
	public-linux-usb-u79uwXL29TY76Z2rM5mHXA,
	public-linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	public-elliot.li.tech-Re5JQEeQqe8AvxtiuMwx3w



Yan Li wrote:
> Hello List,
> 
> By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
> this when I got a new WDC My Book hard drive. I have no way to unplug
> it safely, according to it's manual, with a kernel that doesn't have
> CONFIG_USB_SUSPEND=y.
> 
> On it's manual read "you should unplug and remove the device only when
> the light is off." On Linux unmounting it won't turn it's light off
> and I can feel it's motor is still running.  The only way to unplug it
> properly on a Linux system, as to my knowledge, is to echo `suspend'
> to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
> CONFIG_USB_SUSPEND=y to do this.
> 
> On Windows and Mac OS, `safely remove this device' function effectly
> turns it into `suspend' mode, and it's light off.

You have obviously tested only Windows XP, because Vista doesn't cut the 
power for at least some USB devices. And congratulations for obtaining a 
Vista-incompatible hard drive (of course, joking).

BTW, does the "eject /dev/$DEV" command help?

-- 
Alexander E. Patrakov


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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-01 17:32 ` Alexander E. Patrakov
@ 2009-01-01 17:45   ` Alan Stern
  2009-01-02 13:37   ` Yan Li
  1 sibling, 0 replies; 19+ messages in thread
From: Alan Stern @ 2009-01-01 17:45 UTC (permalink / raw)
  To: Alexander E. Patrakov; +Cc: USB list, Kernel development list

On Thu, 1 Jan 2009, Alexander E. Patrakov wrote:

> Yan Li wrote:
> > Hello List,
> > 
> > By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
> > this when I got a new WDC My Book hard drive. I have no way to unplug
> > it safely, according to it's manual, with a kernel that doesn't have
> > CONFIG_USB_SUSPEND=y.
> > 
> > On it's manual read "you should unplug and remove the device only when
> > the light is off." On Linux unmounting it won't turn it's light off
> > and I can feel it's motor is still running.  The only way to unplug it
> > properly on a Linux system, as to my knowledge, is to echo `suspend'
> > to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
> > CONFIG_USB_SUSPEND=y to do this.
> > 
> > On Windows and Mac OS, `safely remove this device' function effectly
> > turns it into `suspend' mode, and it's light off.
> 
> You have obviously tested only Windows XP, because Vista doesn't cut the 
> power for at least some USB devices.

Yan never said that Windows cuts any power; he only said that the light 
turns off.  This is accomplished by disabling the USB port, not by 
cutting power.

> And congratulations for obtaining a 
> Vista-incompatible hard drive (of course, joking).
> 
> BTW, does the "eject /dev/$DEV" command help?

I wouldn't expect it to help, since it doesn't disable the port or put 
the device into suspend mode.

Alan Stern


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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be   unplugged safely
  2009-01-01 16:03 Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Yan Li
                   ` (2 preceding siblings ...)
  2009-01-01 17:32 ` Alexander E. Patrakov
@ 2009-01-01 19:09 ` Robert Hancock
  2009-01-02  9:56 ` Tino Keitel
  4 siblings, 0 replies; 19+ messages in thread
From: Robert Hancock @ 2009-01-01 19:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-usb

Yan Li wrote:
> Hello List,
> 
> By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
> this when I got a new WDC My Book hard drive. I have no way to unplug
> it safely, according to it's manual, with a kernel that doesn't have
> CONFIG_USB_SUSPEND=y.
> 
> On it's manual read "you should unplug and remove the device only when
> the light is off." On Linux unmounting it won't turn it's light off
> and I can feel it's motor is still running.  The only way to unplug it
> properly on a Linux system, as to my knowledge, is to echo `suspend'
> to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
> CONFIG_USB_SUSPEND=y to do this.
> 
> On Windows and Mac OS, `safely remove this device' function effectly
> turns it into `suspend' mode, and it's light off.
> 
> I'm new in this field and I understood people's concern on enabling
> autosuspend.  As to my understanding, `enabling suspend' and `enabling
> autosuspend' should be controlled by two different knobs.  I did a
> quick search in LKML and haven't found specific oppose to enable USB
> suspend by default, and Debian has started shipping a kernel with
> it turned on since 2.6.26.
> 
> Perhaps we should consider turning it on by default?  Thanks!

It's probably not a bad idea. I'm not sure how big of a problem it 
actually is, though. As long as the filesystem is unmounted before 
unplug you'll probably be OK (unless you ripped out the cable/power so 
quickly afterwards that there was still data in the write cache).

Ideally before disconnecting a removable hard drive one should flush the 
write cache and park the heads (the latter being somewhat important for 
2.5" drives in order to avoid emergency head unloads that would reduce 
the life of the drive). I believe that there's a command one can echo 
into the sd driver in sysfs somewhere that will trigger this.. Therefore 
the right sequence would be:

-unmount filesystem
-remove SCSI disk (synchronize cache and stop unit)
-suspend SCSI device

Thing is that some USB storage devices don't support both of those 
commands (I've got a USB-to-IDE enclosure with a Genesys chipset that 
doesn't translate SCSI START STOP UNIT into an IDE Standby Immediate 
command as it really should, think it just throws "invalid field in CDB" 
errors). However if we've done the above we've really done the best we 
can do..


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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-01 16:03 Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Yan Li
                   ` (3 preceding siblings ...)
  2009-01-01 19:09 ` Robert Hancock
@ 2009-01-02  9:56 ` Tino Keitel
  2009-01-02 14:00   ` Yan Li
  2009-01-02 15:50   ` Mark Lord
  4 siblings, 2 replies; 19+ messages in thread
From: Tino Keitel @ 2009-01-02  9:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, linux-usb

On Fri, Jan 02, 2009 at 00:03:43 +0800, Yan Li wrote:
> Hello List,
> 
> By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
> this when I got a new WDC My Book hard drive. I have no way to unplug
> it safely, according to it's manual, with a kernel that doesn't have
> CONFIG_USB_SUSPEND=y.
> 
> On it's manual read "you should unplug and remove the device only when
> the light is off." On Linux unmounting it won't turn it's light off
> and I can feel it's motor is still running.  The only way to unplug it
> properly on a Linux system, as to my knowledge, is to echo `suspend'
> to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
> CONFIG_USB_SUSPEND=y to do this.

With a WD My Passport drive (2,5"), I need to use sg_start --stop --pc=3
to stop the disk before unplugging it. Maybe this works with your
drive, too.  This is also required by some Firewire hard disks.  Maybe
the eject command should be extended to use this method, as it is used
also by HAL to eject hotplug devices.

Regards,
Tino

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-01 17:29 ` Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Alan Stern
@ 2009-01-02 13:23   ` Yan Li
  0 siblings, 0 replies; 19+ messages in thread
From: Yan Li @ 2009-01-02 13:23 UTC (permalink / raw)
  To: Alan Stern; +Cc: gregkh, linux-usb, linux-kernel

On Thu, Jan 01, 2009 at 12:29:51PM -0500, Alan Stern wrote:
> On Fri, 2 Jan 2009, Yan Li wrote:
> > On it's manual read "you should unplug and remove the device only when
> > the light is off."
> 
> It's not clear whether you should believe this.  The manual may have 
> overstated things.  Still, better to be safe.

Yeah, that maybe true. Better to be safe. And we can't tell users just
to ignore the warnings on the manual.

> > On Windows and Mac OS, `safely remove this device' function effectly
> > turns it into `suspend' mode, and it's light off.
> 
> Yes -- but they don't suspend the device; instead they disable its 
> upstream port.  As far as the device is concerned, there's no 
> difference.  However the Linux API doesn't include any way to disable a 
> USB port.  Maybe we should add one...

Definitely.

> >  I did a
> > quick search in LKML and haven't found specific oppose to enable USB
> > suspend by default, and Debian has started shipping a kernel with
> > it turned on since 2.6.26.
> > 
> > Perhaps we should consider turning it on by default?  Thanks!
> 
> That is indeed the next step to take.

Hope to see this happen soon.

-- 
Li, Yan

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be   unplugged safely
  2009-01-01 17:32 ` Alexander E. Patrakov
  2009-01-01 17:45   ` Alan Stern
@ 2009-01-02 13:37   ` Yan Li
  2009-01-02 13:46     ` Alexander E. Patrakov
  1 sibling, 1 reply; 19+ messages in thread
From: Yan Li @ 2009-01-02 13:37 UTC (permalink / raw)
  To: Alexander E. Patrakov; +Cc: gregkh, linux-usb, linux-kernel

On Thu, Jan 01, 2009 at 10:32:40PM +0500, Alexander E. Patrakov wrote:
> Yan Li wrote:
>> On Windows and Mac OS, `safely remove this device' function effectly
>> turns it into `suspend' mode, and it's light off.
>
> You have obviously tested only Windows XP, because Vista doesn't cut the  
> power for at least some USB devices. And congratulations for obtaining a  
> Vista-incompatible hard drive (of course, joking).

To be honest I tested neither Windows, I just picked up other Linux
user's complaints (pretty much online) who are using both Windows and
Linux and thus can compare.

Curiously, is this change in behavior btw XP and Vista another blunder
MSFT made?

> BTW, does the "eject /dev/$DEV" command help?

Nope. Unlike iPOD this device doesn't honor eject.

-- 
Li, Yan

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be   unplugged safely
  2009-01-02 13:37   ` Yan Li
@ 2009-01-02 13:46     ` Alexander E. Patrakov
  0 siblings, 0 replies; 19+ messages in thread
From: Alexander E. Patrakov @ 2009-01-02 13:46 UTC (permalink / raw)
  To: Alexander E. Patrakov, gregkh, linux-usb, linux-kernel, elliot.li.tech

Yan Li wrote:
> To be honest I tested neither Windows, I just picked up other Linux
> user's complaints (pretty much online) who are using both Windows and
> Linux and thus can compare.
> 
> Curiously, is this change in behavior btw XP and Vista another blunder
> MSFT made?

I don't know whether it is intentional. I don't have Vista installed on 
my computer (but had a beta of it on my old computer). However, Google 
search result for "vista usb flash light" suggests that other people see 
the change, too.

-- 
Alexander E. Patrakov

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02  9:56 ` Tino Keitel
@ 2009-01-02 14:00   ` Yan Li
  2009-01-02 14:08     ` Tino Keitel
                       ` (2 more replies)
  2009-01-02 15:50   ` Mark Lord
  1 sibling, 3 replies; 19+ messages in thread
From: Yan Li @ 2009-01-02 14:00 UTC (permalink / raw)
  To: Tino Keitel, Alan Stern; +Cc: gregkh, linux-usb, linux-kernel

On Fri, Jan 02, 2009 at 10:56:43AM +0100, Tino Keitel wrote:
> With a WD My Passport drive (2,5"), I need to use sg_start --stop --pc=3
> to stop the disk before unplugging it. Maybe this works with your
> drive, too.  This is also required by some Firewire hard disks.  Maybe
> the eject command should be extended to use this method, as it is used
> also by HAL to eject hotplug devices.

Hum...  I grepped my hal and hal-info packages but haven't found any
scripts using `sg_*'. I'm using hal package 0.5.11-6 from Debian
testing.

Now I know 3 methods supposed can be used to shut the device:
1. (Alan Stern said Windows use this) cut the USB port's power
2. send STOP SCSI command to stop it
3. put it into suspend mode

For the 1st method I have no much experience with Windows so I can't
verify. But now I doubt it. Since there are many early USB devices
that still show light on after you "safely remove" it from Windows. I
guess the power is still supplied but the device is send a command to
be shutdown or suspended.

For the 2nd and 3rd methods, I don't know which one is better, hope
some experts can give advice.

Whatever, I think the suspend mode is a standard USB design and the
kernel should support it by default so we should enable
CONFIG_USB_SUSPEND.

-- 
Li, Yan

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02 14:00   ` Yan Li
@ 2009-01-02 14:08     ` Tino Keitel
  2009-01-02 14:28     ` Yan Li
  2009-01-02 16:04     ` Alan Stern
  2 siblings, 0 replies; 19+ messages in thread
From: Tino Keitel @ 2009-01-02 14:08 UTC (permalink / raw)
  To: Alan Stern, gregkh, linux-usb, linux-kernel

On Fri, Jan 02, 2009 at 22:00:23 +0800, Yan Li wrote:
> On Fri, Jan 02, 2009 at 10:56:43AM +0100, Tino Keitel wrote:
> > With a WD My Passport drive (2,5"), I need to use sg_start --stop --pc=3
> > to stop the disk before unplugging it. Maybe this works with your
> > drive, too.  This is also required by some Firewire hard disks.  Maybe
> > the eject command should be extended to use this method, as it is used
> > also by HAL to eject hotplug devices.
> 
> Hum...  I grepped my hal and hal-info packages but haven't found any
> scripts using `sg_*'. I'm using hal package 0.5.11-6 from Debian
> testing.

HAL uses /usr/bin/eject, which doesn't set the power condition (as
sg_start --pc=X does).  So eject (and HAL) doesn't work with disks that
require to set the power condition.

Just try sg_start --stop --pc=3 /dev/sdX to see if it works for you.

Regards,
Tino

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02 14:00   ` Yan Li
  2009-01-02 14:08     ` Tino Keitel
@ 2009-01-02 14:28     ` Yan Li
  2009-01-02 16:04     ` Alan Stern
  2 siblings, 0 replies; 19+ messages in thread
From: Yan Li @ 2009-01-02 14:28 UTC (permalink / raw)
  To: Alan Stern; +Cc: gregkh, linux-usb, linux-kernel

On Fri, Jan 02, 2009 at 10:00:23PM +0800, Yan Li wrote:
> Now I know 3 methods supposed can be used to shut the device:
> 1. (Alan Stern said Windows use this) cut the USB port's power
> 2. send STOP SCSI command to stop it
> 3. put it into suspend mode
> 
> For the 1st method I have no much experience with Windows so I can't
> verify. But now I doubt it. Since there are many early USB devices
> that still show light on after you "safely remove" it from Windows. I
> guess the power is still supplied but the device is send a command to
> be shutdown or suspended.

Sorry, Alan have not said `cut the power'. He said `disable the port'.

-- 
Li, Yan

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02  9:56 ` Tino Keitel
  2009-01-02 14:00   ` Yan Li
@ 2009-01-02 15:50   ` Mark Lord
  2009-01-02 15:51     ` Mark Lord
  1 sibling, 1 reply; 19+ messages in thread
From: Mark Lord @ 2009-01-02 15:50 UTC (permalink / raw)
  To: linux-kernel, gregkh, linux-usb

Tino Keitel wrote:
> On Fri, Jan 02, 2009 at 00:03:43 +0800, Yan Li wrote:
>> Hello List,
>>
>> By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
>> this when I got a new WDC My Book hard drive. I have no way to unplug
>> it safely, according to it's manual, with a kernel that doesn't have
>> CONFIG_USB_SUSPEND=y.
>>
>> On it's manual read "you should unplug and remove the device only when
>> the light is off." On Linux unmounting it won't turn it's light off
>> and I can feel it's motor is still running.  The only way to unplug it
>> properly on a Linux system, as to my knowledge, is to echo `suspend'
>> to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
>> CONFIG_USB_SUSPEND=y to do this.
> 
> With a WD My Passport drive (2,5"), I need to use sg_start --stop --pc=3
> to stop the disk before unplugging it. Maybe this works with your
> drive, too.  This is also required by some Firewire hard disks.  Maybe
> the eject command should be extended to use this method, as it is used
> also by HAL to eject hotplug devices.
..

Incidently, the WD Passport drives support SG_IO,
so things like hdparm and smartctl can work with them as well.

Cheers

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02 15:50   ` Mark Lord
@ 2009-01-02 15:51     ` Mark Lord
  2009-01-02 18:15       ` Tino Keitel
  0 siblings, 1 reply; 19+ messages in thread
From: Mark Lord @ 2009-01-02 15:51 UTC (permalink / raw)
  To: linux-kernel, gregkh, linux-usb

Mark Lord wrote:
> Tino Keitel wrote:
>> On Fri, Jan 02, 2009 at 00:03:43 +0800, Yan Li wrote:
>>> Hello List,
>>>
>>> By default CONFIG_USB_SUSPEND is not enabled and today I got bite by
>>> this when I got a new WDC My Book hard drive. I have no way to unplug
>>> it safely, according to it's manual, with a kernel that doesn't have
>>> CONFIG_USB_SUSPEND=y.
>>>
>>> On it's manual read "you should unplug and remove the device only when
>>> the light is off." On Linux unmounting it won't turn it's light off
>>> and I can feel it's motor is still running.  The only way to unplug it
>>> properly on a Linux system, as to my knowledge, is to echo `suspend'
>>> to `/sys/bus/usb/devices/$DEV/power/level'. And one has to have
>>> CONFIG_USB_SUSPEND=y to do this.
>>
>> With a WD My Passport drive (2,5"), I need to use sg_start --stop --pc=3
>> to stop the disk before unplugging it. Maybe this works with your
>> drive, too.  This is also required by some Firewire hard disks.  Maybe
>> the eject command should be extended to use this method, as it is used
>> also by HAL to eject hotplug devices.
> ..
> 
> Incidently, the WD Passport drives support SG_IO,
> so things like hdparm and smartctl can work with them as well.
..

s/SG_IO/SG_IO+SAT/

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02 14:00   ` Yan Li
  2009-01-02 14:08     ` Tino Keitel
  2009-01-02 14:28     ` Yan Li
@ 2009-01-02 16:04     ` Alan Stern
  2009-01-03  2:33       ` Yan Li
  2 siblings, 1 reply; 19+ messages in thread
From: Alan Stern @ 2009-01-02 16:04 UTC (permalink / raw)
  To: Yan Li; +Cc: Tino Keitel, gregkh, linux-usb, linux-kernel

On Fri, 2 Jan 2009, Yan Li wrote:

> Now I know 3 methods supposed can be used to shut the device:
> 1. (Alan Stern said Windows use this) cut the USB port's power

I said no such thing!  In fact, I said exactly the opposite: Windows 
does _not_ cut the port's power.  Instead it disables the port.

> 2. send STOP SCSI command to stop it

Note that this is different.  The START-STOP command is used to spin-up 
or spin-down a disk.  It does not affect the state of the data link.

> 3. put it into suspend mode

As far as the device is concerned, there is essentially no difference 
between 1 and 3.  When the device's upstream port is disabled, the 
device must go into suspend mode.

The best approach is to send a SYNCHRONIZE CACHE command followed by 
START-STOP (if the device supports it), and then to disable or suspend 
the port.  In Linux, those two commands will be sent automatically if 
you unbind the device from usb-storage.  The suspend has to be done 
manually unless you have set up a udev rule (or something equivalent) 
to enable autosuspend for the device.  Of course, this requires 
CONFIG_USB_SUSPEND.

Alan Stern


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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02 15:51     ` Mark Lord
@ 2009-01-02 18:15       ` Tino Keitel
  2009-01-03  2:24         ` Yan Li
  0 siblings, 1 reply; 19+ messages in thread
From: Tino Keitel @ 2009-01-02 18:15 UTC (permalink / raw)
  To: Mark Lord; +Cc: linux-kernel, gregkh, linux-usb

On Fri, Jan 02, 2009 at 10:51:05 -0500, Mark Lord wrote:
> Mark Lord wrote:

[...]

>> Incidently, the WD Passport drives support SG_IO,
>> so things like hdparm and smartctl can work with them as well.
> ..
>
> s/SG_IO/SG_IO+SAT/

The issue I noticed with the WD Passport drives is that the hard disk
won't spin down with /usr/bin/eject, which is used by HAL if the user
ejects the device (i.e.  via his desktop environment).  The WD Passport
drives need to be set into a sleep power condition. Something
like "sg_start --pc=3 /dev/sdX" needs to be used in this case.

I just checked hdparm -Y, and this works too.

Regards,
Tino

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02 18:15       ` Tino Keitel
@ 2009-01-03  2:24         ` Yan Li
  0 siblings, 0 replies; 19+ messages in thread
From: Yan Li @ 2009-01-03  2:24 UTC (permalink / raw)
  To: Tino Keitel; +Cc: linux-kernel, gregkh, linux-usb

On Fri, Jan 02, 2009 at 07:15:38PM +0100, Tino Keitel wrote:
> The issue I noticed with the WD Passport drives is that the hard disk
> won't spin down with /usr/bin/eject, which is used by HAL if the user
> ejects the device (i.e.  via his desktop environment).  The WD Passport
> drives need to be set into a sleep power condition. Something
> like "sg_start --pc=3 /dev/sdX" needs to be used in this case.
> 
> I just checked hdparm -Y, and this works too.

STOP SCSI command spins down the drive but the device is still `on'.

The only way I found on Linux to shut down it's power is to put it
into `suspend' mode.

-- 
Li, Yan

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

* Re: Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely
  2009-01-02 16:04     ` Alan Stern
@ 2009-01-03  2:33       ` Yan Li
  0 siblings, 0 replies; 19+ messages in thread
From: Yan Li @ 2009-01-03  2:33 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-usb, linux-kernel

On Fri, Jan 02, 2009 at 11:04:40AM -0500, Alan Stern wrote:
> > Now I know 3 methods supposed can be used to shut the device:
> > 1. (Alan Stern said Windows use this) cut the USB port's power
> 
> I said no such thing!  In fact, I said exactly the opposite: Windows 
> does _not_ cut the port's power.  Instead it disables the port.

Sorry, my mistake.

> The best approach is to send a SYNCHRONIZE CACHE command followed by 
> START-STOP (if the device supports it), and then to disable or suspend 
> the port.  In Linux, those two commands will be sent automatically if 
> you unbind the device from usb-storage.  The suspend has to be done 
> manually unless you have set up a udev rule (or something equivalent) 
> to enable autosuspend for the device.  Of course, this requires 
> CONFIG_USB_SUSPEND.

Quite clear, thanks. 

-- 
Li, Yan

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

end of thread, other threads:[~2009-01-03  2:33 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-01 16:03 Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Yan Li
2009-01-01 16:07 ` [PATCH] enable CONFIG_USB_SUSPEND by default Yan Li
2009-01-01 17:29 ` Enable CONFIG_USB_SUSPEND by default or some mobile HD can't be unplugged safely Alan Stern
2009-01-02 13:23   ` Yan Li
2009-01-01 17:32 ` Alexander E. Patrakov
2009-01-01 17:45   ` Alan Stern
2009-01-02 13:37   ` Yan Li
2009-01-02 13:46     ` Alexander E. Patrakov
2009-01-01 19:09 ` Robert Hancock
2009-01-02  9:56 ` Tino Keitel
2009-01-02 14:00   ` Yan Li
2009-01-02 14:08     ` Tino Keitel
2009-01-02 14:28     ` Yan Li
2009-01-02 16:04     ` Alan Stern
2009-01-03  2:33       ` Yan Li
2009-01-02 15:50   ` Mark Lord
2009-01-02 15:51     ` Mark Lord
2009-01-02 18:15       ` Tino Keitel
2009-01-03  2:24         ` Yan Li

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).