Subject: sony memory stick and umass quirks
To: None <current-users@netbsd.org>
From: john heasley <heas@shrubbery.net>
List: current-users
Date: 05/05/2002 16:49:46
i mucked around with the umass_quirks.c entry for the sony MSC memory
stick as such:

        { { USB_VENDOR_SONY, USB_PRODUCT_SONY_MSC }, 
          UMASS_WPROTO_CBI, UMASS_CPROTO_RBC,
          UMASS_QUIRK_FORCE_SHORT_INQUIRY,
          /* 0, */
          PQUIRK_NOMODESENSE,
          UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
          /* NULL, umass_fixup_sony */
          NULL, NULL  
        },

with this it appears as sd0 on the sony vaio Z505LS.  it works for the
most part.  i can mount the msdos partition (sd0e) and read and delete
files (written on a sony DSC camera).  example:

/netbsd: umass0 at uhub1 port 1 configuration 1 interface 0
/netbsd: umass0: Sony USB Memory Stick Slot, rev 1.10/1.31, addr 3
/netbsd: umass0: using RBC over CBI
/netbsd: scsibus0 at umass0: 2 targets, 1 luns per target
/netbsd: scsibus0: waiting 2 seconds for devices to settle ...
/netbsd: sd0 at scsibus0 target 1 lun 0: <, , > SCSI0 0/direct fixed
/netbsd: sd0: mode sense (4) returned nonsense; using fictitious geometry
/netbsd: sd0: 31712 KB, 30 cyl, 64 head, 32 sec, 512 bytes/sect x 63424 sectors
/netbsd: sd0: mode sense (4) returned nonsense; using fictitious geometry
/netbsd: sd0: no disk label

however, writting to the partition (besides deletions) fails miserably.
copying a ~1.5M file to the partition, almost immediately i get failed
resets:

/netbsd: umass0: CBI reset failed, TIMEOUT

these occur several times and typically the device is completely hosed
thereafter and i have to power cycle the box in order to get reads to
work again.

before i start digging; are the defined quirks documented anywhere?
umassvar.h has them (all?), but is thin on documentation.  anyone have
pointers on where i might look first?

eg:
netbsd: umass0: Handling CBI state 10 (CBI Command), xfer=0xc08a7500, NORMAL_COMPLETION
netbsd: umass0: start xfer buffer=0xc08c8060 buflen=32 flags=0x5 timeout=65000
netbsd: umass0: Handling CBI state 11 (CBI Data), xfer=0xc08a7400, NORMAL_COMPLETION
netbsd: umass0: CBI_DATA actlen=32
netbsd: umass0: 0x 700000000000000a0000000000000000 buffer=0xc08c8060, buflen=32
netbsd: umass0: 0x 00000006000000000000010a00000000
netbsd: umass_scsipi_sense_cb: xs=0xc08c8000 residue=0 status=1
netbsd: umass_scsipi_sense_cb: return xs->error=1, xs->xs_status=0x1 xs->resid=0
netbsd: umass0: umass_scsi_cmd: at 1020406028.705158: 1:0 xs=0xc08c8000 cmd=0x2a datalen=1536 (quirks=0x8050, poll=0)
netbsd: umass_scsi_cmd: async dir=2, cmdlen=10 datalen=1536
netbsd: umass0: umass_cbi_transfer cmd=0x2a, len=1536
netbsd: umass0: Handling CBI state 10 (CBI Command), xfer=0xc08a7500, TIMEOUT
netbsd: umass0: failed to send ADSC
netbsd: umass0: CBI Reset
netbsd: umass0: Handling CBI state 15 (CBI Reset), xfer=0xc08a7000, TIMEOUT
netbsd: umass0: CBI reset failed, TIMEOUT
netbsd: umass0: Clear endpoint 0x81 stall
netbsd: umass0: Handling CBI state 16 (CBI bulk-in clear stall), xfer=0xc08c7f00, NORMAL_COMPLETION
netbsd: umass0: Clear endpoint 0x02 stall
netbsd: umass0: Handling CBI state 17 (CBI bulk-out clear stall), xfer=0xc08c7e00, NORMAL_COMPLETION
netbsd: umass_scsipi_cb: at 1020406158.743820, delta=130038662: xs=0xc08c8000 residue=1536 status=3
netbsd: umass_scsipi_cb: at 1020406158.743820: return xs->error=8, xs->xs_status=0x0 xs->resid=1536
netbsd: umass0: umass_scsi_cmd: at 1020406158.744167: 1:0 xs=0xc08c8000 cmd=0x2a datalen=1536 (quirks=0x8050, poll=0)
netbsd: umass_scsi_cmd: async dir=2, cmdlen=10 datalen=1536
netbsd: umass0: umass_cbi_transfer cmd=0x2a, len=1536
netbsd: umass0: Handling CBI state 10 (CBI Command), xfer =0xc08a7500, TIMEOUT
netbsd: umass0: failed to send ADSC
netbsd: umass0: CBI Reset
netbsd: umass0: Handling CBI state 15 (CBI Reset), xfer=0xc08a7000, TIMEOUT
netbsd: umass0: CBI reset failed, TIMEOUT
netbsd: umass0: Clear endpoint 0x81 stall
netbsd: umass0: Handling CBI state 16 (CBI bulk-in clear stall), xfer=0xc08c7f00, NORMAL_COMPLETION
netbsd: umass0: Clear endpoint 0x02 stall
netbsd: umass0: Handling CBI state 17 (CBI bulk-out clear stall), xfer=0xc08c7e00, NORMAL_COMPLETION

	this repeats and seems that no writes are successful.

% usbdevs -v
Controller /dev/usb0:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00
 port 1 addr 2: full speed, self powered, config 1, hub(0x1122), Philips Semiconductors(0x04cc), rev 1.10
  port 1 addr 3: full speed, self powered, config 1, USB Memory Stick Slot(0x0032), Sony(0x054c), rev 1.31
  port 2 powered
  port 3 powered
 port 2 powered