[sane-devel] Workaround for CONFIG_USB_SUSPEND now in CVS

Julien BLACHE jb at jblache.org
Sun Jul 29 18:52:32 UTC 2007


Hi,

CONFIG_USB_SUSPEND, a Linux kernel option that makes the USB layer
automatically put USB devices to suspend state when they're not in
use, has exposed a number of bugs in pretty much all the USB
scanners.

Upon being suspended, the scanners will usually do an unplug/plug
cycle instead of going into the suspended state - what really happens
in most cases is that the scanner resets himself, loosing its settings
and sometimes its firmware. Some scanners may react differently,
exposing more hardware bugs (eg. their USB interface may crash).

Starting with Linux 2.6.22, two things have happened:
 - a blacklist for the autosuspend feature, in which a lot of scanners
are being added, mainly by Oliver Neukum from what I've seen, has been
added. As of 2.6.22, the blacklist only has 2 or 3 entries IIRC, and
is already greatly expanded in Greg KH's git tree - so this will make
it into 2.6.23. This blacklist alone is obviously not going to cut it;
we've got rid of the scanner kernel module because it was painful to
keep it up to date and to update it on user's machine every time we
needed to add a USB ID. This blacklist is just the same thing.

 - a sysfs attribute has been added to USB devices that allows turning
off the USB autosuspend feature on a per-device basis. This attribute
can be found under /sys/bus/usb/devices/*/power/level.


By doing echo on > /sys/bus/usb/devices/<device id>/power/level, it is
possible to disable the USB autosuspend feature (and wake the scanner
up if it's suspended).

By doing echo suspend > /sys/bus/usb/devices/<device id>/power/level,
it is possible to force a device into suspend mode (and it won't be
waken up automatically).

By doing echo auto > /sys/bus/usb/devices/<device id>/power/level, the
default behaviour of automatically suspending the device can be
restored.


So, as of a few minutes ago, the udev rules generated by sane-desc
include a new RUN rule that will disable the USB autosuspend feature
for all the scanners we know.


That's the end of "black scans" as long as you run a kernel >= 2.6.22
and this sysfs interface doesn't change :-)

Have fun,

JB.

-- 
Julien BLACHE                                   <http://www.jblache.org> 
<jb at jblache.org>                                  GPG KeyID 0xF5D65169



More information about the sane-devel mailing list