linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Douglas Gilbert <dougg@torque.net>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH] libata: error processing + rw 6 byte fix
Date: Tue, 23 Aug 2005 14:44:02 +0200	[thread overview]
Message-ID: <20050823124401.GH16461@suse.de> (raw)
In-Reply-To: <430B1799.1060800@torque.net>

On Tue, Aug 23 2005, Douglas Gilbert wrote:
> Jens Axboe wrote:
> > On Mon, Aug 22 2005, Douglas Gilbert wrote:
> > 
> >> 	if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) {
> >>-		qc->nsect = tf->nsect = scsicmd[4];
> >>+		if (scsicmd[4] == 0) {
> >>+			/*
> >>+			 * For READ_6 and WRITE_6 (only)
> >>+			 * transfer_len==0 -> 256 blocks !!
> >>+			 */
> >>+			if (lba48) {
> >>+				tf->hob_nsect = 1;
> >>+				qc->nsect = 256;
> >>+			} else
> >>+				return 1;
> > 
> > 
> > This isn't quite right, for 28-bit lba a 0 sector value means 256
> > sectors to transfer as well. So just make that:
> > 
> >         if (lba48) {
> >                 tf->hob_nsect = 1;
> >                 qc->nsect = 256;
> >         }
> > 
> >         /* continue */
> > 
> > and it should work fine. Similarly for 48-bit lba, 0 means 16^2 sectors.
> 
> Jens,
> Since for 28-bit lba a 0 sector value means 256 sectors
> do I need to check for the lba48 case at all? As proposed
> to Jeff is this ok (for READ_6 and WRITE_6):
> 
>        if (scsicmd[4] == 0) {
>            /*
>             * For READ_6 and WRITE_6 (only)
>             * transfer_len==0 -> 256 blocks !!
>             */
>            qc->nsect = 256;
>        } else
>            qc->nsect = scsicmd[4];
>        tf->nsect = scsicmd[4];

This will break for lba48 devices, since if you have scsicmd[4] == 0, a
lba48 read/write will want to transfer 65536 sectors instead of the
intended 256.

Your qc->nsect logic is correct, but you need to set tf->hob_nsect 1
for lba48 if scsicmd[4] == 0 to correctly tell that command to transfer
256 sectors.

> Also I noticed while testing the original code with READ_6
> (sectors=0) that the device locked up (power cycle required).
> So given the point you make for 48-bit lba, 0 means 16^2
> sectors, then the READ_10 (sectors=0) and READ_16 (sectors=0)
> which are valid nops according to SBC-2 may also lock up
> in libata.

Try with the corrected sector counts, should work. I didn't check the
other READ_X/WRITE_X, so you should probably audit them as well :)

-- 
Jens Axboe


  reply	other threads:[~2005-08-23 12:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-22  9:02 [PATCH] libata: error processing + rw 6 byte fix Douglas Gilbert
2005-08-22 19:10 ` Jeff Garzik
2005-08-23 12:14   ` Douglas Gilbert
2005-08-27  3:31     ` Jeff Garzik
2005-08-23  7:13 ` Jens Axboe
2005-08-23 12:33   ` Douglas Gilbert
2005-08-23 12:44     ` Jens Axboe [this message]
2005-08-27  3:26     ` Jeff Garzik
2005-08-27  5:08       ` Douglas Gilbert
2005-08-27  7:17         ` Jens Axboe
2005-08-27  8:20         ` Jeff Garzik
2005-08-27 10:01           ` Jens Axboe

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=20050823124401.GH16461@suse.de \
    --to=axboe@suse.de \
    --cc=dougg@torque.net \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).