From dillon@FreeBSD.org  Thu Dec 19 17:36:58 2002
Return-Path: <dillon@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 305E137B401; Thu, 19 Dec 2002 17:36:58 -0800 (PST)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 3A0E343EDA; Thu, 19 Dec 2002 17:36:57 -0800 (PST)
	(envelope-from dillon@FreeBSD.org)
Received: from freefall.freebsd.org (dillon@localhost [127.0.0.1])
	by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gBK1avx3050284;
	Thu, 19 Dec 2002 17:36:57 -0800 (PST)
	(envelope-from dillon@freefall.freebsd.org)
Received: (from dillon@localhost)
	by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gBK1avlO050283;
	Thu, 19 Dec 2002 17:36:57 -0800 (PST)
Message-Id: <200212200136.gBK1avlO050283@freefall.freebsd.org>
Date: Thu, 19 Dec 2002 17:36:57 -0800 (PST)
From: Matt Dillon <dillon@FreeBSD.org>
Reply-To: Matt Dillon <dillon@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: njl@freebsd.org
Subject: QUIRK: Sony USB Storage Media USM128
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         46386
>Category:       kern
>Synopsis:       QUIRK: Sony USB Storage Media USM128
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    njl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 19 17:40:03 PST 2002
>Closed-Date:    Sun Jan 12 21:09:33 PST 2003
>Last-Modified:  Sun Jan 12 21:09:33 PST 2003
>Originator:     Matt Dillon
>Release:        FreeBSD 4.7-STABLE i386 / FreeBSD-current
>Organization:
>Environment:

	All FreeBSD systems

>Description:

	mobile# camcontrol inquiry da8
	pass0: <Sony Storage Media 2.51> Removable Direct Access SCSI-0 device 
	pass0: Serial Number u
	pass0: 650KB/s transfers 

mobile# usbdevs -v
Controller /dev/usb0:
addr 1: self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
 port 1 powered
  port 2 addr 2: power 94 mA, config 1, USB Storage Media(0x0010), Sony(0x08ec), rev 2.00

	Manufacturer is Sony (but probably OEMs from MSYSTEMS), 
	model USM128.

	I've done considerable work testing the need for the quirk entry,
	I'm not going to include it all here.  The quirk entry is only
	wildcarded for the rev.  The first to items are exact.  The 
	6->10 hack code in umass does not seem to be sufficient so
	the quirk contains both DA_Q_NO_SYNC_CACHE and DA_Q_NO_6_BYTE.
	Both 6-byte c ommands and any attempt to synchronizing the 
	cache locks up the unit.

>How-To-Repeat:

	Plug in one of these devices :-)

>Fix:

	Quirk entry patch as shown below, in combination with additional
	fixes to USB not included.

Index: sys/cam/scsi/scsi_da.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_da.c,v
retrieving revision 1.118
diff -u -r1.118 scsi_da.c
--- sys/cam/scsi/scsi_da.c	18 Dec 2002 21:47:52 -0000	1.118
+++ sys/cam/scsi/scsi_da.c	19 Dec 2002 21:56:31 -0000
@@ -271,6 +271,16 @@
 	},
 	{
 		/*
+		 * Sony Key-Storage media fails in terrible ways without
+		 * both quirks.  The auto 6->10 code doesn't do the job.
+		 * (note: The Sony diskkey is actually the MSYSTEMS 
+		 * disk-on-key device).
+		 */
+		{T_DIRECT, SIP_MEDIA_REMOVABLE, "Sony", "Storage Media", "*"},
+		/*quirks*/ DA_Q_NO_6_BYTE|DA_Q_NO_SYNC_CACHE
+	},
+	{
+		/*
 		 * Sony DSC cameras (DSC-S30, DSC-S50, DSC-S70)
 		 */
 		{T_DIRECT, SIP_MEDIA_REMOVABLE, "Sony", "Sony DSC", "*"},
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: njl 
State-Changed-When: Sat Dec 21 14:52:37 PST 2002 
State-Changed-Why:  
Quirk maintainer, soliced feedback 


Responsible-Changed-From-To: freebsd-bugs->njl 
Responsible-Changed-By: njl 
Responsible-Changed-When: Sat Dec 21 14:52:37 PST 2002 
Responsible-Changed-Why:  
Quirk maintainer, soliced feedback 

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

From: Nate Lawson <nate@root.org>
To: Matt Dillon <dillon@FreeBSD.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/46386
Date: Sat, 21 Dec 2002 14:50:45 -0800 (PST)

 Hanging in response to a 6 byte cmd is invalid and requires a quirk,
 responding with a CHECK CONDITION is correct and we handle it.  From your
 info, looks like the quirk is needed.
 
 Please send dmesg for failed attempts (no quirk but with your USB fixes).  
 This will help us adapt to nonstandard devices in the future.
 
 -Nate
 

From: Matthew Dillon <dillon@apollo.backplane.com>
To: Nate Lawson <nate@root.org>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/46386
Date: Sat, 21 Dec 2002 20:43:45 -0800 (PST)

 :
 :Hanging in response to a 6 byte cmd is invalid and requires a quirk,
 :responding with a CHECK CONDITION is correct and we handle it.  From your
 :info, looks like the quirk is needed.
 :
 :Please send dmesg for failed attempts (no quirk but with your USB fixes).  
 :This will help us adapt to nonstandard devices in the future.
 :
 :-Nate
 
     Ok, here's the output.  I've included the pertainent information
     from the dmesg without any scsi quirks.  Then I run the test a
     second time with just the DA_Q_NO_SYNC_CACHE quirk.  Then, finally,
     I included the boot dmesg output (unrelated to any tests) for reference.
 
 umass0: Sony USB Storage Media, rev 1.10/2.00, addr 2
 umass0: Get Max Lun not supported (SHORT_XFER)
 da0 at umass-sim0 bus 0 target 0 lun 0
 da0: <Sony Storage Media 2.51> Removable Direct Access SCSI-0 device 
 da0: 1.000MB/s transfers
 da0: Attempt to query device size failed: UNIT ATTENTION, Not ready to ready change,
 	(the above is due to umass not waiting for the device to power up,
 	the SCSI system retries and succeeds, though there are still issues
 	there they are not related to this problem)
 
 	about 60 seconds elapses now (it's stuck trying to synchronize the
 	cache).
 
 (da0:umass-sim0:0:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0
 
 	about 30 seconds elapses (I assume it's trying to read the label
 	information here).
 
 Opened disk da0 -> 5
 
 	And this is where it stops.  /dev/da0 exists now but the system 
 	has failed to recognize the partition table.  i.e. there is no
 	/dev/da0s1 or /dev/da0s1a.
 
 	Additionally, /dev/da0 does not work.  If I issue a
 
 	    dd if=/dev/da0 of=/dev/null bs=512 count=4
 
 	I get dd: /dev/da0: Input/output error.
 
     If I do it a second time, I get another I/O error.  Repeated attempts
     fail.  In otherwords the USB device is hosed.  To me this simply means
     that the attempt to synchronize the cache (there being no Quirk entry)
     has placed the USB device in an unrecoverable situation.  
 
 		    ---------- SECOND TEST -----------
 
     However, it does not adequately test whether we need the DA_Q_NO_6_BYTE 
     quirk.  To test that I recompiled the kernel with just the
     DA_Q_NO_SYNC_CACHE quirk.  This should test whether the DA_Q_NO_6_BYTE
     quirk is required.
 
 umass0: Sony USB Storage Media, rev 1.10/2.00, addr 2
 umass0: Get Max Lun not supported (SHORT_XFER)
 da0 at umass-sim0 bus 0 target 0 lun 0
 da0: <Sony Storage Media 2.51> Removable Direct Access SCSI-0 device 
 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:28,0
 (da0:umass-sim0:0:0:0): Not ready to ready change, medium may have changed
 (da0:umass-sim0:0:0:0): Retrying Command (per Sense Data)
 
     The above is again due to umass interaction with the usb device and
     unrelated to the SCSI issue.
 
 (here it skips tring to do a sync, there is no output)
 (here it's obviously stick trying to do something, like read the label)
 
     That's all the output.  I try to do a:
 
 	dd if=/dev/zero of=/dev/null bs=512 count=4
 
     And I get (after 25 seconds)
 
 	dd: /dev/da0: Input/output error
 
     This seems to indicate that that DA_Q_NO_6_BYTE quirk is also required.
     Which makes sense.  When this particular device gets something it 
     doesn't like nothing short of pulling it out of the socket and sticking
     it back in seems to reset it.
 
     As a double-check I enabled both quirk entries, rebooted, and retested.
     Everything worked.
 
     Finally, I include the full dmesg output from the first test showing
     all the boot information.  Don't ask me what the port errors are
     during boot, I have no clue.  It doesn't seem to effect USB operation
     after booting.
 
     I think, in general, USB devices that can't 6-byte or cache-synch will
     tend to lock up entirely and require quirk entries.  The 6->10 backoff
     code isn't going to help since the devices tend to go south the moment
     they get the 6-byte request.
 
     By the way, I ran these tests on an EPIA5000 mini-itx motherboard.  But
     the results are the same on my DELL2550's.  It only takes 30 seconds 
     for the EPIA's to netboot which is why I ran the tests on them.
 
 						-Matt
 
 
 
 Copyright (c) 1992-2002 The FreeBSD Project.
 Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
 	The Regents of the University of California. All rights reserved.
 FreeBSD 5.0-CURRENT #2: Sat Dec 21 16:04:03 PST 2002
     dillon@apollo.backplane.com:/usr/obj/FreeBSD/FreeBSD-current/src/sys/EPIA5000
 Preloaded elf kernel "kernel" at 0xc0429000.
 Timecounter "i8254"  frequency 1193182 Hz
 Timecounter "TSC"  frequency 533355106 Hz
 CPU: VIA C3 Samuel 2 (533.36-MHz 686-class CPU)
   Origin = "CentaurHauls"  Id = 0x673  Stepping = 3
   Features=0x803035<FPU,DE,TSC,MSR,MTRR,PGE,MMX>
 real memory  = 259981312 (247 MB)
 avail memory = 248037376 (236 MB)
 Initializing GEOMetry subsystem
 npx0: <math processor> on motherboard
 npx0: INT 16 interface
 Using $PIR table, 5 entries at 0xc00fdc70
 pcib0: <Host to PCI bridge> at pcibus 0 on motherboard
 pci0: <PCI bus> on pcib0
 pcib1: <PCI-PCI bridge> at device 1.0 on pci0
 pci1: <PCI bus> on pcib1
 pci1: <display, VGA> at device 0.0 (no driver attached)
 isab0: <PCI-ISA bridge> at device 17.0 on pci0
 isa0: <ISA bus> on isab0
 atapci0: <VIA 8231 ATA100 controller> port 0xd000-0xd00f at device 17.1 on pci0
 ata0: at 0x1f0 irq 14 on atapci0
 ata1: at 0x170 irq 15 on atapci0
 uhci0: <VIA 83C572 USB controller> port 0xd400-0xd41f irq 3 at device 17.2 on pci0
 usb0: <VIA 83C572 USB controller> on uhci0
 usb0: USB revision 1.0
 uhub0: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub0: 2 ports with 2 removable, self powered
 uhub0: port error, restarting port 1
 uhub0: port error, giving up port 1
 uhub0: port error, restarting port 2
 uhub0: port error, giving up port 2
 uhci1: <VIA 83C572 USB controller> port 0xd800-0xd81f irq 3 at device 17.3 on pci0
 usb1: <VIA 83C572 USB controller> on uhci1
 usb1: USB revision 1.0
 uhub1: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub1: 2 ports with 2 removable, self powered
 uhub1: port error, restarting port 1
 uhub1: port error, giving up port 1
 uhub1: port error, restarting port 2
 uhub1: port error, giving up port 2
 pci0: <bridge, PCI-unknown> at device 17.4 (no driver attached)
 pci0: <multimedia, audio> at device 17.5 (no driver attached)
 vr0: <VIA VT6102 Rhine II 10/100BaseTX> port 0xe800-0xe8ff mem 0xd7000000-0xd70000ff irq 11 at device 18.0 on pci0
 vr0: Ethernet address: 00:40:63:c1:34:87
 miibus0: <MII bus> on vr0
 ukphy0: <Generic IEEE 802.3u media interface> on miibus0
 ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
 orm0: <Option ROMs> at iomem 0xcc000-0xd57ff,0xc0000-0xcbfff on isa0
 atkbdc0: <Keyboard controller (i8042)> at port 0x64,0x60 on isa0
 atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
 psm0: <PS/2 Mouse> irq 12 on atkbdc0
 psm0: model IntelliMouse, device ID 3
 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
 sc0: <System console> at flags 0x100 on isa0
 sc0: VGA <16 virtual consoles, flags=0x300>
 sio0 at port 0x3f8-0x3ff irq 4 flags 0x90 on isa0
 sio0: type 16550A
 sio1: configured irq 3 not in bitmap of probed irqs 0
 sio1: port may not be enabled
 ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
 ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
 lpt0: <Printer> on ppbus0
 lpt0: Interrupt-driven port
 unknown: <PNP0303> can't assign resources (port)
 unknown: <PNP0f13> can't assign resources (irq)
 unknown: <PNP0501> can't assign resources (port)
 unknown: <PNP0400> can't assign resources (port)
 Timecounters tick every 10.000 msec
 Sending DHCP Discover packet from interface vr0 (00:40:63:c1:34:87)
 Received DHCP Offer packet on vr0 from 216.240.41.12 (accepted) (no root path)
 Sending DHCP Request packet from interface vr0 (00:40:63:c1:34:87)
 Received DHCP Ack packet on vr0 from 216.240.41.12 (accepted) (got root path)
 vr0 at 216.240.41.57 server 216.240.41.12 server name apollo.backplane.com boot file pxeboot
 subnet mask 255.255.255.192 router 216.240.41.15 rootfs 216.240.41.12:/ 
 Adjusted interface vr0
 Mounting root from nfs:
 NFS ROOT: 216.240.41.12:/
 md0: Malloc disk
 md1: Malloc disk
 md2: Malloc disk
 umass0: Sony USB Storage Media, rev 1.10/2.00, addr 2
 umass0: Get Max Lun not supported (SHORT_XFER)
 da0 at umass-sim0 bus 0 target 0 lun 0
 da0: <Sony Storage Media 2.51> Removable Direct Access SCSI-0 device 
 da0: 1.000MB/s transfers
 da0: Attempt to query device size failed: UNIT ATTENTION, Not ready to ready change,
 (da0:umass-sim0:0:0:0): Synchronize cache failed, status == 0x4, scsi status == 0x0
 Opened disk da0 -> 5
State-Changed-From-To: feedback->closed 
State-Changed-By: njl 
State-Changed-When: Sun Jan 12 20:55:16 PST 2003 
State-Changed-Why:  
Committed in scsi_da.c:1.121   MFC in 3 days 

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