All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Patrick Mansfield <patmans@us.ibm.com>
Cc: Dmitri Katchalov <dmitrik@users.sourceforge.net>,
	Idan Sofer <idan@idanso.dyndns.org>,
	ronald@kuetemeier.com,
	USB development list <linux-usb-devel@lists.sourceforge.net>,
	SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [linux-usb-devel] usb-storage and Sony Handycam
Date: Sat, 8 Nov 2003 22:47:26 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.0311082220430.7127-100000@netrider.rowland.org> (raw)
In-Reply-To: <20031108123749.A3892@beaverton.ibm.com>

On Sat, 8 Nov 2003, Patrick Mansfield wrote:

> On Sat, Nov 08, 2003 at 11:28:37AM -0500, Alan Stern wrote:
> 
> > The "fake sense" is a compromise.  It lets us give a clear indication to 
> > the higher layers that something is wrong and asks them not to send the 
> > same command again.  But it doesn't do much about getting the device back 
> > into a working state (if that's even possible).
> 
> Looking closer at the USB code, is the fake_sense code even hit? The logs
> do not show any of the US_DEBUGP in usb_stor_Bulk_transport(), like
> "Bulk Command S ...".

It probably wasn't hit.  The fake sense data is only sent for devices 
using the Bulk-only transport, and Dmitri's and Idan's devices use the 
Control-Bulk transport IIRC.

> A DID_ERROR causes scsi core to retry the command - it will not even check
> the sense data. A DID_ABORT might be better, scsi core will not retry.
> (We still have issue 1, where the host byte is not checked in
> scsi_status_is_good.)

For CB and CBI devices, babble causes a DID_ERROR return.  For Bulk-only 
it causes a Check-Condition status to be returned along with Invalid 
Command sense data.  Like I said earlier, we haven't yet figured out the 
best way to handle these errors.

> > > That still doesn't tell us why the MODE SENSE failed, and why the failure
> > > does not show up with 2.4.
> > 
> > The best approach for doing this is to have a side-by-side comparison of 
> > the usb-storage debugging logs for 2.4 and 2.6.
> 
> Yes, we do not have a 2.4 trace of the same device.
> 
> > I think we have to assume 
> > that the MODE-SENSE failed because the device simply doesn't support it 
> > correctly.
> > 
> > > Can you run the variants on MODE SENE via user space SG_IO, and figure out
> > > which ones work?
> 
> Still no data on the above (from Dmitri or Ronald).

Doing that will probably be a waste of time.  I firmly believe that there 
is _no_ least common denominator among USB mass storage devices: Some 
work with any MODE-SENSE command, some work with only a few variants, 
others work with others.  Maybe some devices don't work with MODE-SENSE at 
all.  In any case, there isn't any single combination of 
pages/transfer-lengths that will be accepted by every device.  And when a 
device fails to accept such a command it often does so catastrophically, 
requiring a power-cycle to start working again.

The only safe course is to avoid sending these commands at all to the 
devices that can't handle them.

> > > 3) The next command - TEST UNIT READY - gets a check condition, illegal
> > > request. Maybe the fake sense handling is screwing things up - the device
> > > tells us it sent back more data than we asked for, but it is also trying
> > > to check us.
> > 
> > I don't understand your speculation here.  It seems clear to me that this 
> > is a situation where the device and the host are out of sync -- the host 
> > sends a command and the device sends back status from the _previous_ 
> > command.  Repeating the TEST-UNIT-READY may bring us back in sync.  Or 
> > maybe some sort of reset will -- no way to tell without trying it.
> 
> The sense data is not cleared until it is retrieved, so if there is sense
> waiting, and we do not send a REQUEST SENSE, the next REQUEST SENSE will
> retrieve the pre-existing sense data (see SAM-3, I am looking at
> sam3r07.pdf, section 5.9.6 sense data).

Hmmm...  I'm more used to an earlier version of the SCSI protocol,
according to which old sense data is lost whenever a new command is
received unless that command is REQUEST-SENSE.

> If the actual result of the command was checked in the babble cases, and a
> REQUEST SENSE sent, it might have gotten the ILLEGAL REQUEST, and the
> devices sense data might be cleared. It might be bad to do anything for
> babble cases, but the REQUEST SENSE should be sent to at least clear out
> any real sense data if we are going to generate our own fake sense.

There's isn't any reliable way to get the command result or the sense data
after a babble occurs -- in fact, there isn't a reliable way to
re-establish communication with the device at all.  My best thought on
this has been to try reading (and throwing away) data from the device
until a 5-second (for example) timeout expires without receiving anything,
then issue a device reset.  That's more likely to recover from this sort
of error than anything else I can think of, but it's never been 
implemented.

I have seen logs from users where a device reset was sent following a 
babble error.  It didn't help; the device remained wedged.

The USB Mass Storage specification documents are silent on the issue of
babble.  And even if they weren't it probably wouldn't help; the only
reason these devices start babbling is because they aren't compliant with
the standards in the first place.

> Dmitri's change (return USB_STOR_XFER_STALL instead of USB_STOR_XFER_LONG)
> causes us to return USB_STOR_TRANSPORT_GOOD vs USB_STOR_TRANSPORT_ERROR in
> usb_stor_CB_transport. 
> 
> Then in usb_stor_invoke_transport we issue a REQUEST SENSE. 
> 
> If for a USB_STOR_TRANSPORT_ERROR we also did a REQUEST SENSE, the
> following command (TEST UNIT READY) would not get the ILLEGAL REQUEST.

That doesn't make sense.  USB_STOR_TRANSPORT_ERROR means we aren't able to 
communicate with the device.  So how can we send it a REQUEST-SENSE?

> I don't know why the TEST UNIT READY caused an auto REQUEST SENSE to
> be sent.

The CB transport doesn't include any means for the device to return
status.  (Yes, it's stupid.)  The only way we can find out is to issue
auto REQUEST-SENSE for virtually every command.

> Changing the sense stuff does not address the MODE SENSE failing, we still
> have 3 separate issues that are all hit by this device.

If we simply avoided sending the MODE-SENSE in the first place, none of 
the other issues would come up.  IMHO that's the best solution.

Alan Stern


  reply	other threads:[~2003-11-09  3:47 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1068207145.3fab8c2988d43@webmail.netregistry.net>
2003-11-07 16:21 ` usb-storage and Sony Handycam Alan Stern
2003-11-07 17:29   ` Patrick Mansfield
2003-11-07 19:49     ` Alan Stern
2003-11-08  2:54       ` Dmitri Katchalov
2003-11-08  6:34         ` Patrick Mansfield
2003-11-08 13:29           ` Dmitri Katchalov
2003-11-08 16:28           ` Alan Stern
2003-11-08 20:37             ` Patrick Mansfield
2003-11-09  3:47               ` Alan Stern [this message]
2003-11-09  8:45                 ` [linux-usb-devel] " Dmitri Katchalov
2003-11-10 20:45                   ` Patrick Mansfield
2003-11-10 17:59                 ` Patrick Mansfield
2003-11-10 18:46                   ` Alan Stern
2003-11-10 19:04                     ` [linux-usb-devel] " Patrick Mansfield
2003-11-10 19:57                       ` Alan Stern
2003-11-10 22:46                     ` Sancho Dauskardt
2003-11-18 15:20                   ` Unaligned scatter-gather buffers and usb-storage Alan Stern
2003-11-18 22:37                     ` Patrick Mansfield
2003-11-19  8:47                       ` Jens Axboe
2003-11-19 13:01                         ` [linux-usb-devel] " Oliver Neukum
2003-11-19 13:04                           ` Jens Axboe
2003-11-19 14:37                             ` James Bottomley
2003-11-19 14:39                               ` Jens Axboe
2003-11-19 14:58                                 ` James Bottomley
2003-11-19 15:00                                   ` [linux-usb-devel] " Jens Axboe
2003-11-19 16:56                                     ` Kai Makisara
2003-11-19 20:19                                       ` Jens Axboe
2003-11-19 22:06                                         ` Kai Makisara
2003-11-20  6:53                                           ` Jens Axboe
2003-11-20 15:20                                             ` Alan Stern
2003-11-20 15:30                                               ` Jens Axboe
2003-11-20 16:09                                                 ` Alan Stern
2003-11-20 16:24                                                   ` Jens Axboe
2003-11-20 16:28                                                 ` [linux-usb-devel] " Oliver Neukum
2003-11-20 19:23                                                   ` Kai Makisara
2003-11-20 17:18                                               ` Kai Makisara
2003-11-20 19:18                                                 ` [linux-usb-devel] " Kai Mäkisara
2003-11-21 18:03                                                   ` PATCH: (as141) " Alan Stern
2003-11-21 20:07                                                     ` Kai Makisara
2003-12-01  1:30                                                     ` Matthew Dharm
2004-01-05  0:41                                                     ` Matthew Dharm
2004-01-05 10:08                                                       ` Jens Axboe
2004-01-05 21:58                                                         ` PATCH: (as141b) " Alan Stern
2004-01-06 11:28                                                           ` Oliver Neukum
2004-01-06 16:10                                                             ` Alan Stern
2004-02-02 15:51                                                           ` James Bottomley
2004-02-03 15:47                                                             ` Alan Stern
2004-02-03 15:55                                                               ` James Bottomley
2004-02-03 16:02                                                               ` Matthew Wilcox
2003-11-19 15:44                         ` Alan Stern
2003-11-19 15:49                           ` Jens Axboe
2003-11-19 16:58                             ` Alan Stern
2003-11-19 17:03                               ` Jens Axboe
2003-11-07 22:09     ` usb-storage and Sony Handycam Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44L0.0311082220430.7127-100000@netrider.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=dmitrik@users.sourceforge.net \
    --cc=idan@idanso.dyndns.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=patmans@us.ibm.com \
    --cc=ronald@kuetemeier.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.