From nobody@FreeBSD.org Fri Mar 31 22:53:01 2006 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4343316A420 for ; Fri, 31 Mar 2006 22:53:01 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0C84443D45 for ; Fri, 31 Mar 2006 22:53:01 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k2VMr0PV042944 for ; Fri, 31 Mar 2006 22:53:00 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k2VMr0aU042941; Fri, 31 Mar 2006 22:53:00 GMT (envelope-from nobody) Message-Id: <200603312253.k2VMr0aU042941@www.freebsd.org> Date: Fri, 31 Mar 2006 22:53:00 GMT From: Goegele Hannes To: freebsd-gnats-submit@FreeBSD.org Subject: [usb] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge X-Send-Pr-Version: www-2.3 >Number: 95173 >Category: usb >Synopsis: [umass] [patch] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge >Confidential: no >Severity: non-critical >Priority: low >Responsible: remko >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Mar 31 23:00:36 GMT 2006 >Closed-Date: Fri Mar 07 16:00:52 UTC 2008 >Last-Modified: Fri Mar 7 16:10:00 UTC 2008 >Originator: Goegele Hannes >Release: 5.5-PRERELEASE >Organization: >Environment: FreeBSD localhost 5.5-PRERELEASE FreeBSD 5.5-PRERELEASE #1: Sun Feb 5 17:26:01 CET 2006 root@Rex:/usr/obj/usr/src/sys/DESKTOPBSD i386 >Description: I bought an external 2,5 USB-Harddisk-Adapter and it's not possible to mount the disk (5 GB Fat32). The adapter and harddisk are OK and both are working well under W2K and Windows XP. Here is the kernel output: umass0: VIA Technologies Inc. USB 2.0 IDE Bridge, rev 2.00/0.03, addr 2 da0 at umass-sim0 bus 0 target 0 lun 0 da0: Fixed Direct Access SCSI-2 device da0: 1.000MB/s transfers da0: 4769MB (9767520 512 byte sectors: 255H 63S/T 608C) umass0: Invalid CSW: tag 7 should be 8 (da0:umass-sim0:0:0:0): Synchronize cache failed, status == 0x10, scsi status == 0x0 Opened disk da0 -> 5 Opened disk da0 -> 5 Opened disk da0 -> 5 Opened disk da0 -> 5 If i try to mount the disk with "mount -t msdos /dev/da0 /mnt/" the following error message appears: "msdosfs: /dev/da0: Input/output error" "usbdevs -v" gives me Controller /dev/usb0: addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00 port 1 powered port 2 addr 2: full speed, power 100 mA, config 2, USB 2.0 IDE Bridge(0x6204), VIA Technologies Inc.(0x040d), rev 0.03 >How-To-Repeat: Plug in the adapter in the usb-port. >Fix: >Release-Note: >Audit-Trail: From: "James E. Flemer" To: diazepam@gmx.net Cc: bug-followup@FreeBSD.org Subject: Re: usb/95173: [usb] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge Date: Sat, 09 Sep 2006 14:02:21 -0600 This is a multi-part message in MIME format. --------------090805000301020904040608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I have a USB enclosure with the same chip set as the submitter, but a different drive inside: umass0: VIA Technologies Inc. USB 2.0 IDE Bridge, rev 2.00/0.03, addr 2 da0 at umass-sim0 bus 0 target 0 lun 0 da0: Fixed Direct Access SCSI-2 device da0: 40.000MB/s transfers da0: 38154MB (78140160 512 byte sectors: 255H 63S/T 4864C) The device hangs on the SCSI SYNCHRONIZE_CACHE command, though I'm not sure if it is the VIA bridge or the hard drive inside. The underlying SCSI da(4) driver has a DA_Q_NO_SYNC_CACHE quirk to handle devices without working SYNC_CACHE, but I don't know how to get to the da softc from the umass driver to set the quirk flag. A quirk could be added to the scsi_da.c quirks table for the drive, but that would be a poor solution if the problem is really in the bridge. There is a interesting and related patch proposed in this email: http://lists.freebsd.org/pipermail/freebsd-current/2005-January/045779.html With the patch in that email, plus the attached umass patch to add a NO_SYNCHRONIZE_CACHE quirk, my USB enclosure works. (Note, the attached patch includes some other unrelated umass patches, use at your own risk.) -James --------------090805000301020904040608 Content-Type: text/plain; name="umass_no_sync_cache.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="umass_no_sync_cache.diff" Index: sys/dev/usb/umass.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/umass.c,v retrieving revision 1.122.2.10 diff -b -u -r1.122.2.10 umass.c --- sys/dev/usb/umass.c 26 Jun 2006 00:31:25 -0000 1.122.2.10 +++ sys/dev/usb/umass.c 9 Sep 2006 19:57:06 -0000 @@ -113,8 +113,11 @@ #include #include +#include + #include #include +#include #include #include "usbdevs.h" @@ -317,6 +320,10 @@ # define NO_INQUIRY_EVPD 0x0800 /* Pad all RBC requests to 12 bytes. */ # define RBC_PAD_TO_12 0x1000 + /* The device returns wrong CSWTAG. */ +# define WRONG_CSWTAG 0x2000 + /* Device cannot handle SYNCHRONIZE_CACHE. */ +# define NO_SYNCHRONIZE_CACHE 0x4000 }; Static struct umass_devdescr_t umass_devdescrs[] = { @@ -426,6 +433,10 @@ UMASS_PROTO_ATAPI | UMASS_PROTO_BBB, NO_INQUIRY | NO_GETMAXLUN }, + { USB_VENDOR_PANASONIC, USB_PRODUCT_PANASONIC_KXL840AN, RID_WILDCARD, + UMASS_PROTO_ATAPI | UMASS_PROTO_BBB, + NO_GETMAXLUN + }, { USB_VENDOR_PANASONIC, USB_PRODUCT_PANASONIC_KXLCB20AN, RID_WILDCARD, UMASS_PROTO_SCSI | UMASS_PROTO_BBB, NO_QUIRKS @@ -502,6 +513,10 @@ UMASS_PROTO_SCSI | UMASS_PROTO_BBB, NO_QUIRKS }, + { USB_VENDOR_VIA, USB_PRODUCT_VIA_IDE_BRIDGE, RID_WILDCARD, + UMASS_PROTO_SCSI | UMASS_PROTO_BBB, + NO_SYNCHRONIZE_CACHE + }, { USB_VENDOR_WESTERN, USB_PRODUCT_WESTERN_EXTHDD, RID_WILDCARD, UMASS_PROTO_SCSI | UMASS_PROTO_BBB, FORCE_SHORT_INQUIRY | NO_START_STOP | IGNORE_RESIDUE @@ -635,6 +650,7 @@ int timeout; /* in msecs */ int maxlun; /* maximum LUN number */ + int port; /* port on the parent hub */ }; #ifdef USB_DEBUG @@ -928,6 +944,7 @@ sc->iface = uaa->iface; sc->ifaceno = uaa->ifaceno; + sc->port = uaa->port; usb_callout_init(sc->cam_scsi_rescan_ch); /* initialise the proto and drive values in the umass_softc (again) */ @@ -1661,6 +1678,10 @@ USETDW(sc->csw.dCSWSignature, CSWSIGNATURE); } + /* Translate invalid command-status tags. */ + if (sc->quirks & WRONG_CSWTAG) + USETDW(sc->csw.dCSWTag, UGETDW(sc->cbw.dCBWTag)); + int Residue; Residue = UGETDW(sc->csw.dCSWDataResidue); if (Residue == 0 && @@ -1779,6 +1800,7 @@ usbd_device_handle udev; usb_device_request_t req; usbd_status err; + usb_port_status_t ps; usb_interface_descriptor_t *id; int maxlun = 0; u_int8_t buf = 0; @@ -1806,7 +1828,8 @@ /* Device doesn't support Get Max Lun request. */ printf("%s: Get Max Lun not supported (%s)\n", USBDEVNAME(sc->sc_dev), usbd_errstr(err)); - /* XXX Should we port_reset the device? */ + /* Reset the port on the hub for the device. */ + usbd_reset_port(sc->sc_udev, sc->port, &ps); break; } @@ -1886,6 +1909,8 @@ umass_cbi_adsc(sc, sc->cbl, SEND_DIAGNOSTIC_CMDLEN, sc->transfer_xfer[XFER_CBI_RESET1]); /* XXX if the command fails we should reset the port on the hub */ + /* Reset the port on the hub for the device. */ + /* usbd_reset_port(sc->sc_udev, sc->port, &ps); */ } Static void @@ -2896,6 +2921,15 @@ umass_scsi_transform(struct umass_softc *sc, unsigned char *cmd, int cmdlen, unsigned char **rcmd, int *rcmdlen) { + if (sc->quirks & NO_SYNCHRONIZE_CACHE + && cmd[0] == SYNCHRONIZE_CACHE) + { + printf("%s: Unsupported SCSI command 0x%02x", + USBDEVNAME(sc->sc_dev), cmd[0]); + printf("\n"); + return 0; /* failure */ + } + switch (cmd[0]) { case TEST_UNIT_READY: if (sc->quirks & NO_TEST_UNIT_READY) { Index: sys/dev/usb/usbdevs =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.232.2.16 diff -b -u -r1.232.2.16 usbdevs --- sys/dev/usb/usbdevs 20 Aug 2006 05:20:07 -0000 1.232.2.16 +++ sys/dev/usb/usbdevs 9 Sep 2006 19:57:08 -0000 @@ -1343,6 +1343,7 @@ product PALM ZIRE 0x0070 Palm Zire /* Panasonic products */ +product PANASONIC KXL840AN 0x0d01 CD-R Drive KXL-840AN product PANASONIC KXLRW32AN 0x0d09 CD-R Drive KXL-RW32AN product PANASONIC KXLCB20AN 0x0d0a CD-R Drive KXL-CB20AN product PANASONIC KXLCB35AN 0x0d0e DVD-ROM & CD-R/RW @@ -1633,6 +1634,9 @@ /* Universal Access products */ product UNIACCESS PANACHE 0x0101 Panache Surf USB ISDN Adapter +/* VIA products */ +product VIA IDE_BRIDGE 0x6204 USB 2.0 IDE Bridge + /* VidzMedia products */ product VIDZMEDIA MONSTERTV 0x4fb1 MonsterTV P2H --------------090805000301020904040608-- From: Ben Kelly To: bug-followup@FreeBSD.org, diazepam@gmx.net Cc: Subject: Re: usb/95173: [umass] [patch] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge Date: Sun, 02 Dec 2007 16:45:54 -0500 This is a multi-part message in MIME format. --------------010907000802070702090307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I bought a Rocketfish external hard drive enclosure at Best Buy a couple weeks ago and ran into this same problem. I've streamlined James's patch and updated it for 7.0-BETA3. In addition, I modified it to fake a successful sync instead of returning an error. This avoids spamming logs with failure messages and also follows the precedent set by the NO_INQUIRY quirk. As far as I can tell, this has the same end effect as setting the DA_Q_NO_SYNC_CACHE quirk in the cam layer, so I believe it should be equally safe. --------------010907000802070702090307 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="via_umass.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="via_umass.patch" --- /usr/src/sys/dev/usb/umass.c 2007-07-05 05:26:08.000000000 +0000 +++ umass.c 2007-12-02 18:45:27.576058092 +0000 @@ -323,6 +323,12 @@ * sector number. */ # define READ_CAPACITY_OFFBY1 0x2000 + /* Device cannot handle a SCSI synchronize cache command. Normally + * this quirk would be handled in the cam layer, but for IDE bridges + * we need to associate the quirk with the bridge and not the + * underlying disk device. This is handled by faking a success result. + */ +# define NO_SYNCHRONIZE_CACHE 0x4000 }; static struct umass_devdescr_t umass_devdescrs[] = { @@ -804,6 +810,10 @@ UMASS_PROTO_SCSI | UMASS_PROTO_BBB, NO_QUIRKS }, + { USB_VENDOR_VIA, USB_PRODUCT_VIA_USB2IDEBRIDGE, RID_WILDCARD, + UMASS_PROTO_SCSI | UMASS_PROTO_BBB, + NO_SYNCHRONIZE_CACHE + }, { USB_VENDOR_VIVITAR, USB_PRODUCT_VIVITAR_35XX, RID_WILDCARD, UMASS_PROTO_SCSI | UMASS_PROTO_BBB, NO_INQUIRY @@ -2878,6 +2888,15 @@ xpt_done(ccb); return; } + if ((sc->quirks & NO_SYNCHRONIZE_CACHE) && + rcmd[0] == SYNCHRONIZE_CACHE) { + struct ccb_scsiio *csio = &ccb->csio; + + csio->scsi_status = SCSI_STATUS_OK; + ccb->ccb_h.status = CAM_REQ_CMP; + xpt_done(ccb); + return; + } if ((sc->quirks & FORCE_SHORT_INQUIRY) && rcmd[0] == INQUIRY) { csio->dxfer_len = SHORT_INQUIRY_LENGTH; --- /usr/src/sys/dev/usb/usbdevs 2007-11-28 06:10:16.000000000 +0000 +++ usbdevs 2007-12-02 18:44:39.873614696 +0000 @@ -2229,6 +2229,9 @@ /* U.S. Robotics products */ product USR USR5423 0x0121 USR5423 WLAN +/* VIA Technologies products */ +product VIA USB2IDEBRIDGE 0x6204 USB 2.0 IDE Bridge + /* VidzMedia products */ product VIDZMEDIA MONSTERTV 0x4fb1 MonsterTV P2H --------------010907000802070702090307-- From: Ben Kelly To: bug-followup@freebsd.org, diazepam@gmx.net Cc: Subject: Re: usb/95173: [umass] [patch] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge Date: Sat, 26 Jan 2008 01:35:41 -0500 --Apple-Mail-95--316157853 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit My last patch did not seem to get incorporated into the bug system properly. Here is a second attempt. --Apple-Mail-95--316157853 Content-Disposition: attachment; filename=via_usb_ata_patch.txt Content-Type: text/plain; x-unix-mode=0700; name="via_usb_ata_patch.txt" Content-Transfer-Encoding: 7bit Index: src/sys/dev/usb/usbdevs =================================================================== --- src/sys/dev/usb/usbdevs (revision 6) +++ src/sys/dev/usb/usbdevs (revision 9) @@ -2229,6 +2229,9 @@ /* U.S. Robotics products */ product USR USR5423 0x0121 USR5423 WLAN +/* VIA Technologies products */ +product VIA USB2IDEBRIDGE 0x6204 USB 2.0 IDE Bridge + /* VidzMedia products */ product VIDZMEDIA MONSTERTV 0x4fb1 MonsterTV P2H Index: src/sys/dev/usb/umass.c =================================================================== --- src/sys/dev/usb/umass.c (revision 6) +++ src/sys/dev/usb/umass.c (revision 9) @@ -323,6 +323,12 @@ * sector number. */ # define READ_CAPACITY_OFFBY1 0x2000 + /* Device cannot handle a SCSI synchronize cache command. Normally + * this quirk would be handled in the cam layer, but for IDE bridges + * we need to associate the quirk with the bridge and not the + * underlying disk device. This is handled by faking a success result. + */ +# define NO_SYNCHRONIZE_CACHE 0x4000 }; static struct umass_devdescr_t umass_devdescrs[] = { @@ -804,6 +810,10 @@ UMASS_PROTO_SCSI | UMASS_PROTO_BBB, NO_QUIRKS }, + { USB_VENDOR_VIA, USB_PRODUCT_VIA_USB2IDEBRIDGE, RID_WILDCARD, + UMASS_PROTO_SCSI | UMASS_PROTO_BBB, + NO_SYNCHRONIZE_CACHE + }, { USB_VENDOR_VIVITAR, USB_PRODUCT_VIVITAR_35XX, RID_WILDCARD, UMASS_PROTO_SCSI | UMASS_PROTO_BBB, NO_INQUIRY @@ -2878,6 +2888,15 @@ xpt_done(ccb); return; } + if ((sc->quirks & NO_SYNCHRONIZE_CACHE) && + rcmd[0] == SYNCHRONIZE_CACHE) { + struct ccb_scsiio *csio = &ccb->csio; + + csio->scsi_status = SCSI_STATUS_OK; + ccb->ccb_h.status = CAM_REQ_CMP; + xpt_done(ccb); + return; + } if ((sc->quirks & FORCE_SHORT_INQUIRY) && rcmd[0] == INQUIRY) { csio->dxfer_len = SHORT_INQUIRY_LENGTH; --Apple-Mail-95--316157853 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-95--316157853-- From: Marc Fonvieille To: Ben Kelly Cc: freebsd-usb@FreeBSD.org, bug-followup@FreeBSD.org Subject: Re: usb/95173: [umass] [patch] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge Date: Sat, 26 Jan 2008 11:26:18 +0100 On Sat, Jan 26, 2008 at 07:00:06AM +0000, Ben Kelly wrote: > The following reply was made to PR usb/95173; it has been noted by GNATS. > > From: Ben Kelly > To: bug-followup@freebsd.org, diazepam@gmx.net > Cc: > Subject: Re: usb/95173: [umass] [patch] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge > Date: Sat, 26 Jan 2008 01:35:41 -0500 > > --Apple-Mail-95--316157853 > Content-Type: text/plain; > charset=US-ASCII; > format=flowed; > delsp=yes > Content-Transfer-Encoding: 7bit > > My last patch did not seem to get incorporated into the bug system > properly. Here is a second attempt. > > I can confirm this patch fixed the problem I also had with 2 VIA USB 2.0 IDE Bridge based enclosures. I did my tests on 7.0-PRERELEASE. This patch should be committed :) -- Marc From: Ben Kelly To: bug-followup@FreeBSD.org, diazepam@gmx.net Cc: Subject: Re: usb/95173: [umass] [patch] cannot mount external usb harddisk VIA Technologies Inc. USB 2.0 IDE Bridge Date: Sat, 26 Jan 2008 14:14:16 -0500 For the PR I thought I would also just throw in another thought I had. It occurred to me that since umass devices are usually designed for a "can be pulled at any time" environment, it seems likely that most of them disable write caching anyways. With that in mind, would it make more sense to disable the SYNC command by default and add a quirk for those devices where its known to be functioning and useful? This might increase the default compatibility of the FreeBSD USB stack with devices in the future. I count around 34 entries in scsi_da.c for umass devices simply to add the NO_SYNC quirk. Just a thought. If people are interested I can develop a patch for this. Responsible-Changed-From-To: freebsd-usb->remko Responsible-Changed-By: remko Responsible-Changed-When: Tue Feb 12 10:46:46 UTC 2008 Responsible-Changed-Why: After reading Mark's periodic interesting PR's grab this one to handle. http://www.freebsd.org/cgi/query-pr.cgi?pr=95173 State-Changed-From-To: open->patched State-Changed-By: remko State-Changed-When: Thu Feb 21 19:07:24 UTC 2008 State-Changed-Why: Patched in -CURRENT http://www.freebsd.org/cgi/query-pr.cgi?pr=95173 From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: usb/95173: commit references a PR Date: Thu, 21 Feb 2008 19:07:17 +0000 (UTC) remko 2008-02-21 19:07:08 UTC FreeBSD src repository Modified files: sys/dev/usb umass.c usbdevs Log: Add support for the VIA USB2IDE bridge [1]. PR: usb/95173 Submitted by: Goegele Hannes Ben Kelly Tested by: blackend Approved by: imp (mentor, blanket for simple patches) X-MFC-After: 1 week Revision Changes Path 1.162 +19 -0 src/sys/dev/usb/umass.c 1.338 +3 -0 src/sys/dev/usb/usbdevs _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: usb/95173: commit references a PR Date: Fri, 7 Mar 2008 15:54:50 +0000 (UTC) remko 2008-03-07 15:54:41 UTC FreeBSD src repository Modified files: (Branch: RELENG_7) sys/dev/usb umass.c usbdevs Log: MFC rev 1.162 umass.c MFC rev 1.338 usbdevs Add support for the VIA USB2IDE bridge [1]. PR: usb/95173 Submitted by: Goegele Hannes Ben Kelly Tested by: blackend Approved by: imp (mentor, blanket for simple patches) X-MFC-After: 1 week Approved by: imp (mentor, implicit) Revision Changes Path 1.160.2.1 +19 -0 src/sys/dev/usb/umass.c 1.328.2.5 +3 -0 src/sys/dev/usb/usbdevs _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" State-Changed-From-To: patched->closed State-Changed-By: remko State-Changed-When: Fri Mar 7 16:00:51 UTC 2008 State-Changed-Why: MFC'ed to all relevant branches, thanks for the submission! http://www.freebsd.org/cgi/query-pr.cgi?pr=95173 From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: usb/95173: commit references a PR Date: Fri, 7 Mar 2008 16:00:39 +0000 (UTC) remko 2008-03-07 16:00:28 UTC FreeBSD src repository Modified files: (Branch: RELENG_6) sys/dev/usb umass.c usbdevs Log: MFC rev 1.162 umass.c MFC rev 1.338 usbdevs Add support for the VIA USB2IDE bridge [1]. PR: usb/95173 Submitted by: Goegele Hannes Ben Kelly Tested by: blackend Approved by: imp (mentor, blanket for simple patches) X-MFC-After: 1 week Approved by: imp (mentor, implicit) Revision Changes Path 1.122.2.13 +19 -0 src/sys/dev/usb/umass.c 1.232.2.27 +3 -0 src/sys/dev/usb/usbdevs _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org" >Unformatted: