[sane-devel] sane to work with USB 3.0

m. allan noah kitno455 at gmail.com
Fri Nov 7 02:44:09 UTC 2014

I have added a USB3 port to my computer, and have spent a few days
investigating this problem.

It seems to be a bug in Linux kernel related to a bookkeeping error
when the USB device is closed. Sane devices are typically closed after
device detection, and again after the scanning program exits. Contrast
this with Windows, where the driver is a long-running process that
typically communicates with the scanner the entire time it and the
computer are powered on. Each of these closing events is an
opportunity for the host and the device to become confused about the
status of the DATA0/DATA1 toggle, which is used by the USB to detect
dropped packets.

In the current ehci (USB2) implementation in Linux, simply
re-transmitting a packet is enough to re-synchronize the two sides and
prevent data loss. This does not seem to be the case with the Linux
xhci (USB3) driver. This seems to be a known class of issue, and there
has been some movement toward a proper fix on the linux-usb mailing
list. There are some patches available from one of the authors which
might address the problem, but I have not had time to try them.

In the interim, I have added what I consider to be an ugly (but small)
hack to the sane-fujitsu backend. The idea is to count the number of
read and write packets, and prior to disconnection, to send one or
more additional commands to the scanner. This will allow us to have an
even number of packets of both types. Then, the next time we use the
scanner, both the kernel and the scanner will be using DATA0 for the
first packet. I have tested this with an fi-6110 and an fi-7160, and
it seems to work.

I have committed these changes to sane-backends git repo in
7a590f362e7e93979b706dd9e6ae34584e926ec3. If users of fujitsu scanners
could try it out, I would appreciate any feedback. Note that this does
not fix USB3 problems in other sane backends. Until the kernel is
fixed, these types of repairs will have to be made on a per-backend
basis, at the discretion of the maintainer.

If anyone is interested in testing the kernel patches or joining in
that discussion, see:


On Sun, Nov 2, 2014 at 2:47 PM, Andreas Bartels
<andreas_bartels at t-online.de> wrote:
> Dear Sirs,
> I tried everything and comiled at the end sane by myself, but it only helped
> to get sane-find-scanner working.
> Every time I try to do something like scanning my fujitsu snapscan S1500 is
> disapearing in the list while he is in scanimage -L for the first time use.
> The Brother DCP-7030 scanner is allways shown since I did all what shall be
> needed. the only common fault is that at every scantry, not depending which
> scanner I get a fault and it isn't scanning at all.
> After a look round I found at different places the same fault with different
> scanners but allways one common, xhci_hcd was used where the scanners did
> not work. So on my PC its the same for all USB ports and even if I put a USB
> 2.0 Hub between it does use this driver or module for the USB end.
> But in all the other cases I watched they told the sane driver wouldn't take
> it and on some Notebooks it was more told likewise USB 3.0 isn't compatible
> to USB 2.0. So is there any way arround to get it working, because the ware
> vuescan on the same system does work.
> best regards
> Andreas Bartels
> --
> sane-devel mailing list: sane-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
>             to sane-devel-request at lists.alioth.debian.org

"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"

More information about the sane-devel mailing list