Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/atapi_base.c
RevisionDateAuthorComments
 1.30  03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.29  18-Oct-2014  snj branches: 1.29.20;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.28  28-Apr-2008  martin branches: 1.28.44;
Remove clause 3 and 4 from TNF licenses
 1.27  05-Apr-2008  cegger branches: 1.27.2; 1.27.4;
use aprint_*_dev and device_xname
 1.26  11-Dec-2005  christos branches: 1.26.70;
merge ktrace-lwp.
 1.25  29-May-2005  christos - Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
 1.24  21-Feb-2005  thorpej Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding. Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes. Place items described
by the SCSI Primary Commands document into scsi_spc.h.
 1.23  17-Sep-2004  mycroft branches: 1.23.4; 1.23.6;
Change the way bustype_cmd is used. Rather than having it be responsible for
calling scsipi_make_xs() and scsipi_execute_xs(), instead push these into
scsipi_command. Make bustype_cmd and PHOLD/PRELE be called from
scsipi_execute_xs(). This allows us to create a xfer structure -- possibly on
the stack -- and call scsipi_execute_xs() directly.
 1.22  09-Sep-2004  bouyer Make the xxstart() functions reentrant again, as some drivers HBA can call
scsipi_done() from their scsipi_request().
For this, add a struct scsipi_xfer * argument to scsipi_command().
If not NULL scsipi_command() will use this to enqueue this xfer, otherwise
it'll try to allocate a new one. This scsipi_xfer has to be allocated
and initialised by scsipi_make_xs() or equivalent.
In xxstart(), allocate a scsipi_xfer using scsipi_make_xs(), and if not NULL,
dequeue the buffer before calling scsipi_command(). This makes sure that
scsipi_command() will not fail, and also makes sure that xxstart() won't
be called again between the BUFQ_PEEK() and BUFQ_GET().

Fix "dequeued wrong buf" panics reported by Juergen Hannken-Illjes in
private mail and Andreas Wrede on current-users@.
Thanks to Jason Thorpe and Chuck Silver for review, and Andreas Wrede for
testing the patch.
 1.21  27-Aug-2004  bouyer Improve handling of memory shortage, to fix problems like:
sd3(mpt0:0:1:0): unable to allocate scsipi_xfer
sd3: not queued, error 12
Havard Eidnes's analysis of this problem is that the scsipi_xfer pool is
competing for resources with other pools, including the the inode and vnode
pools which can grow quite large.

*_scsipi_cmd(): don't biodone the buffer if scsipi_make_xs() fails, let the
caller deal with the problem
start function of block devices drivers: dequeue the buffer after the
scsipi_command() call. If scsipi_command() fails with ENOMEM don't dequeue
the buffer, and schedule a callout to call the start function after
some delay.
scsipi_init(): prime the scsipi_xfer_pool with one page. This ensure that
there is always some scsipi_xfer to play with. If scsipi_command() fails
because of pool_get(), we're sure there will be resources available later,
when the pending commands have completed.

Reviewed by Jason Thorpe and Havard Eidnes.
Todo: remove the "unable to allocate scsipi_xfer" and "not queued, error %d"
printfs, but I choose to keep them for now, to help make sure the code does
what it should.
 1.20  21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.19  10-Mar-2004  bouyer branches: 1.19.2;
Decrease xs_retries before retrying aborted commands, and report EIO if it
reaches 0. Avoids looping on aborded command in some special cases.
 1.18  15-Nov-2001  lukem branches: 1.18.16;
don't need <sys/types.h> when including <sys/param.h>
 1.17  13-Nov-2001  lukem add RCSIDs
 1.16  14-May-2001  bouyer branches: 1.16.2;
Use SCSI/ATAPI common definition for MODE_{SELECT,SENSE}{,_BIG}. Define
functions to send theses commands in scsipi_base.c and use them instead
of ad-hoc commands setups.
 1.15  25-Apr-2001  bouyer Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.14  30-Sep-1999  thorpej branches: 1.14.2; 1.14.14;
Cleanup the scsipi_xfer flags:
- `flags' is now gone, replaced with `xs_control' and `xs_status'.
- Massive cleanup of the control flags. Now we explicitly say that
a job is to complete asynchronously, rather than relying on side-effects,
and use a new flag to now that device discovery is being performed.
- Do SCSI device discovery interrupt-driven.
 1.13  28-Aug-1999  thorpej If scsipi_make_xs() fails, make sure to flag the buffer as error'd,
if provided, and biodone() it. Callers of scsipi_command() expect
this to be done.
 1.12  25-Jun-1999  thorpej Go to splbio() when calling scsipi_free_xs(), just like the SCSI counterpart.
Fixes PR #7853, Paul Dokas <dokas@cs.umn.edu>.
 1.11  17-Nov-1998  bouyer branches: 1.11.4; 1.11.6; 1.11.8;
In atapi_wdc.c, issue a 'REQUEST SENSE' command when appropriate.
Return XS_SENSE when the full sense info has been retrieved, or
XS_SHORTSENSE if only the sense key was available (from the error register)
Make atapi_interpret_sense() deal with this, and call scsipi_interpret_sense()
for XS_SENSE. (XXX sd_interpret_sense() and the ioctl code needs to be made
aware of XS_SHORTSENSE too ! sense hanlding for these is now less broken for
devices that support 'REQUEST SENSE')
All the ATAPI devices I have access to seems to honnor the SENSE_REQUEST
command, but I suspect some ATAPI devices will not (althouh it's mandatory).
The code should be able to deal with this, but is untested ...
 1.10  12-Oct-1998  bouyer Merge bouyer-ide
 1.9  15-Aug-1998  mycroft branches: 1.9.2;
Assign my copyrights to TNF.
 1.8  15-Jul-1998  mjacob part of fix for kern/3835: use of enumerated returns from target sense handlers
 1.7  11-Jul-1998  mjacob Clarify that Sense Key 1 is a "RECOVERED ERROR"- not just an error.
 1.6  01-Jul-1998  mjacob Use new Sense Key defines (for clarity)
 1.5  15-Jan-1998  cgd add support for an ATAPI attachment for 'sd'.
fix 'cd' driver's NCD_SCSI bogosity (was using testing wrong macro!)
clean up in various ways:
* make common atapi_mode_{sense,select}() functions.
* put ATAPI data structures in more sensible headers, split up by
device type.
* include headers a bit more carefully.
* pass flags to attachment-specific cd functions, and use them.
* get rid of SCSI bits in scsipi_base.h's scsipi_make_xs(), move
them into the correct place in scsi_base.c.
* fix minor typo in struct name in scsipiconf.h (which was apparently
never used except in a #define later in the same file).
* use __attribute__ to force 4-byte alignment for xs command store,
so that architectures trying to bus_space_write_multi_N() (where
N > 1) that data to a controller won't lose.
* clean up a few comments in typos, and make a few #defines easier to
understand/maintain.
* rename cd_link.h to cdvar.h (via repository copy). This is exactly
what a 'var' file is supposed to be.
 1.4  30-Dec-1997  is EACCESS->EROFS, for the write on readonly medium error.
 1.3  01-Oct-1997  enami Cosmetic changes to keep coding style consistency in this directory;

- Indent with tab of width 8.
- Use four column to indent continuation line.
- Fold long line if possible.
- Use return (xx) instead of return xx.
- Compare pointer against NULL instead of testing like boolean.
- Delete whitespace at the end of line.
- Delete whitespace in front of function call operator.
- Delete whitespace after cast.
- Dereference a pointer to function explicitly.
- Add an empty line after local variable declaration.
- Use NULL instead of (char *)0.
- Dont use block for single statement.
 1.2  27-Aug-1997  bouyer branches: 1.2.2;
Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.1  01-Jul-1997  bouyer branches: 1.1.2;
file atapi_base.c was initially added on branch bouyer-scsipi.
 1.1.2.2  01-Jul-1997  thorpej Purely cosmetic formatting changes: some spaces -> tabs, indenting
consistency in prototypes.
 1.1.2.1  01-Jul-1997  bouyer New merged scsi/atapi code. Tested on i386 and sparc. Commiting to a branch
for now, so that it can be tested on other ports too.
The config sheme is as follow:
New merged scsi/atapi code. Tested on i386 and sparc. Commiting to a branch
for now, so that it can be tested on other ports too.
The config sheme is as follow:
scsibus at aha
sd at scsibus
cd at scsibus
atapibus at wdc
cd at atapibus
cd has bus-specific config and function front-end in scsicd.c and atapicd.c
The call to theses functions from cd.c is conditionned to
NSCSICD and NATAPICD (all defined in cd.h by config).
 1.2.2.3  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.1  27-Aug-1997  thorpej file atapi_base.c was added on branch marc-pcmcia on 1997-08-27 23:32:53 +0000
 1.9.2.2  02-Oct-1998  bouyer When printing the error message, also print the channel with the contrller
name and drive number.
 1.9.2.1  15-Aug-1998  bouyer file atapi_base.c was added on branch bouyer-ide on 1998-10-02 18:12:49 +0000
 1.11.8.1  30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.11.6.1  01-Jul-1999  thorpej Sync w/ -current.
 1.11.4.1  25-Jun-1999  perry pullup 1.11->1.12 (thorpej): Go to splbio() when calling scsipi_free_xs()
 1.14.14.3  08-Jan-2002  nathanw Catch up to -current.
 1.14.14.2  14-Nov-2001  nathanw Catch up to -current.
 1.14.14.1  21-Jun-2001  nathanw Catch up to -current.
 1.14.2.2  01-Nov-1999  thorpej Fixup the SC_DEBUG() stuff for the new world order.
 1.14.2.1  19-Oct-1999  thorpej Completely rewritten scsipi_xfer execution engine:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).

There is a lot more work to do, but this correctly functions for the most
part on several file servers I run.
 1.16.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.16.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.16.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.18.16.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.16.4  18-Sep-2004  skrll Sync with HEAD.
 1.18.16.3  03-Sep-2004  skrll Sync with HEAD
 1.18.16.2  25-Aug-2004  skrll Sync with HEAD.
 1.18.16.1  03-Aug-2004  skrll Sync with HEAD
 1.19.2.1  11-Sep-2004  he Pull up revisions 1.21-1.22 (via patch, requested by bouyer in ticket #837):
Improve handling of memory shortage, to fix problems like:
sd3(mpt0:0:1:0): unable to allocate scsipi_xfer
sd3: not queued, error 12
The theory is that other consumers of pool memory is causing
this memory shortage in certain somewhat hard to reproduce
situations.
This is done by giving scsipi_command an extra argument to
optionally pass a preallocated scsipi_xfer, and allocating a
scsipi_xfer before dequeueing a buffer in the various *start()
functions. If the allocation of a scsipi_xfer fails, schedule
a callout for delayed invocation of the start function. Also
reserve one page for scsipi_xfer structs, to ensure that we will
eventually have some available once pending commands complete.
Should fix PR#25670.
 1.23.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.4.1  29-Apr-2005  kent sync with -current
 1.26.70.1  02-Jun-2008  mjf Sync with HEAD.
 1.27.4.1  16-May-2008  yamt sync with head.
 1.27.2.1  18-May-2008  yamt sync with head.
 1.28.44.1  03-Dec-2017  jdolecek update from HEAD
 1.29.20.1  10-Jun-2019  christos Sync with HEAD

RSS XML Feed