History log of /netbsd-current/sys/dev/scsipi/cd.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.355 22-Jun-2024 palle

Add quirk for devices that does not handle READ_DISCINFO


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.354 26-Jun-2022 andvar

s/Ramdom/Random/ in comments.


# 1.353 12-Oct-2021 andvar

fix various typos, mainly in comments.


# 1.352 21-Aug-2021 andvar

fix mainly same typos as in my previous commit but outside sys/dev/dm.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base
# 1.351 16-Apr-2021 reinoud

Limit buffer size for device capabilities requests as a work-around for PR
kern/56109.


Revision tags: thorpej-futex-base
# 1.350 10-Feb-2021 christos

branches: 1.350.2;
PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


# 1.349 26-Oct-2020 mlelstv

branches: 1.349.2;
Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.


# 1.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.354 26-Jun-2022 andvar

s/Ramdom/Random/ in comments.


# 1.353 12-Oct-2021 andvar

fix various typos, mainly in comments.


# 1.352 21-Aug-2021 andvar

fix mainly same typos as in my previous commit but outside sys/dev/dm.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base
# 1.351 16-Apr-2021 reinoud

Limit buffer size for device capabilities requests as a work-around for PR
kern/56109.


Revision tags: thorpej-futex-base
# 1.350 10-Feb-2021 christos

branches: 1.350.2;
PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


# 1.349 26-Oct-2020 mlelstv

branches: 1.349.2;
Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.


# 1.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.353 12-Oct-2021 andvar

fix various typos, mainly in comments.


# 1.352 21-Aug-2021 andvar

fix mainly same typos as in my previous commit but outside sys/dev/dm.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base
# 1.351 16-Apr-2021 reinoud

Limit buffer size for device capabilities requests as a work-around for PR
kern/56109.


Revision tags: thorpej-futex-base
# 1.350 10-Feb-2021 christos

branches: 1.350.2;
PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


# 1.349 26-Oct-2020 mlelstv

branches: 1.349.2;
Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.


# 1.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.352 21-Aug-2021 andvar

fix mainly same typos as in my previous commit but outside sys/dev/dm.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base
# 1.351 16-Apr-2021 reinoud

Limit buffer size for device capabilities requests as a work-around for PR
kern/56109.


Revision tags: thorpej-futex-base
# 1.350 10-Feb-2021 christos

branches: 1.350.2;
PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


# 1.349 26-Oct-2020 mlelstv

branches: 1.349.2;
Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.


# 1.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.351 16-Apr-2021 reinoud

Limit buffer size for device capabilities requests as a work-around for PR
kern/56109.


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.350 10-Feb-2021 christos

PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


# 1.349 26-Oct-2020 mlelstv

branches: 1.349.2;
Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.


# 1.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.350 10-Feb-2021 christos

PR/55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


Revision tags: thorpej-futex-base
# 1.349 26-Oct-2020 mlelstv

Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.


# 1.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.349 26-Oct-2020 mlelstv

Avoid buffer overflow when copying from bounce buffer.
Fixes PR 54810

Don't use uninitialized pointer in split bounce buffer case and
free a partially allocated bounce buffer on error.


# 1.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.348 29-Sep-2020 msaitoh

s/settng/setting/


# 1.347 29-Sep-2020 msaitoh

s/implicitely/implicitly/


# 1.346 29-Sep-2020 msaitoh

s/occurence/occurrence/


# 1.345 29-Sep-2020 msaitoh

s/parition/partition/


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1
# 1.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

branches: 1.343.2;
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.344 13-Apr-2020 maxv

constify


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.343 27-Mar-2020 mlelstv

Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: is-mlppp-base ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

branches: 1.342.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.343 27-Mar-2020 mlelstv

Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.

Fixes PR kern/55104


Revision tags: ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4; 1.341.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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.342 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.341 17-Jun-2017 mlelstv

branches: 1.341.4;
The atapibus detach path did hold the channel mutex while calling into autoconf,
which would trigger a panic when unplugging a USB ATAPI CDROM.

Align detach code for scsibus and atapibus to fix this.

Also avoid races when detaching devices by replacing callout_stop with
callout_halt.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4; 1.340.6;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.341 17-Jun-2017 mlelstv

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.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base
# 1.340 08-Apr-2017 mlelstv

branches: 1.340.4;
ignore a failed scspi_prevent when accessing the RAW_PART as before.


Revision tags: pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

branches: 1.339.2;
Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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


Revision tags: pgoyette-localcount-20170107
# 1.339 05-Jan-2017 mlelstv

Fix memory leak.

Found by maxv@


# 1.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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.338 21-Dec-2016 mlelstv

really keep request queued after resource shortage


# 1.337 21-Dec-2016 mlelstv

cdrestart takes a softc parameter, not a periph.


# 1.336 16-Dec-2016 mlelstv

add comment about "missing" dk_start.


# 1.335 10-Dec-2016 mlelstv

appease gcc.


# 1.334 10-Dec-2016 mlelstv

Refactored sd and cd to use common disk subroutines.


Revision tags: nick-nhusb-base-20161204
# 1.333 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.332 20-Nov-2016 pgoyette

Avoid calling bufq_free() from critical code sections.


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.331 15-May-2016 reinoud

branches: 1.331.2;
Use _align(2) workaround for PR kern/51141. This fixes odd CD length
reporting.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606
# 1.330 26-Apr-2015 mlelstv

Use C99-style initializers for struct dkdriver.


# 1.329 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: nick-nhusb-base-20150406
# 1.328 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.327 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.326 31-Dec-2014 mlelstv

forgot this one. disk_set_info includes the functionality of disk_blocksize.


Revision tags: nick-nhusb-base
# 1.325 18-Oct-2014 snj

branches: 1.325.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


# 1.324 03-Oct-2014 justin

Use uint32_t for blocksize as per other uses and to fix warnings


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-maxphys-base
# 1.323 10-Aug-2014 tls

Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.322 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.321 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.320 12-Jul-2014 hannken

Prevent detaching an open device unless forced.


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.319 18-Apr-2014 martin

Fix PR kern/48550 by aligning the single instance of scsipi_read_cd_cap_data
that we found misaligned in the wild so far properly for the ahcisata
driver. Also point at PR kern/48754 for the real issue.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
# 1.318 19-Mar-2014 martin

branches: 1.318.2;
PR kern/48550: additional initialization and sanity checking on the reported
blocksize of the medium.


Revision tags: riastradh-drm2-base3
# 1.317 16-Mar-2014 dholland

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.316 25-Oct-2013 martin

Turn a few __unused into __diagused


# 1.315 19-Oct-2013 martin

Mark a potentially unused variable


# 1.314 28-Sep-2013 skrll

Don't return EPASSTHROUGH when succeeding in ODIOCGDINFO or ODIOCGDEFLABEL


# 1.313 12-Sep-2013 martin

Remove unused variables


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.312 02-Jul-2013 reinoud

Small patch to clarify last_lba and now using size confusingly. No functional
change.


# 1.311 29-May-2013 christos

branches: 1.311.2;
phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.


Revision tags: agc-symver-base
# 1.310 15-Mar-2013 martin

Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.309 06-May-2012 martin

branches: 1.309.2;
When ejecting a medium, invalidate the in core disklabel - it is not
meaningfull anymore. This makes the following cdclose() use silent
mode and finally fixes PR kern/43785.


# 1.308 06-May-2012 martin

In cdopen: make the test for media presence always silent. In all cases
requiring a message, we will most likely get that from the spinup attempt
anyway.
This avoids the spurious "Check Condition on CDB, Not Ready, Medium Not
Present, Tray Closed" messages at boot/shutdown time.


Revision tags: jmcneill-usbmp-base9
# 1.307 19-Apr-2012 bouyer

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.


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4
# 1.306 25-Feb-2012 shattered

Fix typos in comments.

OK by wiz@


Revision tags: jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.305 02-Feb-2012 tls

branches: 1.305.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.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base
# 1.304 25-Nov-2011 joerg

branches: 1.304.2;
Replace memset with incorrect size argument with M_ZERO.


Revision tags: jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.303 20-May-2011 reinoud

branches: 1.303.4;
Fix size reporting for DVD+R/DL and BluRay's; the value was trunced due to a
32 bit trunc due to a lacking type cast. The number of sectors for such media
can be more than 1<<32-1.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.302 04-Apr-2010 martin

branches: 1.302.2;
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.


# 1.301 23-Mar-2010 martin

If we find a device in non-2048 byte/block mode and manage to switch
it over, we need to adjust the capacity - so just read it again.


# 1.300 23-Mar-2010 martin

Make cdclose() silent, if we only have the raw partition open (e.g. when
probing for media and not finding any)


# 1.299 22-Mar-2010 martin

Add a DIOCTUR (test unit ready) ioctl, to allow userland to easily
(and silently) check for presence of media. While this would be easy
to implement via SCIOCCOMMAND, our kernel has quirks for this
command, which otherwise would not be readily available to userland
applications.


# 1.298 11-Mar-2010 mrg

branches: 1.298.2;
various aprint_* fixes.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.297 06-Jan-2010 martin

branches: 1.297.2;
Some usb devices come with an internal emulated umass CD drive (containing
windows drivers). I have such a device that has 0 features - avoid wrappig
features_len to a very big unsiged 32bit number in this case.


Revision tags: matt-premerge-20091211
# 1.296 06-Dec-2009 dyoung

Delete do-nothing device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.295 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>.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.294 26-Jul-2009 reinoud

Significantly bump time for SCSI track/disc closure. DVD-RW when used
sequentially can significantly take more time.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.293 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@.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.292 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.291 01-Apr-2009 reinoud

Implement MMC_TRACKINFO_DATA and MMC_TRACKINFO_AUDIO detection for cdrom and
dvdrom devices. These two compatibility codes were forgotten when those were
introduced.


# 1.290 18-Mar-2009 cegger

bzero -> memset


# 1.289 17-Mar-2009 reinoud

Fix long standing problem with CD/DVD writing with `dd'. If done this way the
device will remain in a wait-for-more-stuff-to-be-written state delaying other
SCSI calls, esp. some read-size or read-layout calls, until its told there is
no more comming.

To fix this, on last close explicitly flush the caches releasing the device
from this mode and allowing other SCSI commands to reach it.

This fixes PR 40528


# 1.288 14-Mar-2009 ad

'boot -z' bogons


Revision tags: nick-hppapmap-base2
# 1.287 21-Jan-2009 cegger

branches: 1.287.2;
buildfix: re-adapt to major()/minor() returning a 32bit value.


Revision tags: mjf-devfs2-base
# 1.286 13-Jan-2009 yamt

g/c BUFQ_FOO() macros and use bufq_foo() directly.


# 1.285 11-Jan-2009 cegger

make this compile


# 1.284 30-Dec-2008 reinoud

Add ISO partition detection enabling auto-detection of iso9660 and UDF
partitions on optical media like CD/DVD/BD but also on all other media if
there is no NetBSD disklabel or MBR label.

Also fix cd's readdisklabel arguments so the ioctl's arrive at the right
device (!) and update its default label to make more sense.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base
# 1.283 05-Sep-2008 gmcgarry

branches: 1.283.2; 1.283.4;
Remove unreachable code introduced by rev 1.224. Fixes PR#38973.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.282 12-Jun-2008 cegger

branches: 1.282.2;
use device_lookup_private to get softc


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.281 12-May-2008 jnemeth

branches: 1.281.2;
add support for drvctl properties


# 1.280 12-May-2008 tron

Fix SSP kernel builds.


# 1.279 08-May-2008 reinoud

Implement write support for the MMC framework. This consists of a setting
up of write parameters call and a call to perform a series of operations on
these devices.

Note that the MMC framework interface is still not exposed to userland
unless the expose_mmc flag is set. This is to prevent applications to build
on a possibly still moving target. This flag will eventually be removed.


# 1.278 06-May-2008 yamt

branches: 1.278.2;
getiobuf(false, NULL) -> getiobuf(NULL, false)


# 1.277 02-May-2008 reinoud

Extend the MMC framework to also create sensible reports on audio discs.


# 1.276 02-May-2008 reinoud

Fixup CD and DVD drives that appear to be on crack when reporting features.
They state f.e. that a recordable CD-R is rewritable or completely forget
that the fixed packet size formatted CD-RW is strict overwrite rewritable
and not randomly rewritable.


# 1.275 02-May-2008 reinoud

Make the SCSI sense code "Logical Unit Not Ready, Operation In Progress"
(Sense code 0x04, 0x07) not a fatal error anymore but retry command later.
This sense code can be returned on a CD-MRW write that encounters a bad
block resulting in the drive being busy relocating it. During that time it
can return this sense code to indicate its busy for a while.

Also reduce waiting time for the other "Logical Unix Not Ready, Long Write
In Progress" to half a second.


# 1.274 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1
# 1.273 24-Mar-2008 cube

branches: 1.273.2; 1.273.4;
Split device_t for cd(4).


Revision tags: yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.272 02-Jan-2008 ad

branches: 1.272.6;
Merge vmlocking2 to head.


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.271 09-Dec-2007 jmcneill

branches: 1.271.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.270 27-Nov-2007 reinoud

branches: 1.270.2; 1.270.4;
Pullup fixes from UDF write development project. This patch fixes a
conceptional bug in mmc_discinfo, improves DVD+R feature detection and
prevents corruption of mmc_trackinfo readout on some devices that return
short trackinfo structures.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 vmlocking-base
# 1.269 08-Oct-2007 ad

branches: 1.269.4;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base
# 1.268 04-Aug-2007 rumble

branches: 1.268.2; 1.268.4; 1.268.6;
Be sure not to make requests over MAXPHYS when employing bounce buffers.
It was previously possible to round up one sector length if the start block
were not properly aligned.

Resolves PR kern/36716. This may also fix the following reported issues
on port-sgimips:
http://mail-index.netbsd.org/port-sgimips/2005/09/12/0000.html
http://mail-index.netbsd.org/port-sgimips/2005/09/14/0000.html

While here, be sure to put back allocated bufs, which previously appear
to have been leaked. Further, remove the dead write bounce code which never
got executed anyway.

No complaints on tech-kern.


# 1.267 29-Jul-2007 ad

branches: 1.267.4;
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.266 21-Jul-2007 ad

Replace some uses of lockmgr().


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.265 09-Jul-2007 ad

branches: 1.265.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.264 30-Jun-2007 dsl

The cd ioctl definitions are not condusive to being called from within
the kernel (eg from withthe linux compat code).
Add CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF which are like the
existing ioctls withoutthe _BUF, except that the data area immediately
follows the control structure (and is fixed length).
Modify scsipi/cd.c so that it only ever has one 'struct cd_formatted_toc'
allocated on the stack (maybe this info ought to be in the softc)
structure since even one 800 byte on-stack buffer isn't overly friendly.
cdplay(1) still seems able to read the track-list of an ATAPI cd.


# 1.263 30-Jun-2007 dsl

Remove a load of unnecessary casts now that 'addr' is 'void *'.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.262 04-Mar-2007 christos

branches: 1.262.2; 1.262.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.261 14-Jan-2007 martin

branches: 1.261.2;
The previous fix for PR 34202 was wrong (some sizeof used the union, not
the command block) - but instead of fixing this, we can now revert it
completley: the real fix has been applied to ../ic/wdc.c in rev. 1.244,
removing the alignement constraints.


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.260 01-Dec-2006 martin

branches: 1.260.2;
Fix PR kern/34202 differently, by aligning the variables "the traditional
way".


# 1.259 25-Nov-2006 scw

- Call disk_blocksize(9) when we determine the physical block size of the
media. (Will this ever be anything other than 2048?)
- bounds_check_with_label() has been fixed, so put the correct partition
size in the default disklabel.


# 1.258 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.257 14-Nov-2006 reinoud

Implement/add bufq strategy setting by dkctl for the CD class devices.

Though its hardly advisable to change the CD strategy setting to anything
other than `disksort' or `prioscan' it ought to be possible.


# 1.256 28-Oct-2006 reinoud

Implement another class of `unit not ready' sense handling that is not
fatal.. A `long write in progress' is a retry again later command that is
issued when a device returns immediately after a write request but needs
some time before it can handle read requests.


# 1.255 27-Oct-2006 christos

- don't allocate huge arrays on the stack
- no bogus ; after }; in block statements!


Revision tags: yamt-splraiseipl-base2
# 1.254 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.253 10-Oct-2006 riz

Also print blksize with %u - this is what I get for eyeballing
a patch instead of applying it directly. PR#33966.


# 1.252 10-Oct-2006 riz

Print an unsigned parameter with %lu, not %ld. From David A. Holland
in PR#33966.


# 1.251 08-Oct-2006 mlelstv

Use last track info only if it gives a sane value. Fixes PR#34688.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.250 08-Sep-2006 reinoud

branches: 1.250.2;
Oeps! I overlooked the size argument of the SCSI call. It ought to be equal
to the number of bytes we are reading: READ_DISCINFO_BIGSIZE

sorry.


# 1.249 07-Sep-2006 reinoud

The size of struct scsipi_read_discinfo_data is not even due to the data[1]
pseudo array in the structure. The scsi command issued used
sizeof(scsipi_read_discinfo_data) but included thus the last byte that
wasn't going to be inspected anyway. Using the constant
READ_DISCINFO_BIGSIZE fixes the bug.

Even though SCSI adapters *should* accept odd lengths, the Sun U10
(sparc64's) crashes in bus_space_read_multi_stream_2(). That explains the
crash.

NOTE: somewhere in NetBSD/sparc64's atapibus support there is the
assumption on the even size; this needs to be fixed! (Hi Sparc64 portmaster
:-) )


Revision tags: yamt-pdpolicy-base8
# 1.248 01-Sep-2006 matt

branches: 1.248.2;
Use an unsigned int for the blksize on read_cd_capacity.


# 1.247 31-Aug-2006 reinoud

Fix panic on reading/writing to a (raw) CD device and encountering an
error. It now correctly sets bp->b_resid to the full size of the buffer.
The failed SCSI read/write command allways contains the complete buffer.

When encountering a read (or write) error, the scsipi stack sets the
xs->resid to zero since the command has been accepted by the drive. The
scsi command set does not allow a partial read or write to be performed and
will signal a success or an error.


# 1.246 31-Aug-2006 reinoud

Remove two spurious empty lines in functions


# 1.245 31-Aug-2006 reinoud

Fix fencing bug on CD disk size; the comment was wrong, its the *length* of
the device and since we count from zero its equal to the number of sectors
and thus one higher than the last sector.

This fixes the read/write problems on the (raw) device where the last
sector was not readable/writable.


# 1.244 28-Aug-2006 christos

Add missing initializer.


Revision tags: yamt-pdpolicy-base7
# 1.243 10-Aug-2006 reinoud

Fix incorrect `loast possible lba' reporting, remove some empty lines and
add mmc classification for some still rare HD DVD device types.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.242 30-Mar-2006 thorpej

branches: 1.242.6;
Use device_private().


# 1.241 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.240 08-Feb-2006 reinoud

branches: 1.240.2; 1.240.4; 1.240.6;
Add name of the processed feature like the others have.


# 1.239 04-Feb-2006 reinoud

Add support for SCSI MMC feature 0x0024: hardware assisted defect
management to be passed in mmc_discinfo's device capabilities.

When a device reports support for this the hardware will automatically
remap sectors on read- or write-errors. CD-MRW, DVD+MRW, DVD-RAM and BR-RE
support these.


# 1.238 02-Feb-2006 reinoud

branches: 1.238.2;
Adding two Ioctl's to scsipi's cd.c to abstract SCSI MMC devices. The
ioctl's and their structures are currenly hidden from inclusion for normal
userland applications to allow the MMC abstraction interface to mature
first.

Its useage is mainly for applications dedicated to handling and processing
SCSI MMC compliant devices and their media. Examples of these are CDs, DVDs
and comparable optical devices but also some magnetic swapable devices that
present themselves as a SCSI MMC compliant device.

Its current use is currently the to be committed in-kernel UDF filingsystem
and its userland tools.


# 1.237 07-Jan-2006 christos

branches: 1.237.2;
fix typo.


# 1.236 07-Jan-2006 yamt

remove B_EINTR as it isn't used anymore.


# 1.235 04-Jan-2006 yamt

- add simple functions to allocate/free a buffer for i/o.
- make bufpool static.


# 1.234 21-Dec-2005 reinoud

branches: 1.234.2;
Improve disc size reporting. The current discsize thats reported is the
current recorded extent and not the complete maximum extent of the disc.

An empty CD/DVD disc is seen as having an invalid length and given 800 Mb
size. This makes it possible to write to a CD-R using `dd' as some tend to
do.

However when an extent is recorded the initial recorded length is seen as
valid and is thus set as absolute upperbound to read and write actions
preventing extention of the disc.

Committed after consultation on tech-kern with a positive advice by Manuel
Bouyer.


# 1.233 16-Dec-2005 christos

delete extraneous verbiage.


# 1.232 15-Dec-2005 reinoud

Clean up cdgetdisklabel. It was jumping over a return...


# 1.231 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: ktrace-lwp-base
# 1.230 11-Dec-2005 reinoud

Fix illogical use of extra variable. It was mainly to get a better
readability in KNF. This solution gives better readability without the
extra variable.


# 1.229 10-Dec-2005 reinoud

Second stage of read TOC modifications. Introducing the various forms of
TOC reading. Note that the external interfaces haven't changed. Only the
formatted toc is requestable.

The read msinfo command hasn't been changed in this patch though it could
become more clever using the CD_TOC_MSINFO format.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.228 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.227 06-Sep-2005 reinoud

Cleanup and fix cd_size() function; it was returning wrong results.
Also factor out read_cd_capacity()


# 1.226 05-Sep-2005 reinoud

Implement DIOCCACHESYNC for SCSI/ATAPI cd/mmc recordable devices found by
scsipi/cd.c by issueing the SYNCHRONISE CACHES scsi/atapi call as defined
per MMC standard.


# 1.225 28-Aug-2005 reinoud

Document executed SCSI commands with the IOCTL's to prevent confusion.


# 1.224 06-Jul-2005 bouyer

Always allow open() on the raw partition to succeed, even if any of the
SCSI command in cdopen() fails. Fix PR kern/30288 by Pavel Cahyna.


# 1.223 29-May-2005 christos

branches: 1.223.2;
- Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.


Revision tags: kent-audio2-base
# 1.222 25-Apr-2005 drochner

fix more SSD_RCODE_VALID misuse introduced in cleanup


# 1.221 31-Mar-2005 yamt

introduce a function to drain bufq and use it where appropriate.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base
# 1.220 27-Feb-2005 perry

branches: 1.220.2;
nuke trailing whitespace


# 1.219 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.


Revision tags: yamt-km-base2
# 1.218 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.217 31-Jan-2005 reinoud

Fix LP64 problems introduced by my u_long->uint32_t conversion.


# 1.216 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.215 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.214 30-Jan-2005 reinoud

As in revision 1.213, not all information is returned in read-TOC format 0. In order to add a new generic read-toc ioctl, i renamed the origional to _f0 to indicate its only format 0. The routines can then be changed one at a time to the new generic calling. This patch fixes two calls i'd overseen.... silly me forgot to recompile :(


# 1.213 30-Jan-2005 reinoud

The code asumes all programs want to know is TOC response format 0. Support
for TOC response format 1 and 2 are mandatory on CD/DVD too and provide
more information.

Next an IOCTL needs to be implemented that can read all TOC formats in a
generic way. This is pending.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.212 07-Dec-2004 thorpej

branches: 1.212.2; 1.212.4;
USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).


Revision tags: kent-audio1-base
# 1.211 28-Oct-2004 yamt

move buffer queue related stuffs from buf.h to their own header, bufq.h.


# 1.210 26-Sep-2004 dogcow

Fix debug message output args to match yamt's src/sys/sys/buf.h changes.


# 1.209 18-Sep-2004 mycroft

Standardize some variable names and the calling pattern for scsipi_command().
Use void pointer casts.


# 1.208 17-Sep-2004 mycroft

Remove the "xfer" argument to scsipi_command().


# 1.207 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.206 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.205 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.204 06-Sep-2004 bouyer

Fix comment: xxstart() can also be called from xxrestart()


# 1.203 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.202 21-Aug-2004 thorpej

Use ANSI function decls and make use of static.


# 1.201 24-Apr-2004 pk

Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.

See also sd.c rev. 1.214. Again: should we bother trying DBD at all?


Revision tags: netbsd-2-0-base
# 1.200 22-Feb-2004 enami

branches: 1.200.2;
Backout an obvious bug introduced in rev. 1.145.


# 1.199 10-Jan-2004 yamt

store a i/o priority hint in struct buf for buffer queue discipline.


# 1.198 10-Nov-2003 wiz

Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.


# 1.197 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.196 13-Sep-2003 mycroft

Don't be silent if there is no media present.


# 1.195 13-Sep-2003 mycroft

Make sure the "raw partition" can always be opened again.


# 1.194 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.193 08-Sep-2003 mycroft

Oops. Fix a typo in cd_mode_select().


# 1.192 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.191 08-Sep-2003 mycroft

Attempt to deal with Martin's weirdass Sun drive by setting the mode sense
allocation length a little more precisely -- add the space for the header in
cd_mode_sense(). Also delete the XS_CTL_SILENT, since we really do want to
see errors.

Lastly, add a similar wrapper for mode select, simplifying the callers
slightly.


# 1.190 08-Sep-2003 mycroft

Eliminate the separate ATAPI and SCSI attachments for "cd".


# 1.189 08-Sep-2003 mycroft

Nuke some printf()s.


# 1.188 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.187 18-Jul-2003 wiz

Add a cast to avoid an integer overflow.
Fixes playing (at least some) DVDs.
Patch from Tsubai Masanari (tsubai at iri.co.jp) -- thanks a lot!


# 1.186 10-Jul-2003 martin

If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.


# 1.185 29-Jun-2003 fvdl

branches: 1.185.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.184 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.183 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.182 02-May-2003 dsl

Change return type of readdisklabel() to const char *
I hope I've found all the correct places!


# 1.181 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.180 20-Mar-2003 dbj

use PRId64 to printf bp->b_blkno, which is of type daddr_t


# 1.179 25-Feb-2003 thorpej

Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.


# 1.178 05-Feb-2003 pk

Make the buffer cache code MP-safe.


# 1.177 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


# 1.176 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.175 20-Jan-2003 simonb

The Double-Semi-Colon Police.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.174 13-Jan-2003 toshii

Use the correct byte positions to read data returned by DVD_LU_SEND_RPC_STATE.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.173 15-Dec-2002 jmcneill

Another sizeof -> 4 + 2048 fix for dvd_read_manufact after malloc changes


# 1.172 15-Dec-2002 jmcneill

In dvd_read_disckey, sizeof(buf) is no longer '4 + 2048' after the
malloc change. Replace 'sizeof(buf)' with '4 + 2048' -- this makes
dvd_read_disckey work properly again.


# 1.171 15-Dec-2002 fvdl

Don't waste too much kernel stack space on (infrequent) ioctl operations,
use malloc instead for temp space.


# 1.170 09-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.169 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.


Revision tags: kqueue-aftermerge
# 1.168 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


Revision tags: kqueue-beforemerge kqueue-base
# 1.167 18-Sep-2002 chs

remove all vesitages of dk_establish().


# 1.166 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.


Revision tags: gehenna-devsw-base
# 1.165 30-Aug-2002 hannken

Remove the old device buffer queue interface.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>


# 1.164 22-Jul-2002 hannken

Convert to new device buffer queue interface.


# 1.163 27-May-2002 drochner

put multisession offset code into a separate function and initialize
the p_cdsession field of partition 'a' in the default disklabel


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.162 05-May-2002 bouyer

branches: 1.162.2;
If periph->periph_callout is already active, don't freeze the periph again:
scispi_periph_timed_thaw() will be called only one time anyway.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.161 09-Dec-2001 veego

Support for dvd region code (RPC).


# 1.160 15-Nov-2001 lukem

don't need <sys/types.h> when including <sys/param.h>


# 1.159 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.158 22-Oct-2001 bouyer

We can't have XS_CTL_DATA_OUT and XS_CTL_DATA_IN at the same time.
Pointed out by Bernd Ernesti.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.157 02-Sep-2001 tsutsui

branches: 1.157.2;
Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?


# 1.156 20-Aug-2001 ad

Don't special case the retry for Media Changed... More later.


# 1.155 20-Aug-2001 ad

Two changes submitted by Sergey Svishchev <svs@ropnet.ru>:

- Don't send START UNIT upon open if the drive is playing audio (PR 11768).
- If we receive sense indicating that the media changed, retry (PR 8326).


# 1.154 15-Aug-2001 eeh

Add support for smaller sector sizes so we can mount ffs filesystems.


# 1.153 18-Jul-2001 thorpej

bcopy -> memcpy


# 1.152 18-Jul-2001 thorpej

bzero -> memset


# 1.151 26-Jun-2001 bouyer

branches: 1.151.2;
Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).


# 1.150 20-May-2001 christos

PR/12991: Dave Huang: DVD ioctls don't work because we send the wrong size
CDB (16 instead of 12).


# 1.149 17-May-2001 bouyer

SDEV_DB -> SCSIPI_DB


# 1.148 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.147 28-Apr-2001 tsutsui

Don't forget to set XS_CTL_DATA_OUT (that was removed in previous).


# 1.146 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.145 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


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.144 19-Jan-2001 kenh

branches: 1.144.2;
Retry requests if the CD-ROM drive returns the sense code "Device in
Process of Becoming Ready".


# 1.143 08-Jan-2001 fvdl

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.142 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).


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.141 09-Jun-2000 enami

branches: 1.141.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.140 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.


Revision tags: minoura-xpg4dl-base
# 1.139 16-May-2000 thorpej

branches: 1.139.2;
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.138 30-Mar-2000 augustss

Get rid of register declarations.


# 1.137 13-Mar-2000 soren

Fix doubled 'the's in comments.


Revision tags: chs-ubc2-newbase
# 1.136 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.135 21-Jan-2000 thorpej

Update for sys/buf.h/disksort_*() changes.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base fvdl-softdep-base
# 1.134 03-Nov-1999 matt

use __vax__ and __i386__ instead of vax and i386


Revision tags: comdex-fall-1999-base
# 1.133 31-Oct-1999 mycroft

Fix the size of start_sector, end_sector and end_sector_l0. (I'm just going to
assume the Linux people will also fix this, since I reported it to them.)


# 1.132 29-Oct-1999 mycroft

Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.


# 1.131 17-Oct-1999 ragge

branches: 1.131.2; 1.131.4;
Don't call dk_establish() on vax either.


# 1.130 30-Sep-1999 thorpej

branches: 1.130.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.129 23-Sep-1999 enami

Allow to detach wdc, atapibus, wd and cd.


# 1.128 07-Aug-1999 mycroft

Increase several timeouts to 30s.


Revision tags: chs-ubc2-base
# 1.127 27-May-1999 bouyer

in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.


# 1.126 08-Apr-1999 bouyer

Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.


# 1.125 05-Apr-1999 mycroft

If scsipi_command() fails, always print out the error code.


Revision tags: netbsd-1-4-base
# 1.124 28-Feb-1999 explorer

branches: 1.124.2;
Update to slightly altered rnd_attach_source() api


# 1.123 15-Feb-1999 bouyer

For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.


# 1.122 10-Feb-1999 bouyer

Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson.


# 1.121 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.120 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.119 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.118 04-Jan-1999 is

Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>.


Revision tags: kenh-if-detach-base
# 1.117 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.116 20-Nov-1998 thorpej

Add adapter reference counting for SCSI and ATAPI devices.


Revision tags: chs-ubc-base
# 1.115 17-Aug-1998 mycroft

Assign my copyrights to TNF.


# 1.114 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


Revision tags: eeh-paddr_t-base
# 1.113 13-Jul-1998 hpeyerl

Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)


# 1.112 16-Mar-1998 mycroft

Implement CDIOCCLOSE.


# 1.111 15-Jan-1998 cgd

move the 'cd_cd' declaration back up to where it was before
the config changes were made. Though the nature of the declaration
had to change, there wasn't a reason to change its location.


# 1.110 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.109 12-Jan-1998 thorpej

Adjust for changes to config.


# 1.108 02-Dec-1997 mikel

fix typo; from Dave Sainty in PR kern/4602


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.107 18-Oct-1997 thorpej

branches: 1.107.2;
Implement two macros, scsipi_command() and scsipi_command_direct(), and
use them to hide the structure of the function pointers we jump through
to issue a command.


Revision tags: marc-pcmcia-base
# 1.106 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.105 10-Oct-1997 explorer

Add hooks to insert timing info into the random system


# 1.104 08-Oct-1997 thorpej

Implement DIOCGDEFLABEL.


# 1.103 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.102 09-Sep-1997 bouyer

Uses PLAY_MSF instead of PLAY for the CDIOCPLAYTRACKS ioctl. This avoid a int16
overflow in the PLAY cbd when the resquested track(s) are more than 65535
blocks long. Submitted by t-nkyma@tcp-ip.or.jp in PR kern/4092.


Revision tags: thorpej-signal-base
# 1.101 27-Aug-1997 bouyer

branches: 1.101.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.100 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.99 29-Mar-1997 christos

PR/3409: Koji Imada: cdsize() timeout too short for cd changers.


# 1.98 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.97 05-Dec-1996 cgd

branches: 1.97.6;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.


# 1.96 12-Oct-1996 christos

revert previous kprintf change


# 1.95 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.94 13-Aug-1996 explorer

be quiet about read_subchannel. Some CD players use this to poll, and having
a screen filled with kernel messages isn't nice. Closes pr kern/817


# 1.93 13-Aug-1996 explorer

Fix condition where disk_unbusy may not get called


# 1.92 05-May-1996 christos

Cleanup the rest of the SCSIDEBUG printfs. From Bernd Ernesti.


# 1.91 22-Apr-1996 christos

remove include of <sys/cpu.h>


# 1.90 30-Mar-1996 christos

Eliminate scsi_conf.h.


# 1.89 29-Mar-1996 mrg

eliminate unused variables.


# 1.88 27-Mar-1996 cgd

fix pasto: sdminphys -> cdminphys in comment.


# 1.87 27-Mar-1996 mycroft

SDUNIT -> CDUNIT in last.


# 1.86 26-Mar-1996 mycroft

Put back dk_establish() for now.


# 1.85 26-Mar-1996 mycroft

Increase *OUTSTANDING.
Remove old dk_establish() garbage.
Support the `ancient' bit in both drivers.


# 1.84 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.83 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.82 14-Feb-1996 christos

scsi prototypes


# 1.81 30-Jan-1996 thorpej

Accept DIOCEJECT as a synonym for CDIOCEJECT. Implement DIOCLOCK
separately from CDIOCALLOW and CDIOCPREVENT, even though they perform
basically the same function (with a different interface XXX).


# 1.80 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.79 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.78 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.77 11-Nov-1995 mycroft

Remove the gratuitous code to check for a disc at boot time.


# 1.76 10-Oct-1995 mycroft

branches: 1.76.2;
Return EINVAL if something other than a whole number of blocks is requested.


# 1.75 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.74 12-Aug-1995 mycroft

Fix oversight in previous.


# 1.73 12-Aug-1995 mycroft

minphys() functions really should return void.


# 1.72 05-Aug-1995 mycroft

Use an intermediate variable to shorten label initialization code.


# 1.71 24-Jul-1995 cgd

update SCSI minphys routines' definitions to match standard minphys()
definition and usage.


# 1.70 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.69 26-Jun-1995 cgd

make dump stubs consistent


# 1.68 03-May-1995 mycroft

Make the byte-shifting code consistent.


# 1.67 15-Apr-1995 mycroft

Don't boundary check I/O to the `raw' partition.


# 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

Don't bother with DIOCWLABEL.


# 1.62 23-Mar-1995 mycroft

Check for read-only media in open(), not write().


# 1.61 23-Mar-1995 mycroft

Revert cdsize() to do nothing.


# 1.60 23-Mar-1995 mycroft

Rearrange DIOCWDINFO a little; closer to wd.c.


# 1.59 23-Mar-1995 mycroft

Fix typo.


# 1.58 23-Mar-1995 mycroft

Allow DIOCWDINFO even if label is not `writable'.


# 1.57 07-Mar-1995 mycroft

Correct spelling of `fictitious'. Add patterns for optical memory devices.
From Alistair Crooks.


# 1.56 30-Jan-1995 mycroft

Finish last change.


# 1.55 30-Jan-1995 mycroft

Some drives don't grok START with LoEj=1, either.


# 1.54 30-Jan-1995 mycroft

Set the LoadEject bit when issuing a START.


# 1.53 30-Jan-1995 mycroft

Some devices really do require the START before the PREVENT. This makes no
sense.


# 1.52 26-Jan-1995 mycroft

Update copyrights.


# 1.51 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.50 23-Jan-1995 mycroft

Do the PREVENT before the START.


# 1.49 16-Jan-1995 mycroft

Remove unused macros.


# 1.48 13-Jan-1995 mycroft

Always boundary check I/O.


# 1.47 28-Dec-1994 mycroft

Numerous changes. Many bugs fixed, better autoconfig, a few new features.


# 1.46 16-Dec-1994 mycroft

Remove DIOCSBAD handling. It's not actually handled, so why recognize it?


# 1.45 14-Dec-1994 mycroft

Remove dkbad.h.


# 1.44 23-Nov-1994 mycroft

There's no point in bothering to unlock what we didn't lock.


# 1.43 22-Nov-1994 mycroft

Add still more locking.


# 1.42 21-Nov-1994 mycroft

Replace dev_unit with device_softc in scsi_link. Change argument to foostart()
to void*.


# 1.41 20-Nov-1994 mycroft

Add some missing locking, and some general cleanup.


# 1.40 30-Oct-1994 cgd

be more careful with types, also pull in headers where necessary.


# 1.39 20-Oct-1994 mycroft

First cut at making user-level SCSI commands work. This is untested.
Partly from John Brezak.


# 1.38 20-Oct-1994 mycroft

Fix minor omission.


# 1.37 20-Oct-1994 mycroft

openpart -> openmask


# 1.36 20-Oct-1994 mycroft

Similar changes to sd.c.


# 1.35 14-Oct-1994 cgd

move arch dependence to archs. clean up a bit. deal with weird MAXPARTITONS.


# 1.34 11-Aug-1994 mycroft

On probe or open, retry the READ CAPACITY once if the drive reports NOT READY.


# 1.33 05-Aug-1994 mycroft

Fix spelling of `STEREO'.


# 1.32 04-Aug-1994 mycroft

Obey the command queue size for the controller.


# 1.31 04-Jul-1994 chopps

branches: 1.31.2;
change to support other MAXPARTITIONS vals aside from 8


# 1.30 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.29 16-Jun-1994 chopps

resolve confusion over who owns the buf after calling scsi_scsi_cmd()


# 1.28 16-Jun-1994 mycroft

b_un.b_addr -> b_data


# 1.27 11-May-1994 mycroft

Add dummy *dump() routines.


# 1.26 09-May-1994 chopps

remove union's from sense_data struct, conditionaly define RAW_PART


# 1.25 11-Apr-1994 mycroft

Fix various types. Remove some outdated flags.


# 1.24 11-Apr-1994 mycroft

Combine scsi_start_unit() and scsi_stop_unit(), and increase the start
timeout (again).


# 1.23 29-Mar-1994 mycroft

New SCSI system, based on Julian's more recent work.


# 1.22 06-Feb-1994 mycroft

Use b_actf, not av_forw.


# 1.21 11-Jan-1994 mycroft

*strategy functions return void.


# 1.20 23-Dec-1993 cgd

fix from Nick Cuccia (cuccia@remarque.berkeley.edu), apparently
originating from Gary Grebus <glg@k8lt.ampr.org>: partition size
must be in units of DEV_BSIZE.


# 1.19 17-Dec-1993 mycroft

Canonicalize all #includes.


# 1.18 04-Aug-1993 brezak

branches: 1.18.2;
Normalize play_msf changes with 386bsd patch.


# 1.17 04-Aug-1993 brezak

Add play_msf command and MSF variants. This is SCSI2 stuff and is needed for many flavors of player utilities.


# 1.16 01-Aug-1993 mycroft

Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.


# 1.15 19-Jul-1993 cgd

branches: 1.15.2;
patches from allen briggs to fix a minor bug in *attach()


# 1.14 27-Jun-1993 andrew

ANSIfications.


# 1.13 17-Jun-1993 brezak

Silence size complaint at probe.


# 1.12 16-Jun-1993 deraadt

whoops. typo.


# 1.11 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.10 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.9 20-May-1993 deraadt

First cut at cpu independent disklabels.
There will be niggly little details no doubt..


# 1.8 20-May-1993 cgd

add rcsids and clean up file headers


# 1.7 11-May-1993 cgd

fix stupid line transposition (from John Brezak <brezak@osf.org>)


# 1.6 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.5 20-Apr-1993 mycroft

Display more meaningful message on SCSI `unit attention'.


# 1.4 12-Apr-1993 deraadt

fixed various bugs like cdattach() returning garbage.


# 1.3 12-Apr-1993 deraadt

new scsi subsystem.
changes also in config/mkioconf.c
i386/isa/wd.c, fd.c, and all scsi drivers.


# 1.2 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