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

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

 



On Sat, Jul 10, 2010 at 02:10:19PM -0400, Alan Stern wrote:
> 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.

Ok.  I knew that the runtime-PM patches for SCSI were in the works.
However, they've been in the works for a long time now, and I wasn't
sure if anyone was interested in an interim solution.  I hacked this
together last February, and it's saved about 0.25 watts on average for
netbooks with built-in SD cards running Moblin/MeeGo.  (It actually
makes the power consumption of Linux better than Windows XP.)

I know this is a layering violation and not *the right* solution, but I
wanted to make sure the patch didn't languish out-of-tree if it could
get merged.

That said, I don't feel strongly about whether this particular patch
gets merged.  I do feel strongly that there needs to be a solution to
the USB storage PM issue.

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

I think he's giving a talk at OSCON next week, so I'll poke him if I see
him.

Sarah Sharp
--
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