From nobody@FreeBSD.org  Sat Aug  3 04:59:55 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9E4F937B400
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  3 Aug 2002 04:59:55 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 62CB643E6E
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  3 Aug 2002 04:59:55 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g73BxsOT060538
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 3 Aug 2002 04:59:54 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g73Bxsli060537;
	Sat, 3 Aug 2002 04:59:54 -0700 (PDT)
Message-Id: <200208031159.g73Bxsli060537@www.freebsd.org>
Date: Sat, 3 Aug 2002 04:59:54 -0700 (PDT)
From: Henning Meier-Geinitz <henning@meier-geinitz.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: USB scanning works only once
X-Send-Pr-Version: www-1.0

>Number:         41281
>Category:       kern
>Synopsis:       USB scanning works only once
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    njl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 03 05:00:05 PDT 2002
>Closed-Date:    Sun Apr 27 12:24:08 PDT 2003
>Last-Modified:  Sun Apr 27 12:24:08 PDT 2003
>Originator:     Henning Meier-Geinitz
>Release:        4.6
>Organization:
>Environment:
FreeBSD hmg1.meier-geinitz.de 4.6-RELEASE FreeBSD 4.6-RELEASE #0: Tue Jun 11 06:14:12 GMT 2002     murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC
>Description:
I'm trying to scan with my Mustek USB scanner (1200 UB) using SANE. Scanning works exactly once. After that successful scan I have to reboot to scan again because the scan program (e.g. scanimage) just freezes the second time it's started. This is not specific for the scanner, Mustek 1200 CU and 600 CU show the same behaviour. It also doesn't matter if SANE uses the uscanner driver or ugen (via libusb).
The same happens on OpenBSD and NetBSD. Linux works without problems.
I'm using an ohci host controller, but a quick test with NetBSD on an uhci host showed the same behaviour.
>How-To-Repeat:
More details, logs and a short test program can be found in my messages to the usb-bsd mailing list:
http://groups.yahoo.com/group/usb-bsd/message/1549
http://groups.yahoo.com/group/usb-bsd/message/1550
http://groups.yahoo.com/group/usb-bsd/message/1553
>Fix:
     
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: njl 
State-Changed-When: Fri Aug 23 17:34:48 PDT 2002 
State-Changed-Why:  
Please do "ps axl" from another console after the process has hung and 
report. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41281 

From: Nate Lawson <nate@root.org>
To: Henning Meier-Geinitz <henning@meier-geinitz.de>
Cc: freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@freebsd.org
Subject: Re: kern/41281: USB scanning works only once
Date: Sat, 24 Aug 2002 14:23:12 -0700 (PDT)

 On Sat, 24 Aug 2002, Henning Meier-Geinitz wrote:
 > 
 > ps axlww:
 > 
 >   UID   PID  PPID CPU PRI NI   VSZ  RSS WCHAN  STAT  TT       TIME COMMAND
 >     0    92     1   0   2  0   924  580 select Is    ??    0:00.00 /usr/sbin/usbd
 >     0   113     1 114   2  0   920  524 select Is    ??    0:00.00 moused -p /dev/psm0 -t auto
 >     0   131   123   0  18  0  1312  948 pause  I     v0    0:00.02 -csh (csh)
 >     0   140   131   0  10  0  1028  828 wait   I     v0    0:00.01 bash
 >     0   150   140   0   0  0   868  364 uscnrb I+    v0    0:00.00 ./testusb /dev/uscanner0
 
 What is "testusb"?  For some reason, you're just not getting any IO back
 from the scanner (it's blocking in usbd_bulk_transfer() forever).  Please
 compile your kernel with USB_DEBUG, reboot, and try again.  I'd like the
 dmesg output.  Be sure to reply-all to keep GNATS in the cc.
 
 -Nate
 

From: Henning Meier-Geinitz <henning@meier-geinitz.de>
To: Nate Lawson <nate@root.org>
Cc: Henning Meier-Geinitz <henning@meier-geinitz.de>,
	freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@freebsd.org
Subject: Re: kern/41281: USB scanning works only once
Date: Sun, 25 Aug 2002 12:48:29 +0200

 On Sat, Aug 24, 2002 at 02:23:12PM -0700, Nate Lawson wrote:
 > On Sat, 24 Aug 2002, Henning Meier-Geinitz wrote:
 > > 
 > > ps axlww:
 > > 
 > >   UID   PID  PPID CPU PRI NI   VSZ  RSS WCHAN  STAT  TT       TIME COMMAND
 > >     0    92     1   0   2  0   924  580 select Is    ??    0:00.00 /usr/sbin/usbd
 > >     0   113     1 114   2  0   920  524 select Is    ??    0:00.00 moused -p /dev/psm0 -t auto
 > >     0   131   123   0  18  0  1312  948 pause  I     v0    0:00.02 -csh (csh)
 > >     0   140   131   0  10  0  1028  828 wait   I     v0    0:00.01 bash
 > >     0   150   140   0   0  0   868  364 uscnrb I+    v0    0:00.00 ./testusb /dev/uscanner0
 > 
 > What is "testusb"?
 
 That's the test program used to make sure it's not a SANE bug. See
 How-To-Repeat section of the original bug report 
 (http://www.freebsd.org/cgi/query-pr.cgi?pr=41281), specifically:
 http://groups.yahoo.com/group/usb-bsd/message/1549
 The program intends to simply read a register from the scanner.
 
 > For some reason, you're just not getting any IO back
 > from the scanner (it's blocking in usbd_bulk_transfer() forever).
 
 That's also my impression. However, the scanner isn't defective, the
 same happens with all the Mustek scanners based on the Mustek 1017
 chipset and it doesn't happen with Linux (and Windows). Maybe the
 answer is lost somewhere on its way though the USB layer?
 
 > Please
 > compile your kernel with USB_DEBUG, reboot, and try again.  I'd like the
 > dmesg output.
 
 I think I did that in the logs mentioned in How-To-Repeat, see:
 http://groups.yahoo.com/group/usb-bsd/message/1550
 If I missed anything I can try again.
 
 > Be sure to reply-all to keep GNATS in the cc.
 
 Ok, but I did that in my last mail. gnats was'n in any of the To: or
 CC: headers. Now it is.
 
 Bye,
   Henning

From: Henning Meier-Geinitz <henning@meier-geinitz.de>
To: Nate Lawson <nate@root.org>
Cc: freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@freebsd.org
Subject: Re: kern/41281: USB scanning works only once
Date: Wed, 15 Jan 2003 14:50:01 +0100

 Hi,
 
 On Sun, Aug 25, 2002 at 12:48:29PM +0200, Henning Meier-Geinitz wrote:
 [Bug report about some Mustek USB scanners only working once in FreeBSD]
 
 After some more investigation and discussion with the Linux kernel USB
 people it seems to be clear now, that it's a hardware issue.
 
 The Mustek USB scanners that are based on the MA1017 chip (ScanExpress
 1200 CU, 1200 CU Plus, 600 CU, 1200 UB), don't reset the data toggle.
 Never (but replugging/power-cycling). That means, whenever according
 to the USB spec the toggle is set to DATA0 (clear_halt,
 set_configuration, ...), it's only done on the host and the scanner
 doesn't do it. The result is that there is a 50% chance of lost
 packets.
 
 It doesn't happen with the Linux kernel scanner driver because that
 driver doesn't call any of the functions that reset the toggle during
 open/close. However, when reloading the scanner module the timeout
 problems also occurs.
 
 The only workaround seems to be don't do any togggle resetting after
 the first read/write access. I guess it's not worth the trouble if
 these scanners are the only device that exhibit this bug.
 
 Bye,
   Henning

From: Nate Lawson <nate@root.org>
To: Henning Meier-Geinitz <henning@meier-geinitz.de>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/41281: USB scanning works only once
Date: Wed, 12 Mar 2003 21:30:16 -0800 (PST)

 Please send me a pointer to the relevant code in the linux driver and I
 may be able to put together a workaround.
 
 -Nate
 

From: Henning Meier-Geinitz <henning@meier-geinitz.de>
To: Nate Lawson <nate@root.org>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/41281: USB scanning works only once
Date: Thu, 13 Mar 2003 17:58:14 +0100

 Hi,
 
 On Wed, Mar 12, 2003 at 09:30:16PM -0800, Nate Lawson wrote:
 > Please send me a pointer to the relevant code in the linux driver and I
 > may be able to put together a workaround.
 
 Well, the problem is that there is no special code in the Linux kernel
 for working-around the problem. My observation is that the Linux
 kernel invokes functions that change the USB toggle (e.g.
 set_configuration) only on driver load/plugging in the device. BSD
 seems to change the toggle on every open() (and/or close()?) of a USB
 device file. That's not wrong, it just triggers this hardware bug.
 
 I don't know the FreeBSD kernel internals but I gues it's not easy to
 work around this bug without changing the way how USB is handled in
 general.
 
 E.g. set_configuration in Linux is only called in usb_new_device()
 (drivers/usb/core/usb.c) which is called by the hub driver on device
 connect. That's with linux 2.5.64.
 
 Bye,
   Henning
Responsible-Changed-From-To: freebsd-bugs->njl 
Responsible-Changed-By: njl 
Responsible-Changed-When: Fri Mar 14 15:21:24 PST 2003 
Responsible-Changed-Why:  

I have been working on this with the submitter and will be looking into how 
linux does things. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41281 
State-Changed-From-To: feedback->closed 
State-Changed-By: njl 
State-Changed-When: Sun Apr 27 12:23:04 PDT 2003 
State-Changed-Why:  

This PR can serve as a history for this behavior but until someone is 
willing to rework our USB stack as apparently necessary, this will not 
be fixed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41281 
>Unformatted:
