Re: SCSI question

From: Douglas Gilbert (dgilbert@interlog.com)
Date: Fri Apr 07 2000 - 21:55:51 EST


John Justice forwarded this:

>We are running into a problem with data underrun. We are not sure
>how to report this problem back to the OS. The normal behavior in other OS
>is to indicate command complete with a residual count of certain length.
>
>In the scsi.h of 2.2.12 kernel, we do not have any field that can be used to
>report this info. Should we then report an error ?

There is a field in 2.2.x (also in 2.3.x) called 'underflow'.
Some adapters return an error if the number of bytes
actually transferred is less than this figure. It usually sits with
its default value of 0 in which case it is harmless. When I tried
to use it as a default I got burnt since some apps do INQUIRYs and
set the expected response length to an arbitrary 255 bytes.

So you can report an error (aic7xxx yields DID_RETRY_COMMAND) if
the actual data transfer count is less than 'underflow'. Otherwise
there is no way of reporting an underrun in the 2.2 series.

The version 2 sg driver had an ioctl() called SG_SET_UNDERRUN_FLAG
to arm 'underflow'. To my knowledge no one ever used it. At least
I hope not because it has been dropped in version 3 which is
targeted at 2.3/2.4 series kernels. The reason is the addition
of 'resid' field. It is initialized to 0 and should be set
by the adapter to the requested number of data bytes to transfer
less the actual number transferred. [Same definition and name
as CAM3.]

>We did see that the
>scsi.h file in the 2.3 kernel has a new field defined called "resid". Is
>this the reason they added it ?

Yes. Its presence is seen in this sg utility reading a disk
(lk 2.3.99-pre3 with an advansys adapter):
    $ sg_dd if=/dev/sg1 of=/dev/null bs=515 count=2
    2+0 records in
    2+0 records out
>> Non-zero sum of residual counts=6

Doug Gilbert

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:11 EST