From owner-freebsd-current@FreeBSD.ORG Mon Jan 10 23:11:52 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA53616A4CE; Mon, 10 Jan 2005 23:11:52 +0000 (GMT) Received: from vidle.i.cz (vidle.i.cz [193.179.36.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A38843D46; Mon, 10 Jan 2005 23:11:52 +0000 (GMT) (envelope-from mime@traveller.cz) Received: from ns.i.cz (brana.i.cz [193.179.36.134]) by vidle.i.cz (Postfix) with ESMTP id 971A11527B; Tue, 11 Jan 2005 00:11:50 +0100 (CET) Received: from localhost (localhost.i.cz [127.0.0.1]) by ns.i.cz (Postfix) with SMTP id 75D79F4B03; Tue, 11 Jan 2005 00:11:50 +0100 (CET) X-AV-Checked: Tue Jan 11 00:11:50 2005 ns.i.cz Received: from localhost.localdomain (brana.i.cz [192.168.1.10]) by ns.i.cz (Postfix) with ESMTP id E5C7BF4B01; Tue, 11 Jan 2005 00:11:49 +0100 (CET) From: Michal Mertl To: freebsd-current@freebsd.org Content-Type: text/plain Date: Tue, 11 Jan 2005 00:11:47 +0100 Message-Id: <1105398707.726.23.camel@genius2.i.cz> Mime-Version: 1.0 X-Mailer: Evolution 2.0.3 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Subject: usb problems - ehci and umass and possible fix X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2005 23:11:53 -0000 Hello, I've just found one problem with my hardware and I did some analysis of the problem. Even when it's, as I suppose, a known issue, the fix mentioned below might help someone. I've got Pentium-M based notebook and an USB2 memory stick. When I try to use it with EHCI it fails yet it works with UHCI. I found out that it works with EHCI when I enable high debugging in EHCI driver (hw.usb.ehci.debug). ISTR I read somewhere some USB problems might be related to timing issues and that seems to confirm it - with high debug lots of messages are generated which probably slow down the operation a lot. I need to enable the debug only for attaching the device. After it succesfully attaches I can disable the debug and use the device without problems. Lately I've also seen improper initialisation with UHCI, so the problem isn't EHCI specific at the end. With UHCI I get 2 of 3 good initilizations and none whatsoever with EHCI. Error messages with debug disabled seem to come from the cam layer. umass0: M-SysT5 Dell Memory Key, rev 2.00/2.00, addr 2 umass0: SCSI over Bulk-Only; quirks = 0x0000 umass0:0:0:-1: Attached to scbus0 pass0 at umass-sim0 bus 0 target 0 lun 0 pass0: Removable Direct Access SCSI-0 device pass0: Serial Number u pass0: 1.000MB/s transfers GEOM: new disk da0 (da0:umass-sim0:0:0:0): Retrying Command (da0:umass-sim0:0:0:0): Retrying Command (da0:umass-sim0:0:0:0): Retrying Command (da0:umass-sim0:0:0:0): Retrying Command (da0:umass-sim0:0:0:0): error 6 (da0:umass-sim0:0:0:0): Unretryable Error da0 at umass-sim0 bus 0 target 0 lun 0 da0: Removable Direct Access SCSI-0 device da0: Serial Number u da0: 1.000MB/s transfers da0: Attempt to query device size failed: UNIT ATTENTION, Medium not present (da0:umass-sim0:0:0:0): READ CAPACITY. CDB: 25 0 0 0 0 0 0 0 0 0 (da0:umass-sim0:0:0:0): CAM Status: SCSI Status Error (da0:umass-sim0:0:0:0): SCSI Status: Check Condition (da0:umass-sim0:0:0:0): UNIT ATTENTION asc:3a,0 (da0:umass-sim0:0:0:0): Medium not present (da0:umass-sim0:0:0:0): (da0:umass-sim0:0:0:0): READ CAPACITY. CDB: 25 0 0 0 0 0 0 0 0 0 (da0:umass-sim0:0:0:0): UNIT ATTENTION asc:3a,0 (da0:umass-sim0:0:0:0): Medium not present Retrying Command (per Sense Data) (da0:umass-sim0:0:0:0): Retrying Command I thought the problem might be in the device doesn't get normally enough time to initialize. The debug output/failure happens immediately when the device is plugged in. I think most devices powered from USB might actually need a bit of time before they are ready to process commands. It seems FreeBSD gives them in general 300ms which is far too little. For example in Linux sources I found out a delay (or timeout) of 20 seconds for umass devices. I tried to look for information on allowed delays in usb specs but wasn't successful. One solution might be to increase the default delay #define'd in src/sys/dev/usb.h USB_PORT_POWERUP_DELAY. According to mentioned Linux source it seems no delay might be long enough :-(. Increasing it to say 2000 from the current 300ms might still be good enough for most devices. Other solution might be to add some delay before initialization of some classes of devices (like umass) or adding quirks. P.S. The increase of USB_PORT_POWERUP_DELAY really works for me. Regards Michal Mertl