Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/ss_scanjet.c
RevisionDateAuthorComments
 1.54  20-Nov-2016  mlelstv Make scsipi framework MPSAFE.

Data structures are now protected by a per-adapter mutex at IPL_BIO
that is created by the scsibus or atapibus instance when the adapter
is configured.
The enable reference counter and the channel freeze counter which are
currently used by HBA code before the adapter is configured, are made
atomic.
The target drivers are now all tagged as D_MPSAFE.

Almost all HBA drivers still require the kernel lock to present,
so all callbacks into HBA code are still protected by kernel lock
unless the driver is tagged as SCSIPI_ADAPT_MPSAFE.

TODO: refactor sd and cd to use dksubr.
 1.53  25-Oct-2013  martin branches: 1.53.6; 1.53.10;
Mark a diagnostic-only variable
 1.52  28-Feb-2012  mbalmer branches: 1.52.2; 1.52.4;
Convert to device_t, aka softc/device_t split, and clean up a bit the code.
 1.51  23-Nov-2009  rmind branches: 1.51.12; 1.51.16; 1.51.18;
Remove some unecessary includes sys/user.h header.
 1.50  21-Oct-2009  rmind Remove uarea swap-out functionality:

- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code. Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
 1.49  13-Jan-2009  yamt g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.48  05-Apr-2008  cegger branches: 1.48.4; 1.48.12;
use aprint_*_dev and device_xname
 1.47  16-Nov-2006  christos branches: 1.47.48;
__unused removal on arguments; approved by core.
 1.46  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.45  03-Sep-2006  christos branches: 1.45.2; 1.45.4;
comment out unreachable code
 1.44  11-Dec-2005  christos branches: 1.44.4; 1.44.8;
merge ktrace-lwp.
 1.43  15-Oct-2005  yamt - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
from sys/bufq.h to sys/bufq_impl.h.
(is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c. (not tested)
 1.42  30-May-2005  christos branches: 1.42.2;
- remove bogus casts
- add more const
 1.41  27-Feb-2005  perry nuke trailing whitespace
 1.40  01-Feb-2005  reinoud Backing out changes to clean up scsipi. I was pointed out there were
problems i hadn't seen. To prevent lossage i'd decided to back off all
changes and let them be reviewed on tech-kern.
 1.39  31-Jan-2005  reinoud Part of the cleanup of sys/scsipi's use of types; rename all u_int* to
uint* and change the u_long's to uint32_t's where possible. Note that the
iocl definitions/hooks have to be ulong (or u_long) or they'll bomb out.
 1.38  31-Jan-2005  reinoud As part of cleaning up sys/scsipi, replace all u_char by uint8_t and
replace all `short' with int16_t.
 1.37  28-Oct-2004  yamt branches: 1.37.4; 1.37.6;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.36  18-Sep-2004  mycroft Minor rearrangement. Whitespace and #include cleanup.
 1.35  18-Sep-2004  mycroft Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.
 1.34  17-Sep-2004  mycroft Remove the "xfer" argument to scsipi_command().
 1.33  17-Sep-2004  mycroft In places where we've already called scsipi_make_xs(), call scsipi_execute_xs()
directly rather than going through scsipi_command().
 1.32  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.31  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.30  21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.29  22-Apr-2004  itojun sprintf -> snprintf
 1.28  14-Sep-2002  chs branches: 1.28.6; 1.28.8;
recognize HP ScanJet 4c.
add a catch-all case for other HP scanners.
remove a local version of atoi() in favor of strtoul() from libkern.
 1.27  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.26  13-Nov-2001  lukem add RCSIDs
 1.25  18-Jul-2001  thorpej bcmp -> memcmp
 1.24  18-Jul-2001  thorpej bcopy -> memcpy
 1.23  18-Jul-2001  thorpej bzero -> memset
 1.22  25-Apr-2001  bouyer branches: 1.22.2;
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.21  08-Jul-2000  sommerfeld branches: 1.21.2;
printf format paranoia
 1.20  09-Jun-2000  enami Prevent a process being swapped out during I/O if the data buffer is
allocated on stack. This potential problem is noticed by Noriyuki Soda
and the idea and sample code to fix is given by Jason R. Thorpe.
 1.19  12-Mar-2000  augustss branches: 1.19.2;
Remove extra \n in attach message.
 1.18  30-Sep-1999  thorpej branches: 1.18.2;
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.17  05-Apr-1999  mycroft If scsipi_command() fails, always print out the error code.
 1.16  22-Apr-1998  pk branches: 1.16.10;
Set a flag during auto-configuration, so SCSI_AUTOCONF can be passed
when doing additional I/O from the scanner attach functions.
 1.15  19-Nov-1997  augustss Recognize HP ScanJet 5p.
 1.14  18-Oct-1997  thorpej branches: 1.14.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.
 1.13  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.12  27-Aug-1997  bouyer branches: 1.12.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.11  18-Jan-1997  cgd kill use of strchr(); it's moving to libkern
 1.10  22-Dec-1996  cgd note in a comment (XXX) that strchr() (what's it doing here, anyway?)
causes 'const' to be discarded.
 1.9  03-Dec-1996  thorpej Recognize the HP ScanJet 4p, per PR #2663 (Kenneth Stailey).
 1.8  12-Oct-1996  christos revert previous kprintf change
 1.7  10-Oct-1996  christos - printf -> kprintf, sprintf -> ksprintf
- replace sequences of sprintf(p, ...); p += strlen(p) with p += sprintf(p,
 1.6  18-May-1996  christos Added prototypes for inline functions atoi() and strchr().
 1.5  11-May-1996  mycroft Bug fixes from PR 2329, plus a few from me.
 1.4  05-May-1996  christos Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.
 1.3  30-Mar-1996  christos - Eliminate scsi_conf.h
- Fix prototypes
- Fix PR/2248 [Problems with HP scanjet...]
 1.2  19-Mar-1996  mycroft Define a full set of [234][bl]tol() and lto[234][bl]() conversion functions,
inlined.
Use sized types in protocol structures.
Make the definition of scsi_sense_data less ugly.
 1.1  18-Feb-1996  mycroft Add SCSI scanner support by Kenneth Stailey and Joachim Koenig-Baltes,
hacked a bit. Needs more work.
 1.12.2.3  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.12.2.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.12.2.1  27-Aug-1997  thorpej file ss_scanjet.c was added on branch marc-pcmcia on 1997-08-27 23:33:37 +0000
 1.14.2.1  22-Nov-1997  mellon Pull rev 1.15 up from trunk (augustss)
 1.16.10.1  21-Jun-1999  thorpej Sync w/ -current.
 1.18.2.4  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.

Main changes to the scsipi code itself:
- add a scsipi_channel->type to allow umass to attach to both atapibus and
scsibus. Will die when IDE is converted from ata_atapi_attach to
scsipi_channel/scsipi_adapter
- Add a chan_defquirks to scsipi_channel so that adapters can pass a default
set of quirks to be set for each device attached
- add adapt_getgeom and adapt_accesschk callbacks
 1.18.2.3  01-Nov-1999  thorpej Fixup the SC_DEBUG() stuff for the new world order.
 1.18.2.2  20-Oct-1999  thorpej Remove an unnecessary comment regarding XS_CTL_NOSLEEP.
 1.18.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.19.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.21.2.5  17-Sep-2002  nathanw Catch up to -current.
 1.21.2.4  08-Jan-2002  nathanw Catch up to -current.
 1.21.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.21.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.21.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.22.2.3  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.22.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.22.2.1  03-Aug-2001  lukem update to -current
 1.28.8.1  11-Sep-2004  he Pull up revisions 1.31-1.32 (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.28.6.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.6.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.28.6.6  02-Nov-2004  skrll Sync with HEAD.
 1.28.6.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.6.4  18-Sep-2004  skrll Sync with HEAD.
 1.28.6.3  03-Sep-2004  skrll Sync with HEAD
 1.28.6.2  25-Aug-2004  skrll Sync with HEAD.
 1.28.6.1  03-Aug-2004  skrll Sync with HEAD
 1.37.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.37.4.1  29-Apr-2005  kent sync with -current
 1.42.2.2  30-Dec-2006  yamt sync with head.
 1.42.2.1  21-Jun-2006  yamt sync with head.
 1.44.8.1  03-Sep-2006  yamt sync with head.
 1.44.4.1  09-Sep-2006  rpaulo sync with head
 1.45.4.2  10-Dec-2006  yamt sync with head.
 1.45.4.1  22-Oct-2006  yamt sync with head
 1.45.2.1  18-Nov-2006  ad Sync with head.
 1.47.48.2  17-Jan-2009  mjf Sync with HEAD.
 1.47.48.1  02-Jun-2008  mjf Sync with HEAD.
 1.48.12.1  19-Jan-2009  skrll Sync with HEAD.
 1.48.4.2  11-Mar-2010  yamt sync with head
 1.48.4.1  04-May-2009  yamt sync with head.
 1.51.18.1  02-Mar-2012  riz Pull up following revision(s) (requested by mbalmer in ticket #65):
sys/dev/scsipi/ss_scanjet.c: revision 1.52
sys/dev/scsipi/ss.c: revision 1.81
sys/dev/scsipi/ssvar.h: revision 1.19
sys/dev/scsipi/ss_mustek.c: revision 1.41
Convert to device_t, aka softc/device_t split, and clean up a bit the code.
 1.51.16.3  06-Mar-2012  mrg sync to -current
 1.51.16.2  06-Mar-2012  mrg sync to -current
 1.51.16.1  04-Mar-2012  mrg sync to latest -current.
 1.51.12.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.51.12.1  17-Apr-2012  yamt sync with head
 1.52.4.1  18-May-2014  rmind sync with head
 1.52.2.2  03-Dec-2017  jdolecek update from HEAD
 1.52.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.53.10.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.53.6.1  05-Dec-2016  skrll Sync with HEAD

RSS XML Feed