public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Douglas Gilbert <dougg@torque.net>,
	Matthew Dharm <mdharm-kernel@one-eyed-alien.net>,
	Matt Frost <artusemrys@sbcglobal.net>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	USB Storage list <usb-storage@lists.one-eyed-alien.net>,
	linux-kernel@vger.kernel.org,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Matthew Frost <artusemrys@yahoo.com>
Subject: Re: BUG: SCSI: usb storage SDHC card doesn't work in 2.6.27-rc1
Date: Wed, 30 Jul 2008 15:58:27 -0600	[thread overview]
Message-ID: <20080730155827.524f72d2.zaitcev@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0807301720320.2322-100000@iolanthe.rowland.org>

On Wed, 30 Jul 2008 17:28:49 -0400 (EDT), Alan Stern <stern@rowland.harvard.edu> wrote:

> > > +		if (bcs->Status == US_BULK_STAT_OK &&
> > > +				scsi_get_resid(srb) == 0 &&
> > > +					((srb->cmnd[0] == INQUIRY &&
> > > +						transfer_length == 36) ||
> > > +					(srb->cmnd[0] == READ_CAPACITY &&
> > > +						transfer_length == 8))) {
> > > +			us->flags |= US_FL_IGNORE_RESIDUE;
> > 
> > Why do you do this for INQUIRY and READ_CAPACITY only?
> > Why not do it for any command?
> 
> Because those are the only two commands for which I'm reasonably
> certain the device should never return a nonzero residue with Okay
> status.  For other commands there might be a valid positive residue --
> although if there is then the device should also return Check Condition
> status (the spec is unclear on this point).

Perhaps I misunderstand how our SCSI stack works. The code in ub is
simpler, it deals with 3 values at the end of transfer:
  Lasked is how much we asked for
  Lgot   is how much was transferred
  Lresid is the reported residue

So, ub checks if the following is true:
  Lasked = Lgot + Lresid

If device fails this check, you can assume that it's just not set up
to report the residue correctly and so, the danger of valid residue
that you outlined becomes rather academic.

The reason I do it this way is, I've seen a device which reported
a correct residue until the first long read, and then residue was
miscalculated due to a 16-bit wrap (it did transfer right data though).
I think it's one of those which are explicitly blacklisted these
days, but I cannot remember.

-- Pete

  reply	other threads:[~2008-07-30 22:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <103966.68801.qm@web83207.mail.mud.yahoo.com>
2008-07-30  4:08 ` BUG: SCSI: usb storage SDHC card doesn't work in 2.6.27-rc1 James Bottomley
2008-07-30  5:21   ` [usb-storage] " Matthew Dharm
2008-07-30 14:17     ` Alan Stern
2008-07-30 14:55       ` James Bottomley
2008-07-30 15:27         ` Alan Stern
2008-07-30 19:50         ` Douglas Gilbert
2008-07-30 21:00           ` Alan Stern
2008-07-30 21:09             ` Pete Zaitcev
2008-07-30 21:28               ` Alan Stern
2008-07-30 21:58                 ` Pete Zaitcev [this message]
2008-07-31 15:10                   ` Alan Stern
2008-08-01 18:46             ` [usb-storage] " Matthew Frost
2008-08-01 22:22               ` Matthew Frost
2008-08-03 11:56                 ` Douglas Gilbert
2008-08-08 21:07                 ` Matthew Frost
2008-08-08 21:30                   ` Alan Stern
2008-08-09 15:51                     ` Matthew Frost
2008-07-30 14:15   ` Alan Stern
2008-07-30 15:39     ` Matthew Frost

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=20080730155827.524f72d2.zaitcev@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=artusemrys@sbcglobal.net \
    --cc=artusemrys@yahoo.com \
    --cc=dougg@torque.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mdharm-kernel@one-eyed-alien.net \
    --cc=stern@rowland.harvard.edu \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox