Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/st.c
RevisionDateAuthorComments
 1.243  23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.242  05-Dec-2021  msaitoh availabe -> available in comment.
 1.241  13-Jun-2021  mlelstv Restore EOM handling.
 1.240  27-Dec-2019  msaitoh branches: 1.240.12;
s/transfered/transferred/
 1.239  10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.238  19-May-2019  kardel Add simple position recovery when positioning to EOM by reading
the position with READ_POSITION.
this allows for
mt eom
mt st
to return the correct file position.
 1.237  23-Feb-2019  kamil Correct printing type of b_blkno (int64_t) in st.c

Fixes build with kUBSan on NetBSD/i386.
 1.236  12-Feb-2019  kardel Fix PR kern/53949:

Fix inconsistent/incomplete file mark handling to conform again
to mtio(4) at close(2) time. This was necessary as the PREVENT/ALLOW
bracket was reduced from a whole mount session to cover only the
open(2)/close(2) time on ~2002-03-22. The rationale was to allow
robots and humans to change the media during a mount session.

Unfortunately this lead to file marks being written to potentially other
media at the beginning on drives that used the two file marks as EOM
pattern. In order for that to happen the media had to be removed after
data and at most one file mark had been written before removal.

The mount error message has been clarified and a warning about
potential data/file mark lossage on UNIT ATTENTION
during an active mount session with unfinished file marks has been
added.

While there, fix, but disable the commented SUN compatibility to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.
It can now be enabled with options ST_SUNCOMPAT.

Additionally debug output coverage has been extended.
 1.235  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.234  24-Mar-2018  mlelstv branches: 1.234.2;
Use separate lock to protect internal state and release locks when
calling biodone.
 1.233  24-Mar-2018  kamil Revert previous commit in st.c in order to unbreak build

There are various build errors like:
/usr/src/sys/dev/scsipi/st.c: In function 'stattach':
/usr/src/sys/dev/scsipi/st.c:398:16: error: 'struct st_softc'
has no member named 'buf_defer'; did you mean 'buf_queue'?
bufq_alloc(&st->buf_defer, "fcfs", 0);

Original (reverted) commit:
Use separate lock to protect internal state and release locks when
calling biodone.
 1.232  23-Mar-2018  mlelstv Use separate lock to protect internal state and release locks when
calling biodone.
 1.231  17-Jun-2017  mlelstv branches: 1.231.4;
The atapibus detach path did hold the channel mutex while calling into autoconf,
which would trigger a panic when unplugging a USB ATAPI CDROM.

Align detach code for scsibus and atapibus to fix this.

Also avoid races when detaching devices by replacing callout_stop with
callout_halt.
 1.230  20-Nov-2016  mlelstv branches: 1.230.8;
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.229  20-Nov-2016  pgoyette Avoid calling bufq_free() from critical code sections.
 1.228  14-Jul-2016  msaitoh branches: 1.228.2;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.227  24-Aug-2015  pooka would you like some freshly ground _KERNEL_OPT with that?
yes? excellent choice, sir/madam.
 1.226  10-Aug-2014  tls branches: 1.226.2; 1.226.4; 1.226.6; 1.226.10;
Merge tls-earlyentropy branch into HEAD.
 1.225  25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.224  25-Jul-2014  dholland Add d_discard to all struct bdevsw instances I could find.

I've set them all to nodiscard. Some of them (wd, dk, vnd, ld,
raidframe, maybe cgd) should be implemented for real.
 1.223  16-Mar-2014  dholland branches: 1.223.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.222  25-Oct-2013  martin Mark a diagnostic-only variable
 1.221  19-Apr-2012  bouyer branches: 1.221.2; 1.221.4;
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
sync/wide parameters only make sense for parallel SCSI.
For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
tagged queing status if enabled. Just be silent for other
bustypes.

This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
appropriate parameters is enough to enable tagged queuing,
but then scsipi will print:
sd0: async, 8-bit transfers, tagged queueing
which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
but will confuse users. With this change scsipi will only print:
sd0: tagged queueing
which is correct.

In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.

Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.
 1.220  28-Feb-2012  mbalmer Convert st(4) to device_t, while here clean up the code and use uintXX_t
instead of u_intXX_t.
 1.219  25-Feb-2012  shattered Replace magic value 0x7 with constant MT_ISAR.

OK by wiz@
 1.218  02-Feb-2012  tls branches: 1.218.2;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.217  30-May-2010  pgoyette branches: 1.217.8; 1.217.12;
Extract SCSIVERBOSE into a kernel module. The module can be builtin
by defining 'options SCSIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.

The module is built for all architectures, whether or not SCSI or
atapi support exists.
 1.216  06-Dec-2009  dyoung branches: 1.216.2; 1.216.4;
Delete do-nothing device-activation hooks.
 1.215  05-Dec-2009  pooka Convert tsleep(&lbolt) to kpause(). Make ltsleep/mtsleep on lbolt
illegal. I examined all places where lbolt is referenced to make
sure there were pointer aliases of it passed to tsleep, but put a
KASSERT in m/ltsleep() just to be sure.
 1.214  23-Nov-2009  rmind Remove some unecessary includes sys/user.h header.
 1.213  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.212  15-Aug-2009  pgoyette 1. Move the mode_select functionality into common code (in st.c) and
invoke the common routine for both scsi and atapi tapes.

2. Replace a numeric constant with some sizeof's when calculating the
size of the mode_select command buffer, clear the entire buffer, and
KASSERT to ensure the page_0_size loaded from quirk table is valid.

3. Add a quirk for my Seagate Travan-40 tape drive.

As discussed on tech-kern@

Addresses my PR kern/34832
 1.211  12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.210  13-Jan-2009  yamt branches: 1.210.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.209  11-Jan-2009  cegger make this compile
 1.208  17-Nov-2008  bouyer If we return an error make sure we don't return a b_resid of 0; or this
will trigger a KASSERT in physio_done(). Fix issue reported by Todd Kover
on tech-kern@
 1.207  02-Sep-2008  dholland branches: 1.207.2; 1.207.4;
Reword some misleading code.
ok bouyer@
 1.206  01-Sep-2008  dholland fix typo in comment
 1.205  08-Jun-2008  tsutsui branches: 1.205.4;
Use device_lookup_private() rather than using cd_devs[] directly to get softc.

XXX maybe we should change a type of cd_devs[] in struct cfdriver
from (void *) to device_t.
 1.204  28-Apr-2008  martin branches: 1.204.2;
Remove clause 3 and 4 from TNF licenses
 1.203  05-Apr-2008  cegger branches: 1.203.2; 1.203.4;
use aprint_*_dev and device_xname
 1.202  11-Oct-2007  christos branches: 1.202.18;
PR/37108: Pauly Goyette: Compute the timeout value, before immediate is
changed for atapi tape drives.
 1.201  06-Oct-2007  bouyer Move check for b_resid value to the right place. Should definitively fix
kern/36690.
 1.200  01-Oct-2007  bouyer When checking for invalid b_resid valyes, also check negative ones.
Should fix kern/36690.
 1.199  29-Sep-2007  bouyer Properly set b_resid in an error case.
Clamp b_resid to b_bcount in case the info field is larger. Fix a KASSERT
in physio() when a media error occurs on my SDLT320 drive (maybe this drive
is bogus for not setting the highter bits to 0 in the INFO field in this
case).
 1.198  29-Jul-2007  ad branches: 1.198.4; 1.198.6; 1.198.8; 1.198.10;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.197  09-Jul-2007  ad branches: 1.197.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.196  04-Mar-2007  christos branches: 1.196.2; 1.196.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.195  01-Mar-2007  thorpej TRUE -> true, FALSE -> false
 1.194  16-Nov-2006  christos branches: 1.194.2; 1.194.4; 1.194.8;
__unused removal on arguments; approved by core.
 1.193  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.192  23-Aug-2006  christos branches: 1.192.2; 1.192.4;
Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).
 1.191  07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.190  20-Apr-2006  blymn branches: 1.190.2;
Prefix iostat structure elements with io_
 1.189  14-Apr-2006  blymn Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.
 1.188  30-Mar-2006  thorpej Use device_private().
 1.187  28-Mar-2006  thorpej Use device_unit().
 1.186  11-Dec-2005  christos branches: 1.186.4; 1.186.6; 1.186.8; 1.186.10; 1.186.12;
merge ktrace-lwp.
 1.185  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.184  13-Aug-2005  blymn Split out stats attach code ready for shifting
Add sysctl hooks here for the time being.
 1.183  07-Aug-2005  blymn Gather statistics for tape drives.
 1.182  16-Jul-2005  rtr change output from "rogue" to "quirks apply" - resolves pr#25387
 1.181  29-May-2005  christos branches: 1.181.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
 1.180  25-Apr-2005  drochner revert the only part of rev. 1.177 which made a functional
change -- it broke error reporting because st->asc(q) are
not set
(actually, I believe that SSD_RCODE_VALID is misnamed)
 1.179  31-Mar-2005  yamt introduce a function to drain bufq and use it where appropriate.
 1.178  27-Feb-2005  perry branches: 1.178.2;
nuke trailing whitespace
 1.177  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.176  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.175  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.174  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.173  28-Oct-2004  yamt branches: 1.173.4; 1.173.6;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.172  26-Sep-2004  dogcow Fix debug message output args to match yamt's src/sys/sys/buf.h changes.
 1.171  18-Sep-2004  mycroft Minor rearrangement. Whitespace and #include cleanup.
 1.170  18-Sep-2004  mycroft Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.
 1.169  17-Sep-2004  mycroft Remove the "xfer" argument to scsipi_command().
 1.168  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.167  17-Sep-2004  mycroft Do not manipulate xs->bp in "generic" code -- do it only in the psw_done
routine. As part of this, pass down our pre-parsed error code -- though this
interface will probably change later to accomodate better error handling.
 1.166  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.165  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.164  21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.163  29-Jun-2003  fvdl branches: 1.163.2; 1.163.4;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.162  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.161  14-Apr-2003  perry Add a quirk for the Tandberg SLR/5
Fix supplied by Rex McMaster in PR kern/13603
 1.160  20-Mar-2003  dbj use PRId64 to printf bp->b_blkno, which is of type daddr_t
 1.159  03-Feb-2003  thorpej Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.
 1.158  23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.157  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.156  22-Jul-2002  hannken Convert to new device buffer queue interface.
 1.155  05-May-2002  bouyer branches: 1.155.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.
 1.154  03-May-2002  bouyer Back out previous. It has issues with multiple dumps to one tape using
/dev/nrstx, as pointed out by Matthew Jacob.
My problem is probably related to mt using /dev/nrst0 instead of /dev/enrst0
by default.
 1.153  02-May-2002  bouyer If we get a Unit Attention Not Ready To Ready Transition (medium may have
changed) sense, and the periph was not open, then ignore the error.
 1.152  22-Mar-2002  mjacob kern/16014- if we do an 'mt offline', make sure we've allowed the tape
to be ejected (PR_ALLOW). This got nuked in a previous change.
 1.151  22-Mar-2002  mjacob Forced commit so that some more detail on the previous patches can be
inserted into comments. I really think that more testing was required,
but Christos was eager.

+ Add in tape block/file position reporting support.

+ Change the prevent/allow ejection code so that if the device
is close the tape can be ejected. This allows robots to eject
the tape even if the tape isn't at BOT.

+ Don't do a null filemark write if we're reading block position. This
was such an abysmal performance killer that it had to go. Assume
that the tape will DTRT and tell you what the tape position really is
including any buffered data. You are depending on the tape to do
the right thing to report position at all, so the risk factors don't
increase appreciably here. BTW- we only do this for logical block
position. For 'hardware' block position, we still flush.

+ Some substantial tweaking in st_interpret_sense. This essentially duplicates
the FreeBSD driver's exception handling code. This is to try and correctly
handle EOM cases. I'm not sure that this is now correct with respect to
the ENABLE EARLY WARNING code- I hadn't gotten around to validating that.
Add in full 32 bit residuals- this can then be available to an update
MTIOCGET in the future.

+ Make sure we handle SKEY_VOLUME_OVERFLOW correctly.
 1.150  20-Mar-2002  christos Add the ability to report file number/block number. From Matt Jacob.
 1.149  12-Jan-2002  bouyer For fixed block drive, for invalid sense error code, set info to
xs->datalen / st->blksize instead of xs->datalen; as code assume later
that info is a block number.
Should fix kern/2727.
 1.148  07-Dec-2001  yamt add detach support for st.
 1.147  01-Dec-2001  bouyer Hum, no need to print a message each time we're waiting for the drive.
 1.146  01-Dec-2001  bouyer Various quirks for the ATAPI OnStream DI-30, mostly from the FreeBSD driver.
Many thanks to Chris Pinnock for giving me remote access to his hardware.
 1.145  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.144  13-Nov-2001  lukem add RCSIDs
 1.143  18-Jul-2001  thorpej branches: 1.143.2;
bzero -> memset
 1.142  08-Jul-2001  wiz branches: 1.142.2;
Correct various misspellings of 'transfer' and inflected forms.
 1.141  18-Jun-2001  bouyer Snapshot of ATAPI tapes support. Known to be able to read/write to tape with:
st0 at atapibus0 drive 1: <Seagate STT8000A, , 5.51> type 1 sequential
removable
Major changes may still happen in order to properly support other ATAPI
tape drives.
 1.140  30-May-2001  bouyer uninitialised variable (from Krister Walfridsson):
in st_cmprss(), init flags to 0 (never changed, but this should change soon
anyway, for ATAPI tapes support)
 1.139  15-May-2001  lukem delint; use MAX(sizeof(..),sizeof(..)) instead of max(...) for array size
 1.138  14-May-2001  bouyer 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.137  06-May-2001  hannken Fix a typo from thorpej_scsipi merge. No-sense information with retval == 0
should only print if SCSIPI_DEBUG is defined.
 1.136  04-May-2001  bouyer Add an ATAPI front-end to the st driver. Completely untested for now,
but st at scsi should still work :)
 1.135  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.134  18-Jan-2001  jdolecek branches: 1.134.2;
constify
 1.133  22-Nov-2000  soren Remove obsolete comment.
 1.132  03-Nov-2000  pk st_touch_tape(): Pass XS_CTL_SILENT to st_mode_select().
 1.131  03-Nov-2000  pk * st_touch_tape(): start probing at the block size from the sense data if
we have it.

* st_unmount(): reset density to the device default. This prevents using
stale density values after changing to a medium with different density.

Section 9.3.3 of the SCSI specs states that a device shall return the
density value specified in the last succesfull MODE SELECT after an
unload operation, in case it is not able to automatically determine
the density of the new medium.
 1.130  03-Nov-2000  pk * Per st(4), retrieving status and setting modes on the control device
should succeed even if no media is loaded.

* In stopen(), check the return value of st_mount_tape().
 1.129  02-Nov-2000  pk Introduce ST_Q_ERASE_NOIMM, a quirk indicating that the device rejects
an ERASE command with the `Immed' bit on.

Use it on the VIPER 21247 & 21531.
 1.128  02-Nov-2000  pk Prevent printing sense information twice.
 1.127  02-Nov-2000  pk Remove useless check for SDEV_MEDIA_LOADED from st_read_block_limits().
This command should work whether or not media is present in the device.
 1.126  02-Nov-2000  pk * In st_touch_tape(), don't bail out if the MODE SELECT fails since we are,
after all, probing the device for acceptable parameters.

* In st_loadquirks(), copy mode-specific quirks from the quirk table
to `st_softc'; otherwise all such quirks save ST_Q_FORCE_BLKSIZE are ignored.
 1.125  16-Aug-2000  matt Add a NOPREVENT quirk which prevents the sending of PREVENT messages (some
manual 9track tapes don't support it). Add a quirk entry for the NCR H621
9track tape drive.
 1.124  09-Jun-2000  enami branches: 1.124.2;
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.123  06-Jun-2000  soren Density codes are usually given in decimal, so print them that way.
 1.122  19-May-2000  kleink branches: 1.122.2;
Add a quirk table entry for the OnStream ADR50 Drive;
from S.P.Zeidler <spz@serpens.swb.de> in kern/10118.
 1.121  30-Mar-2000  augustss Get rid of register declarations.
 1.120  21-Feb-2000  mjacob Patches from msouth@scruz.net to handle QIC 3220 (HP T20).
 1.119  20-Feb-2000  mjacob minor spelling change
 1.118  22-Jan-2000  mjacob PR/9271 (from srp@zgi.com)- recognize (indirectly) HP4000s via density
code and do the right QIC type dance (1 FM @EOT, fixed block size).
 1.117  21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.116  13-Jan-2000  nisimura Add tweaks for TEAC compact cassette tape drive.
 1.115  12-Jan-2000  mjacob Check in the implementation of the ST_MOUNT_DELAY option.

This is an attempt to allow people to change the default configuration
to try harder at 'mounting' a tape. This allows you to specify, in
seconds, the amount of time a non-control unit open will retry
(once per second) the scsipi_test_unit_ready when it tries to mount
the tape. It also turns off the over-verbose error reporting at
this time unless SCSIDEBUG is set.

The reason this is not enabled as a default is that it's a large change
of behaviour. I find it useful to 'try harder' at mounting a tape in
the tape driver, particularly when loaded via a media changer device
rather than specifying the delays in the backup program.
 1.114  30-Sep-1999  thorpej branches: 1.114.2; 1.114.8;
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.113  04-Sep-1999  simonb Fix tyop in a comment.
 1.112  17-Jun-1999  mjacob STK 9490 && SD-3 drives incorrectly quirked as not supporting the LOAD command.
Anyway, just because a drive doesn't support the LOAD (to BOT) command does
not mean that the drive doesn't support the UNLOAD command. Also note and
print errors in rewinds and unloads (and errors in writing closing filemarks
for same).
 1.111  05-Apr-1999  mycroft If scsipi_command() fails, always print out the error code.
 1.110  28-Feb-1999  explorer branches: 1.110.2; 1.110.4;
Update to slightly altered rnd_attach_source() api
 1.109  10-Feb-1999  bouyer Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.
 1.108  10-Jan-1999  tron Make MTIOCRDSPOS, MTIOCSLOCATE, etc. work with write protected tapes.
Patch supplied by Dave Huang in PR kern/5305.
 1.107  08-Dec-1998  thorpej When closing, wait for pending xfers to drain before deleting the reference
to the adapter.
 1.106  20-Nov-1998  thorpej Add adapter reference counting for SCSI and ATAPI devices.
 1.105  17-Nov-1998  bouyer Rename scsi_interpret_sense() to scsipi_interpret_sense() and move it from
scsi_base.c to scsipi_base.c. Rename the functions from scsi_verbose.c
too, and rename the file itself. Cleaup includes too (scsi_*.h should not
be #included in scsipi_*.h files, which are supposed to be
common to atapi and scsi).
 1.104  11-Sep-1998  mjacob keren/6128: add an entry for the TDC 4200. Full density code set isn't known.
 1.103  02-Sep-1998  mjacob typo for non-SCSIVERBOSE case
 1.102  31-Aug-1998  cgd kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port
used it, and it's non-working and apparently slated for replacement.)
 1.101  17-Aug-1998  mycroft Assign my copyrights to TNF.
 1.100  15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.99  10-Aug-1998  mjacob Responding to an issue brought to my attention- when the device is
opened norewind and 2 filemarks are written at the end a phantom file
is left (just what I was afraid of, but I didn't think about it in
the last delta because somehow I had managed to convince myself that
this was a nonissue. It's not.).

So- in stdone clear ST_WRITTEN for regular reads. In st_close, preserve
the state of ST_WRITTEN, and if no error and 2FM@EOD for this device and
this is a no-rewind open, backspace one filemark. This should preserve
(for this mount session) FILE - FMK - FILE - FMK - FILE ... FILE FMK FMK EOD
sequencing.

This doesn't clean up the case of EOM appends- in this case you *will* still
get (after an MTEOM operation and a write of a file) a phantom empty file,
e.g. FILE - FMK FMK - FILE - FMK FMK EOD *unless* you follow the EOM operation
with an explicit backspace. The trouble is that this makes it difficult for
seamless interchange with other systems which don't necessarily follow.

The preferrable alternative would be to eliminate the 2FM@EOD except for
1/2" Reel tapes, but that has been pretty much nixed within developers.
 1.98  06-Aug-1998  drochner fix incorrect length of LOCATE CDB (reported in PR kern/5306 by
Dave Huang <khym@bga.com>)
 1.97  31-Jul-1998  mjacob Suggestion from Matthias Drochner: If at close you decide to write
filemark 'coz you opened write only and didn't do anything else,
call st_check_eod to possibly write TWO furshlugginer filemarks.

Also- return any errors from writing filemarks out of stclose.
 1.96  31-Jul-1998  mjacob Several more changes. First of all, move CTRL_MODE to have I/O behaviour
like a no-rewind device. Secondly figure out whether the initial TUR
for a CTRL_MODE open resulted in a tape being actually found (if so,
then do a mount session).

Move the 'sun compatibility' behaviour into stdone && stclose- don't
mark a tape as having been written in stopenm, fer gosh sakes.
 1.95  30-Jul-1998  mjacob Some minor comment tweaking.

Also- to be fair and on review, kern/391 isn't really addressed by
the previous commits. In reviewing, I'm embarassed to find that this
talks about reading at EOT. I'm actually going to claim that this
is 'not a bug' or 'fixed already' in that at the end of media (at the
edge of recorded media), you may continuously open the tape (should
you choose to) issue a read, and zero bytes will transfer- this is a
sufficient EOF indicator.
 1.94  30-Jul-1998  mjacob Clarify and name some of the 'open' modes. Clarify a few comments. Remove
a now unused variable. Also, remove the restriction against at density
code being greater than the max SCSI 2 density code: 0x80..0xff are the
Vendor Unique codes and most certainly should be allowed. The check for
invalid values should be less than 0 or greater than 255.

Oh- yeah, the previous commit addressed kern/391.
 1.93  30-Jul-1998  mjacob branches: 1.93.2;
Make some changes wrt EOM behaviour. Distinguish EIO_PENDING from
EOM_PENDING. Set up a persistent EARLYWARNING behaviour flag. If
set, EOM behaviour forces a 'short read' to signal logical (as
opposed to physical) end of media. The user application may, of
course, do with this information what it will.

The EARLYWARNING behaviour may be enabled/disabled by a MTIOCTOP
operation. The default action is to not have EARLYWARNING enabled-
but this may be reversed by an option ST_ENABLE_EARLYWARN in
the kernel build.
 1.92  19-Jul-1998  drochner Remove a check which restricted raw SCSI commands to the "minor 3"
("CTLMODE") subdevice. There are legitimate uses for raw commands with
normal tape handles too.
[I'm not sure if this is a final solution. Administrators might want
to set up a more finegrained policy. However, this should not be mixed
with the "set defaults" semantics of the "CTLMODE" subdevice; another
flag should be used instead (eg execute permission or a minor number bit).]
 1.91  15-Jul-1998  mjacob part of fix for kern/3835: use of enumerated returns from target sense handlers
 1.90  04-Jul-1998  mjacob Minor enhancements:

1) Quirk entries for Storage Tek 9490 (Timberline) and D3 (Redwood)
drives.

2) Modification to st_loadtape to do a REWIND to BOT if the
action is a load and the tape doesn't support the LOAD command
(9490, SD3, and IBM 3590).

3) Cleaned up the 'undersized user record' error message to
make a little more sense.

Various bug fixes:

kern/1275: Now returns values in dsreg and erreg and sets resid
(as best as it can for a 16 but integer). See also
a recent change to mtio.h. We are declining to fix
the portion of this bug about naming a more specific
SCSI device. Since there is nothing programmatic
you can do with that information, it is not useful
to pass back at this time.

A side effect of this change is that doing MTIOCGET
also forces a mode sense (to get the current state
of WRITE PROTECT).


kern/5647: Now no longer logs to the console ILI or Filemark or (first)
EOM (on write) errors (unless SCSIDEBUG is set).

kern/5525: Substantially increased timeouts for a variety of
operations, and split them into categories of
I/O, Space, and Control operations (each have
likely different inherent times). I/O is for
reads/writes. Control is for mode sense/select.
Space is for spacing the tape.

Until EOM handling is changed, though kern/391 is still not fixed. A side
effect of EOM handling is that you now always 'lose' (to the writing
application's view) the last write since EIO is what is returned on
EOM detection during writes. Hopefully the reader applications don't
get too bent out of shape by this.
 1.89  13-Feb-1998  enami Don't include <dev/scsipi/scsi_all.h> twice.
 1.88  07-Feb-1998  pk * Add the "VIPER 150/21531" to quirk list (ST_Q_SENSE_HELP).
* Double timeout on tape position commands to 30 minutes. Some units
seem capable of taking that much time.
 1.87  12-Jan-1998  thorpej Adjust for changes to config.
 1.86  28-Dec-1997  is Added ST_Q_SENSE_HELP to the Archive Viper 150S quirks so that
density 0 (autosense) actually works.
 1.85  07-Nov-1997  mjacob If we're in the middle of opening, don't let st_interpret_sense get
into the act and return EIO or whatever when we're just eating the
initial TEST UNIT READY induced check condition.
 1.84  18-Oct-1997  thorpej branches: 1.84.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.83  16-Oct-1997  mycroft Define FALSE and TRUE locally.
 1.82  13-Oct-1997  explorer o Make usage of /dev/random dependant on
pseudo-device rnd # /dev/random and in-kernel generator
in config files.

o Add declaration to all architectures.

o Clean up copyright message in rnd.c, rnd.h, and rndpool.c to include
that this code is derived in part from Ted Tyso's linux code.
 1.81  12-Oct-1997  mjacob Hello? If we're doing block positioning a timeout of greater than 5 seconds
is probably going to be necessary.
 1.80  10-Oct-1997  explorer Add hooks to insert timing info into the random system
 1.79  09-Oct-1997  enami Cosmetic changes;

- dereference a pointer to function explicitly.
- fold long line to fit columns < 80.
- put whitespaces around a binary operator.
- don't put a single statement into a block.
 1.78  09-Oct-1997  mjacob A) At least IBM 3590 tape drives return a NOT READY error if issued a LOAD
to BOT command- even if at BOT. Urk. B) Make READ POSITION SCSI_SILENT.
 1.77  01-Oct-1997  mjacob Many thanks to Wolfgang Rupprecht for spotting this... In order to be sure
about actual position when reading tape position, you should flush any
pending writes. Well, if the tape is write protected, some drives don't
see the zero count WRITE FILE MARK command as a no-op and complain. Dumb!
 1.76  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.75  29-Sep-1997  mjacob Add in mtop operation MTCMPRESS, which can enable or disable tape compression.
The method for doing this is to try and use the DATA COMPRESSION mode page
first, followed by the DEVICE CONFIGURATION page (this is because most newer
tape devices are now using DATA COMPRESSION instead of DEVICE CONFIGURATION
pages).

Add in the logical && hardware read position and set position ioctls. Oddly
enough, because NetBSD is limited in having the driver track file && record
numbers, the usual agony over what to do once you use logical or hardware
block positioning can be avoided. Amusing.

Make a minor change so that for SCSIVERBOSE cases that SCSI_SILENT in
the xs' flags is still observed.
 1.74  13-Sep-1997  enami Declare SCSIVERBOSE by defopt in files.scsipi. Include opt_scsiverbose.h
in scsi_base.c and st.c.
 1.73  27-Aug-1997  bouyer branches: 1.73.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.72  20-Aug-1997  mjacob If SCSIVERBOSE is enabled, call the routine to print out detailed sense
information.
 1.71  21-Feb-1997  thorpej branches: 1.71.4;
If posting an error condition because the media has been unloaded,
make sure to set the residual count to reflect that no data was
transfered.

From Naofumi HONDA / MINOURA Makoto, PR #3007.
 1.70  05-Dec-1996  cgd branches: 1.70.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.69  12-Oct-1996  christos revert previous kprintf change
 1.68  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.67  24-May-1996  thorpej Implement ST_Q_UNIMODAL quirk, which indicates that a drive will reject
all attempts to mode select, even if the attempted mode is supported.
Add the ST_Q_UNIMODAL quirk for the HP Colorado T4000s which exhibits
this behavior. (Someone please lob a tactical nuke in that direction.)

From David Rosenthal <dshr@vitria.com> on netbsd-bugs.
 1.66  05-May-1996  christos Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.
 1.65  30-Mar-1996  christos Eliminate scsi_conf.h.
 1.64  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.63  17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.62  05-Mar-1996  thorpej Normalize SCSI autoconfiguration output.
From Chris Demetriou <cgd@NetBSD.ORG>. Fixes PR #1958.
 1.61  18-Feb-1996  mycroft Minor change.
 1.60  17-Feb-1996  jtk remove #ifdef notdef made unnecessary by previous changes (PR#1597)
put in missing "if (error)" that caused tape IO to always fail.
(closes PR#2086)
 1.59  14-Feb-1996  christos scsi prototypes
 1.58  09-Feb-1996  briggs PR#2048. Prototype st_erase().
 1.57  11-Jan-1996  thorpej Honor cache request and implement erase command, and add the SCSI tape
device configuration page. Fixes PRs 807, 1201, and 1705.
From John Kohl <jtk@kolvir.blrc.ma.us>.
 1.56  05-Jan-1996  pk SCSI sense `info' field is a signed value (from John Kohl; PR#1597).
 1.55  30-Nov-1995  pk Add quirk for Exabyte 8200/rev. 263H (from Paul Goyette; PR#1797).
 1.54  13-Oct-1995  gwr Add quirk entries for Wangtek SCSI tapes. Also, add entry for
Tandberg 3800 (fixes PR#1592 - from Jochen Pohl).
 1.53  12-Aug-1995  mycroft opri --> s
 1.52  12-Aug-1995  mycroft Fix oversight in previous.
 1.51  12-Aug-1995  mycroft minphys() functions really should return void.
 1.50  24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.49  04-Jul-1995  mycroft Make each disk and tape driver define its own read and write functions.
Deprecate rawread() and rawwrite() completely. Remove d_strategy from cdevsw to
force the abstraction barrier.
 1.48  26-Jun-1995  cgd make dump stubs consistent
 1.47  25-Mar-1995  mycroft Add a rogue entry for the ANRITSU DMT780.
 1.46  30-Dec-1994  mycroft Update the rogue entry for ancient drivers to match reality.
 1.45  28-Dec-1994  mycroft Increase the st_space() timeout.
 1.44  28-Dec-1994  mycroft Numerous changes. Many bugs fixed, better autoconfig, a few new features.
 1.43  22-Nov-1994  mycroft Complete last change.
 1.42  21-Nov-1994  mycroft Return EIO when the drive is empty.
 1.41  21-Nov-1994  mycroft Clean up open and close routines somewhat.
 1.40  21-Nov-1994  mycroft Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.
 1.39  30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.38  20-Oct-1994  mycroft First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.
 1.37  12-Aug-1994  deraadt un-aligned access is not cool on some processors
 1.36  09-Aug-1994  mycroft Change ST_Q_NEEDS_PAGE_0 to something more generic.
 1.35  29-Jun-1994  cgd branches: 1.35.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.34  19-Jun-1994  mycroft Fix a comment.
 1.33  16-Jun-1994  chopps resolve confusion over who owns the buf after calling scsi_scsi_cmd()
 1.32  16-Jun-1994  mycroft b_un.b_addr -> b_data
 1.31  11-May-1994  mycroft Add dummy *dump() routines.
 1.30  09-May-1994  chopps remove union's from sense_data struct, conditionaly define RAW_PART
 1.29  24-Apr-1994  mycroft Deal with variable-length drives that don't specify a maximum block size.
c.f. SCSI 2 protocol definition.
 1.28  13-Apr-1994  mycroft Various cleanup, but no functional differences.
 1.27  11-Apr-1994  mycroft Fix various types. Remove some outdated flags.
 1.26  10-Apr-1994  mycroft Add another rogue...
 1.25  05-Apr-1994  mycroft This line is redundant for LD_UNLOAD (only one use, and it does this itself)
but breaks LD_RETEN, forcing a reload of the driver state on the next I/O
operation. Therefore, it goes away.
 1.24  05-Apr-1994  mycroft Reload the tape after retension.
 1.23  05-Apr-1994  mycroft Implement MTRETEN (untested).
 1.22  05-Apr-1994  mycroft Implement MTEOM, currently untested.
 1.21  01-Apr-1994  mycroft Deal with Mark Weaver's rogue tape drive.
 1.20  29-Mar-1994  mycroft New SCSI system, based on Julian's more recent work.
 1.19  06-Feb-1994  mycroft Remove another use of b_actl.
 1.18  11-Jan-1994  mycroft *strategy functions return void.
 1.17  17-Dec-1993  mycroft Canonicalize all #includes.
 1.16  01-Aug-1993  mycroft branches: 1.16.2;
Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.
 1.15  28-Jul-1993  cgd incorporate changes from 0-9-base to 0-9-ALPHA
 1.14  19-Jul-1993  cgd branches: 1.14.2;
patches from allen briggs to fix a minor bug in *attach()
 1.13  09-Jul-1993  cgd fix evil interaction with new physio; don't set error bit for short reads.
 1.12  27-Jun-1993  andrew ANSIfications.
 1.11  16-Jun-1993  andrew woops - another typo.
 1.10  16-Jun-1993  deraadt whoops. typo.
 1.9  16-Jun-1993  deraadt fix to intuit the maximum number of scsi units available on a device
driver. this piece at least, should be safe from changing sizeof(dev_t)
 1.8  20-May-1993  cgd add rcsids and clean up file headers
 1.7  04-May-1993  deraadt support for making dev->id_alive be set, this is for iostat to
find disk devices. wee bit of a kludge. sub-device attach()
routines must now return 1 for successful attach(), 0 otherwise.
Other bsd's do this too..
 1.6  22-Apr-1993  mycroft Fix up error messages and return values.
 1.5  20-Apr-1993  mycroft Display more meaningful message on SCSI `unit attention'.
 1.4  12-Apr-1993  deraadt fixed various bugs like cdattach() returning garbage.
 1.3  12-Apr-1993  deraadt new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.
 1.2  08-Apr-1993  glass attempting to open an already opened tape drive should get you EBUSY, not
ENXIO.
 1.1  21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.14.2.2  31-Jul-1993  cgd give names, err, wmesg's, to my "pain" -- i.e. convert sleep() to tsleep()
 1.14.2.1  26-Jul-1993  briggs When stioctl() got called with an unknown command, it was not
returning an error code consistently. This change forces it
to return EINVAL when the command is unknown.
 1.16.2.12  16-Feb-1994  mycroft More KNF-like.
 1.16.2.11  15-Feb-1994  mycroft Reset SDEV_WAITING so we actually wake up the waiting process...
 1.16.2.10  06-Feb-1994  mycroft Remove another use of b_actl.
 1.16.2.9  01-Feb-1994  mycroft Fix field name clash.
 1.16.2.8  01-Feb-1994  mycroft Change some things into arrays.
 1.16.2.7  22-Jan-1994  briggs NST -> stcd.cd_ndevs in SC_DEBUG statement.
 1.16.2.6  29-Nov-1993  mycroft Return EBUSY, not ENXIO, if alredy open.
 1.16.2.5  25-Nov-1993  mycroft Correct attach message.
 1.16.2.4  25-Nov-1993  mycroft Correct the display of some messages.
 1.16.2.3  25-Nov-1993  mycroft Compiles. Will it work?
 1.16.2.2  24-Nov-1993  mycroft Under construction...
 1.16.2.1  24-Sep-1993  mycroft cd.c, sd.c, st.c: strategy functions return void.
 1.35.2.2  06-Oct-1994  mycroft Update from trunk.
 1.35.2.1  09-Aug-1994  mycroft update from trunk
 1.70.6.1  12-Mar-1997  is Merge in changes from Trunk
 1.71.4.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.73.2.4  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.73.2.3  16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.73.2.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.73.2.1  27-Aug-1997  thorpej file st.c was added on branch marc-pcmcia on 1997-08-27 23:33:41 +0000
 1.84.2.2  30-Sep-1998  cgd pull up rev 1.98 (via patch; doesn't pull up cleanly) from trunk (drochner)
 1.84.2.1  07-Nov-1997  mellon Pull rev 1.85 up from trunk (mjacob)
 1.93.2.2  08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.93.2.1  30-Jul-1998  eeh file st.c was added on branch eeh-paddr_t on 1998-08-08 03:06:52 +0000
 1.110.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.110.2.1  23-Jan-2000  he Pull up revision 1.118 (requested by mjacob):
Recognize (indirectly) HP4000s via density code and do the right
QIC type dance. Fixes PR#9271.
 1.114.8.1  21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.114.2.8  29-Mar-2001  simonb Make this compile for the non-SCSIVERBOSE case.
 1.114.2.7  11-Feb-2001  bouyer Sync with HEAD.
 1.114.2.6  08-Dec-2000  bouyer Sync with HEAD.
 1.114.2.5  22-Nov-2000  bouyer Sync with HEAD.
 1.114.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.114.2.3  01-Nov-1999  thorpej Fixup the SC_DEBUG() stuff for the new world order.
 1.114.2.2  20-Oct-1999  thorpej Remove an unnecessary comment regarding XS_CTL_NOSLEEP.
 1.114.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.122.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.124.2.1  03-Nov-2000  tv Pullup 1.127 [pk]:
Remove useless check for SDEV_MEDIA_LOADED from st_read_block_limits().
This command should work whether or not media is present in the device.
 1.134.2.10  11-Nov-2002  nathanw Catch up to -current
 1.134.2.9  17-Sep-2002  nathanw Catch up to -current.
 1.134.2.8  01-Aug-2002  nathanw Catch up to -current.
 1.134.2.7  20-Jun-2002  nathanw Catch up to -current.
 1.134.2.6  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.134.2.5  28-Feb-2002  nathanw Catch up to -current.
 1.134.2.4  08-Jan-2002  nathanw Catch up to -current.
 1.134.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.134.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.134.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.142.2.6  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.142.2.5  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.142.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.142.2.3  11-Feb-2002  jdolecek Sync w/ -current.
 1.142.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.142.2.1  03-Aug-2001  lukem update to -current
 1.143.2.2  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.143.2.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.155.2.2  29-Aug-2002  gehenna catch up with -current.
 1.155.2.1  16-May-2002  gehenna Add the block/character device switches.
Replace the direct-access to devsw table with calling devsw API.
 1.163.4.1  11-Sep-2004  he Pull up revisions 1.165-1.166 (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.163.2.10  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.163.2.9  01-Apr-2005  skrll Sync with HEAD.
 1.163.2.8  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.163.2.7  02-Nov-2004  skrll Sync with HEAD.
 1.163.2.6  19-Oct-2004  skrll Sync with HEAD
 1.163.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.163.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.163.2.3  03-Sep-2004  skrll Sync with HEAD
 1.163.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.163.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.173.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.173.4.1  29-Apr-2005  kent sync with -current
 1.178.2.3  02-Dec-2007  riz Pull up following revision(s) (requested by bouyer in ticket #1880):
sys/dev/scsipi/st.c: revision 1.199-1.201 via patch
Properly set b_resid in an error case.
Clamp b_resid to b_bcount in case the info field is larger. Fix a KASSERT
in physio() when a media error occurs on my SDLT320 drive (maybe this drive
is bogus for not setting the highter bits to 0 in the INFO field in this
case).
When checking for invalid b_resid valyes, also check negative ones.
Should fix kern/36690.
Move check for b_resid value to the right place. Should definitively fix
kern/36690.
 1.178.2.2  17-Sep-2007  msaitoh Pull up following revision(s) (requested by bouyer in ticket #1837):
sys/dev/scsipi/st.c: revision 1.180
revert the only part of rev. 1.177 which made a functional
change -- it broke error reporting because st->asc(q) are
not set
(actually, I believe that SSD_RCODE_VALID is misnamed)
 1.178.2.1  06-Apr-2005  tron Pull up revision 1.179 (requested by yamt in ticket #112):
introduce a function to drain bufq and use it where appropriate.
 1.181.2.4  27-Oct-2007  yamt sync with head.
 1.181.2.3  03-Sep-2007  yamt sync with head.
 1.181.2.2  30-Dec-2006  yamt sync with head.
 1.181.2.1  21-Jun-2006  yamt sync with head.
 1.186.12.2  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.186.12.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.186.10.2  11-May-2006  elad sync with head
 1.186.10.1  19-Apr-2006  elad sync with head.
 1.186.8.4  03-Sep-2006  yamt sync with head.
 1.186.8.3  26-Jun-2006  yamt sync with head.
 1.186.8.2  24-May-2006  yamt sync with head.
 1.186.8.1  01-Apr-2006  yamt sync with head.
 1.186.6.2  22-Apr-2006  simonb Sync with head.
 1.186.6.1  04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.186.4.1  09-Sep-2006  rpaulo sync with head
 1.190.2.1  19-Jun-2006  chap Sync with head.
 1.192.4.2  10-Dec-2006  yamt sync with head.
 1.192.4.1  22-Oct-2006  yamt sync with head
 1.192.2.1  18-Nov-2006  ad Sync with head.
 1.194.8.1  06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.194.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.194.2.1  25-Nov-2007  xtraeme Pull up following revision(s) (requested by bouyer in ticket #1002):
sys/dev/scsipi/st.c: revision 1.199 (patch)
sys/dev/scsipi/st.c: revision 1.200 (patch)
sys/dev/scsipi/st.c: revision 1.201 (patch)
Properly set b_resid in an error case.
Clamp b_resid to b_bcount in case the info field is larger. Fix a KASSERT
in physio() when a media error occurs on my SDLT320 drive (maybe this drive
is bogus for not setting the highter bits to 0 in the INFO field in this
case).
When checking for invalid b_resid valyes, also check negative ones.
Should fix kern/36690.
Move check for b_resid value to the right place. Should definitively fix
kern/36690.
 1.196.4.1  11-Jul-2007  mjf Sync with head.
 1.196.2.7  12-Oct-2007  ad Sync with head.
 1.196.2.6  09-Oct-2007  ad Sync with head.
 1.196.2.5  09-Oct-2007  ad Sync with head.
 1.196.2.4  19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.196.2.3  15-Jul-2007  ad Sync with head.
 1.196.2.2  01-Jul-2007  ad Adapt to callout API change.
 1.196.2.1  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.197.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.198.10.2  29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.198.10.1  29-Jul-2007  ad file st.c was added on branch matt-mips64 on 2007-07-29 12:50:24 +0000
 1.198.8.2  14-Oct-2007  yamt sync with head.
 1.198.8.1  06-Oct-2007  yamt sync with head.
 1.198.6.1  06-Nov-2007  matt sync with HEAD
 1.198.4.3  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.198.4.2  07-Oct-2007  joerg Sync with HEAD.
 1.198.4.1  02-Oct-2007  joerg Sync with HEAD.
 1.202.18.5  17-Jan-2009  mjf Sync with HEAD.
 1.202.18.4  28-Sep-2008  mjf Sync with HEAD.
 1.202.18.3  29-Jun-2008  mjf Sync with HEAD.
 1.202.18.2  02-Jun-2008  mjf Sync with HEAD.
 1.202.18.1  05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.203.4.6  11-Aug-2010  yamt sync with head.
 1.203.4.5  11-Mar-2010  yamt sync with head
 1.203.4.4  19-Aug-2009  yamt sync with head.
 1.203.4.3  16-May-2009  yamt sync with head
 1.203.4.2  04-May-2009  yamt sync with head.
 1.203.4.1  16-May-2008  yamt sync with head.
 1.203.2.2  17-Jun-2008  yamt sync with head.
 1.203.2.1  18-May-2008  yamt sync with head.
 1.204.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.204.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.205.4.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.205.4.1  19-Oct-2008  haad Sync with HEAD.
 1.207.4.1  20-Nov-2008  snj Pull up following revision(s) (requested by bouyer in ticket #78):
sys/dev/scsipi/st.c: revision 1.208
If we return an error make sure we don't return a b_resid of 0; or this
will trigger a KASSERT in physio_done(). Fix issue reported by Todd Kover
on tech-kern@
 1.207.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.210.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.216.4.1  03-Jul-2010  rmind sync with head
 1.216.2.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.217.12.5  29-Apr-2012  mrg sync to latest -current.
 1.217.12.4  06-Mar-2012  mrg sync to -current
 1.217.12.3  06-Mar-2012  mrg sync to -current
 1.217.12.2  04-Mar-2012  mrg sync to latest -current.
 1.217.12.1  18-Feb-2012  mrg merge to -current.
 1.217.8.3  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.217.8.2  23-May-2012  yamt sync with head.
 1.217.8.1  17-Apr-2012  yamt sync with head
 1.218.2.2  23-Apr-2012  riz Pull up following revision(s) (requested by bouyer in ticket #192):
sys/dev/scsipi/cd.c: revision 1.307
sys/dev/scsipi/scsiconf.c: revision 1.266
sys/dev/scsipi/sd.c: revision 1.298
sys/dev/scsipi/st_scsi.c: revision 1.35
sys/dev/scsipi/atapiconf.c: revision 1.85
sys/dev/scsipi/scsipiconf.h: revision 1.120
sys/dev/usb/umass_scsipi.c: revision 1.44
sys/dev/scsipi/scsiconf.h: revision 1.57
sys/dev/scsipi/st_atapi.c: revision 1.29
sys/dev/scsipi/scsipi_base.c: revision 1.158
sys/dev/scsipi/st.c: revision 1.221
sys/dev/scsipi/scsipi_ioctl.c: revision 1.67
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
sync/wide parameters only make sense for parallel SCSI.
For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
tagged queing status if enabled. Just be silent for other
bustypes.
This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
appropriate parameters is enough to enable tagged queuing,
but then scsipi will print:
sd0: async, 8-bit transfers, tagged queueing
which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
but will confuse users. With this change scsipi will only print:
sd0: tagged queueing
which is correct.
In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.
Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.
 1.218.2.1  02-Mar-2012  riz Pull up following revision(s) (requested by mbalmer in ticket #64):
sys/dev/scsipi/stvar.h: revision 1.24
sys/dev/scsipi/st_scsi.c: revision 1.34
sys/dev/scsipi/st_atapi.c: revision 1.28
sys/dev/scsipi/st.c: revision 1.220
Convert st(4) to device_t, while here clean up the code and use uintXX_t
instead of u_intXX_t.
 1.221.4.1  18-May-2014  rmind sync with head
 1.221.2.2  03-Dec-2017  jdolecek update from HEAD
 1.221.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.223.2.2  10-Aug-2014  tls Rebase.
 1.223.2.1  07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.226.10.1  07-Mar-2019  martin Pull up following revision(s) (requested by kardel in ticket #1682):

sys/dev/scsipi/st.c: revision 1.236 (patch)
sys/dev/scsipi/st.c: revision 1.237
sys/dev/scsipi/files.scsipi: revision 1.42

Fix PR kern/53949:
Fix inconsistent/incomplete file mark handling to conform again
to mtio(4) at close(2) time. This was necessary as the PREVENT/ALLOW
bracket was reduced from a whole mount session to cover only the
open(2)/close(2) time on ~2002-03-22. The rationale was to allow
robots and humans to change the media during a mount session.

Unfortunately this lead to file marks being written to potentially other
media at the beginning on drives that used the two file marks as EOM
pattern. In order for that to happen the media had to be removed after
data and at most one file mark had been written before removal.

The mount error message has been clarified and a warning about
potential data/file mark lossage on UNIT ATTENTION
during an active mount session with unfinished file marks has been
added.

While there, fix, but disable the commented SUN compatibility to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.

It can now be enabled with options ST_SUNCOMPAT.

Additionally debug output coverage has been extended.

Correct printing type of b_blkno (int64_t) in st.c

Fixes build with kUBSan on NetBSD/i386.

Fix, but disable the commented SUN compatibility in st.c to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.
It can now be enabled with options ST_SUNCOMPAT.
 1.226.6.1  07-Mar-2019  martin Pull up following revision(s) (requested by kardel in ticket #1682):

sys/dev/scsipi/st.c: revision 1.236 (patch)
sys/dev/scsipi/st.c: revision 1.237
sys/dev/scsipi/files.scsipi: revision 1.42

Fix PR kern/53949:
Fix inconsistent/incomplete file mark handling to conform again
to mtio(4) at close(2) time. This was necessary as the PREVENT/ALLOW
bracket was reduced from a whole mount session to cover only the
open(2)/close(2) time on ~2002-03-22. The rationale was to allow
robots and humans to change the media during a mount session.

Unfortunately this lead to file marks being written to potentially other
media at the beginning on drives that used the two file marks as EOM
pattern. In order for that to happen the media had to be removed after
data and at most one file mark had been written before removal.

The mount error message has been clarified and a warning about
potential data/file mark lossage on UNIT ATTENTION
during an active mount session with unfinished file marks has been
added.

While there, fix, but disable the commented SUN compatibility to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.

It can now be enabled with options ST_SUNCOMPAT.

Additionally debug output coverage has been extended.

Correct printing type of b_blkno (int64_t) in st.c

Fixes build with kUBSan on NetBSD/i386.

Fix, but disable the commented SUN compatibility in st.c to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.
It can now be enabled with options ST_SUNCOMPAT.
 1.226.4.4  28-Aug-2017  skrll Sync with HEAD
 1.226.4.3  05-Dec-2016  skrll Sync with HEAD
 1.226.4.2  05-Oct-2016  skrll Sync with HEAD
 1.226.4.1  22-Sep-2015  skrll Sync with HEAD
 1.226.2.1  07-Mar-2019  martin Pull up following revision(s) (requested by kardel in ticket #1682):

sys/dev/scsipi/st.c: revision 1.236 (patch)
sys/dev/scsipi/st.c: revision 1.237
sys/dev/scsipi/files.scsipi: revision 1.42

Fix PR kern/53949:
Fix inconsistent/incomplete file mark handling to conform again
to mtio(4) at close(2) time. This was necessary as the PREVENT/ALLOW
bracket was reduced from a whole mount session to cover only the
open(2)/close(2) time on ~2002-03-22. The rationale was to allow
robots and humans to change the media during a mount session.

Unfortunately this lead to file marks being written to potentially other
media at the beginning on drives that used the two file marks as EOM
pattern. In order for that to happen the media had to be removed after
data and at most one file mark had been written before removal.

The mount error message has been clarified and a warning about
potential data/file mark lossage on UNIT ATTENTION
during an active mount session with unfinished file marks has been
added.

While there, fix, but disable the commented SUN compatibility to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.

It can now be enabled with options ST_SUNCOMPAT.

Additionally debug output coverage has been extended.

Correct printing type of b_blkno (int64_t) in st.c

Fixes build with kUBSan on NetBSD/i386.

Fix, but disable the commented SUN compatibility in st.c to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.
It can now be enabled with options ST_SUNCOMPAT.
 1.228.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.230.8.4  04-Nov-2019  martin Pull up following revision(s) (requested by jnemeth in ticket #1421):

sys/dev/scsipi/st.c: revision 1.238

Add simple position recovery when positioning to EOM by reading
the position with READ_POSITION.
this allows for

mt eom
mt st

to return the correct file position.
 1.230.8.3  01-Mar-2019  martin Pull up following revision(s) (requested by kardel in ticket #1197):

sys/dev/scsipi/st.c: revision 1.236
sys/dev/scsipi/st.c: revision 1.237
sys/dev/scsipi/files.scsipi: revision 1.42

Fix PR kern/53949:

Fix inconsistent/incomplete file mark handling to conform again
to mtio(4) at close(2) time. This was necessary as the PREVENT/ALLOW
bracket was reduced from a whole mount session to cover only the
open(2)/close(2) time on ~2002-03-22. The rationale was to allow
robots and humans to change the media during a mount session.

Unfortunately this lead to file marks being written to potentially other
media at the beginning on drives that used the two file marks as EOM
pattern. In order for that to happen the media had to be removed after
data and at most one file mark had been written before removal.

The mount error message has been clarified and a warning about
potential data/file mark lossage on UNIT ATTENTION
during an active mount session with unfinished file marks has been
added.

While there, fix, but disable the commented SUN compatibility to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.
It can now be enabled with options ST_SUNCOMPAT.
Additionally debug output coverage has been extended.

-

Correct printing type of b_blkno (int64_t) in st.c

Fixes build with kUBSan on NetBSD/i386.
Fix, but disable the commented SUN compatibility in st.c to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.
It can now be enabled with options ST_SUNCOMPAT.
 1.230.8.2  08-Apr-2018  snj Pull up following revision(s) (requested by mlelstv in ticket #703):
sys/dev/scsipi/st.c: 1.234
sys/dev/scsipi/stvar.h: 1.26
Use separate lock to protect internal state and release locks when
calling biodone.
 1.230.8.1  21-Jun-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #53):
sys/dev/scsipi/atapiconf.c: revision 1.91
sys/dev/scsipi/cd.c: revision 1.341
sys/dev/scsipi/scsi_base.c: revision 1.92
sys/dev/scsipi/scsiconf.c: revision 1.280
sys/dev/scsipi/scsipi_base.c: revisions 1.176, 1.177
sys/dev/scsipi/sd.c: revision 1.325
sys/dev/scsipi/ss.c: revision 1.89
sys/dev/scsipi/st.c: revision 1.231
The atapibus detach path did hold the channel mutex while calling into autoconf,
which would trigger a panic when unplugging a USB ATAPI CDROM.
Align detach code for scsibus and atapibus to fix this.
Also avoid races when detaching devices by replacing callout_stop with
callout_halt.
--
pass config_detach error to caller.
 1.231.4.1  30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.234.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.234.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.234.2.1  10-Jun-2019  christos Sync with HEAD
 1.240.12.1  17-Jun-2021  thorpej Sync w/ HEAD.

RSS XML Feed