Subject: kern/32838: USB 2.0 harddrive not recognized.
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <eau@phear.org>
List: netbsd-bugs
Date: 02/14/2006 16:10:00
>Number:         32838
>Category:       kern
>Synopsis:       USB 2.0 harddrive not recognized.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 14 16:10:00 +0000 2006
>Originator:     Eric Auge
>Release:        NetBSD 3.0
>Organization:
>Environment:
NetBSD mubutu.no.phear.org 3.0 NetBSD 3.0 (MUBUTU) #28: Tue Feb 14 16:45:29 CET 2006  root@mubutu.no.phear.org:/usr/obj/sys/arch/i386/compile/MUBUTU i386
>Description:
I just bought some USB 2.0 harddrive, and plugging in 
my USB port lead to this :
[...]
Feb 14 16:17:05 mubutu /netbsd: umass0: ITE TECH. INC. USB TO IDE, rev 2.00/2.00, addr 2
Feb 14 16:17:05 mubutu /netbsd: umass0: using SCSI over Bulk-Only
Feb 14 16:17:10 mubutu /netbsd: umass0: Get Max Lun failed: TIMEOUT
Feb 14 16:17:10 mubutu /netbsd: umass0: unable to get Max Lun: TIMEOUT
Feb 14 16:17:11 mubutu /netbsd: umass0: at uhub0 port 1 (addr 2) disconnected
Feb 14 16:17:11 mubutu /netbsd: umass0 detached
Feb 14 16:17:17 mubutu /netbsd: umass0 at uhub1 port 1 configuration 1 interface 0
[...]
Notice that booting while keeping the hardrive plugged make it 
being recognized at boot, then if unplugged it doesn't work anymore

I made a quick and dirty patch (after browsing the web for similar issues) that make USBD_TIMEOUT not fatal.

in usr/src/sys/dev/usb/umass.c 
line 1753 function umass_bbb_get_max_lun() :

[...]
        case USBD_STALLED:
+        case USBD_TIMEOUT:
[...]

I added USBD_TIMEOUT with the same behavior as STALLED since the device seems to not return STALLED correctly and just TIMEOUT.

May be i'm wrong i don't know exactly the whole issue, 
some explaination could be nice so i understand why it is behaving like this, or what need to be done to do a clean fix for this problem.

here is after this patch :
[...]
Feb 14 16:50:44 mubutu /netbsd: umass0: ITE TECH. INC. USB TO IDE, rev 2.00/2.00, addr 2
Feb 14 16:50:44 mubutu /netbsd: umass0: using SCSI over Bulk-Only
Feb 14 16:50:49 mubutu /netbsd: scsibus0 at umass0: 2 targets, 1 lun per target
Feb 14 16:50:55 mubutu /netbsd: sd0 at scsibus0 target 0 lun 0: <, SAMSUNG MP0603H, UD10> disk fixed
Feb 14 16:50:55 mubutu /netbsd: sd0: fabricating a geometry
Feb 14 16:50:55 mubutu /netbsd: sd0: 57231 MB, 57231 cyl, 64 head, 32 sec, 512 bytes/sect x 117210240 sectors
Feb 14 16:51:06 mubutu /netbsd: sd0: fabricating a geometry
[...]

Hope it helps,
Eric.
>How-To-Repeat:
just plug the hard drive while running...
>Fix:
in usr/src/sys/dev/usb/umass.c 
line 1753 function umass_bbb_get_max_lun() :

[...]
        case USBD_STALLED:
+        case USBD_TIMEOUT:
[...]

may be this isn't a fix, waiting for feedback...