Subject: New SCSI code
To: None <>
From: Charles M. Hannum <>
List: tech-kern
Date: 12/10/1994 00:38:46
I'm working on some fairly extensive changes to the SCSI code.  Here's
a brief summary of what I've done so far.

1) Move the config matching code into individual drivers, but provide
a helper function (scsi_inqmatch) to make it easier.  This leverages
off the config system a bit, using priorities to find the `best'
(i.e. most exact) match.  Any semi-matching driver will return at
least 2, except for uk, which returns 1, thus always giving it last

2) Start to move to explicit sizes for the hardware-defined data.
This is just barely the beginning; much more work needs to be done
here.  Some other type bogosities are also addressed.

3) Remove `adapter_info' from the adapter switch.  The interface was
archaic, and we already have a reasonable mechanism for returning that
data; namely, poking the `openings' entry in the prototype scsi_link
when attaching the low-level driver.  Also, `adapter_targ' is changed
to `adapter_target' for consistency, and a few other unused (and
seemingly pointless) switch entries are removed.

4) Wait for disks to come ready when opening a cd or sd device.
There's currently a 5-second timeout on this during autoconfig, and 30
seconds (plus `friendly' console messages like some other systems) at
any other time.

5) Torch SCSI_ERR_OK, and ignore specific errors (currently ILLEGAL
REQUEST for implicit prevent/allow on first open and last close, MEDIA
CHANGE during first open of a device, NOT READY during probe and
prevent on first open before spinning up the disk, and probably
combinations of these at other times).  I don't think there was any
need before for the low-level driver to know about this (though many
of them did), and there definitely isn't now.

6) Retry on an ignored MEDIA CHANGE.

7) Remove SCSI_NOMASK.  Add SCSI_POLL.  Conceptually, these do almost
the same thing, but there's not really any point in disallowing the
spl calls, all the conditionals slow the code down in the most
frequent cases, and it may be useful some day to use SCSI_POLL where
SCSI_NOMASK wouldn't have been appropriate.

8) Remove HAD_ERROR.  It was identical to COMPLETE, and I got tired of
seeing silly code that conditionally returned one or the other of the

9) Remove XS_SWTIMEOUT.  Everything currently uses XS_TIMEOUT for the
purpose XS_SWTIMEOUT was intended.  Add XS_SELTIMEOUT, to allow the
low-level driver to inform the high-level code that the device appears
to be gone.  Returning XS_TIMEOUT in this case is still acceptable,
but not recommended.

10) Fix *numerous* bugs in the 4 original i386 low-level drivers.
Also, make the aha driver handle mailboxes similar to the bt driver,
which among other things means that timeouts should actually work.
Lots of other cleanup of this code too, and make them all look a
little more similar.

11) Make SCIOCCOMMAND actually return the command status, residual,
and sense data.

And some style cleanup and other random things.

Of course, there are a few outstanding problems, though nothing worse
than what was there before.

A) How to deal with multiple LUNs?  I've never seen this done well.
The old code took the approach of only allowing multiple LUNs for
specific devices based on the inquiry data match.  This may be the
only viable option, due to bugs in many devices.  Suggestions are

B) While number 4 above is nice, the code currently retries on too
many conditions, many of which indicate an error other than the disc
not being present.  The reason for this is that the sense parsing code
currently is stuck returning EIO for a lot of things that are quite
different.  It seems like internally the SCSI subsystem needs to use
its own return values, and map them to errno values only when
returning them to external code.

C) THIS NEEDS TO BE TESTED THOROUGHLY.  I've got ~360k of `diff -c2'
and I'm not even done yet.  The two low-level drivers with the most
changes are being tested locally; so mainly the high-level drivers
need to be tested on more devices.

If you have suggestions on other things that need to be done, or how
to do the above better, let me know...