public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dougg@torque.net>
To: Andries.Brouwer@cwi.nl
Cc: James.Bottomley@steeleye.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi_status() macro
Date: Sat, 17 May 2003 14:38:44 +1000	[thread overview]
Message-ID: <3EC5BCD4.3020600@torque.net> (raw)
In-Reply-To: <UTC200305161212.h4GCCcI13287.aeb@smtp.cwi.nl>

Andries.Brouwer@cwi.nl wrote:
>     > If you're doing this:
>     > 
>     >>+#define scsi_status(result) ((result) & 0x7e)
>     > 
>     > because bit0 is reserved in SCSI-2, then it should be 0x3e because bits
>     > 6 and 7 are also reserved.  Of course, this would clash with the SCSI-3
>     > definition of TASK ABORTED, sigh.
>     > 
>     > Perhaps it's better just not to bother with the mask?
> 
>     James,
>     The macro still gets rid of the upper bytes in
>     scsi_cmnd::result so in needs to be at least
>     a mask of 0xff.
> 
>     With a mask of 0x7e it is correct for SCSI-3,
>     bit 6 is reserved in SCSI-2  and "vendor unique"
>     in SCSI-1 and SCSI_1_CCS. I dug up a SCSI 1 draft and
>     the Status byte table is attached. So as far as I
>     can see our only exposure is to SCSI 1 and CCS
>     devices.
> 
> Yes, SCSI-1 has RVVSSSSV with R=reserved, V=vendor unique, S=status.
> Originally this was a bitmap, and it is still the case that codes
> are not randomly assigned. (We have several places in the
> kernel source that test (status & CHECK_CONDITION).)
<snip>

Andries,
There is method in the madness with (status & CHECK_CONDITION).
In SCSI-2 there is COMMAND TERMINATED status which has the
value of 0x22. It is the only status in SCSI 2, 3 or the most
recent drafts that has bit 1 set besides CHECK CONDITION.

In recent standards and drafts COMMAND TERMINATED is deprecated
but in the still important SCSI 2 standard it exists and
also implies that a sense buffer is available and should be
checked.

How long since anyone saw COMMAND TERMINATED? Well I'm
fighting with the ide-scsi driver (and probably losing)
and I see it often. I have a Creative x52 ATAPI CD
reader that once in a while when reading a data CD
with sg_dd fails with COMMAND_TERMINATED/overlapping_
commands. Since sg_dd sends SCSI reads in a purely
sequential order it points to something really sick
in the ide state machine (most likely caused by ide-scsi).
But I digress.

The bottom line:
    (status & CHECK_CONDITION)
is obscure shorthand for:
    ((status == CHECK_CONDITION) || (status == COMMAND_TERMINATED))
and that second check should not be dropped any time
soon.

Doug Gilbert


  reply	other threads:[~2003-05-17  4:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-16 12:12 [PATCH] scsi_status() macro Andries.Brouwer
2003-05-17  4:38 ` Douglas Gilbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-05-17  4:59 Andries.Brouwer
2003-05-15 23:50 Douglas Gilbert
2003-05-16  1:11 ` James Bottomley
2003-05-16  5:32   ` Douglas Gilbert

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=3EC5BCD4.3020600@torque.net \
    --to=dougg@torque.net \
    --cc=Andries.Brouwer@cwi.nl \
    --cc=James.Bottomley@steeleye.com \
    --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