Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/sd.c
RevisionDateAuthorComments
 1.345  13-Apr-2025  jakllsch Add physical sector and alignment info to struct disk_geom and the
geometry plist, and handle in partutil.

Bump version for disk_geom addition.

Collect DIOCGSECTORALIGN handling into one place.
 1.344  12-Apr-2025  mlelstv Use WRITE_16 for dumps when necessary.
 1.343  05-Mar-2025  jakllsch sd(4): print physical sector information
 1.342  02-Mar-2025  riastradh sd(4): Break overlong lines.

No functional change intended.
 1.341  27-Feb-2025  jakllsch sd(4): Translate discard to UNMAP (10) command
 1.340  27-Feb-2025  jakllsch Implement DIOCGSECTORALIGN for sd(4).

Use only READ CAPACITY 16 if peripheral claims conformance to SPC-3.
 1.339  27-Feb-2025  jakllsch whitespace fixes
 1.338  11-Feb-2025  mlelstv Handle unit startup issues also before "media is loaded".
 1.337  28-Sep-2024  mlelstv Don't artificially limit block size to 4096 bytes, use MAXPHYS.
 1.336  24-Feb-2024  mlelstv Don't try to discover wedges when the unit isn't online.
 1.335  28-Aug-2022  mlelstv branches: 1.335.4;
Don't fetch data beyond end of inquiry buffer, which, here, is not
NUL-terminated.

Reduce target buffer to needed size (product name + NUL terminator).
 1.334  28-Mar-2022  riastradh sd(4): Use d_cfdriver/devtounit to avoid open/detach races.
 1.333  27-Jan-2022  jakllsch use powerof2() in sd_validate_blksize()
 1.332  30-May-2021  dholland typo in comment
 1.331  10-Feb-2021  christos branches: 1.331.4; 1.331.6;
PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()
 1.330  25-Sep-2020  jakllsch branches: 1.330.2;
spelling fixes in sd.c comments
 1.329  13-Apr-2020  maxv constify
 1.328  01-Mar-2020  riastradh branches: 1.328.4;
Add a flag to dk_dump for virtual disk devices.

If a disk is backed by a physical medium other than itself, such as
cgd(4), then it passes DK_DUMP_RECURSIVE to disable the recursion
detection for dk_dump.

If, however, a device represents a physical medium on its own, such
as wd(4), then it passes 0 instead.

With this, I can now dump to dk on cgd on dk on wd.
 1.327  19-Mar-2019  mlelstv branches: 1.327.4;
Set disk product name as disk type. The information can be queried through
drvctl(4).
 1.326  07-Oct-2018  christos Handle the SATA to USB external enclosure sold by "Sabrent" and
made by JMicro (vendor=0x152d product=0x0578). This bridge does
not understand FUA, so add a quirk for it.
 1.325  17-Jun-2017  mlelstv branches: 1.325.4; 1.325.6;
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.324  10-Apr-2017  jdolecek branches: 1.324.4; 1.324.6;
execute the cache page MODE SENSE with XS_CTL_SILENT; it's pretty normal
for e.g. USB sticks thus showing error is not really useful, and the pretty
printing triggers autoload of scsiverbose module and immediate deadlock when
the DIOCGCACHE call is made by WAPBL during root mount

adresses PR kern/52147 by Michael van Elst
 1.323  05-Apr-2017  jdolecek expose disk device FUA/DPO support via DIOCGCACHE, and allow the flags
to be set for I/O; implement support in sd(4) and nvme(4)

discussed on tech-kern
 1.322  21-Dec-2016  mlelstv branches: 1.322.2;
really keep request queued after resource shortage
 1.321  16-Dec-2016  mlelstv add comment about "missing" dk_start.
 1.320  10-Dec-2016  mlelstv Refactored sd and cd to use common disk subroutines.
 1.319  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.318  20-Nov-2016  pgoyette Avoid calling bufq_free() from critical code sections.
 1.317  24-Aug-2015  pooka branches: 1.317.2;
would you like some freshly ground _KERNEL_OPT with that?
yes? excellent choice, sir/madam.
 1.316  26-Apr-2015  mlelstv Use C99-style initializers for struct dkdriver.
 1.315  13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.314  02-Jan-2015  christos We have three sets of DTYPE_ constants in the kernel:
altq Drop Type
disklabel Disk Type
file Descriptor Type
(not to mention constants that contain the string DTYPE).
Let's make them two, by changing the disklabel one to be DisK TYPE since the
other disklabel constants seem to do that. Not many userland programs use
these constants (and the ones that they do are mostly in ifdefs). They will
be fixed shortly.
 1.313  31-Dec-2014  christos make more drivers use disk_ioctl, and add a dev parameter to it so that
we can merge the "easy" disklabel ioctls to it. Ultimately all this will
go do dk_ioctl once all the drivers have been converted.
 1.312  31-Dec-2014  christos Centralize wedge ioctls in disk_ioctl.
 1.311  31-Dec-2014  mlelstv disk_blocksize and disk_set_info relay the same information
to the disk subsystem.

Make disk_set_info also set blocksize shift values.
Remove every call to disk_blocksize.

Keep disk_blocksize for ABI compatibility, make it also set dg_secsize.
 1.310  04-Nov-2014  mlelstv branches: 1.310.2;
support DIOCMWEDGES ioctl.
 1.309  05-Sep-2014  matt Don't use new as a variable name.
 1.308  10-Aug-2014  tls branches: 1.308.2;
Merge tls-earlyentropy branch into HEAD.
 1.307  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.306  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.305  16-Mar-2014  dholland branches: 1.305.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.304  25-Oct-2013  martin Mark a diagnostic-only variable
 1.303  28-Sep-2013  skrll Remove unnecessary initialisation of error
 1.302  26-Sep-2013  kiyohara Reset variable error to 0 before handle each ioctl cmd. Or returns EPASSTHROUGH
when some cmds. (e.g. ODIOCGDINFO)
 1.301  13-Jun-2013  tls branches: 1.301.2;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.300  29-May-2013  christos phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.
 1.299  16-Apr-2013  jakllsch Clamp sectors per unit in the default disklabel to the maximum value,
instead of allowing it to wrap, as is already done in wd(4).
 1.298  19-Apr-2012  bouyer branches: 1.298.2;
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.297  06-Apr-2012  christos Add a quirk for the Apple iPod whose mode sense commands fails with not ready.
Seems to work just fine if we send a start command first...
 1.296  02-Feb-2012  tls branches: 1.296.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.295  25-Nov-2011  joerg branches: 1.295.2;
Replace memset with incorrect size argument with M_ZERO.
 1.294  30-Jul-2011  jmcneill branches: 1.294.2;
Add an FSILENT flag and use it to suppress "Medium Not Present" scsipi
spam when trying to access offline drives at boot.
 1.293  14-Apr-2010  jakllsch Implement DIOC[GS]STRATEGY for sd(4).
 1.292  24-Feb-2010  dyoung branches: 1.292.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.291  08-Jan-2010  dyoung branches: 1.291.2;
Expand PMF_FN_* macros.
 1.290  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.289  03-Aug-2009  jnemeth Fix previous where the call of sd_set_properties was moved from
the end of sdattach() to the end of sd_get_parms(). The code at
the bottom of sd_get_parms() was only used for optical drives or
in the case where the drive geometry couldn't be retrived for some
reason, to create a fake geometry. The case for setting up the
real geometry was handled above that code.
 1.288  21-Jun-2009  jakllsch Move call of sd_set_properties() to end of sd_get_parms(), rather than
sdattach(). This allows DIOCGDISKINFO to do the right thing even when
the media has changed. Note that drvctl -p will only DTRT if disk has
been opened since the most recent media chenged.
 1.287  05-Jun-2009  haad Add support for DIOCGDISKINFO to disk like device drivers. Change
partutil.c::getdiskinfo to use it to get disk geometry info.
Use DIOCGWEDGEINFO ioctl to get information about partition size, if disk
driver doesn't support it use old DIOCGDINFO. This patch adds support for
wedge like devices(lvm logical volumes, ZFS zvol partitions) to newfs and
other tools.

No objections on tech-userlevel@.
 1.286  20-May-2009  dyoung On second thought, let's call disk_predetach() disk_begindetach().
Verbs are good.
 1.285  19-May-2009  dyoung Use disk_predetach().
 1.284  19-May-2009  dyoung Delete wdactivate() and sdactivate(). They were no-ops, but as a
side-effect of registering them, config_detach(9) cleared DVF_ACTIVE
before it called wddetach() or sddetach(). Even though sd(4)'s
detachment may have subsequently failed with EBUSY, we could not
begin new disk I/O on sd(4) because the device had been deactivated.

By analogy to sdstrategy(), test device_is_active() in wdstrategy()
and if it is false set b_errno to EIO instead of initiating new
disk I/O.

XXX We should decline more politely to start new I/O, since
XXX !device_is_active() may mean simply that the device is suspended.
XXX I suppose that EIO is safe as long as system suspension is
XXX all-or-nothing.
 1.283  17-May-2009  dyoung Reverse the sense of the DETACH_FORCE check so that we return EBUSY in
the correct circumstances.
 1.282  16-May-2009  dyoung Do not detach a sd(4) instance if it is open, but return EBUSY,
instead. If the detach is forced, do what sdclose() does on the
last close: flush the cache, delete our reference to the SCSI bus
device, et cetera.
 1.281  12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.280  12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.279  10-Apr-2009  dyoung Use a PMF shutdown hook instead of shutdownhook_establish(). This ought
to stop the crash during shutdown that yamt@ reports in kern/41182.
 1.278  07-Apr-2009  dyoung Detach atapibus(4), scsibus(4), cd(4), and sd(4) during shutdown.
Destroy sd->sc_callout in sddetach(). Delete some dead code in
cddetach().
 1.277  13-Jan-2009  yamt branches: 1.277.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.276  11-Jan-2009  cegger make this compile
 1.275  16-Jul-2008  drochner branches: 1.275.2; 1.275.4;
split device/softc for sd (tested with a USB stick)
 1.274  08-Jun-2008  tsutsui branches: 1.274.2; 1.274.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.273  28-Apr-2008  martin branches: 1.273.2;
Remove clause 3 and 4 from TNF licenses
 1.272  05-Apr-2008  cegger branches: 1.272.2; 1.272.4;
use aprint_*_dev and device_xname
 1.271  29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.270  21-Feb-2008  drochner put back the old shutdown handlers to flush the disk cache,
the pmf API can't deal with all the different suspend/resume/reboot
cases well yet, so better keep suspend/resume and reboot/halt/poweroff
clearly seperated
 1.269  25-Dec-2007  perry branches: 1.269.2; 1.269.6;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.268  09-Dec-2007  jmcneill branches: 1.268.2;
Merge jmcneill-pm branch.
 1.267  08-Oct-2007  ad branches: 1.267.4; 1.267.6; 1.267.8;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.266  01-Oct-2007  bouyer Properly initialize xs_callout in sddump(). We're using a static scsipi_xfer
here which didn't get through scsipi_get_xs().
Pointed out by Greg Oster.
 1.265  03-Aug-2007  tsutsui branches: 1.265.2; 1.265.4; 1.265.6; 1.265.8;
Don't allocate data buffer on stack in sd_read_capacity().

If data buffer is allocated on stack at the end of CPU cacheline,
the same cacheline region might be accessed via kernel stack even
after bus_dmamap_sync(9) against the data buffer in lower scsi drivers
so that read data via DMA could be lost.

Fixes occasional readdisklabel(9) failure at boot on ews4800mips
with osiop(4) driver and 128byte cacheline.

XXX: Other functions/drivers might have the similar problem.
 1.264  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.263  21-Jul-2007  ad Replace some uses of lockmgr().
 1.262  09-Jul-2007  ad branches: 1.262.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.261  04-Mar-2007  christos branches: 1.261.2; 1.261.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.260  03-Mar-2007  jnemeth add support devctl properties
 1.259  21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.258  30-Nov-2006  christos branches: 1.258.2; 1.258.4; 1.258.6;
Prevent kernel crashes caused by umass devices that return bogus mode sense
data, such as the "Cooler Master". From Rhialto. While there, clean up some
debugging code and make the offset unsigned.
 1.257  29-Nov-2006  drochner restore a nice little feature which got lost in some previous commit:
the d_typename field of the default disklabel is initialized with
text from the SCSI inquiry, so that one gets at least a vague idea which
disk he is dealing with
 1.256  26-Nov-2006  itohy If the block size reported by Read Capacity looks valid, just use it.
Use Request Sense only if Read Capacity succeeded and did not return
valid block size.
Discussed on tech-kern.
Fix the easier part of NetBSD PR kern/26537.
(The harder part is the device hangs on large (>= 8KB) transfer.
Possibly umass BBB problem?)

Remove scsipi_size() and scsipi_validate_secsize() from scsipi_base.c
and add their functions to sd.c since they are used only by sd.c.

Use SCSI term `block' instead of `sector' where applicable.
 1.255  25-Nov-2006  scw - Call disk_blocksize(9) once we know the disk's physical block size.
- bounds_check_with_label() has been fixed, so no need to fake the
raw partition's size in terms of DEV_BSIZE units.
 1.254  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.253  20-Oct-2006  scw Validate the sector size returned by READ CAPACITY. If it looks bogus
print a warning and fallback to a suitable default.

Fixes a problem on hp700 reported by skrll@
 1.252  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.251  09-Oct-2006  scw Some removable umass(4) devices don't respond to mode sense page 6, or
simply return zero for logical block size. In either case, use the sector
length reported by READ_CAPACITY instead of defaulting to 512 bytes.

This partially addresses the problems reported in PR port-i386/34707 and
PR kern/34737. Namely the incorrectly reported drive geometry and the
'hanging' issue.

However, since the device in question reports 2048-byte physical sectors
it will remain unusable until DEV_BSIZE is banished.
 1.250  14-Sep-2006  reinoud branches: 1.250.2;
Fix same panic problem as with cd.c when a scsi error happends on
read/write action. It would panic on a diagnosic assertion. When a scsi
read/write command fails, the whole extent is gone bad so mark all as not
done.
 1.249  09-Jul-2006  drochner branches: 1.249.2; 1.249.4;
some fixes for removable media (USB floppies in particular):
-allow to open RAW_PART, even if readdisklabel() doesn't like what it sees
-fix PERIPH_MEDIA_LOADED toggling on every other open attempt
-Don't reset PERIPH_REMOVABLE if prevent/allow fails - this is normal
for floppy drives. The flag is required for media change detection.
Honour XS_CTL_SILENT for the "no door lock" printouts, and set that flag
where scsipi_prevent() is called during open/close.
Tested with a USB floppy and a USB cardreader.
 1.248  01-Jun-2006  nathanw branches: 1.248.2;
Change return type of sdgetdisklabel() from void to int; return an error
if readdisklabel() returned an error.

sdopen(): Return an error if sdgetdisklabel() returns an error. This prevents
a crash in spec_open() (and possibly elsewhere) if a sd device is detached in
the middle of sdopen().
 1.247  30-Mar-2006  thorpej branches: 1.247.2;
Use device_private().
 1.246  28-Mar-2006  thorpej Use device_unit().
 1.245  20-Feb-2006  thorpej branches: 1.245.2; 1.245.4; 1.245.6;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
 1.244  11-Dec-2005  christos branches: 1.244.2; 1.244.4; 1.244.6;
merge ktrace-lwp.
 1.243  09-Dec-2005  bouyer Adapt previous change to recent scsipi. Pointed out by Simon Burge.
 1.242  08-Dec-2005  bouyer Some USB devices reports themselves as removable, but have no door and
so don't support the SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL command.
When an "Illegal field in CDB" is reported for this command, mark the
device as non-removable (which is always true for USB keys from the SCSI
point of view), print a message and ignore the error.
For DIOCLOCK, return ENOTTY if the device is not removable instead of
trying a command which will fail.

Fix a problem reported by Hubert Feyrer for some USB umass devices, patch
tested by him.
 1.241  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.240  29-May-2005  christos branches: 1.240.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
 1.239  25-Apr-2005  drochner Revert the part if 1.236 which comprises a functional change.
While I didn't observe a misbehaviour yet, this _must_ be
wrong because SSD_RCODE_VALID is used incorrectly.
 1.238  31-Mar-2005  yamt introduce a function to drain bufq and use it where appropriate.
 1.237  27-Feb-2005  perry branches: 1.237.2;
nuke trailing whitespace
 1.236  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.235  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.234  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.233  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.232  07-Dec-2004  thorpej branches: 1.232.2; 1.232.4;
SYNCHRONIZE_CACHE -> SYNCHRONIZE_CACHE_10
 1.231  07-Dec-2004  thorpej USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).
 1.230  04-Dec-2004  thorpej Use READ/WRITE (16) if the LBA is larger than 32 bits. Another bit
of kern/28514.
 1.229  28-Oct-2004  yamt move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.228  26-Sep-2004  dogcow Fix debug message output args to match yamt's src/sys/sys/buf.h changes.
 1.227  25-Sep-2004  thorpej Add support for wedges to the SCSI disk driver.
 1.226  17-Sep-2004  mycroft Remove the "xfer" argument to scsipi_command().
 1.225  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.224  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.223  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.222  06-Sep-2004  bouyer Fix comment: xxstart() can also be called from xxrestart()
 1.221  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.220  21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.219  28-Jun-2004  martin Add prototypes for the new functions added in previous commit.
 1.218  28-Jun-2004  mycroft Separate page 4/5 reading into separate functions. For "removable" devices,
try page 5 (flex geometry) first. This fixes problems with some broken USB
devices that do not handle page 4 correctly (rather than returning nothing,
or stalling, they return the CSW where there should be data).
 1.217  21-May-2004  bouyer If READ_FORMAT_CAPACITIES fails with "Medium Format Corrupted" ASC/ASQ error,
handle it as if the drive was not formatted, so that "scsictl sdx format"
can open the raw device.
 1.216  14-Mar-2004  thorpej branches: 1.216.2;
Use scsipi_adapter_minphys().
 1.215  28-Feb-2004  yamt change the way to handle NEW_BUFQ_STRATEGY option.
instead of putting #ifdefs into each drivers,
use a global variable to indicate default strategy.

XXX should have a way to specify other strategies.
 1.214  23-Dec-2003  pk Some older devices do not understand the `disable block descriptors' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

XXX this applies to the `page 4' case. The `page 5' didn't consider the
possible presence of a block descriptor at all, though it did allow the
device to return one. While that's fixed now, the `page 5' mode sense
does not use the `disable block descriptors' bit.

I'm not sure we should bother with this at all..
 1.213  29-Oct-2003  mycroft Back out the bogus initializer -- the compiler bug is fixed.
 1.212  28-Oct-2003  cl note 'm68k {u,}int64_t used uninitialized' bug.
add reference to gcc bug report.
mark all (known) occurrences.
 1.211  27-Oct-2003  fredb Appease gcc3 -Wno-uninitialized (even though blkno is clearly assigned in
each branch of a conditional).
 1.210  18-Sep-2003  mycroft Whoops, make sure 6-byte commands work again.
 1.209  18-Sep-2003  mycroft Merge the geometry and cache handling code for all direct access and optical
devices, as it's general to all SCSI MMC devices. In the process, remove
PQUIRK_NO_FLEX_PAGE.
 1.208  13-Sep-2003  mycroft Don't be silent if there is no media present.
 1.207  13-Sep-2003  mycroft Make sure the "raw partition" can always be opened again.
 1.206  09-Sep-2003  mycroft In the test for whether to start the unit, I used the wrong error code.
ENODEV is only returned when we get "medium not present," which we can fail
immediately on. All other "not ready" cases return EIO.
 1.205  08-Sep-2003  mycroft Fix an error path where we might scsipi_prevent() on a non-removable device.
 1.204  08-Sep-2003  mycroft Do a START UNIT only if the TEST UNIT READY reports that the device is not
ready. This avoids gratuitously starting the motor on floppy and CD-ROM
drives, and eliminates the need for the audio playing test in cdopen().

Therefore, also remove PQUIRK_NOSTARTUNIT.
 1.203  07-Sep-2003  mycroft Set PQUIRK_ONLYBIG in the wdc-atapi frontend, obviating the need to ever test
the "bus type" for this.

Merge all the code in the SCSI and ATAPI backends for "cd" devices. All of
the mode page handling and whatnot is general to SCSI MMC devices, and should
never have been separated to begin with. This fixes a variety of problems,
and adds load/unload support for SCSI-attached devices.
 1.202  29-Jun-2003  fvdl branches: 1.202.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.201  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.200  13-May-2003  thorpej Use aprint*().
 1.199  10-May-2003  thorpej Change bounds_check_with_label() to take a pointer to the disk structure,
rather than the label itself. This paves the way for some future changes.
 1.198  02-May-2003  dsl Change return type of readdisklabel() to const char *
I hope I've found all the correct places!
 1.197  03-Apr-2003  fvdl Check RAW_PART against the media size instead of the disklabel.
Add the media size in 512-byte sectors to the softc, to avoid
some 64 bit computations. Bump the capacity stored in softcs
for disks to 64 bits.
 1.196  20-Mar-2003  dbj use PRId64 to printf bp->b_blkno, which is of type daddr_t
 1.195  03-Feb-2003  thorpej Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.
 1.194  23-Jan-2003  bad Being able to make image backups of your whole disk, not to mention not
causing certain ata disks to lock up by reading beyond the last block,
beats catering to broken devices.

bounds_check_with_label() RAW_PART too.
 1.193  06-Jan-2003  wiz writable, not writeable.
 1.192  15-Dec-2002  fvdl Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.
 1.191  01-Nov-2002  mrg implement separate read/write disk statistics:
- disk_unbusy() gets a new parameter to tell the IO direction.
- struct disk_sysctl gets 4 new members for read/write bytes/transfers.
when processing hw.diskstats, add the read&write bytes/transfers for
the old combined stats to attempt to keep backwards compatibility.

unfortunately, due to multiple bugs, this will cause new kernels and old
vmstat/iostat/systat programs to fail. however, the next time this is
change it will not fail again.

this is just the kernel portion.
 1.190  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.189  18-Oct-2002  junyoung Add option NEW_BUFQ_STRATEGY, a new buffer queue strategy for better
system responsiness under high disk I/O load.

OK'ed by Juergen Hannken-Illjes.
 1.188  18-Sep-2002  chs remove all vesitages of dk_establish().
 1.187  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.186  30-Aug-2002  hannken Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>
 1.185  21-Jul-2002  hannken Rename bufq_init() to bufq_alloc().
Add bufq_free() to remove a buffer queue.
Avoid MALLOC while holding a spinlock.

From Chuck Silvers.
 1.184  16-Jul-2002  hannken Implement a new device buffer queue interface.
One basic struct, a function to setup a queue with a specific strategy and
three macros to put buf's into the queue, get and remove the next buf or
get the next buf without removal.

The BUFQ_XXX interface will be removed in the future.
The B_ORDERED flag is not longer supported.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>
 1.183  15-May-2002  bouyer branches: 1.183.2;
The number of sector is unsigned long, so use %lu to print it.
 1.182  05-May-2002  bouyer 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.181  09-Jan-2002  thorpej Add ioctls to get (DIOCGCACHE) and set (DIOCSCACHE) cache enables
on disks in a generic way. Implement these ioctls for SCSI disks.

This is not fully fleshed-out yet, but it allows people to experiment
with disk caches more easily.
 1.180  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.179  13-Nov-2001  lukem add RCSIDs
 1.178  18-Jul-2001  thorpej branches: 1.178.2;
bzero -> memset
 1.177  01-Jun-2001  bouyer branches: 1.177.2;
Fix typo in sddump() which caused core dumps to fail with ENXIO.
 1.176  29-May-2001  chs fix some problems in sddump() with uninitialized variables.
 1.175  22-May-2001  mjacob Make SDRETRIES an option you can dig out of opt_scsi.h.

Add SD_IO_TIMEOUT (an option in opt_scsi.h) also, which defaults to the
normal 60 * 1000 timeout for normal read/write commamds. This allows you
to shorten or lengthen the timeout as needed.
 1.174  06-May-2001  drochner Since __HAVE_OLD_DISKLABEL, DISKMINOR(u, p) isn't continuous over "p"
anymore. So we can't pass a range to vdevgone() but have to loop over the
partitions explicitely.
(otherwise the next device unit will be killed)
 1.173  28-Apr-2001  tsutsui Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).
 1.172  28-Apr-2001  thorpej Use simple tags for read and write, unless B_ORDERED is set, in
which case we use an ordered tag.
 1.171  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.170  09-Mar-2001  explorer Only lock the pack in if the disk device is a removable one. This fixes a
problem with Hitachi SCA drives
 1.169  08-Jan-2001  fvdl branches: 1.169.2;
Return error in the case of using ODIOCGDINFO or ODIOCGDEFLABEL when
the number of partitions is > OLDMAXPARTITIONS. This is better
than silently truncating the label (don't want to silently throw
away partitions when using an old disklabel binary on a label with
> 8 partitions). From Enami Tsugutomo.
 1.168  07-Jan-2001  fvdl Adapt all disk devices in MI directories to handle ODIOC* calls
for ports that have bumped MAXPARTITIONS (and thus define
__HAVE_OLD_DISKLABEL).
 1.167  08-Dec-2000  augustss Don't access (in core) disk label of a removable disk that is not there.
 1.166  24-Nov-2000  chs avoid division and remainder operations for devices where
the sector size is DEV_BSIZE (ie. practically everything).
 1.165  22-Nov-2000  soren Remove obsolete comment.
 1.164  05-Jul-2000  thorpej Garbage-collect __BDEVSW_DUMP_OLD_TYPE.
 1.163  09-Jun-2000  enami branches: 1.163.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.162  30-May-2000  augustss Add a quirk, SDEV_ONLYBIG, which implies that the device cannot handle
the 6 byte versions of READ, WRITE, and MODE_SENSE.
This greatly simplifies the UFI (USB Floppy) handling.
 1.161  23-May-2000  bouyer branches: 1.161.2;
sd_interpret_sense() can be called from interrupt context; call scsipi_start()
with XS_CTL_ASYNC if the failed command was called with XS_CTL_ASYNC.
Add a SDF_RESTART flag to keep state, cleared in sddone().
A mounted disk can now spin down, it will propely spin up at the next access.
 1.160  16-May-2000  thorpej Nuke dk_establish() from orbit except from those ports which still use
it to determine the boot device: mvme68k, pc532, macppc, ofppc. Those
platforms should be changed to use device_register(). In the mean time,
those ports defined __BROKEN_DK_ESTABLISH.
 1.159  30-Mar-2000  augustss Get rid of register declarations.
 1.158  13-Mar-2000  soren Fix doubled 'the's in comments.
 1.157  07-Feb-2000  thorpej Fix a bug in disksort_*() which caused non-optimal ordering when multiple
active partitions were on a single spindle. Add a b_rawblkno member to
struct buf which contains the non-partition-relative block number to sort
by.
 1.156  25-Jan-2000  drochner try to dtrt for sector sizes <DEV_BSIZE (at least, don't divide by 0)
 1.155  21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.154  23-Dec-1999  leo Implement the DIOCKLABEL ioctl. Through this ioctl it it possible keep the
disklabel on the last close or to drop it.
 1.153  03-Nov-1999  matt use __vax__ and __i386__ instead of vax and i386
 1.152  30-Oct-1999  bouyer In sddump(), check sd->sc_dev.dv_flags once sd has been initialised.
Patch supplied by tsutsui@ceres.dti.ne.jp in kern/8708.
 1.151  17-Oct-1999  ragge branches: 1.151.2; 1.151.4;
Don't call dk_establish() on vax either.
 1.150  17-Oct-1999  enami Cosmetic changes.
 1.149  30-Sep-1999  thorpej branches: 1.149.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.148  21-Sep-1999  enami Calculate the correct device minor of the first partition.
 1.147  11-Sep-1999  thorpej Implement detaching SCSI and ATAPI disks.
 1.146  26-Aug-1999  hannken Make `sc_ops->sdo_flush' synchronous. The flags `SDF_FLUSHING' and
`SDF_DIRTY' were never reset because `sddone' doesn't get called from
synchronous scsi commands.
 1.145  31-May-1999  lukem * use format_bytes() to display the disk size
* wrap a couple of printf()s
 1.144  28-Feb-1999  explorer branches: 1.144.4;
Update to slightly altered rnd_attach_source() api
 1.143  10-Feb-1999  bouyer Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.
 1.142  08-Feb-1999  bouyer Change DIOCEJECT to do what's needed to eject a device before the eject
command (unlock for sd and cd) if no other partitions are open, return
EBUSY otherwise. DIOCEJECT will have the old semantic if its argument is not
0. The old ioctl has been renamed to ODIOCEJECT for binary compatibility.
 1.141  29-Jan-1999  bouyer Return ENODEV instead of EIO when we are trying to open a device without media
in the drive. restrict "opening of empty drive" to character devices only
(reading a block device returns a short read instead of ENODEV, which can lead
to confusion).
 1.140  26-Jan-1999  bouyer Allows the raw partition to be open()'ed, even when scsipi_start() fails
(no media or other ...) so that we can always send ioctl's to the device.
 1.139  19-Jan-1999  bouyer Move test for SDEV_NOSTARTUNIT quirk from sd.c to scsipi_start().
Add a SDEV_NOSTARTUNIT quirk entry for BCD-16X 1997-04-25", "", "VER 2.2"
CD-rom (from Michael Santos).
 1.138  08-Dec-1998  thorpej When closing, wait for pending xfers to drain before unlocking the door,
and wait again before deleting the reference to the adapter.
 1.137  20-Nov-1998  thorpej Add adapter reference counting for SCSI and ATAPI devices.
 1.136  17-Nov-1998  bouyer The ATAPI-specific hack is not needed any more.
 1.135  17-Aug-1998  thorpej Only mark the disk dirty if we write.
 1.134  17-Aug-1998  mycroft Assign my copyrights to TNF.
 1.133  15-Aug-1998  thorpej Should not use SCSI_POLL if the system is not cold.
 1.132  15-Aug-1998  thorpej Keep track if the disk has had done i/o, making it dirty. On last close,
or at shutdown, flush the cache if the disk is still dirty and it support
cache flushing. Fixes PRs #5588 (Jim Bernard) and #5589 (Justin Gibbs).
 1.131  05-Aug-1998  drochner Improve generation of default disklabels:
-store printable product ID in cd's and sd's softc, use it as "typename"
-for this, add a "destination buffer length" argument to scsipi_strvis()
-return ATAPI device type for ATAPI devices
 1.130  31-Jul-1998  thorpej Typo.
 1.129  30-Jul-1998  thorpej From cd.c: call disk_unbusy() if we are unable to enqueue our command.
 1.128  30-Jul-1998  mjacob branches: 1.128.2;
opt_scsiverbose.h now is opt_scsi.h and contains the defopted
SCSIVERBOSE and the new ST_ENABLE_EARLYWARN.
 1.127  15-Jul-1998  mjacob Fix for kern/3835: add an sd sense handler. If we get a check condition/sense
data ASC/ASCQ of 0x04/0x01 (logical unit not ready, initialization in progress),
hang out for 5 seconds and return a RETRY THE OPERATION command. If we
get a check condition/sense data ASC/ASCQ of 0x04/0x02 (logical unit not
ready, initialization command required), send a polled/nosleep START UNIT
command and return a RETRY THE OPERATION command if that succeeds.

Don't send a START UNIT to a disk quirked as SDEV_NO_START. Don't send
a START UNIT to removable media. The reason for the latter is to not
just blindly spin up new (maybe changed) media.

I should note that I've successfully made this work with the ISP host
adapter so far. Other host adapters will need some work to be able
to manage or reasonably fail NOSLEEP/POLL commands while in this
state. Alternatively, the internal SCSI midlayer structure has got
to allow for more controlled error recovery (e.g., restart queues
controlled by the target driver).
 1.126  03-Mar-1998  cgd in the ATAPI bug workaround code ("HACK"), don't forget to set
SCSI_AUTOCONF when executing SCSI commands.
 1.125  15-Jan-1998  cgd #if some bug workaround code which only needs to be compiled if
ATAPI 'sd's are present.
 1.124  15-Jan-1998  cgd add support for an ATAPI attachment for 'sd'.
fix 'cd' driver's NCD_SCSI bogosity (was using testing wrong macro!)
clean up in various ways:
* make common atapi_mode_{sense,select}() functions.
* put ATAPI data structures in more sensible headers, split up by
device type.
* include headers a bit more carefully.
* pass flags to attachment-specific cd functions, and use them.
* get rid of SCSI bits in scsipi_base.h's scsipi_make_xs(), move
them into the correct place in scsi_base.c.
* fix minor typo in struct name in scsipiconf.h (which was apparently
never used except in a #define later in the same file).
* use __attribute__ to force 4-byte alignment for xs command store,
so that architectures trying to bus_space_write_multi_N() (where
N > 1) that data to a controller won't lose.
* clean up a few comments in typos, and make a few #defines easier to
understand/maintain.
* rename cd_link.h to cdvar.h (via repository copy). This is exactly
what a 'var' file is supposed to be.
 1.123  12-Jan-1998  thorpej Adjust for changes to config.
 1.122  18-Oct-1997  thorpej 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.121  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.120  10-Oct-1997  explorer Add hooks to insert timing info into the random system
 1.119  08-Oct-1997  thorpej Implement DIOCGDEFLABEL.
 1.118  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.117  20-Sep-1997  mjacob Allow SDOUTSTANDING to be defined elsewhere (e.g., config file).
 1.116  27-Aug-1997  bouyer branches: 1.116.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.115  04-Aug-1997  fair trivial change for PR#3815
 1.114  02-Jul-1997  phil branches: 1.114.2;
Report actual disksize on finding a disk.
(From: der Mouse <mouse@Rodents.Montreal.QC.CA>)
 1.113  24-Jun-1997  thorpej foosize()'s return value is in DEV_BSIZE units; adjust the size obtained
from the disklabel accordingly.
 1.112  18-Jun-1997  pk sdsize(): only call sdopen()/sdclose() if not already open, per the
current openmask.
 1.111  02-Apr-1997  mycroft Push the buffer cleanup code into scsi_done(), and split it so that biodone()
is called *after* the driver `done' routine. This fixes disk I/O statistics
on SCSI devices.

Also, calling the `done' routine with a `complete' argument of 0 and actually
having it do anything meaningful loses in at least 3 ways, so just nuke the
argument altogether and don't call it this way. If the driver needs to do
some error handling, that's what `err_handler' is for.
 1.110  04-Mar-1997  mikel garbage collect unused variable (was this struct declaration orginally
a typedef?); from Enami Tsugutomo in PR kern/3282.
 1.109  21-Feb-1997  thorpej 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.108  21-Feb-1997  thorpej Handle optical disks a little better, from Naofumi HONDA / MINOURA Makoto
in PR #3009, with some slight KNF from me.
 1.107  05-Dec-1996  cgd branches: 1.107.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.106  29-Nov-1996  thorpej Start a mode sense with a clean sense buffer.
Fixes PR #2953, from David M. Stanhope <dms@celtech.com>.
 1.105  23-Oct-1996  matthias * At least the Teac FC-1 Shugart-SCSI bridgeboard does motor on/off
management by itself. But when it gets a start unit request, it keeps
the floppy motor running all the time. This adds code for dealing with
yet another quirk (SDEV_NOSTARTUNIT) that prevents sd.c from sending
start unit requests. A entry for the Teac FC-1 is added to the quirk
table.
 1.104  12-Oct-1996  christos revert previous kprintf change
 1.103  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.102  05-Jul-1996  christos - Apply PR/2535: Add support for flex scsi disks.
- Add a quirk called SCSI_NOMODESENSE for drives like the iomega jaz,
that don't support mode sense.
 1.101  04-Jun-1996  thorpej In sddump(), don't check the SDEV_MEDIA_LOADED bit of the device, since
that bit might have been cleared by successful unmounting of all filesystems
on the dump device, e.g. in the case of "reboot -d".
 1.100  14-May-1996  leo branches: 1.100.4;
Clear SDEV_MEDIA_LOADED bit on the last close of a device. This causes the
geometry info & the disklabel to be reloaded on each 'first-open' of the
device.
 1.99  14-May-1996  thorpej Print the error code in the "not queued" message, to make debugging
a bit easier, and make sure a newline gets printed.
 1.98  05-May-1996  christos Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.
 1.97  03-May-1996  christos - SCSIDEBUG printf() fixes.
 1.96  22-Apr-1996  christos remove include of <sys/cpu.h>
 1.95  30-Mar-1996  christos Eliminate scsi_conf.h.
 1.94  26-Mar-1996  mycroft Put back dk_establish() for now.
 1.93  26-Mar-1996  mycroft Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.
 1.92  24-Mar-1996  mycroft Fix trivial oversight in last.
 1.91  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.90  17-Mar-1996  pk Parentheses are your friends.
 1.89  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.88  05-Mar-1996  thorpej Normalize SCSI autoconfiguration output.
From Chris Demetriou <cgd@NetBSD.ORG>. Fixes PR #1958.
 1.87  14-Feb-1996  christos scsi prototypes
 1.86  30-Jan-1996  thorpej Implement DIOCLOCK and DIOCEJECT. DIOCEJECT is limited to removable
media. Fixes PR #1975.
 1.85  12-Jan-1996  thorpej Handle cases like the following:
- controller calls scsi_done() with error XS_TIMEOUT
- scsi_done() calls sddone()
- sddone() calls disk_unbusy()
- scsi_done() calls controller to retry command (missing the
call to disk_busy())
- controller calls scsi_done()
- scsi_done() calls sddone()
- sddone() calls disk_busy(), which panics because of the imbalance.
Bug noticed by Leo Weppleman, who also suggested this fix; pass an additional
boolean argument ("complete") to the device's "done" routine, with a
value of `0' passed from the previous call to "done", and add an additional
call to "done" when the xfer resources are freed.
 1.84  07-Jan-1996  thorpej New generic disk framework. Highlights:

- New metrics handling. Metrics are now kept in the new
`struct disk'. Busy time is now stored as a timeval, and
transfer count in bytes.

- Storage for disklabels is now dynamically allocated, so that
the size of the disk structure is not machine-dependent.

- Several new functions for attaching and detaching disks, and
handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.83  07-Dec-1995  thorpej Remove a couple of now unneeded assignments.
 1.82  07-Dec-1995  thorpej In sdminphys(), add a comment about the semantics of the "length" field
in a 6-byte read/write cdb (namely, length == 0 really means 256), and
that we handle this conservatively by limiting the transfer to 255 blocks.
*sigh* One just never knows how a pre-scsi-1 device is going to behave.
 1.81  07-Dec-1995  thorpej In both cd.c and sd.c:
If the read or write request can fit into a 6-byte cdb, then
use a 6-byte cdb, otherwise use the 10-byte as before.

In sd.c:
In sdattach(), make a note if the device is "ancient" (i.e.
inqbuf.version & SID_ANSII == 0).

Implement sdminphys(): if the device is "ancient", shorten the
transfer so it will fit into a 6-byte cdb.

These changes have eliminated the rejected read/write requests on my
Sun 3/60 with 2 ESDI disks behind an Emulex MD21.
 1.80  10-Oct-1995  mycroft branches: 1.80.2;
Return EINVAL if something other than a whole number of blocks is requested.
 1.79  30-Sep-1995  pk Specify SCSI_DATA_OUT in sddump() (from John Kohl; PR#1482).
 1.78  26-Sep-1995  thorpej Don't declare Debugger(). It's handled in <sys/systm.h>.
#include <sys/systm.h> where necessary, as suggested by Jonathan Stone.
Fixes PR #1511.
 1.77  12-Aug-1995  mycroft opri --> s
 1.76  12-Aug-1995  mycroft Fix oversight in previous.
 1.75  12-Aug-1995  mycroft minphys() functions really should return void.
 1.74  05-Aug-1995  mycroft Use an intermediate variable to shorten label initialization code.
 1.73  24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.72  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.71  26-Jun-1995  cgd implement new-style block device dump routine if __BDEVSW_DUMP_OLD_TYPE
not defined, otherwise use an "not implemented" stub.
 1.70  03-May-1995  cgd looks like some extra ')'s were left in here.
 1.69  03-May-1995  mycroft Make the byte-shifting code consistent.
 1.68  15-Apr-1995  mycroft Don't boundary check I/O to the `raw' partition.
 1.67  10-Apr-1995  mycroft kernel_pmap --> pmap_kernel()
 1.66  01-Apr-1995  mycroft Add a missing unlock.
 1.65  29-Mar-1995  mycroft Revamp the locking mechanism slightly.
 1.64  25-Mar-1995  mycroft Remove the write protect check altogether, and rely on the drive to do it.
 1.63  23-Mar-1995  mycroft Check for read-only media in open(), not write().
 1.62  23-Mar-1995  mycroft Rearrange DIOCWDINFO a little; closer to wd.c.
 1.61  23-Mar-1995  mycroft Allow DIOCWDINFO even if label is not `writable'.
 1.60  07-Mar-1995  mycroft Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.
 1.59  30-Jan-1995  mycroft Some drives don't grok START with LoEj=1, either.
 1.58  30-Jan-1995  mycroft Set the LoadEject bit when issuing a START.
 1.57  30-Jan-1995  mycroft Some devices really do require the START before the PREVENT. This makes no
sense.
 1.56  26-Jan-1995  mycroft Update copyrights.
 1.55  26-Jan-1995  mycroft Redo the `wait for spin up' code. The Mach 3 method clearly doesn't work.
Also, rearrange the first open sequences a bit; SDEV_OPEN is no longer magic.
 1.54  23-Jan-1995  mycroft Do the PREVENT before the START.
 1.53  16-Jan-1995  mycroft If the disk reports a block size of 0, assume it really meant 512.
 1.52  13-Jan-1995  mycroft Always boundary check I/O.
 1.51  28-Dec-1994  mycroft Numerous changes. Many bugs fixed, better autoconfig, a few new features.
 1.50  16-Dec-1994  mycroft Remove DIOCSBAD handling. It's not actually handled, so why recognize it?
 1.49  14-Dec-1994  mycroft Remove dkbad.h.
 1.48  23-Nov-1994  mycroft There's no point in bothering to unlock what we didn't lock.
 1.47  22-Nov-1994  mycroft Add still more locking.
 1.46  21-Nov-1994  mycroft Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.
 1.45  20-Nov-1994  mycroft Add some missing locking, and some general cleanup.
 1.44  15-Nov-1994  deraadt Enough Chinese torture already
 1.43  30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.42  20-Oct-1994  mycroft First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.
 1.41  20-Oct-1994  mycroft Back out change to print geometry from label at boot; can't do this reliably.
 1.40  20-Oct-1994  mycroft openpart -> openmask
 1.39  20-Oct-1994  mycroft Trivial stylistic changes.
 1.38  20-Oct-1994  mycroft Use the block size in the label in most cases.
 1.37  20-Oct-1994  mycroft Various changes:
* Get rid of unused `partflags'.
* Use dk_openpart, and remove `openparts'. Also, allow an open on both
the block and characters devices at the same time.
* If there was a label, print the geometry from the label at boot time.
* Turn `wlabel' into a flag, and *don't* set it automatically in
DIOCWLABEL; disklabel(8) does that.
Other minor changes.
 1.36  14-Oct-1994  cgd move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.
 1.35  26-Jul-1994  mycroft Normalize label handling.
 1.34  04-Jul-1994  chopps branches: 1.34.2;
change to support other MAXPARTITIONS vals aside from 8
 1.33  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.32  16-Jun-1994  chopps resolve confusion over who owns the buf after calling scsi_scsi_cmd()
 1.31  16-Jun-1994  mycroft b_un.b_addr -> b_data
 1.30  09-May-1994  chopps remove union's from sense_data struct, conditionaly define RAW_PART
 1.29  11-Apr-1994  mycroft Fix various types. Remove some outdated flags.
 1.28  11-Apr-1994  mycroft Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).
 1.27  06-Apr-1994  mycroft Redo the last change; it was compltely bogus.
 1.26  06-Apr-1994  mycroft Try to detect garbage data from page 4 sense.
 1.25  29-Mar-1994  mycroft New SCSI system, based on Julian's more recent work.
 1.24  24-Mar-1994  cgd print even more SCSI sense data; this should be in a function...
 1.23  24-Mar-1994  cgd print out lots of info on non-media hardware error...
 1.22  06-Feb-1994  mycroft Use b_actf, not av_forw.
 1.21  25-Jan-1994  deraadt print nice numbers for disks >2G. from <adrian@lemmings.cursci.com>
 1.20  11-Jan-1994  mycroft *strategy functions return void.
 1.19  17-Dec-1993  mycroft Canonicalize all #includes.
 1.18  01-Aug-1993  mycroft branches: 1.18.2;
Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.
 1.17  19-Jul-1993  cgd branches: 1.17.2;
patches from allen briggs to fix a minor bug in *attach()
 1.16  04-Jul-1993  andrew Reject non block-aligned transfers (where a block is 512 bytes in length);
they were causing scsi controller lockups. Replace an occurrence of "512"
with SECSIZE, which is #defined to be 512.
 1.15  27-Jun-1993  andrew ANSIfications.
 1.14  16-Jun-1993  deraadt whoops. typo.
 1.13  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.12  25-May-1993  deraadt patch00149 by Julian Elischer <julian@jules.dialix.oz.au> & Rodney Grimes.
When an error was encountered, the sd/cd drivers printed blockno&ff0000
rather that blockno.
 1.11  21-May-1993  davidb Changed when disks are started, to get DEC disks working.
 1.10  20-May-1993  deraadt more disklabel changes
 1.9  20-May-1993  cgd add rcsids and clean up file headers
 1.8  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.7  26-Apr-1993  deraadt cosmetic change
 1.6  20-Apr-1993  mycroft Display more meaningful message on SCSI `unit attention'.
 1.5  12-Apr-1993  deraadt fixed various bugs like cdattach() returning garbage.
 1.4  12-Apr-1993  deraadt small fixes
 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  10-Apr-1993  glass fixed to be compliant, subservient, and to take advantage of the newly
hacked config(8)
 1.1  21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.17.2.1  31-Jul-1993  cgd give names, err, wmesg's, to my "pain" -- i.e. convert sleep() to tsleep()
 1.18.2.12  16-Feb-1994  mycroft More KNF-like.
 1.18.2.11  06-Feb-1994  mycroft Use b_actf, not av_forw.
 1.18.2.10  01-Feb-1994  mycroft Add scsi_stop_unit(), from Mac code. Other minor nits.
 1.18.2.9  29-Nov-1993  mycroft Use dk_establish().
 1.18.2.8  25-Nov-1993  mycroft Fix silly typo.
 1.18.2.7  25-Nov-1993  mycroft (Hopefully) make cd work. Make cd and sd more similar. Implement variable
block sizes in sd.
 1.18.2.6  24-Nov-1993  mycroft Final tweaks to get it going.
 1.18.2.5  24-Nov-1993  mycroft Fix unitialized variable.
 1.18.2.4  24-Nov-1993  mycroft More construction...
 1.18.2.3  24-Nov-1993  mycroft Still under construction...
 1.18.2.2  24-Nov-1993  mycroft Under construction...
 1.18.2.1  24-Sep-1993  mycroft cd.c, sd.c, st.c: strategy functions return void.
 1.34.2.1  26-Jul-1994  cgd from branch.
 1.80.2.1  04-Feb-1996  gwr Pull in rev 1.82 (Jason's fix to use 6-byte command blocks).
 1.100.4.3  04-Mar-1997  mycroft Pull up support for fetching geometry info on optical disks.
 1.100.4.2  29-Nov-1996  thorpej Start a mode sense with a clean sense buffer.
From David M. Stanhope <dms@celtech.com>, PR #2953.
 1.100.4.1  04-Jun-1996  thorpej Update from trunk:

In sddump(), don't check the SDEV_MEDIA_LOADED bit of the device, since
that bit might have been cleared by successful unmounting of all filesystems
on the dump device, e.g. in the case of "reboot -d".
 1.107.6.1  12-Mar-1997  is Merge in changes from Trunk
 1.114.2.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.116.2.4  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.116.2.3  22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.116.2.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.116.2.1  27-Aug-1997  thorpej file sd.c was added on branch marc-pcmcia on 1997-08-27 23:33:32 +0000
 1.128.2.2  08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.128.2.1  30-Jul-1998  eeh file sd.c was added on branch eeh-paddr_t on 1998-08-08 03:06:52 +0000
 1.144.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.149.2.2  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.149.2.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.151.4.1  15-Nov-1999  fvdl Sync with -current
 1.151.2.9  12-Mar-2001  bouyer Sync with HEAD.
 1.151.2.8  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.151.2.7  13-Dec-2000  bouyer Make it compile again.
 1.151.2.6  13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.151.2.5  08-Dec-2000  bouyer Sync with HEAD.
 1.151.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.151.2.3  01-Nov-1999  thorpej Fixup the SC_DEBUG() stuff for the new world order.
 1.151.2.2  20-Oct-1999  thorpej Remove an unnecessary comment regarding XS_CTL_NOSLEEP.
 1.151.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.161.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.163.2.3  06-May-2001  he Pull up revision 1.174 (requested by fvdl):
Compensate for the fact that after __HAVE_OLD_DISKLABEL,
DISKMINOR(u,p) is no longer contiguous over ``p'', so ranges
cannot be passed to vdevgone().
 1.163.2.2  01-May-2001  he Pull up revisions 1.167-1.168 (requested by fvdl):
Increase the number of BSD disklabel partitions on i386 to 16.
 1.163.2.1  11-Mar-2001  he Pull up revision 1.170 (requested by explorer):
Fix a problem with some Hitachi drives by only issuing the ``lock
media'' and ``unlock media'' commands to removable media.
 1.169.2.14  07-Jan-2003  thorpej Sync with HEAD.
 1.169.2.13  19-Dec-2002  thorpej Sync with HEAD.
 1.169.2.12  11-Nov-2002  nathanw Catch up to -current
 1.169.2.11  18-Oct-2002  nathanw Catch up to -current.
 1.169.2.10  17-Sep-2002  nathanw Catch up to -current.
 1.169.2.9  01-Aug-2002  nathanw Catch up to -current.
 1.169.2.8  20-Jun-2002  nathanw Catch up to -current.
 1.169.2.7  28-Feb-2002  nathanw Catch up to -current.
 1.169.2.6  11-Jan-2002  nathanw More catchup.
 1.169.2.5  08-Jan-2002  nathanw Catch up to -current.
 1.169.2.4  14-Nov-2001  nathanw Catch up to -current.
 1.169.2.3  24-Aug-2001  nathanw Catch up with -current.
 1.169.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.169.2.1  09-Apr-2001  nathanw Catch up with -current.
 1.177.2.5  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.177.2.4  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.177.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.177.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.177.2.1  03-Aug-2001  lukem update to -current
 1.178.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.178.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.183.2.4  31-Aug-2002  gehenna catch up with -current.
 1.183.2.3  29-Aug-2002  gehenna catch up with -current.
 1.183.2.2  20-Jul-2002  gehenna catch up with -current.
 1.183.2.1  16-May-2002  gehenna Add the block/character device switches.
Replace the direct-access to devsw table with calling devsw API.
 1.202.2.13  11-Dec-2005  christos Sync with head.
 1.202.2.12  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.202.2.11  01-Apr-2005  skrll Sync with HEAD.
 1.202.2.10  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.202.2.9  18-Dec-2004  skrll Sync with HEAD.
 1.202.2.8  02-Nov-2004  skrll Sync with HEAD.
 1.202.2.7  19-Oct-2004  skrll Sync with HEAD
 1.202.2.6  21-Sep-2004  skrll Fix the sync with head I botched.
 1.202.2.5  18-Sep-2004  skrll Sync with HEAD.
 1.202.2.4  03-Sep-2004  skrll Sync with HEAD
 1.202.2.3  25-Aug-2004  skrll Sync with HEAD.
 1.202.2.2  03-Aug-2004  skrll Sync with HEAD
 1.202.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.216.2.3  11-Sep-2004  he Pull up revisions 1.221-1.223 (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.216.2.2  02-Jul-2004  he Pull up revisions 1.218-1.219 (requested by mycroft in ticket #572):
Several fixes mostly related to USB:
o Separate page 4/5 reading into separate functions. For
``removeable'' devices, try page 5 first. Fixes problem
with some broken USB devices which do not handle page 4
correctly.
o Add prototypes for recently added functions.
 1.216.2.1  29-May-2004  tron Pull up revision 1.217 (requested by bouyer in ticket #399):
If READ_FORMAT_CAPACITIES fails with "Medium Format Corrupted" ASC/ASQ error,
handle it as if the drive was not formatted, so that "scsictl sdx format"
can open the raw device.
 1.232.4.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.232.2.1  29-Apr-2005  kent sync with -current
 1.237.2.3  29-Dec-2005  riz Pull up following revision(s) (requested by bouyer in ticket #1045):
sys/dev/scsipi/sd.c: revision 1.243
Adapt previous change to recent scsipi. Pointed out by Simon Burge.
 1.237.2.2  29-Dec-2005  riz Pull up following revision(s) (requested by bouyer in ticket #1045):
sys/dev/scsipi/sd.c: revision 1.242
Some USB devices reports themselves as removable, but have no door and
so don't support the SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL command.
When an "Illegal field in CDB" is reported for this command, mark the
device as non-removable (which is always true for USB keys from the SCSI
point of view), print a message and ignore the error.
For DIOCLOCK, return ENOTTY if the device is not removable instead of
trying a command which will fail.
Fix a problem reported by Hubert Feyrer for some USB umass devices, patch
tested by him.
 1.237.2.1  06-Apr-2005  tron Pull up revision 1.238 (requested by yamt in ticket #112):
introduce a function to drain bufq and use it where appropriate.
 1.240.2.8  17-Mar-2008  yamt sync with head.
 1.240.2.7  27-Feb-2008  yamt sync with head.
 1.240.2.6  21-Jan-2008  yamt sync with head
 1.240.2.5  27-Oct-2007  yamt sync with head.
 1.240.2.4  03-Sep-2007  yamt sync with head.
 1.240.2.3  26-Feb-2007  yamt sync with head.
 1.240.2.2  30-Dec-2006  yamt sync with head.
 1.240.2.1  21-Jun-2006  yamt sync with head.
 1.244.6.2  01-Jun-2006  kardel Sync with head.
 1.244.6.1  22-Apr-2006  simonb Sync with head.
 1.244.4.1  09-Sep-2006  rpaulo sync with head
 1.244.2.1  01-Mar-2006  yamt sync with head.
 1.245.6.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.245.4.1  19-Apr-2006  elad sync with head.
 1.245.2.3  11-Aug-2006  yamt sync with head
 1.245.2.2  26-Jun-2006  yamt sync with head.
 1.245.2.1  01-Apr-2006  yamt sync with head.
 1.247.2.1  19-Jun-2006  chap Sync with head.
 1.248.2.1  13-Jul-2006  gdamore Merge from HEAD.
 1.249.4.2  12-Jan-2007  ad Sync with head.
 1.249.4.1  18-Nov-2006  ad Sync with head.
 1.249.2.1  22-Sep-2006  riz Pull up following revision(s) (requested by reinoud in ticket #168):
sys/dev/scsipi/sd.c: revision 1.250
Fix same panic problem as with cd.c when a scsi error happends on
read/write action. It would panic on a diagnosic assertion. When a scsi
read/write command fails, the whole extent is gone bad so mark all as not
done.
 1.250.2.2  10-Dec-2006  yamt sync with head.
 1.250.2.1  22-Oct-2006  yamt sync with head
 1.258.6.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.258.4.2  12-Mar-2007  rmind Sync with HEAD.
 1.258.4.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.258.2.1  31-Jul-2007  liamjfoy Pull up following revision(s) (requested by jnemeth in ticket #803):
sys/dev/scsipi/sd.c: revision 1.260
add support devctl properties
 1.261.4.1  11-Jul-2007  mjf Sync with head.
 1.261.2.5  09-Oct-2007  ad Sync with head.
 1.261.2.4  20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.261.2.3  19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.261.2.2  01-Jul-2007  ad Adapt to callout API change.
 1.261.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.262.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.265.8.2  03-Aug-2007  tsutsui Don't allocate data buffer on stack in sd_read_capacity().

If data buffer is allocated on stack at the end of CPU cacheline,
the same cacheline region might be accessed via kernel stack even
after bus_dmamap_sync(9) against the data buffer in lower scsi drivers
so that read data via DMA could be lost.

Fixes occasional readdisklabel(9) failure at boot on ews4800mips
with osiop(4) driver and 128byte cacheline.

XXX: Other functions/drivers might have the similar problem.
 1.265.8.1  03-Aug-2007  tsutsui file sd.c was added on branch matt-mips64 on 2007-08-03 13:56:38 +0000
 1.265.6.2  14-Oct-2007  yamt sync with head.
 1.265.6.1  06-Oct-2007  yamt sync with head.
 1.265.4.3  23-Mar-2008  matt sync with HEAD
 1.265.4.2  09-Jan-2008  matt sync with HEAD
 1.265.4.1  06-Nov-2007  matt sync with HEAD
 1.265.2.5  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.265.2.4  06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.265.2.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.265.2.2  02-Oct-2007  joerg Sync with HEAD.
 1.265.2.1  03-Aug-2007  joerg file sd.c was added on branch jmcneill-pm on 2007-10-02 18:28:39 +0000
 1.267.8.1  11-Dec-2007  yamt sync with head.
 1.267.6.1  26-Dec-2007  ad Sync with head.
 1.267.4.1  18-Feb-2008  mjf Sync with HEAD.
 1.268.2.1  02-Jan-2008  bouyer Sync with HEAD
 1.269.6.8  17-Jan-2009  mjf - Fix a CVS merge breakage
- Catch up with some driver changes
 1.269.6.7  17-Jan-2009  mjf Sync with HEAD.
 1.269.6.6  28-Sep-2008  mjf Sync with HEAD.
 1.269.6.5  29-Jun-2008  mjf Sync with HEAD.
 1.269.6.4  02-Jun-2008  mjf Sync with HEAD.
 1.269.6.3  06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.269.6.2  03-Apr-2008  mjf Sync with HEAD.
 1.269.6.1  29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.269.2.1  24-Mar-2008  keiichi sync with head.
 1.272.4.8  11-Aug-2010  yamt sync with head.
 1.272.4.7  11-Mar-2010  yamt sync with head
 1.272.4.6  19-Aug-2009  yamt sync with head.
 1.272.4.5  18-Jul-2009  yamt sync with head.
 1.272.4.4  20-Jun-2009  yamt sync with head
 1.272.4.3  16-May-2009  yamt sync with head
 1.272.4.2  04-May-2009  yamt sync with head.
 1.272.4.1  16-May-2008  yamt sync with head.
 1.272.2.2  17-Jun-2008  yamt sync with head.
 1.272.2.1  18-May-2008  yamt sync with head.
 1.273.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.273.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.274.4.1  19-Oct-2008  haad Sync with HEAD.
 1.274.2.1  18-Jul-2008  simonb Sync with head.
 1.275.4.1  31-Oct-2012  riz sys/dev/scsipi/sd.c patch

Allow disk strategy to be queried and changed at runtime
for sd(4) disks.
[buhrow, ticket #1807]
 1.275.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.275.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.277.2.2  23-Jul-2009  jym Sync with HEAD.
 1.277.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.291.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.292.2.1  30-May-2010  rmind sync with head
 1.294.2.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.294.2.2  23-May-2012  yamt sync with head.
 1.294.2.1  17-Apr-2012  yamt sync with head
 1.295.2.2  29-Apr-2012  mrg sync to latest -current.
 1.295.2.1  18-Feb-2012  mrg merge to -current.
 1.296.2.1  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.298.2.4  03-Dec-2017  jdolecek update from HEAD
 1.298.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.298.2.2  23-Jun-2013  tls resync from head
 1.298.2.1  12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.301.2.1  18-May-2014  rmind sync with head
 1.305.2.2  10-Aug-2014  tls Rebase.
 1.305.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.308.2.1  11-Nov-2014  martin Pull up following revision(s) (requested by mlelstv in ticket #201):
sbin/dkctl/dkctl.8: revision 1.24
sbin/dkctl/dkctl.8: revision 1.25
sys/dev/scsipi/sd.c: revision 1.310
sys/dev/ata/wd.c: revision 1.415
sbin/dkctl/dkctl.c: revision 1.21
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.315
sys/dev/ld.c: revision 1.78
sys/dev/vnd.c: revision 1.234
sys/dev/dksubr.c: revision 1.54
sys/sys/dkio.h: revision 1.20
sys/dev/dkwedge/dk.c: revision 1.74
Add ioctl to autodiscover wedges.
Implement DIOCMWEDGES ioctl that triggers wedge autodiscovery.
Also fix a reference counting bug and clean up some code.
support DIOCMWEDGES ioctl.
Add 'makewedges' option to autodiscover wedges from a changed label.
New sentence, new line. Bump date for previous.
 1.310.2.6  28-Aug-2017  skrll Sync with HEAD
 1.310.2.5  05-Feb-2017  skrll Sync with HEAD
 1.310.2.4  05-Dec-2016  skrll Sync with HEAD
 1.310.2.3  22-Sep-2015  skrll Sync with HEAD
 1.310.2.2  06-Jun-2015  skrll Sync with HEAD
 1.310.2.1  06-Apr-2015  skrll Sync with HEAD
 1.317.2.5  26-Apr-2017  pgoyette Sync with HEAD
 1.317.2.4  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.317.2.3  26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.317.2.2  19-Jul-2016  pgoyette Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it. This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@
 1.317.2.1  18-Jul-2016  pgoyette Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.
 1.322.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.324.6.2  11-Feb-2021  martin Pull up following revision(s) (requested by ryoon in ticket #1652):

sys/dev/scsipi/cd.c: revision 1.350
sys/dev/scsipi/sd.c: revision 1.331

PR 55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()
 1.324.6.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.324.4.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.325.6.3  21-Apr-2020  martin Sync with HEAD
 1.325.6.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.325.6.1  10-Jun-2019  christos Sync with HEAD
 1.325.4.1  20-Oct-2018  pgoyette Sync with head
 1.327.4.3  29-Aug-2022  martin Pull up following revision(s) (requested by mlelstv in ticket #1509):

sys/dev/scsipi/sdvar.h: revision 1.40
sys/dev/scsipi/sd.c: revision 1.335

Don't fetch data beyond end of inquiry buffer, which, here, is not
NUL-terminated.

Reduce target buffer to needed size (product name + NUL terminator).
 1.327.4.2  11-Feb-2021  martin Pull up following revision(s) (requested by ryoon in ticket #1203):

sys/dev/scsipi/cd.c: revision 1.350
sys/dev/scsipi/sd.c: revision 1.331

PR 55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()
 1.327.4.1  21-Mar-2020  martin Pull up following revision(s) (requested by riastradh in ticket #795):

sys/dev/dksubr.c: revision 1.112
sys/arch/xen/xen/xbd_xenbus.c: revision 1.95
sys/dev/scsipi/sd.c: revision 1.328
sys/dev/dkvar.h: revision 1.32
sys/dev/ld.c: revision 1.109
sys/dev/cgd.c: revision 1.120
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.380
sys/dev/ata/wd.c: revision 1.458

Add a flag to dk_dump for virtual disk devices.

If a disk is backed by a physical medium other than itself, such as
cgd(4), then it passes DK_DUMP_RECURSIVE to disable the recursion
detection for dk_dump.

If, however, a device represents a physical medium on its own, such
as wd(4), then it passes 0 instead.

With this, I can now dump to dk on cgd on dk on wd.
 1.328.4.1  20-Apr-2020  bouyer Sync with HEAD
 1.330.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.331.6.1  31-May-2021  cjep sync with head
 1.331.4.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.335.4.1  12-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #838):

sys/dev/scsipi/sd.c: revision 1.336

Don't try to discover wedges when the unit isn't online.

RSS XML Feed