Re: [RFC] usb: storage: Auto-suspend when media is removed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 10 Jul 2010, Sarah Sharp wrote:

> (I recently found this patch languishing in my git tree.  I've updated it
> to 2.6.35-rc4, but I haven't retested it.)
> 
> A while back, Oliver Neukum made a patch to suspend mass storage devices
> between SCSI commands.  This patch uses some of the work from Oliver's
> patch.
> 
> Unfortunately, Oliver's patch made SD readers lose their minds.  After a
> suspend, all previous internal state is lost and they can't tell
> whether a card had been recently inserted or removed.  After a suspend,
> the first TEST_UNIT_READY command sent to an SD card reader will report
> "Media may have changed", and the next TEST_UNIT_READY command will report
> actual media presence or removal.  If the SD readers are suspended between
> TEST_UNIT_READY commands, they will continually report "Media may have
> changed", and no media change will ever be detected.
> 
> Disable autosuspend for a mass storage device until we know medium is not
> present, by peeking into the results of a TEST_UNIT_READY command.  I
> matched against the key, asc, and ascq fields, but I believe I only really
> need to match the asc and asq fields.
> 
> This patch is only useful if the autosuspend timeout is set to 0 seconds
> (an immediate suspend).  You can generate the udev rule to enable
> autosuspend and set the timeout with my usb-pm tool script
> (vid-pid-to-udev-rule.sh) at http://git.moblin.org/cgit.cgi/usb-pm-tool/
> 
> This patch would be even more useful if we could get userspace to stop
> polling for new media so often.
> 
> This patch works fine with empty SD card readers.  Some thumb drives
> will also autosuspend when they are unmounted or ejected from the Gnome
> filesystem GUI.  Other thumb drives always report "Medium may have
> changed" if they need to flash stupid LEDs, like the original Linux
> Plumbers Conference thumb drive.

I would prefer not to have this accepted.  There already are patches
waiting in James Bottomley's queue to add runtime PM support to the
SCSI subsystem; once they are merged, adding autosuspend to usb-storage
will be a 4-line change -- already written and tested.

(Unfortunately James is very bad about letting people know the status
of pending patches.  I have no idea when these will be merged or even
if he is willing to accept them.)

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux