History log of /freebsd-10.0-release/sys/cam/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
259332 13-Dec-2013 trasz

MFC r258871:

Properly report an error instead of panicing when user tries to create
LUN backed by non-disk device, e.g. /dev/null.

Approved by: re (glebius)
Sponsored by: The FreeBSD Foundation

259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

257049 24-Oct-2013 mav

MFC r256552:
Unify periph invalidation and destruction reporting.
Print message containing device model and serial number on invalidation.

Approved by: re (hrs)


257047 24-Oct-2013 mav

MFC r256533:
Unhide "Serial Number" lines from bootverbose. That information may
be useful for system administration to have in hard copy (in logs) if
one of several devices suddenly dies.

Approved by: re (hrs)


256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


256201 09-Oct-2013 trasz

Remove no longer useful debugging output and a stale comment.

Approved by: re (gjb)
Sponsored by: FreeBSD Foundation


256197 09-Oct-2013 trasz

Make the error handling more consistant. Shouldn't make any functional
difference.

Approved by: re (gjb)
Sponsored by: FreeBSD Foundation


256195 09-Oct-2013 trasz

Tidy up, cache return value of a function, and add an assertion;
shouldn't make any functional difference.

Approved by: re (gjb)
Sponsored by: FreeBSD Foundation


256188 09-Oct-2013 mav

Close the race on path ID allocation in xpt_bus_register() if two buses are
registered simultaneously. Due to topology unlock between the ID allocation
and the bus registration there is a chance that two buses may get the
same IDs. That is supposed reason of lock assertion panic in CAM during
initial bus scanning after new iscsid initiates two sessions same time.

Reported by: trasz
Approved by: re (glebus, marius)
MFC after: 2 weeks


256187 09-Oct-2013 trasz

Fix NOP-In/NOP-Out payload handling. Previous way didn't work at all; fortunately
nothing seems to actually use this feature, but it's required by standard.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


256163 08-Oct-2013 trasz

Properly fix out of memory handling in the iSCSI target.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


256065 05-Oct-2013 trasz

Split cfiscsi_datamove() in two; no functional changes.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


256058 04-Oct-2013 trasz

Don't leak memory when removing an unconnected session, and remove useless
UMA_ZONE_NOFREE that caused another leak when unloading the module.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


255915 27-Sep-2013 nwhitehorn

Make sure the CCB xflags field is initialized to zero so that
CAM_EXTLUN_VALID is not erroneously set. Also add an XPORT_SRP
identifier to the known SCSI transports for the SCSI RDMA protocol, as
used, for example with Infiniband storage.

Reviewed by: scottl
Approved by: re (marius)


255870 25-Sep-2013 scottl

Re-do r255853. Along with adding back the API/ABI changes from the
original, this hides the contents of cam_compat.h from ktrace/kdump/truss,
avoiding problems there. There are no user-servicable parts in there, so
no need for those tools to be groping around in there.

Approved by: re


255865 25-Sep-2013 gjb

Revert r255853 pending fixes to build errors in usr.bin/kdump

Approved by: re (implicit)


255853 24-Sep-2013 scottl

Update the CAM API for FreeBSD 10:

- Remove the timeout_ch field. It's been deprecated since FreeBSD 7.0;
MPSAFE drivers should be managing their own timeout storage. The
remaining non-MPSAFE drivers have been modified to also manage their own
storage, and should be considered for updating to MPSAFE (or removal)
during the FreeBSD 10.x lifecycle.

- Add fields related to soft timeouts and quality of service, to be used
in upcoming work.

- Add room for more flags in the CCB header and path_inq structures.

- Begin support for extended 64-bit LUNs.

- Bump the CAM version number to 0x18, but add compat shims. Tested with
camcontrol and smartctl.

Reviewed by: nathanw, ken, kib
Approved by: re
Obtained from: Netflix


255848 24-Sep-2013 trasz

Properly ignore PDUs with CmdSN outside of allowed range.

Approved by: re (glebius)
Sponsored by: FreeBSD Foundation


255837 24-Sep-2013 trasz

Fix a few instances of M_WAITOK in threads marked as prohibited from sleep,
missed in r255824.

Approved by: re (kib)
Sponsored by: FreeBSD Foundation


255824 23-Sep-2013 trasz

Don't use M_WAITOK when running from context where sleeping is prohibited,
such as callout or a geom thread.

Approved by: re (marius)
Sponsored by: FreeBSD Foundation


255739 20-Sep-2013 trasz

Add some spare fields to structs used by the new iSCSI stack - some just
in case, some for future MC/S support.

This requires kernel and world rebuild.

Approved by: re (blanket)
Sponsored by: FreeBSD Foundation


255570 14-Sep-2013 trasz

Bring in the new iSCSI target and initiator.

Reviewed by: ken (parts)
Approved by: re (delphij)
Sponsored by: FreeBSD Foundation


255309 06-Sep-2013 mav

Make SES driver adequately react on simple enclosure devices -- read Short
Enclosure status to enclosure status field, clear previous state and exit.


255307 06-Sep-2013 bryanv

Add camcontrol support for the SCSI sanitize command

Reviewed by: ken, mjacob (eariler version)
Sponsored by: Netapp


255304 06-Sep-2013 mav

Fix kernel panic if cache->nelms is zero.

MFC after: 2 weeks


255126 01-Sep-2013 mav

Add debug trace points for freeze/release device queue.


255120 01-Sep-2013 mav

Bring legacy CAM target implementation back into API/KPI-coherent and even
functional state. While CTL is much more superior target from all points,
there is no reason why this code should not work.

Tested with ahc(4) as target side HBA.

MFC after: 2 weeks


255119 01-Sep-2013 mav

Fix SES_ENABLE_PASSTHROUGH kernel option, unexpectedly broken during driver
overhaul.

MFC after: 3 days


255118 01-Sep-2013 mav

Fix targbh crash on XPT_IMMED_NOTIFY error during attach.


255117 01-Sep-2013 mav

Fix the build with CTLFEDEBUG, broken by unmapped I/O support changes.


255043 29-Aug-2013 ken

Bump up the default timeouts for move commands in the ch(4) driver
to 15 minutes, and 5 minutes for things like READ ELEMENT STATUS.

This is needed to account for the worst case scenarios on at least
some Spectra Logic tape libraries.

Sponsored by: Spectra Logic
MFC after: 3 days


254970 27-Aug-2013 ken

If a drive returns ASC/ASCQ 0x04,0x11 "Logical unit not ready,
notify (enable spinup) required", instead of doing the normal
retries, poll for a change in status.

We will poll every half second for a minute for the status to
change.

Hitachi drives (and likely other SAS drives) return that ASC/ASCQ
when they are waiting to spin up. What it means is that they are
waiting for the SAS expander to send them the SAS
NOTIFY (ENABLE SPINUP) primitive.

That primitive is the mechanism expanders/enclosures use to
sequence drive spinup to avoid overloading power supplies.

Sponsored by: Spectra Logic
MFC after: 3 days


254766 24-Aug-2013 mav

Add new attribute lunname to report only textual LUN-specific device IDs.
While lunid attribute prefers to report numeric ones, having both may be
useful in some situations.


254760 24-Aug-2013 ken

Add support to physio(9) for devices that don't want I/O split and
configure sa(4) to request no I/O splitting by default.

For tape devices, the user needs to be able to clearly understand
what blocksize is actually being used when writing to a tape
device. The previous behavior of physio(9) was that it would split
up any I/O that was too large for the device, or too large to fit
into MAXPHYS. This means that if, for instance, the user wrote a
1MB block to a tape device, and MAXPHYS was 128KB, the 1MB write
would be split into 8 128K chunks. This would be done without
informing the user.

This has suboptimal effects, especially when trying to communicate
status to the user. In the event of an error writing to a tape
(e.g. physical end of tape) in the middle of a 1MB block that has
been split into 8 pieces, the user could have the first two 128K
pieces written successfully, the third returned with an error, and
the last 5 returned with 0 bytes written. If the user is using
a standard write(2) system call, all he will see is the ENOSPC
error. He won't have a clue how much actually got written. (With
a writev(2) system call, he should be able to determine how much
got written in addition to the error.)

The solution is to prevent physio(9) from splitting the I/O. The
new cdev flag, SI_NOSPLIT, tells physio that the driver does not
want I/O to be split beforehand.

Although the sa(4) driver now enables SI_NOSPLIT by default,
that can be disabled by two loader tunables for now. It will not
be configurable starting in FreeBSD 11.0. kern.cam.sa.allow_io_split
allows the user to configure I/O splitting for all sa(4) driver
instances. kern.cam.sa.%d.allow_io_split allows the user to
configure I/O splitting for a specific sa(4) instance.

There are also now three sa(4) driver sysctl variables that let the
users see some sa(4) driver values. kern.cam.sa.%d.allow_io_split
shows whether I/O splitting is turned on. kern.cam.sa.%d.maxio shows
the maximum I/O size allowed by kernel configuration parameters
(e.g. MAXPHYS, DFLTPHYS) and the capabilities of the controller.
kern.cam.sa.%d.cpi_maxio shows the maximum I/O size supported by
the controller.

Note that a better long term solution would be to implement support
for chaining buffers, so that that MAXPHYS is no longer a limiting
factor for I/O size to tape and disk devices. At that point, the
controller and the tape drive would become the limiting factors.

sys/conf.h: Add a new cdev flag, SI_NOSPLIT, that allows a
driver to tell physio not to split up I/O.

sys/param.h: Bump __FreeBSD_version to 1000049 for the addition
of the SI_NOSPLIT cdev flag.

kern_physio.c: If the SI_NOSPLIT flag is set on the cdev, return
any I/O that is larger than si_iosize_max or
MAXPHYS, has more than one segment, or would have
to be split because of misalignment with EFBIG.
(File too large).

In the event of an error, print a console message to
give the user a clue about what happened.

scsi_sa.c: Set the SI_NOSPLIT cdev flag on the devices created
for the sa(4) driver by default.

Add tunables to control whether we allow I/O splitting
in physio(9).

Explain in the comments that allowing I/O splitting
will be deprecated for the sa(4) driver in FreeBSD
11.0.

Add sysctl variables to display the maximum I/O
size we can do (which could be further limited by
read block limits) and the maximum I/O size that
the controller can do.

Limit our maximum I/O size (recorded in the cdev's
si_iosize_max) by MAXPHYS. This isn't strictly
necessary, because physio(9) will limit it to
MAXPHYS, but it will provide some clarity for the
application.

Record the controller's maximum I/O size reported
in the Path Inquiry CCB.

sa.4: Document the block size behavior, and explain that
the option of allowing physio(9) to split the I/O
will disappear in FreeBSD 11.0.

Sponsored by: Spectra Logic


254759 24-Aug-2013 trasz

CTL changes required for iSCSI target, most notably LUN remapping
and a mechanism to allow CTL frontends for retrieving LUN options.

Reviewed by: ken (earlier version)


254595 21-Aug-2013 trasz

Fix the (unused for now) SCSI_PROTO_iSCSI define to match style(9).


254416 16-Aug-2013 ken

Add unmapped I/O and larger I/O support to the sa(4) driver.

We now pay attention to the maxio field in the XPT_PATH_INQ CCB,
and if it is set, propagate it up to physio via the si_iosize_max
field in the cdev structure.

We also now pay attention to the PIM_UNMAPPED capability bit in the
XPT_PATH_INQ CCB, and set the new SI_UNMAPPED cdev flag when the
underlying SIM supports unmapped I/O.

scsi_sa.c: Add unmapped I/O support and propagate the SIM's
maximum I/O size up.

Adjust scsi_tape_read_write() in the same way that
scsi_read_write() was changed to support unmapped
I/O. We overload the readop parameter with bits
that tell us whether it's an unmapped I/O, and we
need to set the CAM_DATA_BIO CCB flag. This change
should be backwards compatible in source and
binary forms.

MFC after: 1 week
Sponsored by: Spectra Logic


254378 15-Aug-2013 trasz

Turn comments about locking into actual lock assertions.

Reviewed by: ken
Tested by: ken
MFC after: 1 month


254329 14-Aug-2013 smh

Added 4K quirks for:-
* OCZ Agility 2 SSDs
* Marvell SSDs
* Intel X25-M Series SSDs


254058 07-Aug-2013 mav

Remove droping topology mutex after iterating 100 periphs in CAMGETPASSTHRU.
That is not so slow and so often operation to handle unneeded otherwise
xsoftc.xpt_generation and respective locking complications.


254052 07-Aug-2013 mav

Improve r253721 by reporting detected lack of BIO_FLUSH support to GEOM.
That prevents more of such requests from coming and errors from logging.


253987 06-Aug-2013 trasz

Remove dead code.


253960 05-Aug-2013 mav

MFprojects/camlock r249006:
Pass SIM pointer as an argument to camisr_runqueue() instead of doneq
pointer.


253958 05-Aug-2013 mav

MFprojects/camlock r249505:
Change CCB queue resize logic to be able safely handle overallocations:
- (re)allocate queue space in power of 2 chunks with 64 elements minimum
and never shrink it; with only 4/8 bytes per element size is insignificant.
- automatically reallocate the queue to double size if it is overflowed.
- if queue reallocation failed, store extra CCBs in unsorted TAILQ,
fetching them back as soon as some queue element is freed.

To free space in CCB for TAILQ linking, change highpowerq from keeping
high-power CCBs to keeping devices frozen due to high-power CCBs.

This encloses all pieces of queue resize logic inside of cam_queue.[ch],
removing some not obvious duties from xpt_release_ccb().


253803 30-Jul-2013 mav

Add NO_RC16 quirk to make da driver avoid using READ CAPACITY(16) command
if possible. Use it for Kingston JetFlash USB sticks, that are known to
return garbage in response to that command.


253752 28-Jul-2013 mav

Fix returning incorrect bio_resid value with failed BIO_DELETE requests.
Neither residual length reported for ATA/SCSI command nor one from another
BIO_DELETE request are in any way related to the value to be returned.


253724 27-Jul-2013 mav

Synchronize device cache on close only if there were some write operations.
While these operations are not really needed otherwise, at least for SCSI
they may cause extra errors if some other initiator holds write exclusive
reservation on the LUN (SYNCHRONIZE CACHE handled as "write" operation).


253722 27-Jul-2013 mav

Oops, revert unwanted part of r253721.


253721 27-Jul-2013 mav

Detect unsupported PREVENT ALLOW MEDIUM REMOVAL and SYNCHRONIZE CACHE(10)
to not spam devices with useless commands and logs with errors.


253549 22-Jul-2013 ken

CAM and mps(4) driver scanning changes.

Add a PIM_NOSCAN flag to the CAM path inquiry CCB. This tells CAM
not to perform a rescan on a bus when it is registered.

We now use this flag in the mps(4) driver. Since it knows what
devices it has attached, it is more efficient for it to just issue
a target rescan on the targets that are attached.

Also, remove the private rescan thread from the mps(4) driver in
favor of the rescan thread already built into CAM. Without this
change, but with the change above, the MPS scanner could run before
or during CAM's initial setup, which would cause duplicate device
reprobes and announcements.

sys/param.h:
Bump __FreeBSD_version to 1000039 for the inclusion of the
PIM_RESCAN CAM path inquiry flag.

sys/cam/cam_ccb.h:
sys/cam/cam_xpt.c:
Added a PIM_NOSCAN flag. If a SIM sets this in the path
inquiry ccb, then CAM won't rescan the bus in
xpt_bus_regsister.

sys/dev/mps/mps_sas.c
For versions of FreeBSD that have the PIM_NOSCAN path
inquiry flag, don't freeze the sim queue during scanning,
because CAM won't be scanning this bus. Instead, hold
up the boot. Don't call mpssas_rescan_target in
mpssas_startup_decrement; it's redundant and I don't
know why it was in there.

Set PIM_NOSCAN in path inquiry CCBs.

Remove methods related to the internal rescan daemon.

Always use async events to trigger a probe for EEDP support.
In older versions of FreeBSD where AC_ADVINFO_CHANGED is
not available, use AC_FOUND_DEVICE and issue the
necessary READ CAPACITY manually.

Provide a path to xpt_register_async() so that we only
receive events for our own SCSI domain.

Improve error reporting in cases where setup for EEDP
detection fails.

sys/dev/mps/mps_sas.h:
Remove softc flags and data related to the scanner thread.

sys/dev/mps/mps_sas_lsi.c:
Unconditionally rescan the target whenever a device is added.

Sponsored by: Spectra Logic
MFC after: 1 week


253370 15-Jul-2013 mav

Make some improvements to r253322 to really rescan target, not a bus.
Add there and in two more places checks for NULL on xpt_alloc_ccb_nowait().


253368 15-Jul-2013 ken

Fix an argument reversal in calls to scsi_read_element_status().

Reported by: Ulrich Spoerlein <uqs@FreeBSD.org>
MFC after: 3 days


253323 13-Jul-2013 mav

When printing opcode description, map T_NODEVICE to Direct Access Device to
handle REPORT LUNS, etc.


253322 13-Jul-2013 mav

Improve handling of 0x3F/0x0E "Reported LUNs data has changed" and 0x25/0x00
"Logical unit not supported" errors. First initiates specific target rescan,
second -- destroys specific LUN. That allows to automatically detect changes
in list of device LUNs. This mechanism doesn't work when target is completely
idle, but probably that is all what can be done without active polling.

Reviewed by: ken
Sponsored by: iXsystems, Inc.


253307 12-Jul-2013 scottl

Const-ify the new da_delete_functions.
Remove a redundant sanity check

Submitted by: Steven Hartland
Obtained from: Netflix
MFC after: 3 days


253274 12-Jul-2013 ken

Fix a problem with READ ELEMENT STATUS that occurs on some
changers that don't support the DVCID and CURDATA bits that were
introduced in the SMC spec.

These changers will return an Illegal Request type error if the
bits are set. This causes "chio status" to fail.

The fix is two-fold. First, for changers that claim to be SCSI-2
or older, don't set the DVCID and CURDATA bits for READ ELEMENT
STATUS. For newer changers (SCSI-3 and newer), we default to
setting the new bits, but back off and try the READ ELEMENT STATUS
without the bits if we get an Illegal Request type error.

This has been tested on a Qualstar TLS-8211, which is a SCSI-2
changer that does not support the new bits, and a Spectra T-380,
which is a SCSI-3 changer that does support the new bits. In the
absence of a SCSI-3 changer that does not support the bits, I
tested that with some error injection code. (The SMC spec says
that support for CURDATA is mandatory, and DVCID is optional.)

scsi_ch.c: Add a new quirk, CH_Q_NO_DVCID that gets set for
SCSI-2 and older libraries, or newer libraries that
report errors when the DVCID/CURDATA bits are set.

In chgetelemstatus(), use the new quirk to
determine whether or not to set DVCID and CURDATA.
If we get an error with the bits set, back off and
try without the bits. Set the quirk flag if the
read element status succeeds without the bits set.

Increase the READ ELEMENT STATUS timeout to 60
seconds after testing with a Spectra T-380. The
previous value was 10 seconds, and too short for
the T-380. This may be decreased later after
some additional testing and investigation.

Tested by: Andre Albsmeier <Andre.Albsmeier@siemens.com>
Sponsored by: Spectra Logic
MFC after: 3 days


253228 12-Jul-2013 scottl

Refactor the various delete methods out of dastart(). Cleans up a bunch
of style and adds more modularity and clarity.

Obtained from: Netflix
MFC after: 3 days


253091 09-Jul-2013 smh

Added 4K QUIRK for OCZ Vertex 4 SSDs

Submitted by: Borja Marcos <borjam@sarenet.es>
MFC after: 2 days


252684 04-Jul-2013 jkim

Make it little bit more C++ friendly. This explicit casting fixes some
ports, emulators/virtualbox-ose and sysutils/smartmontools for example.


252657 03-Jul-2013 smh

Bump disk(9) ABI version to signify the addition of d_delmaxsize by r249940.

Ensure that d_delmaxsize is always set, removing init to 0 which could cause
future issues if use cases change.

Allow kern.cam.da.X.delete_max (which maps to d_delmaxsize) to be increased
up to the calculated max after being reduced.

MFC after: 1 day
X-MFC-With: r249940


252569 03-Jul-2013 mav

Fix NULL-deference kernel panic on attempt of destroying non-existing
ramdisk-backed CTL LUN.


252382 29-Jun-2013 scottl

Introduce accessors for the ccb status word. Convert one (of many more)
modules to use it, will convert the others once the appropriate shed
color is selected by consensus.

Obtained from: Netflix
MFC after: 3 days


252250 26-Jun-2013 mav

Fix some UTF-8 chars slipped into r252204 via copy/paste.


252204 25-Jun-2013 mav

Add bunch of names for Seagate and HGST vennor-specififc ASC/ASCQ codes.


252045 20-Jun-2013 smh

Corrected ATA Passthrough defines from decimal to hex

Reviewed by: scottl
MFC after: 1 week


251989 19-Jun-2013 scottl

Fix an unfortunate typo with the compat shims

Obtained from: Netflix
MFC after: now


251837 17-Jun-2013 scottl

Add infrastructure for doing compatibility shims, as has been sorely
needed for the last 10 years. Far too much of the internal API is
exposed, and every small adjustment causes applications to stop working.
To kick this off, bump the API version to 0x17 as should have been done
with r246713, but add shims to compensate. Thanks to the shims, there
should be no visible change in application behavior.

I have plans to do a significant overhaul of the API to harnen it for
the future, but until then, I welcome others to add shims for older
versions of the API.

Obtained from: Netflix


251792 15-Jun-2013 mav

Restore use of polling mode for disk cache flush in case of kernel panic.
While I am not sure that any extra hardware access is a good idea after
panic, that is an existing behaviour that should better work correctly.


251683 13-Jun-2013 mav

Revert r251649:
ken@ noticed that with recently added d_gone() disk method GEOM already
holds reference on the periph, so we don't need another one.


251654 12-Jun-2013 mav

Make CAM return and GEOM DISK pass through new GEOM::lunid attribute.

SPC-4 specification states that serial number may be property of device,
but not a specific logical unit. People reported about FC storages using
serial number in that way, making it unusable for purposes of LUN multipath
detection. SPC-4 states that designators associated with logical unit from
the VPD page 83h "Device Identification" should be used for that purpose.
Report first of them in the new attribute in such preference order: NAA,
EUI-64, T10 and SCSI name string.

While there, make GEOM DISK properly report GEOM::ident in XML output also
using d_getattr() method, if available. This fixes serial numbers reporting
for SCSI disks in `geom disk list` output and confxml.

Discussed with: gibbs, ken
Sponsored by: iXsystems, Inc.
MFC after: 2 weeks


251649 12-Jun-2013 mav

Acquire periph reference when handling d_getattr() method call.

While GEOM in general has provider opened while sending BIO_GETATTR,
GEOM DISK does not really need to open disk to read medium-unrelated
attributes for own use.

Proposed by: ken


251479 07-Jun-2013 scottl

Simplify the checking of flags for cam_periph_mapmem(). This gets rid of
a lot of code redundancy and grossness at very minor expense.

Reviewed by: smh
Obtained from: Netflix
MFC after: 3 days


251061 28-May-2013 smh

Added missing SCSI quirks from r241784

Re-ordered SSD quirks alphabetically so they are easier to maintain.

Removed my email and PR reference from comments on each quirk.

Added quirks for more SSDs:
* Crucial M4
* Corsair Force GT
* Intel 520 Series
* Kingston E100 Series
* Samsung 830 Series

Reviewed by: pjd (mentor)
Approved by: pjd (mentor)
MFC after: 1 week


250967 24-May-2013 smh

Enforce validation on the selected delete method via sysctl.

This prevents users from selecting a delete method which may cause
corruption e.g. MPS WS16 on pre P14 firmware.

Reviewed by: pjd (mentor)
Approved by: pjd (mentor)
MFC after: 2 days


250792 18-May-2013 smh

Added output of device QUIRKS for CAM and AHCI devices during boot.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


250557 12-May-2013 mav

Suppress error printing for "PREVENT ALLOW MEDIUM REMOVAL" on da open.
Change at r250208 exposed more errors here, hidden before. The same flag
is used in cd driver.


250532 11-May-2013 eadler

Intel's 320-series and 510-series SSDs advertise 512-byte sectors
sizes for both logical and physical. Add ADA_Q_4K quirks
for both.

PR: kern/178040
Submitted by: Jeremy Chadwick <jdc@koitsu.org>


250508 11-May-2013 mav

Disable sending Early R_OK on SiI3726/SiI3826 port multipliers.
With "cached read" HDD testing and multiple ports busy on a SATA
host controller, 3726/3826 PMP will very rarely drop a deferred
R_OK that was intended for the host. Symptom will be all 5 drives
under test will timeout, get reset, and recover.

Submitted by: Rich Futyma <rich.futyma@sanmina.com>
MFC after: 2 weeks


250460 10-May-2013 eadler

Fxi a bunch of typos.

PR: misc/174625
Submitted by: Jeremy Chadwick <jdc@koitsu.org>


250301 06-May-2013 mav

Rework r250298 in more correct way.


250298 06-May-2013 mav

Fix byte order of ATA WWN when converting it to SCSI LUN ID.


250208 03-May-2013 mav

Tune support for removable media in da driver:
- remove DA_FLAG_SAW_MEDIA flag, almost opposite to DA_FLAG_PACK_INVALID,
using the last instead.
- allow opening device with no media present, reporting zero media size
and non-zero sector size, as geom/notes suggests. That allow to read
device attributes and potentially do other things, not related to media.


250183 02-May-2013 smh

Enable CAM SCSI to choice ATA TRIM during autodetection and correct method
names after increasing the priority of ATA TRIM.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250181 02-May-2013 smh

Use the existence of ATA Information VPD to determine if we should attempt
to query ATA functionality via ATA Pass-Through (16) as this page is defined
as "must" for SATL devices, hence indicating that the device is at least
likely to support Pass-Through (16).

This eliminates errors produced by CTL when ATA Pass-Through (16) fails.

Switch ATA probe daerror call to SF_NO_PRINT to avoid errors printing out
for devices which return invalid errors.

Output details about supported and choosen delete method when verbose booted.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250180 02-May-2013 smh

Fix probe in progress check in dareprobe

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250179 02-May-2013 smh

Update probe flow so that devices with lbp can also disable disksort.

Ensure that delete_available is reset so re-probes after a media change,
to one with different delete characteristics, will result in the correct
methods being flagged as available.

Make all ccb state changes use a consistent flow:
* free()
* xpt_release_ccb()
* softc->state = <new state>
* xpt_schedule()

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 1 week


250131 01-May-2013 eadler

Correct a few sizeof()s

Submitted by: swildner@DragonFlyBSD.org
Reviewed by: alfred


250033 28-Apr-2013 smh

Correct comment typo's
Add missing comment

Reviewed by: pjd (mentor)
Approved by: pjd (mentor)
MFC after: 2 weeks


250025 28-Apr-2013 mav

Add some cam_freeze_devq()'s missed at r249466.
This makes number of freezes match the number of releases.

Reported by: dim


249981 27-Apr-2013 mav

MFprojects/camlock r249542:
Remove ADA_FLAG_PACK_INVALID flag. Since ATA disks have no concept of media
change it only duplicates CAM_PERIPH_INVALID flag, so we can use last one.

Slightly cleanup DA_FLAG_PACK_INVALID use.


249980 27-Apr-2013 mav

MFprojects/camlock r249541:
Give periph validity flag own periph reference. That slightly simplifies
the release logic and covers hypothetical case if lock is dropped inside
the periph_oninval() method.


249941 26-Apr-2013 smh

Added automatic detection of non-rotating media which disables the
use of BIO queue sorting, hence optimising performance for devices
such as SSD's

Reviewed by: scottl
Approved by: pjd (mentor)
MFC after: 2 weeks


249940 26-Apr-2013 smh

Teach GEOM and CAM about the difference between the max "size" of r/w and delete
requests.

sys/geom/geom_disk.h:
- Added d_delmaxsize which represents the maximum size of individual
device delete requests in bytes. This can be used by devices to
inform geom of their size limitations regarding delete operations
which are generally different from the read / write limits as data
is not usually transferred from the host to physical device.

sys/geom/geom_disk.c:
- Use new d_delmaxsize to calculate the size of chunks passed through to
the underlying strategy during deletes instead of using read / write
optimised values. This defaults to d_maxsize if unset (0).

- Moved d_maxsize default up so it can be used to default d_delmaxsize

sys/cam/ata/ata_da.c:
- Added d_delmaxsize calculations for TRIM and CFA

sys/cam/scsi/scsi_da.c:
- Added re-calculation of d_delmaxsize whenever delete_method is set.

- Added kern.cam.da.X.delete_max sysctl which allows the max size for
delete requests to be limited. This is useful in preventing timeouts
on devices who's delete methods are slow. It should be noted that
this limit is reset then the device delete method is changed and
that it can only be lowered not increased from the device max.

Reviewed by: mav
Approved by: pjd (mentor)


249939 26-Apr-2013 smh

Added available delete methods discovery during device probe, including the
maximum sizes for said methods, which are used when processing BIO_DELETE
requests. This includes updating UNMAP support discovery to be based on
SBC-3 T10/1799-D Revision 31 specification.

Added ATA TRIM support to cam scsi devices via ATA Pass-Through(16)

sys/cam/scsi/scsi_da.c:
- Added ATA Data Set Management TRIM support via ATA Pass-Through(16)
as a delete_method

- Added four new probe states used to identity available methods and their
limits for the processing of BIO_DELETE commands via both UNMAP and the
new ATA TRIM commands.

- Renamed Probe states to better indicate their use

- Added delete method descriptions used when informing user of issues.

- Added automatic calculation of the optimum delete mode based on which
method presents the largest maximum request size as this is most likely
to result in the best performance.

- Added WRITE SAME max block limits

- Updated UNMAP range generation to mirror that used by ATA TRIM, this
optimises the generation of ranges and fixes a potential overflow
issue in the count when combining multiple BIO_DELETE requests

- Added output of warnings about short deletes. This should only ever
be triggered on devices that fail to correctly advertise their supported
delete modes / max sizes.

- Fixed WS16 requests being incorrectly limited to 65535 in length.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249937 26-Apr-2013 smh

Refactored scsi_xpt use of device_has_vpd to generic scsi_vpd_supported_page
so its available for use in generic scsi code.

This is a pre-requirement for using VPD queries to determine available SCSI
delete methods within scsi_da.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249934 26-Apr-2013 smh

Updated TRIM calculations in cam/ata to be based off ATA_DSM_* defines

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249933 26-Apr-2013 smh

Added the ability to send ATA identify and Data Set Management (DSM) TRIM
commands to an ATA device attached via a SCSI control.

sys/cam/scsi/scsi_all.c:
- Added scsi_ata_identify, scsi_ata_trim
Which use ATA Pass-Through to send commands to the attached disk.

sys/cam/scsi/scsi_all.h:
- Added defines for all missing ATA Pass-Through commands values.

- Added scsi_ata_identify, scsi_ata_trim methods used in ATA TRIM
support.

- Added scsi_vpd_logical_block_prov structure used when querying for
the supported sizes UNMAP commands.

- Added scsi_vpd_block_limits structure used when querying for the
supported sizes of the UNMAP command.

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249929 26-Apr-2013 smh

Removed unneeded tests in dadeletemethodset changing it to return void

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


249701 20-Apr-2013 ken

Fix compilation.

Pointy hat to: ken


249664 20-Apr-2013 sbruno

Expose CAM_BOOT_DELAY as a kernel conf item now.

This allows users who boot without loader to adjust their environments
around slightly buggy or slow hardware.

PR: kern/161809
Submitted by: rozhuk.im@gmail.com
MFC after: 2 weeks


249658 19-Apr-2013 ken

Update chio(1) and ch(4) to support reporting element designators.

This allows mapping a tape drive in a changer (as reported by
'chio status') to a sa(4) driver instance by comparing the
serial numbers.

The designators can be ASCII (which is printed out directly), binary
(which is printed in hex format) or UTF-8, which is printed in either
native UTF-8 format if the terminal can support it, or in %XX notation
for non-ASCII characters. Thanks to Hiroki Sato <hrs@> for the
explaining UTF-8 printing and example UTF-8 printing code.

chio.h: Modify the changer_element_status structure to add new
fields and definitions from the SMC3r16 spec.

Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
define a new CHIOGSTATUS ioctl.

Clean up some tab/space issues.

chio.c: For the 'status' subcommand, print the designator field
if it is supplied by a device.

scsi_ch.h: Add new flags for DVCID and CURDATA to the READ
ELEMENT STATUS command structure.

Add a read_element_status_device_id structure
for the data fields in the new standard. Add new
unions, dt_or_obsolete and voltage_devid, to hold
and address data from either SCSI-2 or newer devices.

scsi_ch.c: Implement support for fetching device IDs with READ
ELEMENT STATUS data.

Add new arguments to scsi_read_element_status() to
allow the user to request the DVCID and CURDATA bits.
This isn't compiled into libcam (it's only an internal
kernel interface), so we don't need any special
handling for the API change.

If the user issues the new CHIOGSTATUS ioctl, copy all of
the available element status data out. If he issues the
OCHIOGSTATUS ioctl, we don't copy the new fields in the
structure.

Fix a bug in chopen() that would result in the peripheral
never getting unheld if chgetparams() failed.

Sponsored by: Spectra Logic
Submitted by: Po-Li Soong
MFC After: 1 week


249585 17-Apr-2013 gabor

- Corrrect mispellings of word useful

Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)


249582 17-Apr-2013 gabor

- Correct mispellings of the word occurrence

Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)


249481 14-Apr-2013 mav

Remove some more pieces of multilevel freeze mechanism, missed in r249466.


249470 14-Apr-2013 mav

Remove owner field from struct cam_ed, unused at least since FreeBSD 7.


249468 14-Apr-2013 mav

MFprojects/camlock r248982:
Stop abusing xpt_periph in random plases that really have no periph related
to CCB, for example, bus scanning. NULL value is fine in such cases and it
is correctly logged in debug messages as "noperiph". If at some point we
need some real XPT periphs (alike to pmpX now), quite likely they will be
per-bus, and not a single global instance as xpt_periph now.


249466 14-Apr-2013 mav

MFprojects/camlock r248890, r248897, r248898, r248900, r248903, r248905,
r248917, r248918, r248978, r249001, r249014, r249030:

Remove multilevel freezing mechanism, implemented to handle specifics of
the ATA/SATA error recovery, when post-reset recovery commands should be
allocated when queues are already full of payload requests. Instead of
removing frozen CCBs with specified range of priorities from the queue
to provide free openings, use simple hack, allowing explicit CCBs over-
allocation for requests with priority higher (numerically lower) then
CAM_PRIORITY_OOB threshold.

Simplify CCB allocation logic by removing SIM-level allocation queue.
After that SIM-level queue manages only CCBs execution, while allocation
logic is localized within each single device.

Suggested by: gibbs


249438 13-Apr-2013 mav

MFprojects/camlock r248894:
Use full freeze while PMP does hard reset. This is only cosmetical change.


249410 12-Apr-2013 trasz

Remove ctl(4) from GENERIC. Also remove 'options CTL_DISABLE'
and kern.cam.ctl.disable tunable; those were introduced as a workaround
to make it possible to boot GENERIC on low memory machines.

With ctl(4) being built as a module and automatically loaded by ctladm(8),
this makes CTL work out of the box.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249352 11-Apr-2013 mav

Do not sent 120 TEST UNIT READY requests on generic NOT READY statuses.

Some failing disks tend to return vendor-specific ASC/ASCQ codes with
NOT READY sense key. It caused extremely long recovery attempts, repeating
these 120 TURs (it takes at least 1 minute) for every I/O request.
Instead of that use default error handling, doing just few retries.

Reviewed by: ken, gibbs
MFC after: 1 month


249347 10-Apr-2013 ken

Add a callback to the ada(4) driver so that it knows when GEOM has released
references to it.

This is the functional equivalent to change r237518, which added this
functionality to the cd(4) and da(4) drivers.

This fix prevents a panic caused by GEOM calling adaopen() while the device
is going away. We now keep the device around until GEOM has finished
cleaning up its state.

ata_da.c: In adaregister(), add a d_gone callback to the GEOM disk
structure registered for the ada driver. Increment the
peripheral reference count for GEOM.

Add a new callback, adadiskgonecb(), that GEOM calls when
it is done with its resources. This callback releases the
reference acquired in adaregister().

Submitted by: Po-Li Soong
Sponsored by: Spectra Logic
MFC After: 5 days


249256 08-Apr-2013 ken

Fix a memory leak that showed up when we delete LUNs. The memory used for
the LUN was never freed.

ctl.c: Adjust ctl_alloc_lun() to make sure we don't clear the
CTL_LUN_MALLOCED flag.

Reported by: Sreenivasa Honnur <shonnur@chelsio.com>
Sponsored by: Spectra Logic
MFC after: 3 days


249224 07-Apr-2013 mav

Remove extra semicolons from CAM_SIM_[UN]LOCK() macros.


249213 06-Apr-2013 marius

- With the demise of !ATA_CAM, ATA_STATIC_ID is the only ata(4) related
option left but actually consumed by ada(4), so move it to opt_ada.h
and get rid of opt_ata.h.
- Fix stand-alone build of atacore(4) by adding opt_cam.h.
- Use __FBSDID.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.


249205 06-Apr-2013 mav

Replicate r245306 from SCSI to ATA. The problem didn't appear so far,
covered by multilevel freeze mechanism, but it is better to be safe.


249199 06-Apr-2013 marius

Unbreak ATA_NO_48BIT_DMA with ATA_CAM by treating 48-bit DMA as an
optional property with PATA transport.

Reviewed by: mav
MFC after: 3 days


249194 06-Apr-2013 trasz

Make SYNCHRONIZE CACHE work with LUNs backed by device files (as opposed
to regular files, which already worked fine). With this change, it's no
longer neccessary to use "ctladm realsync off" workaround.


249108 04-Apr-2013 mav

MFprojects/camlock:
r249017:
Some cosmetic things:
- Unify device to target insertion inside xpt_alloc_device() instead of
duplicating it three times.
- Remove extra checks for empty lists of devices and targets on release
since zero refcount check also implies it.
- Reformat code to reduce indentation.

r249103:
- Add lock assertions to every point where reference counters are modified.
- When reference counters are reaching zero, add assertions that there are
no children items left.
- Add a bit more locking to the xptpdperiphtraverse().


249106 04-Apr-2013 mav

MFprojects/camlock r248931:
Replace some direct mutex operations with wrappers.

MFC after: 2 weeks


249105 04-Apr-2013 mav

MFprojects/camlock r248930:
Remove extra NULL checks. d_drv1 can never be NULL during periph life cycle.

MFC after: 2 weeks


249104 04-Apr-2013 mav

MFprojects/camlock r248928:
Move CAM_DEBUG_CDB messages from the point of queuing to the point of
sending to SIM. That allows to inspect real requests execution order,
respecting priorities, freezing, etc.

MFC after: 2 weeks


249102 04-Apr-2013 trasz

Since the CTL version in FreeBSD does not support High Availability,
ctl_is_single should always be set to 1. Make it so. Previously
it was always 0, because ctl_isc_start() never got to run.

Suggested by: ken


249099 04-Apr-2013 mav

Remove xpt_sim_opened(), the only consumer of which was atapicam, which is
now gone.


249091 04-Apr-2013 mav

Use xpt_lock_buses() instead of equivalent mtx_lock(&xsoftc.xpt_topo_lock)
to unify the code.


249083 04-Apr-2013 mav

Remove all legacy ATA code parts, not used since options ATA_CAM enabled in
most kernels before FreeBSD 9.0. Remove such modules and respective kernel
options: atadisk, ataraid, atapicd, atapifd, atapist, atapicam. Remove the
atacontrol utility and some man pages. Remove useless now options ATA_CAM.

No objections: current@, stable@
MFC after: never


249065 03-Apr-2013 trasz

Fix locking problem in ctl_maintenance_in() - one cannot use M_WAITOK or call
ctl_done() with mutex held.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249048 03-Apr-2013 mav

Add xpt_release_ccb()'s missed at r248872. That made `shutdown -p` stuck
on controller with small number of queue slots and several disks connected.


249028 02-Apr-2013 ken

Fix sending virtual scatter/gather lists from the CTL CAM frontend
peripheral.

Sponsored by: Spectra Logic


249026 02-Apr-2013 trasz

Don't directly dereference userland pointer; instead use kernel pointer
copied in from userspace. This fixes instant panic when creating CTL LUN
on sparc64. Not a security problem, since the API is root-only.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249019 02-Apr-2013 trasz

Fix comment formatting.


249012 02-Apr-2013 trasz

Remove unused code.

Reviewed by: ken


249009 02-Apr-2013 trasz

Make it possible to build CTL as a module.

Reviewed by: ken
Sponsored by: FreeBSD Foundation


249008 02-Apr-2013 trasz

Fix panic in the error path caused by recursive acquisition of XPT topology
lock.

Reviewed by: ken


248992 02-Apr-2013 smh

Added ATA Pass-Through support to CAM

sys/cam/scsi/scsi_all.c:
- Added scsi_ata_pass_16 method
Which use ATA Pass-Through to send commands to the attached disk.

sys/cam/scsi/scsi_all.h:
- Added defines for all missing ATA Pass-Through commands values.

- Added scsi_ata_pass_16 method.

- Fixed a comment typo while I'm here

Reviewed by: mav
Approved by: pjd (mentor)
MFC after: 2 weeks


248922 29-Mar-2013 smh

Adds the ability to enable / disable sorting of BIO requests queued within
CAM. This can significantly improve performance particularly for SSDs
which don't suffer from seek latencies.

The sysctl / tunable kern.cam.sort_io_queues provides the systems default
setting where:-
0 = queued BIOs are NOT sorted
1 = queued BIOs are sorted (default)

Each device gets its own sysctl kern.cam.<type>.<id>.sort_io_queue
Valid values are:-
-1 = use system default (default)
0 = queued BIOs are NOT sorted
1 = queued BIOs are sorted

Note: Additional patch will look to add automatic use of none sorted queues
for none rotating media e.g. SSD's

Reviewed by: scottl
Approved by: pjd (mentor)
MFC after: 2 weeks


248874 29-Mar-2013 marius

Unbreak compilation after r248868.


248872 29-Mar-2013 mav

Make pre-shutdown flush and spindown routines to not use xpt_polled_action(),
but execute the commands in regular way. There is no any reason to cook CPU
while the system is still fully operational. After this change polling in
CAM is used only for kernel dumping.


248868 29-Mar-2013 mav

Implement CAM_PERIPH_FOREACH() macro, safely iterating over the list of
driver's periphs, acquiring and releaseing periph references while doing it.

Use it to iterate over the lists of ada and da periphs when flushing caches
and putting devices to sleep on shutdown and suspend. Previous code could
panic in theory if some device disappear in the middle of the process.


248800 27-Mar-2013 mav

On SIM destruction free associated CCBs, preallocated inside xpt_get_ccb().
Before this change they were just leaked. Fortunately USB sticks now use
only one CCB, and so leak was only 2KB per detach, while other bigger SIMs
with much more allocated CCBs are rarely detached.

MFC after: 2 weeks


248695 25-Mar-2013 mav

Remove two bzero()s that are erasing only few more bytes then set later.


248520 19-Mar-2013 kib

Commit the removal of a whitespace to record the proper commit message
for the r248519:

For the cam-attached HBAs, allow the driver to specify that it accepts
the unmapped bio by the PIM_UNMAPPED flag. The CAM passes the
CAM_DATA_BIO data transfer type request for the unmapped bio, and the
driver could use the bus_dmamap_load_ccb() as a helper to
transparently handle the ccb.

Sponsored by: The FreeBSD Foundation
Reviewed by: scottl
Tested by: pho, scottl


248519 19-Mar-2013 kib

Support unmapped i/o for the md(4).

The vnode-backed md(4) has to map the unmapped bio because VOP_READ()
and VOP_WRITE() interfaces do not allow to pass unmapped requests to
the filesystem. Vnode-backed md(4) uses pbufs instead of relying on
the bio_transient_map, to avoid usual md deadlock.

Sponsored by: The FreeBSD Foundation
Tested by: pho, scottl


248515 19-Mar-2013 kib

Do not remap usermode pages into KVA for physio.

Sponsored by: The FreeBSD Foundation
Tested by: pho


248501 19-Mar-2013 kib

Assert that a ccb passed to cam_periph_mapmem() for XPT_SCSI_IO and
XPT_ATA_IO holds virtual buffer address.

Sponsored by: The FreeBSD Foundation
Tested by: pho


247814 04-Mar-2013 ken

Re-enable CTL in GENERIC on i386 and amd64, but turn on the CTL disable
tunable by default.

This will allow GENERIC configurations to boot on small memory boxes, but
not require end users who want to use CTL to recompile their kernel. They
can simply set kern.cam.ctl.disable=0 in loader.conf.

The eventual solution to the memory usage problem is to change the way
CTL allocates memory to be more configurable, but this should fix things
for small memory situations in the mean time.

UPDATING: Explain the change in the CTL configuration, and
how users can enable CTL if they would like to use
it.

sys/conf/options: Add a new option, CTL_DISABLE, that prevents CTL
from initializing.

ctl.c: If CTL_DISABLE is turned on, don't initialize.

i386/conf/GENERIC,
amd64/conf/GENERIC: Re-enable device ctl, and add the CTL_DISABLE
option.


247161 22-Feb-2013 mav

Hide SEMB port of the SiI3826 Port Multiplier by default to avoid extra
errors while it tries to talk via I2C to usually missing external SEP.
There is tunable to enable it back when needed.


247154 22-Feb-2013 mav

Add DA_Q_NO_PREVENT quirk for Kingston DataTraveler G3 1.00 USB flash.

PREVENT ALLOW MEDIUM REMOVAL commands return errors on these devices
without returning sense data. In some cases unrelated following commands
start to return errors too, that makes device to be dropped by CAM.


246713 12-Feb-2013 kib

Reform the busdma API so that new types may be added without modifying
every architecture's busdma_machdep.c. It is done by unifying the
bus_dmamap_load_buffer() routines so that they may be called from MI
code. The MD busdma is then given a chance to do any final processing
in the complete() callback.

The cam changes unify the bus_dmamap_load* handling in cam drivers.

The arm and mips implementations are updated to track virtual
addresses for sync(). Previously this was done in a type specific
way. Now it is done in a generic way by recording the list of
virtuals in the map.

Submitted by: jeff (sponsored by EMC/Isilon)
Reviewed by: kan (previous version), scottl,
mjacob (isp(4), no objections for target mode changes)
Discussed with: ian (arm changes)
Tested by: marius (sparc64), mips (jmallet), isci(4) on x86 (jharris),
amd64 (Fabian Keil <freebsd-listen@fabiankeil.de>)


246146 31-Jan-2013 smh

Format CDB output as 2 digit hex correcting the length

Approved by: pjd (mentor)
MFC after: 1 week


245891 24-Jan-2013 jh

Sanitize the element descriptor string before using it as a device name.

Reported and tested by: Vitalij Satanivskij
Reviewed by: gibbs, mav


245647 19-Jan-2013 kan

Do not pretend to have autosense data when no such data is available.

Make umass return an error code if SCSI sense retrieval request
has failed. Make sure scsi_error_action honors SF_NO_RETRY and
SF_NO_RECOVERY in all cases, even if it cannot parse sense bytes.

Reviewed by: hselasky (umass), scottl (cam)


245310 11-Jan-2013 mav

- Add missig xpt_schedule() call for cases when requested immediate CCB
priority is lower then payload/TUR one.

- Reduce TUR priority and avoid sending them if there are any other
outstanding commands, alike to DA driver.


245306 11-Jan-2013 mav

Do not schedule periph for payload/TUR requests if reprobe is in progress
to avoid sending extra READ CAPACITY requests by dastart(). Schedule periph
again on reprobe completion, or otherwise it may stuck indefinitely long.

This should fix USB explore thread hanging on device unplug, waiting for
periph destruction.

Reported by: hselasky


245253 10-Jan-2013 smh

Changed scsi_da device requests to use the sysctl tunable value for retry_count
and da_default_timeout where their current hardcoded values matched the current
default value for said tunables.

PR: kern/169976
Reviewed by: pjd (mentor)
Approved by: mav


245252 10-Jan-2013 smh

Updates delete_method sysctl changes to always maintain disk d_flags
DISKFLAG_CANDELETE. While this change makes this layer consistent
other layers such as UFS and ZFS BIO_DELETE support may not notice
any change made manually via these device sysctls until the device
is reopened via a mount.

Also corrected var order in dadeletemethodsysctl

PR: kern/169801
Reviewed by: pjd (mentor)
Approved by: mav
MFC after: 2 weeks


245251 10-Jan-2013 smh

Removes essentially unused variables from scsi_da probe setups

PR: kern/169835
Reviewed by: pjd (mentor)
Approved by: mav
MFC after: 2 weeks


245228 09-Jan-2013 ken

Make CTL work a little better with loading and unloading drivers.

Previously CTL would leave individual LUNs enabled in the target
driver, whether or not the port as a whole was enabled. It would
also leave the wildcard LUN enabled indefinitely.

This change means that CTL will enable and disable any active LUNs,
as well as the wildcard LUN, when enabling and disabling a port.

Also, fix a bug that could crop up due to an uninitialized CCB
type.

ctl.c: Before calling ctl_frontend_online(), run through
the LUN list and enable all active LUNs.

After calling ctl_frontend_offline(), run through
the LUN list and disble all active LUNs.

scsi_ctl.c: Before bringing a port online, allocate the
wildcard peripheral for that bus. And after taking
a port offline, invalidate the wildcard peripheral
for that bus.

Make sure that we hold the SIM lock around all
calls to xpt_action() and other transport layer
interfaces that require it.

Use CAM_SIM_{LOCK|UNLOCK} consistently to acquire
and release the SIM lock.

Update a number of outdated comments. Some of
these should have been fixed long ago.

Actually do LUN disbables now. The newer drivers
in the tree work correctly for this as far as I
know.

Initialize the CCB type to CTLFE_CCB_DEFAULT to
avoid a panic due to uninitialized memory.

Submitted by: Chuck Tuffli (partially)
MFC after: 1 week


244508 20-Dec-2012 mav

Make SES driver to not fall out on some errors in Additional Status page.
This allows CAM devices still get their physical paths even if status of
later elements it corrupted.

Sponsored by: iXsystems, Inc.


244418 19-Dec-2012 mav

Fix bug in r242720, that caused additional status page to not be used if
descriptor page is supported.


244052 09-Dec-2012 ken

Fix a couple of CTL locking issues and clean up some duplicated code.

ctl_frontend_cam_sim.c: Coalesce cfcs_online() and cfcs_offline()
into a single function since these were
identical except for one line.

Make sure we hold the SIM lock around path
creation, and calling xpt_rescan().

scsi_ctl.c: In ctlfe_onoffline(), make sure we hold the
SIM lock around path creation and free
calls, as well as xpt_action().

In ctlfe_lun_enable(), hold the SIM lock
around path and peripheral operations that
require it.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244016 08-Dec-2012 ken

Make sure we hold the SIM lock when calling xpt_free_path().

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244015 08-Dec-2012 ken

Fix the CTL OOA queue dumping code so that it does not hold a mutex
while doing a copyout. That can cause a panic, because copyout
can trigger VM faults, and we can't handle VM faults while holding
a mutex.

The solution here is to malloc a separate buffer to hold the OOA
queue entries, so that we don't risk a VM fault while filling up
the buffer and we don't have to drop the lock. The other solution
would be to wire the user's memory while filling their buffer with
copyout, but that would have been a little more complex.

Also fix a debugging parenthesis issue in ctl_abort_task() pointed
out by Chuck Tuffli.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244014 08-Dec-2012 ken

Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4)
drivers.

The bug occurrs when a userland process has the driver instance
open and the underlying device goes away. We get the devfs
callback that the device node has been destroyed, but not all of
the closes necessary to fully decrement the reference count on the
CAM peripheral.

The reason is that once devfs calls back and says the device has
been destroyed, it is moved off to deadfs, and devfs guarantees
that there will be no more open or close calls. So the solution
is to keep track of how many outstanding open calls there are on
the device, and just release that many references when we get the
callback from devfs.

scsi_pass.c,
scsi_enc.c,
scsi_enc_internal.h: Add an open count to the softc in these
drivers. Increment it on open and
decrement it on close.

When we get a devfs callback to say that
the device node has gone away, decrement
the peripheral reference count by the
number of still outstanding opens.

Make sure we don't access the peripheral
with cam_periph_unlock() after what might
be the final call to
cam_periph_release_locked(). The
peripheral might have been freed, and we
will be dereferencing freed memory.

scsi_ch.c,
scsi_sg.c: For the ch(4) and sg(4) drivers, add the
same changes described above, and in
addition, fix another bug that was
previously fixed in the pass(4) and enc(4)
drivers.

These drivers were calling destroy_dev()
from their cleanup routine, but that could
cause a deadlock because the cleanup
routine could be indirectly called from
the driver's close routine. This would
cause a deadlock, because the device node
is being held open by the active close
call, and can't be destroyed.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


244001 07-Dec-2012 ken

Fix a panic during CAM EDT traversal.

The problem was a race condition between the EDT traversal used by
things like 'camcontrol devlist', and CAM peripheral driver
removal.

The EDT traversal code holds the CAM topology lock, and wants
to show devices that have been invalidated. It acquires a
reference to the peripheral to make sure the peripheral it is
examining doesn't go away.

However, because the peripheral removal code in camperiphfree()
drops the CAM topology lock to call the peripheral's destructor
routine, we can run into a situation where the EDT traversal
increments the peripheral reference count after free process is
already in progress. At that point, the reference count is
ignored, because it was 0 when we started the process.

Fix this race by setting a flag, CAM_PERIPH_FREE, that I previously
added and checked in xptperiphtraverse() and xptpdperiphtravsere(),
but failed to use. If the EDT traversal code sees that flag,
it will know that the peripheral free process has already started,
and that it should not access that peripheral.

Also, fix an inconsistency in the locking between
xptpdperiphtraverse() and xptperiphtraverse(). They now both
hold the CAM topology lock while calling the peripheral traversal
function.

cam_xpt.c: Change xptperiphtraverse() to hold the CAM topology
lock across calls to the traversal function.

Take out the comment in xptpdperiphtraverse() that
referenced the locking inconsistency.

cam_periph.c: Set the CAM_PERIPH_FREE flag when we are in the
process of freeing a peripheral driver.

Sponsored by: Spectra Logic Corporation
MFC after: 1 week


243571 26-Nov-2012 mav

Fix problem with the Samsung 840 PRO series SSD detection.
The device reports support for SATA Asynchronous Notification in its
IDENTIFY data, but returns error on attempt to enable that feature.
Make SATA XPT of CAM only report these errors, but not fail the device.

MFC after: 1 week


242720 07-Nov-2012 mav

Use information about suported diagnostic pages to avoid reading optional
Element Descriptor page if it is not supported. This removes one error
message from verbose logs during boot on systems with some enclosures.

Sponsored by: iXsystems, Inc.


242358 30-Oct-2012 trasz

Use M_ZERO instead of explicit memsets and bzeros.


242322 29-Oct-2012 trasz

Fix locking problem in disk_resize(); previously it would run without
topology lock, resulting in assertion when running with DIAGNOSTIC.

Reviewed by: mav (earlier version)


242175 27-Oct-2012 mav

Remove priority enforcement from xpt_ation(). It is not good and even not
safe in some cases to reduce CCB priority after it was scheduled with high
priority. This fixes reproducible deadlock when command sent through the
pass interface while ATA XPT recovers from command timeout.

Instead of that enforce priority at passioctl(). libcam provides no obvious
interface to specify CCB priority and so much (all?) code specifies zero
(highest) priority. This change limits pass CCBs priority to NORMAL run
level, allowing XPT to complete bus and device recovery after reset before
running any payload.


242174 27-Oct-2012 mav

Remove several uses of numeric priorities from immediate CCB setups.


242173 27-Oct-2012 mav

Remove one more numeric priority constant.


241952 23-Oct-2012 mav

Remove two more 'periph == NULL' checks missed in r241404.
This condition can never be true as functions are called from single place
and the checks just pollute the code and confuse Clang Static Analyzer.


241896 22-Oct-2012 kib

Remove the support for using non-mpsafe filesystem modules.

In particular, do not lock Giant conditionally when calling into the
filesystem module, remove the VFS_LOCK_GIANT() and related
macros. Stop handling buffers belonging to non-mpsafe filesystems.

The VFS_VERSION is bumped to indicate the interface change which does
not result in the interface signatures changes.

Conducted and reviewed by: attilio
Tested by: pho


241844 22-Oct-2012 eadler

remove duplicate semicolons where possible.

Approved by: cperciva
MFC after: 1 week


241784 20-Oct-2012 eadler

Adds 4K quirks for the some SSD's which all perform better when 4K
aligned and only except 4K deletes (TRIM).

PR: kern/169974
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Tested by: ak
Reviewed by: mav
Approved by: cperciva (implicit)
MFC after: 1 week


241613 16-Oct-2012 eadler

Add support for samsung HM250JI

PR: usb/121474
Submitted by: Ben Stuyts <ben@altesco.nl>
Approved by: cperciva (implicit)
MFC after: 3 days


241580 15-Oct-2012 eadler

Add support for the USB DISK Pro PMAP.

This patch has sit for 6 years in the PR database.

PR: usb/96381
Submitted by: jhs
Reviewed by: mav
Approved by: cperciva (implicit)
MFC after: 3 days


241536 14-Oct-2012 mav

Add explicit check for not set time inside cam_periph_freeze_after_event().

System time is set later on boot process then initial bus scan by CAM.
Until that moment microtime() is equal to microuptime(), and if system
boots quickly, the value can be close to zero. That causes settle time
waiting even for buses that don't use reset during probe.

On my test system this reduces boot time by 1 second if USB enabled, or
by 4 seconds if USB disabled. CAM waited for ctl2cam0 bus "settle".


241510 13-Oct-2012 mav

Don't exclude XPT SIM from locking in xpt_create_path_unlocked().
We don't want xpt periph, device, target or bus disappeared because of
incorrect reference counting.


241509 13-Oct-2012 mav

Use xpt_create_path_unlocked() for initial debug path compilation because
we are not holding respective SIM lock.


241508 13-Oct-2012 mav

Extend SIM lock coverage during the bus registration process.


241504 13-Oct-2012 mav

Fix XPT_DEBUG paths operations locking:
- Extend the lock to cover xpt_path_release() for the new path.
- While xpt_action() is called while holding right SIM lock for the new
bus, the old path release may require different SIM lock. So we have
to temporary drop the new lock and get the old one.


241503 13-Oct-2012 mav

XPT_DEV_MATCH is probably the only xpt_action() method that is called
without holding SIM lock. It really doesn't need that lock, but adding it
removes that specific exception, allowing to assert locking there later.

Submitted by: ken@ (earlier version)


241488 12-Oct-2012 mav

Get SIM lock in several places while calling CAM functions.
This fixes several use-after-free panics on systems with SAS enclosures.

Submitted by: ken@, mav@


241485 12-Oct-2012 mav

Protect xpt_getattr() calls with the SIM lock and assert that.

Submitted by: ken@ (earlier version)


241456 11-Oct-2012 mav

Use separate malloc buckets for CAM devices, CCBs and paths. This will
make it easier to track down the source of any use after free problems.

Submitted by: ken@


241455 11-Oct-2012 mav

Don't duplicate path/ccb allocation code, use existing functions.


241444 11-Oct-2012 mav

Increase device CCB queue array size by CAM_RL_VALUES - 1 (4) elements.
It is required to store extra recovery requests in case of bus resets.
On ATA/SATA this fixes assertion panics on HEAD with INVARIANTS enabled or
possible memory corruptions otherwise if timeout/reset happens when device
CCB queue is already full.

Reported by: gibbs@
MFC after: 1 week


241410 10-Oct-2012 mav

There are SCSI conditions that are not an errors. In those cases cderror()
returns zero while request status is not CAM_REQ_CMP. That could cause
partial device attach or other unexpected results.

Found by: Clang Static Analyzer


241405 10-Oct-2012 mav

Really handle xpt_compile_path() error in xpt_bus_register() instead of
print error message and probably crash just after it on NULL dereference.

Found by: Clang Static Analyzer


241404 10-Oct-2012 mav

Remove 'periph == NULL' check from bunch of periph drivers.
This condition can never be true as functions are called from single place
and the checks just pollute the code and confuse Clang Static Analyzer.


241305 06-Oct-2012 avg

ata_da: set disk::d_ident from serial number

MFC after: 10 days


241028 28-Sep-2012 mav

Change queue overflow checks from DIAGNOSTIC+panic() to KASSERT() to make
them enabled on HEAD by default. It is probably better to do single compare
then hunt for unexpected memory corruption.


240993 27-Sep-2012 trasz

Remove useless NULL checks after M_WAITOK allocations.


240948 26-Sep-2012 trasz

Fix panic in CTL caused by trying to free invalid pointers passed
by the userland process via the IOCTL interface.

Reviewed by: ken@


240701 19-Sep-2012 tijl

Fix a panic when trying to play invalid audio tracks.


240521 14-Sep-2012 eadler

s/ is is / is /g
s/ a a / a /g

Approved by: cperciva
MFC after: 3 days


240325 10-Sep-2012 jhb

Remove some more NetBSD compat shims and other unused bits from these
drivers:
- Remove scsi_low_pisa.*, they were unused.
- Remove <compat/netbsd/physio_proc.h> and calls to the stubs in that
header. They were empty nops.
- Retire sl_xname and use device_get_nameunit() and device_printf() with
the underlying device_t instead.
- Remove unused {ct,ncv,nsp,stg}print() functions.
- Remove empty SOFT_INTR_REQUIRED() macro and the unused sl_irq member.


240172 06-Sep-2012 jhb

Remove NetBSD compat shims for drivers originally shared with NetBSD/pc98.
NetBSD/pc98 was never merged into the main NetBSD tree and is no longer
developed. Adding locking to these drivers would have made the compat
shims hard to impossible to maintain, so remove the shims to ease
future changes.

These changes were verified by md5. Some additional shims can be removed
that do affect the compiled results that I will probably do in another
round.

Approved by: nyan (tentatively)


239655 24-Aug-2012 jimharris

Fix scsi_da's BIO_DELETE->SCSI_UNMAP translation to use correct local
variable when determining various sizes related to SCSI UNMAP block
descriptor lists.

Sponsored by: Intel
Reviewed by: mav
MFC after: 3 days


239213 12-Aug-2012 mjacob

1. Remove SEN support. I doubt there are any working examples
of this hardware still running (close to twenty years now).

2. Quiesece and use ENC_VLOG instead of ENC_LOG for most
complaints. That is, they're visible with bootverbose, but
otherwise quiesced and not repeatedly spamming messages
with constant reminders that hardware in this space is
rarely fully compliant.

MFC after: 1 month


239212 12-Aug-2012 mjacob

Add missing VERIFY_10 definition.

MFC after: 1 month


238894 30-Jul-2012 bz

Remove opt_enc.h from files committed with r235911. enc(4) is the
'encapsulating interface' used with IPsec and has nothing to do with
storage 'enclosure' services.

MFC after: 3 days
Noticed while: debugging why enc(4) is no longer automatically created


238886 29-Jul-2012 mav

Implement media change notification for DA and CD removable media devices.
It includes three parts:
1) Modifications to CAM to detect media media changes and report them to
disk(9) layer. For modern SATA (and potentially UAS) devices it utilizes
Asynchronous Notification mechanism to receive events from hardware.
Active polling with TEST UNIT READY commands with 3 seconds period is used
for incapable hardware. After that both CD and DA drivers work the same way,
detecting two conditions: "NOT READY: Medium not present" after medium was
detected previously, and "UNIT ATTENTION: Not ready to ready change, medium
may have changed". First one reported to disk(9) as media removal, second
as media insert/change. To reliably receive second event new
AC_UNIT_ATTENTION async added to make UAs broadcasted to all periphs by
generic error handling code in cam_periph_error().
2) Modifications to GEOM core to handle media remove and change events.
Media removal handled by spoiling all consumers attached to the provider.
Media change event also schedules provider retaste after spoiling to probe
new media. New flag G_CF_ORPHAN was added to consumers to reflect that
consumer is in process of destruction. It allows retaste to create new
geom instance of the same class, while previous one is still dying.
3) Modifications to some GEOM classes: DEV -- to report media change
events to devd; VFS -- to handle spoiling same as orphan to prevent
accessing replaced media. PART class already handles spoiling alike to
orphan.

Reviewed by: silence on geom@ and scsi@
Tested by: avg
Sponsored by: iXsystems, Inc. / PC-BSD
MFC after: 2 months


238870 28-Jul-2012 mjacob

Handle a case where we had an SRR that pushed back the
data pointer. This is a temp fix that resubmits the
command, adjusted, so that the backend can fetch the
data again.

Sponsored by: Spectralogic
MFC after: 1 month


238740 24-Jul-2012 mav

Fix off by one error in ses_enc_desc_last_byte().


238739 24-Jul-2012 mav

Do not call ses_softc_cleanup() in case of configuration read failure.
Just free inclomplete daemon cache instead to let it retry next time.
Premature ses_softc_cleanup() caused NULL dereference when freed softc
was accessed later.


238596 18-Jul-2012 mav

Fix some typos in r238595.

Reported by: brueffer


238595 18-Jul-2012 mav

Add bunch of new ASC/ASCQ values from T10 site.


238437 14-Jul-2012 mjacob

The call to disk_resize causes a panic if DIAGNOSTIC is set.
Coping with that while the finest minds of our generation
figure out why.


238393 12-Jul-2012 brueffer

Add and utilize defines for the ATA device register.

PR: 169764
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: mav
MFC after: 2 weeks


238382 11-Jul-2012 brueffer

Apply similar same change as in r238379:

Renamed the kern.cam.ada.ada_send_ordered sysctl and tunable to
kern.cam.ada.send_ordered, more in line with the other da sysctls/tunables.

Suggested by: kib


238379 11-Jul-2012 brueffer

Renamed the kern.cam.da.da_send_ordered sysctl and tunable to
kern.cam.da.send_ordered, more in line with the other da sysctls/tunables.

PR: 169765
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: mav


238363 11-Jul-2012 brueffer

- fix description of SECURITY_FREEZE_LOCK (1)
- add missing underscores to SECURITY_DISABLE_PASSWORD

PR: 169763 (1)
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
Reviewed by: mav
MFC after: 1 week


238217 07-Jul-2012 trasz

Make the da(4) driver notify GEOM about LUN size change.

Reviewed by: mav
Sponsored by: FreeBSD Foundation


238200 07-Jul-2012 eadler

Remove variables which are initialized but never used thereafter
reported by gcc46 warning

Reviewed by: scottl
Approved by: cperciva
MFC after: 1 week


237726 28-Jun-2012 ken

Add a loader tunable, kern.cam.ctl.disable, that will disable
loading CTL. This may be useful in very low memory installations.

MFC after: 3 days


237689 28-Jun-2012 imp

Add a sysctl to set the cdrom timeout. Data recovery operations from
a CD or DVD drive with a damaged disc often benefit from a shorter
timeout. Also, when retries are set to 0, an application is expecting
errors and recovering them so do not print the error into the log.
The number of expected errors can literally be in the hundreds of
thousands which significantly slows data recovery.

Reviewed by: ken@ (but quite some time ago).


237682 28-Jun-2012 ken

Fix a typo in a panic() call.

PR: kern/169497
Submitted by: Steven Hartland <steven.hartland@multiplay.co.uk>
MFC after: 3 days


237601 26-Jun-2012 ken

Fix an issue that caused the kernel to panic inside CTL when trying
to attach to target capable HBAs that implement the old immediate
notify (XPT_IMMED_NOTIFY) and notify acknowledge (XPT_NOTIFY_ACK)
CCBs. The new API has been in place since SVN change 196008 in
2009.

The solution is two-fold: fix CTL to handle the responses from the
HBAs, and convert the HBA drivers in question to use the new API.

These drivers have not been tested with CTL, so how well they will
interoperate with CTL is unknown.

scsi_target.c: Update the userland target example code to use the
new immediate notify API.

scsi_ctl.c: Detect when an immediate notify CCB is returned
with CAM_REQ_INVALID or CAM_PROVIDE_FAIL status,
and just free it.

Fix a duplicate assignment.

aic79xx.c,
aic79xx_osm.c: Update the aic79xx driver to use the new API.
Target mode is not enabled on for this driver, so
the changes will have no practical effect.

aic7xxx.c,
aic7xxx_osm.c: Update the aic7xxx driver to use the new API.

sbp_targ.c: Update the firewire target code to work with the
new API.

mpt_cam.c: Update the mpt(4) driver to work with the new API.
Target mode is only enabled for Fibre Channel
mpt(4) devices.

MFC after: 3 days


237518 24-Jun-2012 ken

Fix a bug which causes a panic in daopen(). The panic is caused by
a da(4) instance going away while GEOM is still probing it.

In this case, the GEOM disk class instance has been created by
disk_create(), and the taste of the disk is queued in the GEOM
event queue.

While that event is queued, the da(4) instance goes away. When the
open call comes into the da(4) driver, it dereferences the freed
(but non-NULL) peripheral pointer provided by GEOM, which results
in a panic.

The solution is to add a callback to the GEOM disk code that is
called when all of its resources are cleaned up. This is
implemented inside GEOM by adding an optional callback that is
called when all consumers have detached from a provider, and the
provider is about to be deleted.

scsi_cd.c,
scsi_da.c: In the register routine for the cd(4) and da(4)
routines, acquire a reference to the CAM peripheral
instance just before we call disk_create().

Use the new GEOM disk d_gone() callback to register
a callback (dadiskgonecb()/cddiskgonecb()) that
decrements the peripheral reference count once GEOM
has finished cleaning up its resources.

In the cd(4) driver, clean up open and close
behavior slightly. GEOM makes sure we only get one
open() and one close call, so there is no need to
set an open flag and decrement the reference count
if we are not the first open.

In the cd(4) driver, use cam_periph_release_locked()
in a couple of error scenarios to avoid extra mutex
calls.

geom.h: Add a new, optional, providergone callback that
is called when a provider is about to be deleted.

geom_disk.h: Add a new d_gone() callback to the GEOM disk
interface.

Bump the DISK_VERSION to version 2. This probably
should have been done after a couple of previous
changes, especially the addition of the d_getattr()
callback.

geom_disk.c: Add a providergone callback for the disk class,
g_disk_providergone(), that calls the user's
d_gone() callback if it exists.

Bump the DISK_VERSION to 2.

geom_subr.c: In g_destroy_provider(), call the providergone
callback if it has been provided.

In g_new_geomf(), propagate the class's
providergone callback to the new geom instance.

blkfront.c: Callers of disk_create() are supposed to pass in
DISK_VERSION, not an explicit disk API version
number. Update the blkfront driver to do that.

disk.9: Update the disk(9) man page to include information
on the new d_gone() callback, as well as the
previously added d_getattr() callback, d_descr
field, and HBA PCI ID fields.

MFC after: 5 days


237478 23-Jun-2012 mav

Add scsi_extract_sense_ccb() -- wrapper around scsi_extract_sense_len().
It allows to remove number of duplicate checks from several places.


237452 22-Jun-2012 ken

Change 'camcontrol defects' to first probe a drive to find out how much
defect information it has before grabbing the full defect list.

This works around a bug with some Hitachi drives that generate data overrun
errors when they are asked for more defect data than they have.

The change is done in a spec-compliant way, so it should have no negative
impact on drives that don't have this issue.

This is based on work originally done at Sandvine.

scsi_da.h: Add a define for the maximum amount of data that can be
contained in a defect list.

camcontrol.c: Update the readdefects() function to issue an initial
command to determine the length of the defect list, and
then use that length in the request for the full defect
list.

camcontrol.8: Add a note that some drives will report 0 defects available
if you don't request either the PLIST or GLIST.

Submitted by: Mark Johnston <markjdb@gmail.com> (original version)
MFC after: 3 days


237446 22-Jun-2012 mav

Don't print SCSI Queue Full and CAM_REQUEUE_REQ statuses as errors if they
were handled and retried. They are part of normal operation for SCSI TCQ.

MFC after: 3 days


237401 21-Jun-2012 mav

Make cam_periph_hold() behavior consistent: drop taken reference and
return ENXIO if periph was invalidated while we were waiting for it.

MFC after: 1 week


237398 21-Jun-2012 mav

In camisr() clear CAM_SIM_ON_DONEQ flag after camisr_runqueue() purged SIM
done queue. Clearing it before caused extra SIM queueing in some cases.
It was invisible during normal operation, but during USB device unplug and
respective SIM destruction it could keep pointer on SIM without having
counted reference and as result crash the system by use afer free.

Reported by: hselasky
MFC after: 1 week


237336 20-Jun-2012 mav

Remove unused error variables in cdclose() and daclose().


237335 20-Jun-2012 mav

Check status of cam_periph_hold() inside cdclose(). If cd device was
invalidated while open, cam_periph_hold() will return error and won't
get the reference. Following reference release will crash the system.

Sponsored by: iXsystems, Inc.
MFC after: 3 days


237328 20-Jun-2012 ken

Fix several reference counting and object lifetime issues between
the pass(4) and enc(4) drivers and devfs.

The pass(4) driver uses the destroy_dev_sched() routine to
schedule its device node for destruction in a separate thread
context. It does this because the passcleanup() routine can get
called indirectly from the passclose() routine, and that would
cause a deadlock if the close routine tried to destroy its own
device node.

In any case, once a particular passthrough driver number, e.g.
pass3, is destroyed, CAM considers that unit number (3 in this
case) available for reuse.

The problem is that devfs may not be done cleaning up the previous
instance of pass3, and will panic if isn't done cleaning up the
previous instance.

The solution is to get a callback from devfs when the device node
is removed, and make sure we hold a reference to the peripheral
until that happens.

Testing exposed some other cases where we have reference counting
issues, and those were also fixed in the pass(4) driver.

cam_periph.c: In camperiphfree(), reorder some of the operations.

The peripheral destructor needs to be called before
the peripheral is removed from the peripheral is
removed from the list. This is because once we
remove the peripheral from the list, and drop the
topology lock, the peripheral number may be reused.
But if the destructor hasn't been called yet, there
may still be resources hanging around (like devfs
nodes) that haven't been fully cleaned up.

cam_xpt.c: Add an argument to xpt_remove_periph() to indicate
whether the topology lock is already held.

scsi_enc.c: Acquire an extra reference to the peripheral during
registration, and release it once we get a callback
from devfs indicating that the device node is gone.

Call destroy_dev_sched_cb() in enc_oninvalidate()
instead of calling destroy_dev() in the cleanup
routine.

scsi_pass.c: Add reference counting to handle peripheral and
devfs object lifetime issues.

Add a reference to the peripheral and the devfs
node in the peripheral registration.

Don't attempt to add a physical path alias if the
peripheral has been marked invalid.

Release the devfs reference once the initial
physical path alias taskqueue run has completed.

Schedule devfs node destruction in the
passoninvalidate(), and release our peripheral
reference in a new routine, passdevgonecb() once
the devfs node is gone. This allows the peripheral
to fully go away, and the peripheral destructor,
passcleanup(), will get called.

MFC after: 3 days
Sponsored by: Spectra Logic


237225 18-Jun-2012 mav

Remove never used CD/DA_FLAG_TAGGED_QUEUING flags.

MFC after: 1 week


236814 09-Jun-2012 mav

One more major cam_periph_error() rewrite to improve error handling and
reporting. It includes:
- removing of error messages controlled by bootverbose, replacing them
with more universal and informative debugging on CAM_DEBUG_INFO level,
that is now built into the kernel by default;
- more close following to the arguments submitted by caller, such as
SF_PRINT_ALWAYS, SF_QUIET_IR and SF_NO_PRINT; consumer knows better which
errors are usual/expected at this point and which are really informative;
- adding two new flags SF_NO_RECOVERY and SF_NO_RETRY to allow caller
specify how much assistance it needs at this point; previously consumers
controlled that by not calling cam_periph_error() at all, but that made
behavior inconsistent and debugging complicated;
- tuning debug messages and taken actions order to make debugging output
more readable and cause-effect relationships visible;
- making camperiphdone() (common device recovery completion handler) to
also use cam_periph_error() in most cases, instead of own dumb code;
- removing manual sense fetching code from cam_periph_error(); I was told
by number of people that it is SIM obligation to fetch sense data, so this
code is useless and only significantly complicates recovery logic;
- making ada, da and pass driver to use cam_periph_error() with new limited
recovery options to handle error recovery and debugging in common way;
as one of results, CAM_REQUEUE_REQ and other retrying statuses are now
working fine with pass driver, that caused many problems before.
- reverting r186891 by raj@ to avoid burning few seconds in tight DELAY()
loops on device probe, while device simply loads media; I think that problem
may already be fixed in other way, and even if it is not, solution must be
different.

Sponsored by: iXsystems, Inc.
MFC after: 2 weeks


236713 07-Jun-2012 mav

Add CAM_DEBUG_INFO debug messages for periph created/invalidated/destroyed
and for asyncs sent.


236712 07-Jun-2012 mav

To make CAM debugging easier, compile in some debug flags (CAM_DEBUG_INFO,
CAM_DEBUG_CDB, CAM_DEBUG_PERIPH and CAM_DEBUG_PROBE) by default.
List of these flags can be modified with CAM_DEBUG_COMPILE kernel option.
CAMDEBUG kernel option still enables all possible debug, if not overriden.

Additional 50KB of kernel size is a good price for the ability to debug
problems without rebuilding the kernel. In case where size is important,
debugging can be compiled out by setting CAM_DEBUG_COMPILE option to 0.


236691 06-Jun-2012 mav

Remove declaration of scsi_interpret_sense(), removed 11 years ago.


236689 06-Jun-2012 ken

Fix a memory leak in the kernel case in scsi_command_string().

Submitted by: Kashyap Desai <Kashyap.Desai@lsi.com>
MFC after: 3 days


236666 06-Jun-2012 mav

ATA/SATA controllers have no idea about protocol of the connected device
until transport will do some probe actions (at least soft reset).
Make ATA/SATA SIMs to not report bogus and confusing PROTO_ATA protocol.
Make ATA/SATA transport to fill that gap by reporting protocol to SIM with
XPT_SET_TRAN_SETTINGS and patching XPT_GET_TRAN_SETTINGS results if needed.


236639 05-Jun-2012 mav

Use default error handler when flushing disk caches.


236613 05-Jun-2012 mav

Tune and add some more CAM_DEBUG() points for the probe sequences.


236605 05-Jun-2012 mav

Replace #ifdef CAMDEBUG + if + panic() with single KASSERT().


236604 05-Jun-2012 mav

Do not reinvent a wheel and let default error handler do its job.


236602 05-Jun-2012 mav

Tune and add some missing CAM_DEBUG() points for better consistency.


236552 04-Jun-2012 mav

Remove some dead code that I doubt will ever be implemented.


236437 02-Jun-2012 mav

Rewrite enabling NCQ for SATA devices in a way more alike to SCSI TCQ.
This allows to control it with `camcontrol negotiate adaX -T (en|dis)able`
on the fly, same as for SCSI devices.

Sponsored by: iXsystems, Inc.


236426 01-Jun-2012 mjacob

Print FC PortID as a hex number. This makes it easy to
figure out domain, etc..

Zero ATIO and INOTify allocations. It makes for much
less guesswork when looking at the structure and
seeing 'deadc0de' present.

Reviewed by: kdm
MFC after: 2 weeks
Sponsored by: Spectralogic


236393 01-Jun-2012 mav

Use AC_GETDEV_CHANGED async to notify ada driver about DMA and NCQ status
change. Now that allows switching between PIO and DMA modes on the fly.


236283 30-May-2012 eadler

Add support for newer garmin devices

PR: kern/163932
Submitted by: Bartosz Fabianowski <freebsd@chillt.de>
Approved by: cperciva
MFC after: 1 week


236234 29-May-2012 mav

Allow to change number of openings (used tags) for ATA/SATA devices
via `camcontrol tags ... -N ...`. There is no need to tune it in
usual cases, but some users want to have it for debugging purposes.

MFC after: 2 weeks


236228 29-May-2012 mav

Plug request and references leak caused by race between invalidated
ond probe periph destruction and new incoming probe request.

This at least caused problems with SATA Port Multipliers hot-plug.

MFC after: 2 weeks


236138 27-May-2012 ken

Work around a race condition in devfs by changing the way closes
are handled in most CAM peripheral drivers that are not handled by
GEOM's disk class.

The usual character driver open and close semantics are that the
driver gets N open calls, but only one close, when the last caller
closes the device.

CAM peripheral drivers expect that behavior to be honored to the
letter, and the CAM peripheral driver code (specifically
cam_periph_release_locked_busses()) panics if it is done incorrectly.

Since devfs has to drop its locks while it calls a driver's close
routine, and it does not have a way to delay or prevent open calls
while it is calling the close routine, there is a race.

The sequence of events, simplified a bit, is:

- devfs acquires a lock
- devfs checks the reference count, and if it is 1, continues to close.
- devfs releases the lock

- 2nd process open call on the device happens here

- devfs calls the driver's close routine

- devfs acquires a lock
- devfs decrements the reference count
- devfs releases the lock

- 2nd process close call on the device happens here

At the second close, we get a panic in
cam_periph_release_locked_busses(), complaining that peripheral
has been released when the reference count is already 0. This is
because we have gotten two closes in a row, which should not
happen.

The fix is to add the D_TRACKCLOSE flag to the driver's cdevsw, so
that we get a close() call for each open(). That does happen
reliably, so we can make sure that our reference counts are
correct.

Note that the sa(4) and pt(4) drivers only allow one context
through the open routine. So these drivers aren't exposed to the
same race condition.

scsi_ch.c,
scsi_enc.c,
scsi_enc_internal.h,
scsi_pass.c,
scsi_sg.c:
For these drivers, change the open() routine to
increment the reference count for every open, and
just decrement the reference count in the close.

Call cam_periph_release_locked() in some scenarios
to avoid additional lock and unlock calls.

scsi_pt.c: Call cam_periph_release_locked() in some scenarios
to avoid additional lock and unlock calls.

MFC after: 3 days


235982 25-May-2012 mav

Add tunable/sysctl kern.cam.pmp.hide_special, controlling whether special
PMP ports such as PMP configuration or SEMB should be exposed or hidden.
These ports were always hidden before as useless and sometimes promatic.
But with updated ses driver supporting SEMB it is no longer so straight.
Keep ports hidden by default to avoid probe request ttimeouts if SEP is
not connected to PMP's SEMB via I2C, that is very often situation.


235980 25-May-2012 mav

Remove sleep() from invalidate call in ses driver, waiting for daemon
process exit. Instead use CAM's standard reference counting to prevent
periph going away until process won't complete. I think that sleep in
single CAM SWI thread is not a good idea and may lead to deadlocks if
daemon process waits for some command completion. Combined with recent
patch avoiding use of CAM SWI for ATA it just causes panics because of
sleeps prohibited in interrupt thread context.


235911 24-May-2012 mav

MFprojects/zfsd:
Revamp the CAM enclosure services driver.
This updated driver uses an in-kernel daemon to track state changes and
publishes physical path location information\for disk elements into the
CAM device database.

Sponsored by: Spectra Logic Corporation
Sponsored by: iXsystems, Inc.
Submitted by: gibbs, will, mav


235897 24-May-2012 mav

MFprojects/zfsd:
- Add low-level support for SATA Enclosure Management Bridge (SEMB)
devices -- SATA equivalents of the SCSI SES/SAF-TE devices.
- Add some utility functions for SCSI SAF-TE devices access.

Sponsored by: iXsystems, Inc.


235333 12-May-2012 mav

Add two functions xpt_batch_start() and xpt_batch_done() to the CAM SIM KPI
to allow drivers to handle request completion directly without passing
them to the CAM SWI thread removing extra context switch.
Modify all ATA/SATA drivers to use them.

Reviewed by: gibbs, ken
MFC after: 2 weeks


234821 29-Apr-2012 eadler

Add support for:
Olympus FE-210 camera
LG UP3S MP3 player
Laser MP3-2GA13 MP3

PR: usb/119201
Submitted by: Peter Jeremy <peterjeremy@optushome.com.au>
Approved by: cperciva
MFC after: 1 week


234414 18-Apr-2012 mav

Alike to SCSI make adaclose() to not return error if device gone.
This fixes KASSERT panic inside GEOM if kernel built with INVARIANTS.

MFC after: 1 week


234374 17-Apr-2012 trasz

Fix panic at boot with SD/MMC readers with no media present, introduced
at r234177. Note that this is a temporary fix, until I come up with something
prettier.


234177 12-Apr-2012 trasz

Refactor da(4) to remove one of two code paths used to query capacity
data.

Reviewed by: ken, mav (earlier version)
Sponsored by: The FreeBSD Foundation


233963 06-Apr-2012 ken

Change the SCSI INQUIRY peripheral qualifier that CTL reports for LUNs
that don't exist.

Anecdotal evidence indicates that it is better to return 011b (bad LUN)
than 001b (LUN offline). However, this change also gives the user a
sysctl/tunable, kern.cam.ctl.inquiry_pq_no_lun, to override the change
and return to the previous behavior. (The previous behavior was to
return 001b, or LUN offline.)

ctl.c: Change the default inquiry peripheral qualifier to 011b,
and add a sysctl and tunable to allow the user to change
it back to 001b if needed.

Don't insert a Copan copyright statement in the inquiry
data. The copyright statements on the files are
sufficient.

ctl_private.h: Add sysctl variable context to the CTL softc.

ctl_cmd_table.c,
ctl_frontend_internal.c,
ctl_frontend.c,
ctl_backend.c,
ctl_error.c: Include sys/sysctl.h.

MFC after: 3 days


233746 31-Mar-2012 mav

Be more conservative in using READ CAPACITY(16) command. Previous code
checked PROTECT bit in INQUIRY data for all SPC devices, while it is defined
only since SPC-3. But there are some SPC-2 USB devices were reported, that
have PROTECT bit set, return no error for READ CAPACITY(16) command, but
return wrong sector count value in response.

MFC after: 3 days


232604 06-Mar-2012 trasz

Add LUN resizing to CTL. Also make it possible to explicitly set
size when creating file-backed or device-backed LUN.

Reviewed by: ken (earlier version)
Sponsored by: The FreeBSD Foundation


232074 23-Feb-2012 dim

Use a better way to silence unneeded internal declaration warnings in
several sys/cam/ctl files.

Suggested by: ed
Reviewed by: ken
MFC after: 1 week


231745 15-Feb-2012 gibbs

Limit the ST3146855LW U320 drive to 55 tags to avoid command timeouts
under load.

Submitted by: Gelson Borsoi
MFC after: 1 day


231092 06-Feb-2012 emaste

Avoid panic from unlocking a not locked mutex (in some error cases).

Reviewed by: ken@


230921 02-Feb-2012 mav

Insert ordered command every 1/4 of the current command timeout, not 1/4
of the default one.

Without this change setting kern.cam.ada.default_timeout to 1 instead of 30
allowed me to trigger several false positive command timeouts under heavy
ZFS load on a SiI3132 siis(4) controller with 5 HDDs on a port multiplier.

MFC after: 1 week


230912 02-Feb-2012 mav

Make CAM ATA honor old hw.ata.ata_dma and hw.ata.atapi_dma tunables.

Even having more specific hint.ata.X.mode controls, global ones are
still could be useful from some points, including compatibility.

PR: kern/164651
MFC after: 1 week


230590 26-Jan-2012 ken

Add CAM infrastructure to allow reporting when a drive's long read capacity
data changes.

cam_ccb.h: Add a new advanced information type, CDAI_TYPE_RCAPLONG,
for long read capacity data.

cam_xpt_internal.h:
Add a read capacity data pointer and length to struct cam_ed.

cam_xpt.c: Free the read capacity buffer when a device goes away.
While we're here, make sure we don't leak memory for other
malloced fields in struct cam_ed.

scsi_all.c: Update the scsi_read_capacity_16() to take a uint8_t * and
a length instead of just a pointer to the parameter data
structure. This will hopefully make this function somewhat
immune to future changes in the parameter data.

scsi_all.h: Add some extra bit definitions to struct
scsi_read_capacity_data_long, and bump up the structure
size to the full size specified by SBC-3.

Change the prototype for scsi_read_capacity_16().

scsi_da.c: Register changes in read capacity data with the transport
layer. This allows the transport layer to send out an
async notification to interested parties. Update the
dasetgeom() API.

Use scsi_extract_sense_len() instead of
scsi_extract_sense().

scsi_xpt.c: Add support for the new CDAI_TYPE_RCAPLONG advanced
information type.

Make sure we set the physpath pointer to NULL after freeing
it. This allows blindly freeing it in the struct cam_ed
destructor.

sys/param.h: Bump __FreeBSD_version from 1000005 to 1000006 to make it
easier for third party drivers to determine that the read
capacity data async notification is available.

camcontrol.c,
mptutil/mpt_cam.c:
Update these for the new scsi_read_capacity_16() argument
structure.

Sponsored by: Spectra Logic


230544 25-Jan-2012 ken

Fix a bug introduced in r230000. We were eliminating all LUNs on a target
in response to CAM_DEV_NOT_THERE, instead of just the LUN in question.

This will now just eliminate the specified LUN in response to
CAM_DEV_NOT_THERE.

Reported by: Richard Todd <rmtodd@servalan.servalan.com>
MFC after: 3 days


230334 19-Jan-2012 ken

Quiet some clang warnings when compiling CTL.

ctl_error.c,
ctl_error.h: Take out the ctl_sense_format enumeration, and use
scsi_sense_data_type instead.

Remove ctl_get_sense_format() and switch ctl_build_ua()
over to using scsi_sense_data_type.

ctl_backend_ramdisk.c,
ctl_backend_block.c:
Use C99 structure initializers instead of GNU initializers.

ctl.c: Switch over to using the SCSI sense format enumeration
instead of the CTL-specific enumeration.

Submitted by: dim (partially)
MFC after: 1 month


230157 15-Jan-2012 avg

dadump: don't leak the periph lock on i/o error

Reported by: az
MFC after: 1 week


230053 13-Jan-2012 mav

Add BIO_DELETE support for SCSI Direct Access devices (da).

Depending on device capabilities use different methods to implement it.
Currently used method can be read/set via kern.cam.da.X.delete_method
sysctls. Possible values are:
NONE - no provisioning support reported by the device;
DISABLE - provisioning support was disabled because of errors;
ZERO - use WRITE SAME (10) command to write zeroes;
WS10 - use WRITE SAME (10) command with UNMAP bit set;
WS16 - use WRITE SAME (16) command with UNMAP bit set;
UNMAP - use UNMAP command (equivalent of the ATA DSM TRIM command).
The last two methods (UNMAP and WS16) are defined by SBC specification and
the UNMAP method is the most advanced one. The rest of methods I've found
supported in Linux, and as soon as they were trivial to implement, then
why not? Hope they will be useful in some cases.

Unluckily I have no devices properly reporting parameters of the logical
block provisioning support via respective VPD pages (0xB0 and 0xB2). So
all info I have/use now is the flag telling whether logical block
provisioning is supported or not. As result, specific methods chosen now
by trying different ones in order (UNMAP, WS16, DISABLE) and checking
completion status to fallback if needed. I don't expect problems from this,
as if something go wrong, it should just disable itself. It may disable
even too aggressively if only some command parameter misfit.

Unlike Linux, which executes each delete with separate request, I've
implemented here the same request aggregation as implemented in ada driver.
Tests on SSDs I have show much better results doing it this way: above
8GB/s of the linear delete on Intel SATA SSD on LSI SAS HBA (mps).

Reviewed by: silence on scsi@
MFC after: 2 month
Sponsored by: iXsystems, Inc.


230033 12-Jan-2012 ken

Silence some unnecessary verbosity.

Reported by: mav
MFC after: 1 month


230000 12-Jan-2012 ken

Fix a race condition in CAM peripheral free handling, locking
in the CAM XPT bus traversal code, and a number of other periph level
issues.

cam_periph.h,
cam_periph.c: Modify cam_periph_acquire() to test the CAM_PERIPH_INVALID
flag prior to allowing a reference count to be gained
on a peripheral. Callers of this function will receive
CAM_REQ_CMP_ERR status in the situation of attempting to
reference an invalidated periph. This guarantees that
a peripheral scheduled for a deferred free will not
be accessed during its wait for destruction.

Panic during attempts to drop a reference count on
a peripheral that already has a zero reference count.

In cam_periph_list(), use a local sbuf with SBUF_FIXEDLEN
set so that mallocs do not occur while the xpt topology
lock is held, regardless of the allocation policy of the
passed in sbuf.

Add a new routine, cam_periph_release_locked_buses(),
that can be called when the caller already holds
the CAM topology lock.

Add some extra debugging for duplicate peripheral
allocations in cam_periph_alloc().

Treat CAM_DEV_NOT_THERE much the same as a selection
timeout (AC_LOST_DEVICE is emitted), but forgo retries.

cam_xpt.c: Revamp the way the EDT traversal code does locking
and reference counting. This was broken, since it
assumed that the EDT would not change during
traversal, but that assumption is no longer valid.

So, to prevent devices from going away while we
traverse the EDT, make sure we properly lock
everything and hold references on devices that
we are using.

The two peripheral driver traversal routines should
be examined. xptpdperiphtraverse() holds the
topology lock for the entire time it runs.
xptperiphtraverse() is now locked properly, but
only holds the topology lock while it is traversing
the list, and not while the traversal function is
running.

The bus locking code in xptbustraverse() should
also be revisited at a later time, since it is
complex and should probably be simplified.

scsi_da.c: Pay attention to the return value from cam_periph_acquire().

Return 0 always from daclose() even if the disk is now gone.

Add some rudimentary error injection support.

scsi_sg.c: Fix reference counting in the sg(4) driver.

The sg driver was calling cam_periph_release() on close,
but never called cam_periph_acquire() (which increments
the reference count) on open.

The periph code correctly complained that the sg(4)
driver was trying to decrement the refcount when it
was already 0.

Sponsored by: Spectra Logic
MFC after: 2 weeks


229997 12-Jan-2012 ken

Add the CAM Target Layer (CTL).

CTL is a disk and processor device emulation subsystem originally written
for Copan Systems under Linux starting in 2003. It has been shipping in
Copan (now SGI) products since 2005.

It was ported to FreeBSD in 2008, and thanks to an agreement between SGI
(who acquired Copan's assets in 2010) and Spectra Logic in 2010, CTL is
available under a BSD-style license. The intent behind the agreement was
that Spectra would work to get CTL into the FreeBSD tree.

Some CTL features:

- Disk and processor device emulation.
- Tagged queueing
- SCSI task attribute support (ordered, head of queue, simple tags)
- SCSI implicit command ordering support. (e.g. if a read follows a mode
select, the read will be blocked until the mode select completes.)
- Full task management support (abort, LUN reset, target reset, etc.)
- Support for multiple ports
- Support for multiple simultaneous initiators
- Support for multiple simultaneous backing stores
- Persistent reservation support
- Mode sense/select support
- Error injection support
- High Availability support (1)
- All I/O handled in-kernel, no userland context switch overhead.

(1) HA Support is just an API stub, and needs much more to be fully
functional.

ctl.c: The core of CTL. Command handlers and processing,
character driver, and HA support are here.

ctl.h: Basic function declarations and data structures.

ctl_backend.c,
ctl_backend.h: The basic CTL backend API.

ctl_backend_block.c,
ctl_backend_block.h: The block and file backend. This allows for using
a disk or a file as the backing store for a LUN.
Multiple threads are started to do I/O to the
backing device, primarily because the VFS API
requires that to get any concurrency.

ctl_backend_ramdisk.c: A "fake" ramdisk backend. It only allocates a
small amount of memory to act as a source and sink
for reads and writes from an initiator. Therefore
it cannot be used for any real data, but it can be
used to test for throughput. It can also be used
to test initiators' support for extremely large LUNs.

ctl_cmd_table.c: This is a table with all 256 possible SCSI opcodes,
and command handler functions defined for supported
opcodes.

ctl_debug.h: Debugging support.

ctl_error.c,
ctl_error.h: CTL-specific wrappers around the CAM sense building
functions.

ctl_frontend.c,
ctl_frontend.h: These files define the basic CTL frontend port API.

ctl_frontend_cam_sim.c: This is a CTL frontend port that is also a CAM SIM.
This frontend allows for using CTL without any
target-capable hardware. So any LUNs you create in
CTL are visible in CAM via this port.

ctl_frontend_internal.c,
ctl_frontend_internal.h:
This is a frontend port written for Copan to do
some system-specific tasks that required sending
commands into CTL from inside the kernel. This
isn't entirely relevant to FreeBSD in general,
but can perhaps be repurposed.

ctl_ha.h: This is a stubbed-out High Availability API. Much
more is needed for full HA support. See the
comments in the header and the description of what
is needed in the README.ctl.txt file for more
details.

ctl_io.h: This defines most of the core CTL I/O structures.
union ctl_io is conceptually very similar to CAM's
union ccb.

ctl_ioctl.h: This defines all ioctls available through the CTL
character device, and the data structures needed
for those ioctls.

ctl_mem_pool.c,
ctl_mem_pool.h: Generic memory pool implementation used by the
internal frontend.

ctl_private.h: Private data structres (e.g. CTL softc) and
function prototypes. This also includes the SCSI
vendor and product names used by CTL.

ctl_scsi_all.c,
ctl_scsi_all.h: CTL wrappers around CAM sense printing functions.

ctl_ser_table.c: Command serialization table. This defines what
happens when one type of command is followed by
another type of command.

ctl_util.c,
ctl_util.h: CTL utility functions, primarily designed to be
used from userland. See ctladm for the primary
consumer of these functions. These include CDB
building functions.

scsi_ctl.c: CAM target peripheral driver and CTL frontend port.
This is the path into CTL for commands from
target-capable hardware/SIMs.

README.ctl.txt: CTL code features, roadmap, to-do list.

usr.sbin/Makefile: Add ctladm.

ctladm/Makefile,
ctladm/ctladm.8,
ctladm/ctladm.c,
ctladm/ctladm.h,
ctladm/util.c: ctladm(8) is the CTL management utility.
It fills a role similar to camcontrol(8).
It allow configuring LUNs, issuing commands,
injecting errors and various other control
functions.

usr.bin/Makefile: Add ctlstat.

ctlstat/Makefile
ctlstat/ctlstat.8,
ctlstat/ctlstat.c: ctlstat(8) fills a role similar to iostat(8).
It reports I/O statistics for CTL.

sys/conf/files: Add CTL files.

sys/conf/NOTES: Add device ctl.

sys/cam/scsi_all.h: To conform to more recent specs, the inquiry CDB
length field is now 2 bytes long.

Add several mode page definitions for CTL.

sys/cam/scsi_all.c: Handle the new 2 byte inquiry length.

sys/dev/ciss/ciss.c,
sys/dev/ata/atapi-cam.c,
sys/cam/scsi/scsi_targ_bh.c,
scsi_target/scsi_cmds.c,
mlxcontrol/interface.c: Update for 2 byte inquiry length field.

scsi_da.h: Add versions of the format and rigid disk pages
that are in a more reasonable format for CTL.

amd64/conf/GENERIC,
i386/conf/GENERIC,
ia64/conf/GENERIC,
sparc64/conf/GENERIC: Add device ctl.

i386/conf/PAE: The CTL frontend SIM at least does not compile
cleanly on PAE.

Sponsored by: Copan Systems, SGI and Spectra Logic
MFC after: 1 month


229395 03-Jan-2012 mav

Add support for CDRIOCGETBLOCKSIZE and CDRIOCSETBLOCKSIZE IOCTLs to control
sector size same as acd driver does. Together with r228808 and r228847 this
allows existing multimedia/vlc to play Audio CDs via CAM cd driver.

PR: ports/162190
MFC after: 1 week


229288 02-Jan-2012 mav

Remove unneeded checks for CAM_DEV_QFRZN after cam_periph_runccb() call.
cam_periph_runccb() since the beginning checks it and releases device queue.
After r203108 it even clears CAM_DEV_QFRZN flag after that to avoid double
release, so removed code is unreachable now.

MFC after: 1 month


228851 23-Dec-2011 mav

Report stripeoffset as zero not stripesize if physical block is zero
aligned, same as it is done for ATA.


228847 23-Dec-2011 mav

Addition to r228808:
READ CD is a 12 byte command. So fill additional bytes and update CDB length
when patching READ(10).

MFC after: 1 month


228846 23-Dec-2011 mav

Use READ CAPACITY(16) to get information about device physical sectors.
As soon as not all devices support READ CAPACITY(16), automatically fall
back to READ CAPACITY(10) if CAM_REQ_INVALID or SSD_KEY_ILLEGAL_REQUEST
status returned.

It also provides first bits of information about Logical Block Provisioning
(aka UNMAP/TRIM) support by the device.


228820 23-Dec-2011 mav

Merge to da driver quirks hinting 4K physical sector sizes for SATA disks
connected via SAS or USB. Unluckily I've found that SAS (mps) and USB-SATA
I have translate models in different ways, requiring twice more quirks.
Unluckily for Hitachi, their model names are trimmed on SAS, making
impossible to identify 4K sector drives that way.


228819 23-Dec-2011 mav

Update list of 4K physical sector hard drives.


228808 22-Dec-2011 mav

Make cd driver to handle Audio CDs, reporting their 2352 bytes sectors to
GEOM and using READ CD command for reading data, same as acd driver does.
Audio CDs identified by checking respective bit of the control field of
the first track in TOC.

This fixes bunch of error messages during boot (GEOM taste) with Audio CD
inserted and allows to grab Audio CD image using just dd.

MFC after: 1 month


228481 13-Dec-2011 ed

Change targ(4) to use cdevpriv, instead of multiple character devices.

Also update the manpage and the scsi_target example program accordingly.

Discussed on: scsi@
Tested by: Chuck Tuffli <chuck tuffli net>


228442 12-Dec-2011 mdf

Do not use the sometimes-reserved work 'bool' for a variable name.

MFC after: 2 weeks
Sponsored by: Isilon Systems, LLC


228344 08-Dec-2011 eadler

- Add support for Support SEAGATE DAT Scopion 130

PR: kern/141934
Submitted by: HASHI Hiroaki <hashiz@stenmark.meridiani.jp>
Approved by: sbruno@
MFC after: 1 week


228027 27-Nov-2011 marius

Move the scsi_da_bios_params() prototype from pc98_machdep.h to md_var.h
where the prototype for pc98_ata_disk_firmware_geom_adjust() also lives
in order to avoid an #ifdef'ed include in cam(4).


228022 27-Nov-2011 marius

For sparc64 also adjust the geometry of da(4) driven disks to not overflow
the 16-bit cylinders field of the VTOC8 disk label (at around 502GB). The
geometry chosen for disks above that limit allows to use disks up to 2TB,
which is the limit of the extended VTOC8 format. The geometry used for
disks smaller than the 16-bit cylinders limit stays the same as used by
cam_calc_geometry(9) for extended translation.
Thanks to Hans-Joerg Sirtl for providing hardware for testing this change.

MFC after: 3 days


227637 17-Nov-2011 mav

Introduce CAM_SIM_POLLED SIM flag, indicating that it works in polling mode.
It blocks CAM SWI usage on requests completion, unneeded because of polling
and denied during kernel dumping because of blocked scheduler.

Before r198899 there was periph flag CAM_PERIPH_POLLED, but that was wrong,
because there is whole SIM is polled or handled by SWI, not a single periph.

Tested by: kib
MFC after: 1 month


227489 13-Nov-2011 eadler

- fix duplicate "a a" in some comments

Submitted by: eadler
Approved by: simon
MFC after: 3 days


227309 07-Nov-2011 ed

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


227293 07-Nov-2011 ed

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


225950 03-Oct-2011 ken

Add descriptor sense support to CAM, and honor sense residuals properly in
CAM.

Desriptor sense is a new sense data format that originated in SPC-3. Among
other things, it allows for an 8-byte info field, which is necessary to
pass back block numbers larger than 4 bytes.

This change adds a number of new functions to scsi_all.c (and therefore
libcam) that abstract out most access to sense data.

This includes a bump of CAM_VERSION, because the CCB ABI has changed.
Userland programs that use the CAM pass(4) driver will need to be
recompiled.

camcontrol.c: Change uses of scsi_extract_sense() to use
scsi_extract_sense_len().

Use scsi_get_sks() instead of accessing sense key specific
data directly.

scsi_modes: Update the control mode page to the latest version (SPC-4).

scsi_cmds.c,
scsi_target.c: Change references to struct scsi_sense_data to struct
scsi_sense_data_fixed. This should be changed to allow the
user to specify fixed or descriptor sense, and then use
scsi_set_sense_data() to build the sense data.

ps3cdrom.c: Use scsi_set_sense_data() instead of setting sense data
manually.

cam_periph.c: Use scsi_extract_sense_len() instead of using
scsi_extract_sense() or accessing sense data directly.

cam_ccb.h: Bump the CAM_VERSION from 0x15 to 0x16. The change of
struct scsi_sense_data from 32 to 252 bytes changes the
size of struct ccb_scsiio, but not the size of union ccb.
So the version must be bumped to prevent structure
mis-matches.

scsi_all.h: Lots of updated SCSI sense data and other structures.

Add function prototypes for the new sense data functions.

Take out the inline implementation of scsi_extract_sense().
It is now too large to put in a header file.

Add macros to calculate whether fields are present and
filled in fixed and descriptor sense data

scsi_all.c: In scsi_op_desc(), allow the user to pass in NULL inquiry
data, and we'll assume a direct access device in that case.

Changed the SCSI RESERVED sense key name and description
to COMPLETED, as it is now defined in the spec.

Change the error recovery action for a number of read errors
to prevent lots of retries when the drive has said that the
block isn't accessible. This speeds up reconstruction of
the block by any RAID software running on top of the drive
(e.g. ZFS).

In scsi_sense_desc(), allow for invalid sense key numbers.
This allows calling this routine without checking the input
values first.

Change scsi_error_action() to use scsi_extract_sense_len(),
and handle things when invalid asc/ascq values are
encountered.

Add a new routine, scsi_desc_iterate(), that will call the
supplied function for every descriptor in descriptor format
sense data.

Add scsi_set_sense_data(), and scsi_set_sense_data_va(),
which build descriptor and fixed format sense data. They
currently default to fixed format sense data.

Add a number of scsi_get_*() functions, which get different
types of sense data fields from either fixed or descriptor
format sense data, if the data is present.

Add a number of scsi_*_sbuf() functions, which print
formatted versions of various sense data fields. These
functions work for either fixed or descriptor sense.

Add a number of scsi_sense_*_sbuf() functions, which have a
standard calling interface and print the indicated field.
These functions take descriptors only.

Add scsi_sense_desc_sbuf(), which will print a formatted
version of the given sense descriptor.

Pull out a majority of the scsi_sense_sbuf() function and
put it into scsi_sense_only_sbuf(). This allows callers
that don't use struct ccb_scsiio to easily utilize the
printing routines. Revamp that function to handle
descriptor sense and use the new sense fetching and
printing routines.

Move scsi_extract_sense() into scsi_all.c, and implement it
in terms of the new function, scsi_extract_sense_len().
The _len() version takes a length (which should be the
sense length - residual) and can indicate which fields are
present and valid in the sense data.

Add a couple of new scsi_get_*() routines to get the sense
key, asc, and ascq only.

mly.c: Rename struct scsi_sense_data to struct
scsi_sense_data_fixed.

sbp_targ.c: Use the new sense fetching routines to get sense data
instead of accessing it directly.

sbp.c: Change the firewire/SCSI sense data transformation code to
use struct scsi_sense_data_fixed instead of struct
scsi_sense_data. This should be changed later to use
scsi_set_sense_data().

ciss.c: Calculate the sense residual properly. Use
scsi_get_sense_key() to fetch the sense key.

mps_sas.c,
mpt_cam.c: Set the sense residual properly.

iir.c: Use scsi_set_sense_data() instead of building sense data by
hand.

iscsi_subr.c: Use scsi_extract_sense_len() instead of grabbing sense data
directly.

umass.c: Use scsi_set_sense_data() to build sense data.

Grab the sense key using scsi_get_sense_key().

Calculate the sense residual properly.

isp_freebsd.h: Use scsi_get_*() routines to grab asc, ascq, and sense key
values.

Calculate and set the sense residual.

MFC after: 3 days
Sponsored by: Spectra Logic Corporation


224806 12-Aug-2011 mjacob

Fixes for sure bus reference miscounting and potential device and
target reference miscounts. It also adds a helper function to get
the current reference counts for components of cam_path for debug
aid. One minor style(9) change.

Partially Obtained from: Chuck Tuffli (Emulex)
Reviewed by: scsi@ (ken)
Approved by: re (kib)
MFC after: 1 month


224531 30-Jul-2011 mav

Higher-priority initialization request can eat request scheduling done from
adaclose(). Add immediate_priority check into adaschedule() to restore it.

Approved by: re (kib)
MFC after: 1 week


224497 29-Jul-2011 mav

Add control for ATA disk read-ahead, alike to the previously added write
cache control. Some controller BIOS'es tend to disable read-ahead, that
dramatically reduces read performance. Previously ata(4) always enabled
read-ahead unconditionally.

Approved by: re (kib)


224496 29-Jul-2011 mav

In some cases failed SATA disks may report their presence, but don't
respond to any commands. I've found that because of multiple command
retries, each of which cause 30s timeout, bus reset and another retry or
requeue for many commands, it may take ages to eventually drop the
failed device. The odd thing is that those retries continue even after
XPT considered device as dead and invalidated it.

This patch makes cam_periph_error() to block any command retries after
periph was marked as invalid. With that patch all activity completes in
1-2 minutes, just after several timeouts, required to consider device
death. This should make ZFS, gmirror, graid, etc. operation more robust.

Reviewed by: mjacob@ on scsi@

Approved by: re (kib)


224283 23-Jul-2011 mav

Do not try to execute FLUSHCACHE on close and print extra messages for
invalidated (considered lost) ada device. Exactly same already done for
the da devices.

Approved by: re (kib)
MFC after: 1 week


223557 26-Jun-2011 gibbs

cam/scsi/scsi_cd.c:
In cdregister(), hold the periph lock semaphore during changer
probe/configuration. This removes a window where an open of the
cd device may succeed before probe processing has completed.


223556 26-Jun-2011 gibbs

cam/cam_xpt.c:
In camisr_runqueue(), we need to run the sims queue regardless of
whether or not the current peripheral has more work to do. This
reverts a change mistakenly made in revision 223081.

Reported by: ache


223475 23-Jun-2011 mav

Fix ATAPI breakage introduced by r223443. It made SCSI commands to ATAPI
device to never complete, that caused probe process (system boot) stuck.


223448 22-Jun-2011 will

Return CAM_REQ_INVALID if the SCSI XPT receives an unsupported operation
via the XPT_DEV_ADVINFO CCB.

Reviewed by: ken


223443 22-Jun-2011 will

Plumb support for the device advanced information CCB in the ATA XPT.

This was previously done only for SCSI XPT in r223081, on which the change
in r223089 depended in order to respond to serial number requests. As a
result of r223089, da(4) and ada(4) devices register a d_getattr for geom to
use to obtain the information.

Reported by: ache
Reviewed by: ken


223277 18-Jun-2011 kib

Fix a typo in adagetattr() from r223089. In particular, this restores
the ability to use ahci(4) for kernel dumps.


223089 14-Jun-2011 gibbs

Plumb device physical path reporting from CAM devices, through GEOM and
DEVFS, and make it accessible via the diskinfo utility.

Extend GEOM's generic attribute query mechanism into generic disk consumers.
sys/geom/geom_disk.c:
sys/geom/geom_disk.h:
sys/cam/scsi/scsi_da.c:
sys/cam/ata/ata_da.c:
- Allow disk providers to implement a new method which can override
the default BIO_GETATTR response, d_getattr(struct bio *). This
function returns -1 if not handled, otherwise it returns 0 or an
errno to be passed to g_io_deliver().

sys/cam/scsi/scsi_da.c:
sys/cam/ata/ata_da.c:
- Don't copy the serial number to dp->d_ident anymore, as the CAM XPT
is now responsible for returning this information via
d_getattr()->(a)dagetattr()->xpt_getatr().

sys/geom/geom_dev.c:
- Implement a new ioctl, DIOCGPHYSPATH, which returns the GEOM
attribute "GEOM::physpath", if possible. If the attribute request
returns a zero-length string, ENOENT is returned.

usr.sbin/diskinfo/diskinfo.c:
- If the DIOCGPHYSPATH ioctl is successful, report physical path
data when diskinfo is executed with the '-v' option.

Submitted by: will
Reviewed by: gibbs
Sponsored by: Spectra Logic Corporation

Add generic attribute change notification support to GEOM.

sys/sys/geom/geom.h:
Add a new attrchanged method field to both g_class
and g_geom.

sys/sys/geom/geom.h:
sys/geom/geom_event.c:
- Provide the g_attr_changed() function that providers
can use to advertise attribute changes.
- Perform delivery of attribute change notifications
from a thread context via the standard GEOM event
mechanism.

sys/geom/geom_subr.c:
Inherit the attrchanged method from class to geom (class instance).

sys/geom/geom_disk.c:
Provide disk_attr_changed() to provide g_attr_changed() access
to consumers of the disk API.

sys/cam/scsi/scsi_pass.c:
sys/cam/scsi/scsi_da.c:
sys/geom/geom_dev.c:
sys/geom/geom_disk.c:
Use attribute changed events to track updates to physical path
information.

sys/cam/scsi/scsi_da.c:
Add AC_ADVINFO_CHANGED to the registered asynchronous CAM
events for this driver. When this event occurs, and
the updated buffer type references our physical path
attribute, emit a GEOM attribute changed event via the
disk_attr_changed() API.

sys/cam/scsi/scsi_pass.c:
Add AC_ADVINFO_CHANGED to the registered asynchronous CAM
events for this driver. When this event occurs, update
the physical patch devfs alias for this pass instance.

Submitted by: gibbs
Sponsored by: Spectra Logic Corporation


223084 14-Jun-2011 gibbs

sys/cam/scsi/scsi_da.c:
- Only attempt the closing synchronize cache on a disk
if it is still there.
- When a device is lost, report the number of outstanding
I/Os as they are drained.
- When a device is lost, return any unprocessed bios with
ENXIO instead of EIO.
- Filter asynchronous events, but always allow cam_periph_async()
to see them too.

Sponsored by: Spectra Logic Corporation


223081 14-Jun-2011 gibbs

Lay groundwork in CAM for recording and reporting physical path and
other device attributes stored in the CAM Existing Device Table (EDT).
This includes some infrastructure requried by the enclosure services
driver to export physical path information.

Make the CAM device advanced info interface accept store requests.

sys/cam/scsi/scsi_all.c:
sys/cam/scsi/scsi_all.h:
- Replace scsi_get_sas_addr() with a scsi_get_devid() which takes
a callback that decides whether to accept a particular descriptor.
Provide callbacks for NAA IEEE Registered addresses and for SAS
addresses, replacing the old function. This is needed because
the old function doesn't work for an enclosure address for a SAS
device, which is not flagged as a SAS address, but is NAA IEEE
Registered. It may be worthwhile merging this interface with the
devid match interface.
- Add a few more defines for some device ID fields.

sbin/camcontrol/camcontrol.c:
- Update for the CCB_DEV_ADVINFO interface change.

cam/cam_xpt_internal.h:
- Add the new fields for the physical path string to the CAM EDT.
cam/cam_ccb.h:
- Rename CCB_GDEV_ADVINFO to simply CCB_DEV_ADVINFO, and the ccb
structure to ccb_dev_advinfo.
- Add a flag that changes this CCB's action to store, rather than
the default, retrieve.
- Add a new buffer type, CDAI_TYPE_PHYS_PATH, for the new CAM EDT
physpath field.
- Remove the never-implemented transport & proto flags.
cam/cam_xpt.c:
cam/cam_xpt.h:
- Add xpt_getattr(), which provides a wrapper for fetching a device's
attribute using the GEOM strings as key. This method currently
supports "GEOM::ident" and "GEOM::physpath".

Submitted by: will
Reviewed by : gibbs

Extend the XPT_DEV_MATCH api to allow a device search by device ID.
As far as the API is concerned, device ID is a binary blob to be
interpreted by the transport layer. The SCSI implementation assumes
it is an array of VPD device ID descriptors.

sys/cam/cam_ccb.h:
Create a new structure, device_id_match_pattern, and
update the XPT_DEV_MATCH datastructures and flags so
that this pattern type can be used.

sys/cam/cam_xpt.c:
- A single pattern matching on both inquiry data and device
ID is invalid. Report any violators.
- Pass device ID match requests through to the new routine
scsi_devid_match(). The direct call of a SCSI routine is
a layering violation, but no worse than the one a few
lines up that checks inquiry data. Defer cleaning this
up until our future, larger, rototilling of CAM.
- Zero out cam_ed and cam_et nodes on allocation. Prior to
this change, device_id_len and device_id were not inialized,
preventing proper detection of the presence of this
information.

sys/cam/scsi/scsi_all.c:
sys/cam/scsi/scsi_all.h:
Add the scsi_match_devid() routine.

Add a helper function for extracting peripherial driver names

sys/cam/cam_periph.c:
sys/cam/cam_periph.h:
Add the cam_periph_list() method which fills an sbuf
with a comma delimited list of the peripheral instances
associated with a given CAM path.

Add a helper functions for SCSI commands used by the SES driver.

sys/cam/scsi/scsi_all.c:
sys/cam/scsi/scsi_all.h:
Add structure definitions and csio filling functions for
the receive diagnostic results and send diagnostic commands.

Misc CAM XPT cleanups.

sys/cam/cam_xpt.c:
Broadcast AC_FOUND_DEVICE and AC_PATH_REGISTERED
events at the time async event handlers are attached
even when registering just for events on a partitular
SIM. Previously, you had to register for these
events on all SIMs in the system in order to get
the initial broadcast even though subsequent device
and path arrivals would be delivered.

sys/cam/cam_xpt.c:
Remove SIM mutex held asserts from path accessors.
CAM paths are reference counted and it is this
reference count, not the sim mutex, that garantees
they are stable.

Sponsored by: Spectra Logic Corporation


223019 12-Jun-2011 mav

Do not report CFA devices as ATAPI, even though IDENTIFY data look alike.


222643 03-Jun-2011 mav

Increase maximum supported number of ranges per TRIM command from 256 to 512
to use full potential of Intel X25-M SSDs. On synthetic test with 32K ranges
it gives about 20% speedup, which probably costs more then 2K of RAM.


222628 02-Jun-2011 mav

When possible, join ranges of subsequest BIO_DELETE requests to handle more
(up to 2048 instead of 256 or even 64) of them with single TRIM request.

OCZ Vertex2/Vertex3 SSDs can handle no more then 64 ranges per TRIM request.
Due to lack of BIO_DELETE clustering now, it means that we could delete no
more then 2MB per request (on FS with 32K block) with limited request rate.
This change increases delete rate on Vertex2 from 250MB/s to 950MB/s.


222520 31-May-2011 mav

Add quirks to hint 4K physical sector (Advanced Format) for ATA disks not
reporting it properly (none? of known disks now).

Hitachi and WDC AF disks seem could be identified more or less formally.
For Seagate and Samsung enumerate some found models/series.
For other disks it can be forced with kern.cam.ada.X.quirks=1 tunable.


222339 27-May-2011 mav

Change new constant names to ones used by OpenSolaris.


222336 27-May-2011 mav

Add names for few more SES element types according SES-2 specification.


221585 07-May-2011 avg

scsi_cd: silence READ_TOC errors in CDIOREADTOCHEADER ioctl

An optical disk may not have a TOC (e.g. for blank media) and userland
software may legitimately try to use CDIOREADTOCHEADER to find out about
the TOC.

Silence from: scsi@
MFC after: 10 days


221384 03-May-2011 mav

Do not report legacy unit numbers (do not create legacy aliases) for disks
on port multiplier ports above first two. They don't fit into ATA_STATIC_ID
scheme and so can't be mapped properly. No need to pollute dev.


221201 29-Apr-2011 mav

Make CAM_DEBUG_CDB also dump ATA commands in addition to SCSI.


221071 26-Apr-2011 mav

- Add shim to simplify migration to the CAM-based ATA. For each new adaX
device in /dev/ create symbolic link with adY name, trying to mimic old ATA
numbering. Imitation is not complete, but should be enough in most cases to
mount file systems without touching /etc/fstab.
- To know what behavior to mimic, restore ATA_STATIC_ID option in cases
where it was present before.
- Add some more details to UPDATING.


220886 20-Apr-2011 mav

Add basic support for DMA-capable ATA disks on DMA-incapable controller.
This is really rare situation these days, but still may happen in embedded.


220786 18-Apr-2011 mav

Remove always false "< 0" check for unsgined int variable. This check is
also duplicate, as the value was already checked for 0 before decrementing.

Reported by: rpaulo


220785 18-Apr-2011 mav

Remove some used variables.

Found with: Clang Static Analyzer


220778 18-Apr-2011 mav

Remove some used variables.

Found with: Clang Static Analyzer


220690 16-Apr-2011 jh

Move a comment to the right place. The rearrange done in r208928 left
the comment to a wrong place.


220686 16-Apr-2011 jh

Move TUNABLE_INT_FETCH() out of the SIM lock to avoid sleeping while
holding the lock. The fix is analogous to r220618 for ada(4).

Reviewed by: mav


220650 15-Apr-2011 mav

Make ada(4) driver put ATA disks into sleep state on suspend.

Submitted by: jkim (original version)


220644 14-Apr-2011 mav

Make CAM report devices with ATA/SATA transport to devstat(9) as IDE.


220618 14-Apr-2011 mav

Fix typo in write_cache tunable name and move TUNABLE_INT_FETCH() out of
the SIM lock to fix WITNESS warning.

Reported by: jh


220616 14-Apr-2011 mav

Properly log few more ATA commands used by the kernel.


220602 13-Apr-2011 mav

Improve SATA Asynchronous Notification feature support in CAM:
- make SATA SIMs announce capabilities to handle SDB with Notification bit;
- make PMP driver honor this SIMs capability;
- make SATA XPT to negotiate and enable this feature for ATAPI devices.

This feature allows supporting SATA ATAPI devices to inform system about
some events happened, that may require attention. In my case this allows
LG GH22LS50 SATA DVR-RW drive to report tray open/close events. Events
reported to CAM in form of AC_SCSI_AEN async. Further they could be used
as a hints for checking device status and reporting media change to upper
layers, for example, via spoiling mechanism of GEOM.


220454 08-Apr-2011 mav

- Add kern.cam.ada.X.write_cache tunables/sysctls to control write caching
on per-device basis.
- While adding support for per-device sysctls, merge from graid branch
support for ADA_TEST_FAILURE kernel option, which opens few more sysctl,
allowing to simulate read and write errors for testing purposes.


220412 07-Apr-2011 mav

Make ada(4) driver to control device write cache, same as ata(4) does.
Add kern.cam.ada.write_cache sysctl/tunable to control it alike hw.ata.wc.


219241 03-Mar-2011 mjacob

Don't automatically send a START UNIT to sequential access devices-
this might cause them to load the tape unintentionally.

Reviewed by: gibbs
MFC after: 1 month


219075 26-Feb-2011 nwhitehorn

Missed a file in r219056: add disk description for da(4).


219056 26-Feb-2011 nwhitehorn

Add the disk ident and a human-meaningful description (here, the disk model
string) to the geom_disk config XML so that they are easily accessible from
userland.

MFC after: 1 week


219028 25-Feb-2011 netchild

Add some FEATURE macros for various features (AUDIT/CAM/IPC/KTR/MAC/NFS/NTP/
PMC/SYSV/...).

No FreeBSD version bump, the userland application to query the features will
be committed last and can serve as an indication of the availablility if
needed.

Sponsored by: Google Summer of Code 2010
Submitted by: kibab
Reviewed by: arch@ (parts by rwatson, trasz, jhb)
X-MFC after: to be determined in last commit with code from this project


218909 21-Feb-2011 brucec

Fix typos - remove duplicate "the".

PR: bin/154928
Submitted by: Eitan Adler <lists at eitanadler.com>
MFC after: 3 days


217875 26-Jan-2011 mav

In addition to r217444 ignore also ATA status errors on DMA Auto-Activation
enabling request. Some HP disks reported to return ABORT error there while
declaring support for this feature.


217874 26-Jan-2011 mav

Make device initialization sequence shorter when possible. Do not enable/
disable already enabled/disabled SATA features.


217586 19-Jan-2011 mdf

sysctl(8) should use the CTLTYPE to determine the type of data when
reading. (This was already done for writing to a sysctl). This
requires all SYSCTL setups to specify a type. Most of them are now
checked at compile-time.

Remove SYSCTL_*X* sysctl additions as the print being in hex should be
controlled by the -x flag to sysctl(8).

Succested by: bde


217444 15-Jan-2011 mav

Some old WD SATA disks report supported and enabled device-initiated
interface power management, but return ABORT error on attempt to disable
it. Make CAM SATA probe sequence ignore this error, as it is not fatal.


217369 13-Jan-2011 mdf

Add a 64-bit hex-printed sysctl(9) since there is at least one place in
the code that wanted it. It is named X64 rather than XQUAD since the
quad name is a historical abomination that should not be perpetuated.


217368 13-Jan-2011 mdf

Fix up a few more sysctl(9) mis-typing found in various LINT builds.


217265 11-Jan-2011 jhb

Remove unneeded includes of <sys/linker_set.h>. Other headers that use
it internally contain nested includes.

Reviewed by: bde


216361 10-Dec-2010 ken

Fix a few issues related to the XPT_GDEV_ADVINFO CCB.

camcontrol.c: In buildbusdevlist(), don't attempt to get call
getdevid() for an unconfigured device, even when the
verbose flag is set. The cam_open_btl() call will almost
certainly fail.

Probe for the buffer size when issuing the XPT_GDEV_ADVINFO
CCB. Probing for the buffer size first helps us avoid
allocating the maximum buffer size when it really may not
be necessary. This also helps avoid errors from
cam_periph_mapmem() if we attempt to map more than MAXPHYS.

cam_periph.c: In cam_periph_mapmem(), if the XPT_GDEV_ADVINFO CCB
shows a bufsiz of 0, we don't have anything to map,
so just return.

Also, set the maximum mapping size to MAXPHYS
instead of DFLTPHYS for XPT_GDEV_ADVINFO CCBs,
since they don't actually go down to the hardware.

scsi_pass.c: Don't bother mapping the buffer in XPT_GDEV_ADVINFO
CCBs if bufsiz is 0.


216088 30-Nov-2010 ken

Add Serial Management Protocol (SMP) passthrough support to CAM.

This includes support in the kernel, camcontrol(8), libcam and the mps(4)
driver for SMP passthrough.

The CAM SCSI probe code has been modified to fetch Inquiry VPD page 0x00
to determine supported pages, and will now fetch page 0x83 in addition to
page 0x80 if supported.

Add two new CAM CCBs, XPT_SMP_IO, and XPT_GDEV_ADVINFO. The SMP CCB is
intended for SMP requests and responses. The ADVINFO is currently used to
fetch cached VPD page 0x83 data from the transport layer, but is intended
to be extensible to fetch other types of device-specific data.

SMP-only devices are not currently represented in the CAM topology, and so
the current semantics are that the SIM will route SMP CCBs to either the
addressed device, if it contains an SMP target, or its parent, if it
contains an SMP target. (This is noted in cam_ccb.h, since it will change
later once we have the ability to have SMP-only devices in CAM's topology.)

smp_all.c,
smp_all.h: New helper routines for SMP. This includes
SMP request building routines, response parsing
routines, error decoding routines, and structure
definitions for a number of SMP commands.

libcam/Makefile: Add smp_all.c to libcam, so that SMP functionality
is available to userland applications.

camcontrol.8,
camcontrol.c: Add smp passthrough support to camcontrol. Several
new subcommands are now available:

'smpcmd' functions much like 'cmd', except that it
allows the user to send generic SMP commands.

'smprg' sends the SMP report general command, and
displays the decoded output. It will automatically
fetch extended output if it is available.

'smppc' sends the SMP phy control command, with any
number of potential options. Among other things,
this allows the user to reset a phy on a SAS
expander, or disable a phy on an expander.

'smpmaninfo' sends the SMP report manufacturer
information and displays the decoded output.

'smpphylist' displays a list of phys on an
expander, and the CAM devices attached to those
phys, if any.

cam.h,
cam.c: Add a status value for SMP errors
(CAM_SMP_STATUS_ERROR).

Add a missing description for CAM_SCSI_IT_NEXUS_LOST.

Add support for SMP commands to cam_error_string().

cam_ccb.h: Rename the CAM_DIR_RESV flag to CAM_DIR_BOTH. SMP
commands are by nature bi-directional, and we may
need to support bi-directional SCSI commands later.

Add the XPT_SMP_IO CCB. Since SMP commands are
bi-directional, there are pointers for both the
request and response.

Add a fill routine for SMP CCBs.

Add the XPT_GDEV_ADVINFO CCB. This is currently
used to fetch cached page 0x83 data from the
transport later, but is extensible to fetch many
other types of data.

cam_periph.c: Add support in cam_periph_mapmem() for XPT_SMP_IO
and XPT_GDEV_ADVINFO CCBs.

cam_xpt.c: Add support for executing XPT_SMP_IO CCBs.

cam_xpt_internal.h: Add fields for VPD pages 0x00 and 0x83 in struct
cam_ed.

scsi_all.c: Add scsi_get_sas_addr(), a function that parses
VPD page 0x83 data and pulls out a SAS address.

scsi_all.h: Add VPD page 0x00 and 0x83 structures, and a
prototype for scsi_get_sas_addr().

scsi_pass.c: Add support for mapping buffers in XPT_SMP_IO and
XPT_GDEV_ADVINFO CCBs.

scsi_xpt.c: In the SCSI probe code, first ask the device for
VPD page 0x00. If any VPD pages are supported,
that page is required to be implemented. Based on
the response, we may probe for the serial number
(page 0x80) or device id (page 0x83).

Add support for the XPT_GDEV_ADVINFO CCB.

sys/conf/files: Add smp_all.c.

mps.c: Add support for passing in a uio in mps_map_command(),
so we can map a S/G list at once.

Add support for SMP passthrough commands in
mps_data_cb(). SMP is a special case, because the
first buffer in the S/G list is outbound and the
second buffer is inbound.

Add support for warning the user if the busdma code
comes back with more buffers than will work for the
command. This will, for example, help the user
determine why an SMP command failed if busdma comes
back with three buffers.

mps_pci.c: Add sys/uio.h.

mps_sas.c: Add the SAS address and the parent handle to the
list of fields we pull from device page 0 and cache
in struct mpssas_target. These are needed for SMP
passthrough.

Add support for the XPT_SMP_IO CCB. For now, this
CCB is routed to the addressed device if it supports
SMP, or to its parent if it does not and the parent
does. This is necessary because CAM does not
currently support SMP-only nodes in the topology.

Make SMP passthrough support conditional on
__FreeBSD_version >= 900026. This will make it
easier to MFC this change to the driver without
MFCing the CAM changes as well.

mps_user.c: Un-staticize mpi_init_sge() so we can use it for
the SMP passthrough code.

mpsvar.h: Add a uio and iovecs into struct mps_command for
SMP passthrough commands.

Add a cm_max_segs field to struct mps_command so
that we can warn the user if busdma comes back with
too many segments.

Clear the cm_reply when a command gets freed. If
it is not cleared, reply frames will eventually get
freed into the pool multiple times and corrupt the
pool. (This fix is from scottl.)

Add a prototype for mpi_init_sge().

sys/param.h: Bump __FreeBSD_version to 900026 for the for the
inclusion of the XPT_GDEV_ADVINFO and XPT_SMP_IO
CAM CCBs.


215454 18-Nov-2010 mav

If HBA doesn't report user-enabled SATA capabilies (like ATA_CAM wrapper) -
handle all of them as disabled. This was original cause of the problem,
workarounded by r215453.

MFC after: 1 week


214989 08-Nov-2010 mav

When requesting sense data for SIM not doing it automatically (such as
ATAPI or USB), request only as much data as requested by consumer.
On the way back -- report how much sense data we have actually received.


214288 24-Oct-2010 mav

Make da driver to handle some probably broken Android devices, returning
zero media and sector size instead of "Medium not present" error,
until some confirmation button is tapped on device.


214279 24-Oct-2010 brucec

Mostly revert r203420, and add similar functionality into ada(4) since the
existing code caused problems with some SCSI controllers.

A new sysctl kern.cam.ada.spindown_shutdown has been added that controls
whether or not to spin-down disks when shutting down.
Spinning down the disks unloads/parks the heads - this is
much better than removing power when the disk is still
spinning because otherwise an Emergency Unload occurs which may cause damage
to the actuator.

PR: kern/140752
Submitted by: olli
Reviewed by: arundel
Discussed with: mav
MFC after: 2 weeks


212991 22-Sep-2010 mav

Decrease poll interval from 1000 to 100us. This significantly reduces
kernel dump time, especially with minidump.


212926 20-Sep-2010 mdf

Use destroy_dev_sched(9) instead of destroy_dev(9) in passcleanup() as
it is indirectly a d_close method.

Prompted by: kib
Reviewed by: mav
MFC after: 2 weeks


212160 02-Sep-2010 gibbs

Correct bioq_disksort so that bioq_insert_tail() offers barrier semantic.
Add the BIO_ORDERED flag for struct bio and update bio clients to use it.

The barrier semantics of bioq_insert_tail() were broken in two ways:

o In bioq_disksort(), an added bio could be inserted at the head of
the queue, even when a barrier was present, if the sort key for
the new entry was less than that of the last queued barrier bio.

o The last_offset used to generate the sort key for newly queued bios
did not stay at the position of the barrier until either the
barrier was de-queued, or a new barrier (which updates last_offset)
was queued. When a barrier is in effect, we know that the disk
will pass through the barrier position just before the
"blocked bios" are released, so using the barrier's offset for
last_offset is the optimal choice.

sys/geom/sched/subr_disk.c:
sys/kern/subr_disk.c:
o Update last_offset in bioq_insert_tail().

o Only update last_offset in bioq_remove() if the removed bio is
at the head of the queue (typically due to a call via
bioq_takefirst()) and no barrier is active.

o In bioq_disksort(), if we have a barrier (insert_point is non-NULL),
set prev to the barrier and cur to it's next element. Now that
last_offset is kept at the barrier position, this change isn't
strictly necessary, but since we have to take a decision branch
anyway, it does avoid one, no-op, loop iteration in the while
loop that immediately follows.

o In bioq_disksort(), bypass the normal sort for bios with the
BIO_ORDERED attribute and instead insert them into the queue
with bioq_insert_tail(). bioq_insert_tail() not only gives
the desired command order during insertion, but also provides
barrier semantics so that commands disksorted in the future
cannot pass the just enqueued transaction.

sys/sys/bio.h:
Add BIO_ORDERED as bit 4 of the bio_flags field in struct bio.

sys/cam/ata/ata_da.c:
sys/cam/scsi/scsi_da.c
Use an ordered command for SCSI/ATA-NCQ commands issued in
response to bios with the BIO_ORDERED flag set.

sys/cam/scsi/scsi_da.c
Use an ordered tag when issuing a synchronize cache command.

Wrap some lines to 80 columns.

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
sys/geom/geom_io.c
Mark bios with the BIO_FLUSH command as BIO_ORDERED.

Sponsored by: Spectra Logic Corporation
MFC after: 1 month


211529 20-Aug-2010 mjacob

Revert r211434. Offline discussions have convinced me that this should
be left alone for now.


211434 17-Aug-2010 mjacob

Now is as good a time as any to find out if we induce breakage
by issueing aborts for any pending commands when we're decommssioning
a disk.

MFC after: 3 months


210779 02-Aug-2010 bcr

Fix two (very common) occurrences of s/sytem/system in comments.

Approved by: mav
MFC after: 3 days


210471 25-Jul-2010 mav

Export PCI IDs of ATA/SATA controllers through CAM and ata(4) layers to
GEOM. This information needed for proper soft-RAID's on-disk metadata
reading and writing.


209744 06-Jul-2010 mav

ATA device reset starts probe sequence from the beginning. If reset caused
by timeout/error of one of probe commands, process may continue infinitely.
Make CAM ATA more robust to faulty devices and false positive detections,
abort probe after two restarts on timeouts or ten on other errors.


209590 29-Jun-2010 mjacob

Don't lock buses around a call to xptperiphlistmatch- the buses will be
locked at appropriate places.

MFC after: 1 week
X-MFC: 208752


209188 14-Jun-2010 ken

For the target port groups structures, don't allocate the initial element.
This makes things easier for target implementations to calculate how many
elements they need to allocate.

Discussed with: mjacob, gibbs
MFC after: 1 week


208928 08-Jun-2010 mjacob

Rearrange how things are done to avoid dereferencing stale pointers in
the case of immediate unconfigure after configure. Hold the periph an
extra count while we have the task to create sysctl context outstanding
so that the periph doesn't go away unexpectedly.

Sponsored by: Panasas
Reviewed by: scsi@
MFC after: 1 month


208918 08-Jun-2010 mjacob

One byte off for scsi_target_group cdb.

MFC after: 2 weeks


208911 08-Jun-2010 mjacob

Implement the usage of Report Luns as part of SCSI probing for SCP3 or
better devices. This can be disabled on a per-device basis using quirks as
well.

This also handles the case where there is actually no connected LUN 0
(which can definitely be the case for storage arrays).

Reviewed by: scsi@
MFC after: 1 month


208905 08-Jun-2010 mjacob

Make additional definitions up to and including SPC-4. Add in definitions
for REPORT and SET TARGET PORT GROUP commands (foundations for future work).

Regularize opcodes to be upper case hex.

Pick *one* of tab or space after #define (tab) and stick with that.

MFC after: 2 weeks


208900 07-Jun-2010 mjacob

redfacedly noting a missing part of a patch.

Pointy Hat To: Me
MFC after: 2 Week
X-MFC: 208896


208896 07-Jun-2010 mjacob

Do a minor amount of stylifying. Also, get a Fibre Channel WWPN if one exists
for a da unit and create a sysctl OID for it.


208823 05-Jun-2010 mav

Add allocation error hadling.

Found with: Coverity Prevent(tm)
CID: 3897


208819 05-Jun-2010 mav

Fix double free on error.

Found with: Coverity Prevent(tm)
CID: 4573


208800 04-Jun-2010 avg

scsi_cd: pass correct pointer to free()

Found with: Coverity Prevent(tm)
CID: 2986
MFC after: 4 days


208752 02-Jun-2010 mjacob

Protect periph drivers list and rearrange things to minimize the chance of
stepping oneself during probing.

Don't blindly decrement a periph probe count.

Reviewed by: scsi@
Obtained from: Alexander Motin, Atillio Rao, Others
MFC after: 1 month


208582 26-May-2010 mjacob

Add a new primitive, XPT_SCAN_TGT, to cover the range between scanning a
whole bus (XPT_SCAN_BUS) and a single lun on that bus (XPT_SCAN_LUN).

It's less resource comsumptive than scanning a whole bus when the
caller knows only one target has changes.

Reviewed by: scsi@
Sponsored by: Panasas
MFC after: 1 month


208349 20-May-2010 marius

Change ad_firmware_geom_adjust() to operate on a struct disk * only and
hook it up to ada(4) also. While at it, rename *ad_firmware_geom_adjust()
to *ata_disk_firmware_geom_adjust() etc now that these are no longer
limited to ad(4).

Reviewed by: mav
MFC after: 3 days


208348 20-May-2010 marius

Remove unnecessary headers which were inherited from cam_xpt.c without
reason.

Reviewed by: mav
MFC after: 3 days


207938 11-May-2010 mjacob

Pick up the right change, not it's close cousin. The one
previously submitted was wrong.

Point hat: mjacob
X-MFC: 207933
MFC after: 1 week


207933 11-May-2010 mjacob

Deal sensibly with more than 26 sg devices. It isn't a complete
solution.

Sponsored by: Panasas
MFC after: 1 week


207499 02-May-2010 mav

Make SATA XPT negotiate and enable some additional SATA features, such as:
- device initiated power management (some devices support only this way);
- Automatic Partial to Slumber Transition (more power saving);
- DMA auto-activation (expected to slightly improve performance).
More features could be added later, when hardware supports.


207490 02-May-2010 mav

Add xpt_schedule_dev_sendq() call, lost at r203108. It is not needed in
usual operation, but required in some conditions to make queue running
after being shrinked.

MFC after: 3 days


207433 30-Apr-2010 mav

Revert r198705.
As scottl@ noticed, max_target/max_lun was intended to be only a hint for
existing bus scanner. Some FC/SAS SIMs report fake values there, that are
smaller then maximum supported IDs. In that case this check makes impossible
manual scan outside hinted range.

For ATA/SATA SIMs respective check was instead implemented at SIM level.
Newer SCSI SIMs expected to have these checks at driver or firmware level.
Some older SCSI SIMs have no this check and the issues will get back there.


207428 30-Apr-2010 mav

Report PMP absence using target 15, same as for precence (not a wildcard),
to not confuse target ID checks at SIMs.


207282 27-Apr-2010 mav

Update device identify data and serial number when device change detected.
Reprobe immediately following this should have fresh data.


207222 26-Apr-2010 mav

MFp4:
Move PI_TAG_ABLE check from ada driver to ATA XPT.


206648 15-Apr-2010 avg

scsi_cd: CD_FLAG_VALID_MEDIA is sufficient to set d_sectorsize and
d_mediasize

CD_FLAG_VALID_TOC is not required for setting those media properties.

PR: kern/145385
Submitted by: Juergen Lock <nox@jelal.kn-bremen.de>
a slightly different version
Tested by: Pavel Sukhoy <sukhoy@ripn.net>,
Markus Wild <m.wild@cybernet.ch>,
Juergen Lock <nox@jelal.kn-bremen.de>,
uqs
MFC after: 1 week


206112 02-Apr-2010 mjacob

Nullify our periph pointer in dacleanup to try and catch
race conditions in callbacks/downcalls.


206029 01-Apr-2010 mjacob

Add a couple missing basic mode page codes.

MFC after: 1 week


205993 31-Mar-2010 mjacob

For unhandled actions in xpt_action_default, remember to call
xpt_done for queued requests. This solves the problem of
indefinite hangs for unspecified transports when XPT_SCAN_BUS
is called.

A few minor cosmetics elsewhere.

MFC after: 1 week


205252 17-Mar-2010 mjacob

We actually can generate a host number.

MFC after: 1 month


204354 26-Feb-2010 mav

Make PUIS detection more strict. Previous implementation caused false
positives on VMWare's virtual CD-ROMs.


204353 26-Feb-2010 mav

Fix newlines broken at r204220.


204253 23-Feb-2010 mav

Make xpt_rescan() more correct, as it was before r197208: do not use
XPT_SCAN_LUN for wildcard LUN, fall back to XPT_SCAN_BUS.


204220 22-Feb-2010 mav

Virtualize transport part of periph announcement.


204195 22-Feb-2010 mav

Improve output for controllers that doesn't report SATA speed.


203931 15-Feb-2010 mav

Make CD driver a bit more robust and predictable to unreported errors.


203499 04-Feb-2010 mav

On probe error, if restart requested, skip any retries and recovery.
Just restart probe from the beginning immediately.


203440 03-Feb-2010 mav

Disable kern.cam.power_down ATM. It doesn't work fine on some controllers.


203421 03-Feb-2010 mav

MFp4:
Add Power Up In Stand-by feature support. Device with PUIS enabled
require explicit command to do initial spin-up. Mark that command
with CAM_HIGH_POWER flag, to allow CAM manage staggered spin-up.


203420 03-Feb-2010 mav

MFp4:
Make CAM to stop all attached devices on system shutdown.
It allows devices to park heads, reducing stress on power loss.
Add `kern.cam.power_down` tunable and sysctl to controll it.


203386 02-Feb-2010 mav

Change the way in which fake async events generated. Do not use
taskqueue for lock decoupling, as it causes unwanted races.


203385 02-Feb-2010 mav

- Use separate buffer for identify data fetching. We can't use main buffer
here if device already running, as data need to be formatted before use.
- Remove some saved_ccb variables. They are unused now.


203384 02-Feb-2010 mav

Some missed parts for r203376.


203376 02-Feb-2010 mav

- Give ATA/SATA SIMs info about ATAPI packet size, supported by device.
- Make ATA XPT to reject longer SCSI CDBs then supported by device, or
any SCSI CDBs, if device doesn't support ATAPI.


203108 28-Jan-2010 mav

MFp4: Large set of CAM inprovements.

- Unify bus reset/probe sequence. Whenever bus attached at boot or later,
CAM will automatically reset and scan it. It allows to remove duplicate
code from many drivers.
- Any bus, attached before CAM completed it's boot-time initialization,
will equally join to the process, delaying boot if needed.
- New kern.cam.boot_delay loader tunable should help controllers that
are still unable to register their buses in time (such as slow USB/
PCCard/ CardBus devices), by adding one more event to wait on boot.
- To allow synchronization between different CAM levels, concept of
requests priorities was extended. Priorities now split between several
"run levels". Device can be freezed at specified level, allowing higher
priority requests to pass. For example, no payload requests allowed,
until PMP driver enable port. ATA XPT negotiate transfer parameters,
periph driver configure caching and so on.
- Frozen requests are no more counted by request allocation scheduler.
It fixes deadlocks, when frozen low priority payload requests occupying
slots, required by higher levels to manage theit execution.
- Two last changes were holding proper ATA reinitialization and error
recovery implementation. Now it is done: SATA controllers and Port
Multipliers now implement automatic hot-plug and should correctly
recover from timeouts and bus resets.
- Improve SCSI error recovery for devices on buses without automatic sense
reporting, such as ATAPI or USB. For example, it allows CAM to wait, while
CD drive loads disk, instead of immediately return error status.
- Decapitalize diagnostic messages and make them more readable and sensible.
- Teach PMP driver to limit maximum speed on fan-out ports.
- Make boot wait for PMP scan completes, and make rescan more reliable.
- Fix pass driver, to return CCB to user level in case of error.
- Increase number of retries in cd driver, as device may return several UAs.


201990 10-Jan-2010 mav

- Report SATA in legacy emulation mode still as SATA.
- Make ATA XPT able to handle such case.


201758 07-Jan-2010 mbr

Remove extraneous semicolons, no functional changes.

Submitted by: Marc Balmer <marc@msys.ch>
MFC after: 1 week


201139 28-Dec-2009 mav

Add BIO_DELETE support to ada(4):
- For SSDs use TRIM feature of DATA SET MANAGEMENT command, as defined by
ACS-2 specification working draft.
- For CompactFlash use CFA ERASE command, same as ad(4) does.

With this patch, `newfs -E /dev/ada1` was able to restore write speed of
my heavily weared OCZ Vertex SSD (firmware 1.4) up to the initial level
for the most part of it's capacity. Previous 1.3 firmware, even reportiong
TRIM capabilty bit set, was not working, reporting ABORT error for every
DSM command.

I have no idea whether it is normal, but for some reason it takes 200ms
to handle any TRIM command on this drive, that was making delete extremely
slow. But TRIM command is able to accept long list of LBAs and the length of
that list seems doesn't affect it's execution time. Implemented request
clusting algorithm allowed me to rise delete rate up to reasonable numbers,
when many parallel DELETE requests running.


200969 24-Dec-2009 mav

Report stripe size only if physical sector size is not equal to logical.


200668 18-Dec-2009 mav

Remove duplicate devstat_start_transaction_bio() call. It is already called
from geom_disk. Dulicate call causes wrong queue depth and busy accounting.


200295 09-Dec-2009 mav

Clear result before requesting XPT_PATH_INQ.
Many SIMs doesn't fill maxio field yet.


200218 07-Dec-2009 mav

MFp4;
- Cleanup kernel messages, mostly PMP.
- Took references on devices, while PMP reinitializes them, to not let them
go and distort freeze reference counting.


200180 06-Dec-2009 mav

MFp4:
If we panicked with SIM lock held, do not try to flush caches.
Extra lock recursing will not make debugging easier.


200171 06-Dec-2009 mav

MFp4:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into
cam(4) interface modules. When enabled, this options deprecates all ata(4)
peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers
(ada, cd, ...) and interfaces to be natively used instead.

As side effect of this, ata(4) mode setting code was completely rewritten
to make controller API more strict and permit above change. While doing
this, SATA revision was separated from PATA mode. It allows DMA-incapable
SATA devices to operate and makes hw.ata.atapi_dma tunable work again.

Also allow ata(4) controller drivers (except some specific or broken ones)
to handle larger data transfers. Previous constraint of 64K was artificial
and is not really required by PCI ATA BM specification or hardware.

Submitted by: nwitehorn (powerpc part)


200036 02-Dec-2009 scottl

Fix several cases where the periph lock was held over malloc.

Submitted by: Jaakko Heinonen


200008 01-Dec-2009 mav

Add CAM_ATAIO_DMA ATA command flag to mark DMA protocol commands.
It is not needed for SATA controllers, but required for PATA.


199821 26-Nov-2009 mav

MFp4:
Improve ATA mode/SATA revision control.


199799 25-Nov-2009 mav

Fix small copu-paste bug.


199747 24-Nov-2009 mav

MFp4:
- Extend XPT-SIM transfer settings control API. Now it allows to report to
SATA SIM number of tags supported by each device, implement ATA mode and
SATA revision negotiation for both SATA and PATA SIMs.
- Make ahci(4) and siis(4) to use submitted maximum tag number, when
scheduling requests. It allows to support NCQ on devices with lower tags
count then controller supports.
- Make PMP driver to report attached devices connection speeds.
- Implement ATA mode negotiation between user settings, device and
controller capabilities.


199321 16-Nov-2009 mav

Disable PortMultiplier Async Notifications for time of ports reset.
They are useless at that time, but confuse Marvell AHCI.

Add quirk for SiI57XX Port Multipliers, to hide extra port.


199281 14-Nov-2009 mav

MFp4:
Some more missed parts from previous commits.


199280 14-Nov-2009 mav

MFp4:
Remove code that years ago was closing race between request submission
to SIM and device/SIM freeze. That race become impossible after moving from
spl to mutex locking, while this workaround causes some unexpected effects.


199279 14-Nov-2009 mav

MFp4:
Fix several device freeze counting bugs.


199263 14-Nov-2009 mav

MFp4:
Do not enable tagged queueing if controller reports 0 tags support.


199178 11-Nov-2009 mav

MFp4:
- Move tagged queueing control from ADA to ATA XPT. It allows to control
device command queue length correctly. First step to support < 32 tags.
- Limit queue for non-tagged devices by 2 slots for ahci(4) and siis(4).
- Implement quirk matching for ATA devices.
- Move xpt_schedule_dev_sendq() from header to source file.
- Move delayed queue shrinking to the more expected place - element freeing.
- Remove some SCSIsms in ATA.


198947 05-Nov-2009 mav

MFp4:
Implement device stats accounting for ATA commands.


198905 04-Nov-2009 mav

Fix protype.


198904 04-Nov-2009 mav

PMP commands use short format. PMP write doesn't return result.


198899 04-Nov-2009 mav

MFp4:
- Remove CAM_PERIPH_POLLED flag. It is broken by design. Polling can't be
periph flag. May be SIM, may be CCB, but now it works fine just without it.
- Remove check unused for at least five years. If we will ever have non-BIO
devices in CAM, this check is smallest of what we will need.
- If several controllers complete requests same time, call swi_sched()
only once.


198897 04-Nov-2009 mav

MFp4:
- Add support for sector size > 512 bytes and physical sector of several
logical sectors, introduced by ATA-7 specification.
- Remove some obsoleted code.


198849 03-Nov-2009 mav

MFp4:
Improve reporting ATA Status error details.


198832 02-Nov-2009 thompsa

Provide the same sanity check on the sector size in dagetcapacity as when the
disk is first probed. dagetcapacity is called whenever the disk is opened from
geom via d_open(), a zero sector size will cause geom to panic later on.


198782 02-Nov-2009 mav

The async callback could free the device. If it is a broadcast async,
it doesn't hold device reference, so take our own reference.

Submitted by: thompsa


198748 01-Nov-2009 mav

MFp4:
Fix reference counting bug, when device unreferenced before then
invalidated. To do it, do not handle validity flag as another
reference, but explicitly modify reference count each time flag is
modified.

Discovered by: thompsa


198708 31-Oct-2009 mav

MFp4:
- Reduce code duplication in ATA XPT and PMP driver.
- Move PIO size setting from ada driver to ATA XPT. It is XPT business
to negotiate transfer details. ada driver is now stateless.
- Report PIO size to SIM. It is required for correct PATA SIM operation.
- Tune PMP scan timings. It workarounds some problems with SiI.
- If reset hapens during PMP initialization - restart it.
- Introduce early-initialized periph drivers, which are used during initial
scan process. Use it for xpt, probe, aprobe and pmp. It gives pmp chance
to finish scan before mountroot and numerate devices in right order.


198705 31-Oct-2009 mav

MFp4:
Ensure target/lun passed from user-level supported on this bus.
Scanning unsupported IDs causes different issues from duplicate
devices to system crash.


198394 23-Oct-2009 mav

Make "Retrying Command" to be printed before actual retrying.
It should make debug/error log a bit more readable.


198389 23-Oct-2009 mav

MFp4:
Move Port Multiplier support code out of ATA XPT into pmp periph driver.
This is convinient, as PMP itself is a bus target and has own state.


198385 23-Oct-2009 mav

Fix the build.


198382 23-Oct-2009 mav

Replace most of priority numbers with defines. No logical changes.


198381 23-Oct-2009 mav

Remove some obsoleted comments.


198377 22-Oct-2009 mav

After thinking again, implement cam_ccbq_fini().
This is effectively NULL change, but makes this API a bit more consistent.


198372 22-Oct-2009 mav

cam_ccbq_fini() declared for 11 years, but never implemented. Remove it.


198356 22-Oct-2009 brueffer

Fix a memory leak in an error case.

PR: 138376
Submitted by: Patroklos Argyroudis <argp@census-labs.com>
Reviewed by: scottl
MFC after: 1 week


198333 21-Oct-2009 mav

MFp4:
Do not search for bus when it is not needed,


198331 21-Oct-2009 mav

MFp4:
Separate CAM_DEV_IDENTIFY_DATA_VALID flag from CAM_DEV_INQUIRY_DATA_VALID.
Add workaround for very old devices without support for mode setting.
Add some PATA bus scanning support.
Remove some SCSIsms.


198328 21-Oct-2009 mav

MFp4:
Add support for PIO-only devices.
Fix maxio values and 256 sectors transactions for 28bits commands.
Implement periodic ordered commands insertion, sames as da driver does.
Remove some SCSIsms.


198322 21-Oct-2009 mav

MFp4:
Report real max_target = 15. SIM doesn't need to know that target 15 is PMP.
It is XPT business.


197896 09-Oct-2009 pjd

Export disk serial numbers for adaX disks.

Reviewed by: mav
MFC after: 3 days


197541 27-Sep-2009 mav

Report SATA 3.x devices.


197421 22-Sep-2009 mav

MFp4:
If on sense request device returns no sence, give up and return,
or we may loop forever.


197332 19-Sep-2009 mjacob

Remember to unlock the peripheral prior to notifying the user. Make some
allocations M_NOWAIT so that we don't try and sleep with a nested non-sleepable
lock.

This makes the userland scsi_target begin to function again.

Obtained from: Sean Bruno
MFC after: 1 month


197208 15-Sep-2009 ken

Fix some instances where CAM rescans get hung up or take a long time to
complete.

Also, allow xpt_rescan() to rescan a LUN instead of a full bus.

MFC after: 3 days
Sponsored by: Copan Systems, Inc.


197134 12-Sep-2009 rwatson

Use C99 initialization for struct filterops.

Obtained from: Mac OS X
Sponsored by: Apple Inc.
MFC after: 3 weeks


196983 08-Sep-2009 scottl

Free the correct buffer in an error case.

Submitted by: phk


196970 08-Sep-2009 phk

Revert previous commit and add myself to the list of people who should
know better than to commit with a cat in the area.


196969 08-Sep-2009 phk

Add necessary include.


196903 06-Sep-2009 mav

MFp4:
Remove duplicate qfrozen_cnt variable from struct cam_ed.
ccbq.queue.qfrozen_cnt should be used instead.


196901 06-Sep-2009 mav

Remove unneeded CAM_SIM_MPSAFE check.


196900 06-Sep-2009 mav

s/bus %d/scbus%d/ in some messages to correct terminology.


196898 06-Sep-2009 mav

MFp4:
Report scbusX in xpt_announce_periph() to less confuse users by two
different bus addressing schemes.


196897 06-Sep-2009 mav

Avoid extra swi_sched() call, if this SIM is already queued.
It reduces overhead for coalesced command completions.


196824 04-Sep-2009 pjd

Make serial numbers of daX disks visible by GEOM.

No objections from: scottl
Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl)


196659 30-Aug-2009 mav

Short ATA command format has 28bit address, not 36bit.
Rename ata_36bit_cmd() into ata_28bit_cmd(), while it didn't become legacy.

MFC after: 2 days


196657 30-Aug-2009 mav

ATA_FLUSHCACHE is a 36bit format command, not 48.


196568 26-Aug-2009 stas

- Add quirk for Sony DSC digital cameras. This umass devices fail
to attach without these quirks applied.

PR: usb/137035
URL: http://lists.freebsd.org/pipermail/freebsd-current/2009-August/010852.html
Reported by: Henri Hennebert <hlh@restart.be>, Andrey V. Elsukov <bu7cher@yandex.ru>
MFC after: 1 week


196353 18-Aug-2009 mav

Fix copy/paste bug, that requests data read during ATA device probe sequence
for ATA_SETFEATURES/ATA_SF_SETXFER command which by definition transfers no
data. Most of controllers are irrelevant to this bug, but some nVidia's
doesn't.

Tested on: current@
Approved by: re (kib)


196352 18-Aug-2009 mav

Fix iSCSI initiator and vpo driver operation, broken by CAM changes.

Reviewed by: scottl, Danny Braniss
Approved by: re (rwatson)


196008 01-Aug-2009 mjacob

Add 8Gb support (isp_2500). Fix a fair number of configuration and
firmware loading bugs.

Target mode support has received some serious attention to make it
more usable and stable.

Some backward compatible additions to CAM have been made that make
target mode async events easier to deal with have also been put
into place.

Further refinement and better support for NP-IV (N-port Virtualization)
is now in place.

Code for release prior to RELENG_7 has been stripped away for code clarity.

Sponsored by: Copan Systems

Reviewed by: scottl, ken, jung-uk kim
Approved by: re


195748 17-Jul-2009 mav

Fix copy-paste bug. Use regular non-polled mode for executing FLUSHCACHE
command on disk close.

Approved by: re (implicitly)


195688 14-Jul-2009 emaste

Change xpt_scan_bus to scsi_scan_bus and xpt_scan_lun to scsi_scan_lun
in comments and printfs to match new function names after refacoring.

Approved by: re


195685 14-Jul-2009 emaste

Fix leaks in probestart, probedone, and scsi_scan_bus. Also free
page_list using the matching malloc type for the allocation.

Approved by: re
Reviewed by: scottl [1]
MFC after: 1 week

[1] Original patch was against xpt_cam.c, prior to the cam refactoring.


195665 13-Jul-2009 mav

Fix copy-paste bug, enabling SIM PMP support, when it was not really found.

Approved by: re (implicitly)


195653 13-Jul-2009 mav

Rename ATA probe driver to "aprobe" to resolve name conflict with SCSI
and fix loading cam as module.

Approved by: re (implicitly)


195534 10-Jul-2009 scottl

Separate the parallel scsi knowledge out of the core of the XPT, and
modularize it so that new transports can be created.

Add a transport for SATA

Add a periph+protocol layer for ATA

Add a driver for AHCI-compliant hardware.

Add a maxio field to CAM so that drivers can advertise their max
I/O capability. Modify various drivers so that they are insulated
from the value of MAXPHYS.

The new ATA/SATA code supports AHCI-compliant hardware, and will override
the classic ATA driver if it is loaded as a module at boot time or compiled
into the kernel. The stack now support NCQ (tagged queueing) for increased
performance on modern SATA drives. It also supports port multipliers.

ATA drives are accessed via 'ada' device nodes. ATAPI drives are
accessed via 'cd' device nodes. They can all be enumerated and manipulated
via camcontrol, just like SCSI drives. SCSI commands are not translated to
their ATA equivalents; ATA native commands are used throughout the entire
stack, including camcontrol. See the camcontrol manpage for further
details. Testing this code may require that you update your fstab, and
possibly modify your BIOS to enable AHCI functionality, if available.

This code is very experimental at the moment. The userland ABI/API has
changed, so applications will need to be recompiled. It may change
further in the near future. The 'ada' device name may also change as
more infrastructure is completed in this project. The goal is to
eventually put all CAM busses and devices until newbus, allowing for
interesting topology and management options.

Few functional changes will be seen with existing SCSI/SAS/FC drivers,
though the userland ABI has still changed. In the future, transports
specific modules for SAS and FC may appear in order to better support
the topologies and capabilities of these technologies.

The modularization of CAM and the addition of the ATA/SATA modules is
meant to break CAM out of the mold of being specific to SCSI, letting it
grow to be a framework for arbitrary transports and protocols. It also
allows drivers to be written to support discrete hardware without
jeopardizing the stability of non-related hardware. While only an AHCI
driver is provided now, a Silicon Image driver is also in the works.
Drivers for ICH1-4, ICH5-6, PIIX, classic IDE, and any other hardware
is possible and encouraged. Help with new transports is also encouraged.

Submitted by: scottl, mav
Approved by: re


194990 25-Jun-2009 kib

Change the type of uio_resid member of struct uio from int to ssize_t.
Note that this does not actually enable full-range i/o requests for
64 architectures, and is done now to update KBI only.

Tested by: pho
Reviewed by: jhb, bde (as part of the review of the bigger patch)


194627 22-Jun-2009 scottl

Change cam_periph_ioctl() to take 'cmd' and a u_long instead of an
int. All of its callers pass in cmd as a u_long, so this has
always been a dangerous type demotion. It was spooted by clang/llvm
trying to do a type promotion and sign extension within
cam_periph_ioctl.

Submitted by: rdivacky


194189 14-Jun-2009 ed

Include <camlib.h> for cam_path_string().

Submitted by: Pawel Worach


193951 10-Jun-2009 kib

Adapt vfs kqfilter to the shared vnode lock used by zfs write vop. Use
vnode interlock to protect the knote fields [1]. The locking assumes
that shared vnode lock is held, thus we get exclusive access to knote
either by exclusive vnode lock protection, or by shared vnode lock +
vnode interlock.

Do not use kl_locked() method to assert either lock ownership or the
fact that curthread does not own the lock. For shared locks, ownership
is not recorded, e.g. VOP_ISLOCKED can return LK_SHARED for the shared
lock not owned by curthread, causing false positives in kqueue subsystem
assertions about knlist lock.

Remove kl_locked method from knlist lock vector, and add two separate
assertion methods kl_assert_locked and kl_assert_unlocked, that are
supposed to use proper asserts. Change knlist_init accordingly.

Add convenience function knlist_init_mtx to reduce number of arguments
for typical knlist initialization.

Submitted by: jhb [1]
Noted by: jhb [2]
Reviewed by: jhb
Tested by: rnoland


192019 12-May-2009 trasz

Remove dead code.

Found with: Coverity Prevent(tm)
CID: 3667


192016 12-May-2009 trasz

Add missing free(9) in error case.

Found with: Coverity Prevent(tm)
CID: 4224


192015 12-May-2009 trasz

Add missing 'break' statements.

Found with: Coverity Prevent(tm)
CID: 3936, 3937
Reviewed by: scottl@


191304 20-Apr-2009 ed

Get rid of the device index number stored in the sa(4) unit number.

The device index number stored in the unit number of sa(4) devices is
only used to print debug messages. Get rid of this index number and use
devtoname() to just print the entire device name.


191243 18-Apr-2009 ed

Remove unused SESUNIT() macro from ses(4).


190878 10-Apr-2009 thompsa

Revert r190676,190677

The geom and CAM changes for root_hold are the wrong solution for USB design
quirks.

Requested by: scottl


190677 03-Apr-2009 thompsa

Add interleaving root hold tokens from the CAM probe to disk_create and geom
provider tasting. This is needed for disk attachments that happen after threads
are running in the boot process.

Tested by: rnoland


188688 16-Feb-2009 scottl

GCC attacks!


188671 16-Feb-2009 scottl

Fix parallel SCSI negotiation in the CAM_NEW_TRAN_CODE world order.
Overzealous sanity checks were locking the sync_rate and offset values to
zero, thanks to a twisty maze of recursive code.


188670 16-Feb-2009 scottl

Instrument the probe state machine so that things like DV can be tracked.


188570 13-Feb-2009 scottl

In the case that the probe has determined that it can't query the device for
a serial number, fall through to the next case so that initial negotiation
still happens. Without this, devices were showing up with only 1 available
tag opening, leading to observations of very poor I/O performance.

This should fix problems reported with VMWare Fusion and ESX. Early
generation MPT-SAS controllers with SATA disks might also be affected.
HP CISS controllers are also likely affected, as are many other
pseudo-scsi disk subsystems.


188503 11-Feb-2009 jhb

Reorder dacleanup() and cdcleanup() slightly so that the sysctl context is
freed while the periph lock is not held. While here, wait until after
freeing the softc before reacquiring the periph lock.

Tested by: sbruno


188458 10-Feb-2009 jhb

Adding dynamic sysctls no longer requires Giant.

Submitted by: rdivacky


188395 09-Feb-2009 fjoe

cam_periph_alloc: fix "invalid periph name" error condition

Found with: Coverity Prevent(tm)
CID: 130


188345 08-Feb-2009 trasz

Remove an overzealous check.

Submitted by: das
Reviewed by: scottl
Approved by: rwatson (mentor, implicit)
Sponsored by: FreeBSD Foundation


187957 31-Jan-2009 bz

There is no need to initialize the variable here.

Submitted by: Christoph Mallon christoph.mallon@gmx.de
Reviewed by: kib (as part of a larger patch)
MFC after: 2 weeks


187718 26-Jan-2009 jhb

Now that mtx_sleep/msleep can accept Giant as the interlock, simplify the
CAM locking code slightly to no longer special case sleeping when a sim
uses Giant for its lock.

Tested by: trasz


187652 23-Jan-2009 trasz

Protect against NULL pointer dereference.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


187651 23-Jan-2009 trasz

Don't leak memory when alloc fails.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 2908


187650 23-Jan-2009 trasz

Guard against NULL pointer dereference.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 1847


187649 23-Jan-2009 trasz

Guard against NULL pointer dereference.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 130


187247 14-Jan-2009 trasz

Add missing 'break' statement.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3667


187245 14-Jan-2009 trasz

Fix use after free.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3712


187244 14-Jan-2009 trasz

Remove unused variable.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3665


187243 14-Jan-2009 trasz

Add missing 'break' statement.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Found with: Coverity Prevent(tm)
CID: 3927


187028 10-Jan-2009 trasz

Don't call destroy_dev(9) with a mutex held. While here, shuffle
things around so the periph destructors look alike. Based on a patch
by Jaakko Heinonen.

Submitted by: Jaakko Heinonen
Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186905 08-Jan-2009 trasz

Make "kldunload atapicam" return EBUSY instead of deadlocking when a device
created by atapicam is being kept opened or mounted. This is probably just
a temporary solution until we invent something better.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Reported by: Jaakko Heinonen


186891 08-Jan-2009 raj

cam: Retry TEST UNIT READY command if not successful.

This fixes problems with discovering some USB devices that are very slow to
respond during initialisation.

When a USB device is inserted, CAM performs the sequence:
1) INQUIRY
2) INQUIRY (second time with other parameters)
3) TEST UNIT READY
4) READ CAPACITY

Before this change CAM didn't check if TEST UNIT READY was successful and went
on blindly to the next state and sent READ CAPACITY. If the device was still
not ready by then, CAM ended with error message. This patch adds checking for the
status of TEST UNIT READY command and retrying up to 10 times with 0.5 sec
interval.

Submitted by: Grzegorz Bernacki gjb ! semihalf dot com
Reviewed by: scottl


186882 08-Jan-2009 imp

Make it possible to override the number of retries for the CD media.
When trying to read scratched or damaged CDs and DVDs, the default
mechanism is sub-optimal. Programs like ddrescue do much better if
you turn off retries entirely, since their algorithms are designed
scan big areas fast, then winnow the areas down. Turning off retries
speeds these programs up by as much as 20x, since the drive is able to
'stream past' many small errors...

The sysctl/tunable kern.cam.cd.retry_count controls this. That
defaults to '4' (for a total of 5 attempts). Setting to 0 turns off
all retry attempts.

Reviewed by: scottl@


186424 23-Dec-2008 remko

Add quirk for the Storcase InfoStation 12bay
SATA to FC SAN.

PR: 129858
Submitted by: Nick Triantos <nick-freebsd at triantos dot com>
MFC after: 1 week


186396 22-Dec-2008 scottl

Fix a comment to reflect what really happens.


186371 21-Dec-2008 scottl

Fix refcount locking in cd, pass, and sg periphs.


186320 19-Dec-2008 trasz

Fix cam_sim_free() wakeup condition and add mtx_asserts.

Submitted by: Christoph Mallon
Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186319 19-Dec-2008 trasz

Periph driver fixes, second try.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186318 19-Dec-2008 trasz

Move mtx_assert lower, when we can be sure that the pointer
to the mutex is valid.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186219 17-Dec-2008 trasz

Revert r186186 for now; it breaks stuff.

Approved by: rwatson (mentor)


186186 16-Dec-2008 trasz

Fix locking in periph drivers - don't try to unlock periph
that was already deallocated.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186185 16-Dec-2008 trasz

Add SIM refcounting. This is slightly different from what DragonFly
does - in DragonFly, it's cam_sim_release() what actually frees the
SIM; cam_sim_free does nothing more than calling cam_sim_release().
Here, we drain in cam_sim_free, waiting for refcount to drop to zero.
We cannot do the same think DragonFly does, because after cam_sim_free
returns, client would destroy the sim->mtx, and CAM would trip over
an initialized mutex.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


186184 16-Dec-2008 trasz

Get rid of dead_sim. There is no way to make it work - any attempt
to actually use it would panic on mtx operation, as dead_sim doesn't
have a proper mutex. Even if it had a properly initialized mutex,
it wouldn't have properly locked and owned one.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


184205 23-Oct-2008 des

Retire the MALLOC and FREE macros. They are an abomination unto style(9).

MFC after: 3 months


183397 27-Sep-2008 ed

Replace all calls to minor() with dev2unit().

After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by: kib


183381 26-Sep-2008 ed

Remove unit2minor() use from kernel code.

When I changed kern_conf.c three months ago I made device unit numbers
equal to (unneeded) device minor numbers. We used to require
bitshifting, because there were eight bits in the middle that were
reserved for a device major number. Not very long after I turned
dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
The unit2minor() and minor2unit() macro's were no-ops.

We'd better not remove these four macro's from the kernel, because there
is a lot of (external) code that may still depend on them. For now it's
harmless to remove all invocations of unit2minor() and minor2unit().

Reviewed by: kib


183145 18-Sep-2008 sbruno

Add a new cam_status CAM_SCSI_IT_NEXUS_LOST. This will be used by future patches
for target mode that are forthcoming.

Reviewed by: Scott Long
MFC after: 2 days


182433 29-Aug-2008 scottl

Fix a locking mistake in daopen(). If the open fails, which can happen
because the media was removed, the periph would get its refcount dropped
and ultimately freed before getting unlocked. This created a dangling
pointer that was easy to trip over. This fixes a common source of
crashes with removaable media, but problems remain and will get tracked
down.


181791 16-Aug-2008 ken

SCSI_DELAY is specified in milliseconds, not seconds.

Submitted by: Andre Albsmeier <Andre.Albsmeier@siemens.com>
MFC after: 1 week


181381 07-Aug-2008 jkim

Update SCSI opcodes and ASCs from t10.org.

http://www.t10.org/lists/1spc-lst.htm

Note opcodes for scanner and communication devices are taken from the previous
revision because they are not listed in the files any more.
Also, note newly added ASCs are all marked with 'XXX TBD' and take SS_RDEF action
for now. Some ASCs need SS_TUR for error recovery or SS_FATAL to prevent further
retrials. We should deal with them later.

Reviewed by: scottl, ken


181126 01-Aug-2008 emaste

Fix whitespace.


180389 09-Jul-2008 remko

Add quirk for the Samsung YP-U3

PR: 125398
Submitted by: Tino Engel <goaengel at gmx dot net>
Approved by: imp (mentor, implicit)
MFC after: 1 week


177304 17-Mar-2008 scottl

Locking in the ses_ioctl handler doesn't have to be so strict because
the referenced data is only obtained/changed in the device open handler,
and the ioctl handler can only run after the open handler. Also fix a
few nearby style issues.

Submitted by: Matt Jacob


176623 27-Feb-2008 scottl

When probing a newly found device, don't automatically assume that the
device supports retrieving a serial number. Instead, first query the
list of VPD pages it does support, and only query the serial number if
it's supported, else silently move on. This eliminates a lot of noise
during verbose booting, and will likely eliminate the need for most
NOSERIAL quirks.


176577 26-Feb-2008 scottl

Add a missing unlock to an error path fro XPT_DEBUG handling.


176426 20-Feb-2008 scottl

Fix a couple of locking mistakes in the ses_ioctl path.

Submitted by: Matt Jacob


176204 12-Feb-2008 raj

Fix typo.

Approved by: cognet (mentor)


175766 28-Jan-2008 brueffer

Correct the kernel config hint in a printf statement.

Submitted by: R.Mahmatkhanov <cvs-src@yandex.ru>
Reviewed by: scottl
Approved by: rwatson (mentor)
MFC after: 3 days


175246 12-Jan-2008 maxim

o Correct EasyMP3 EM732X usb 2.0 flash mp3 player revision:
it's 1.00 not 1.0.

PR: usb/96546
Submitted by: Eugene Grosbein
MFC after: 1 month


175054 02-Jan-2008 obrien

style(9)


174898 25-Dec-2007 rwatson

Add a new 'why' argument to kdb_enter(), and a set of constants to use
for that argument. This will allow DDB to detect the broad category of
reason why the debugger has been entered, which it can use for the
purposes of deciding which DDB script to run.

Assign approximate why values to all current consumers of the
kdb_enter() interface.


174654 16-Dec-2007 scottl

Add a missing mutex unlock.

Reported by: Michael Jung


174534 11-Dec-2007 davidxu

Add quirks for Netac Onlydisk 2000 USB disk.


173639 15-Nov-2007 scottl

Fix a change in the previous commit that was actually a type-o.


172836 20-Oct-2007 julian

Rename the kthread_xxx (e.g. kthread_create()) calls
to kproc_xxx as they actually make whole processes.
Thos makes way for us to add REAL kthread_create() and friends
that actually make theads. it turns out that most of these
calls actually end up being moved back to the thread version
when it's added. but we need to make this cosmetic change first.

I'd LOVE to do this rename in 7.0 so that we can eventually MFC the
new kthread_xxx() calls.


172605 12-Oct-2007 scottl

Add a bunch of definitions and structures to support newer drivers.


171529 21-Jul-2007 kan

Do not forget to cam_periph_unhold the peripheral before exiting
due to error.

PR: kern/114636
Submitted by: Tijl Coosemans
Approved by: re (hrs)


171142 01-Jul-2007 imp

After talking with njl@, change this wildcard entry to be a bit less wild.

Approved by: re (blanket)


171118 30-Jun-2007 imp

Quirk for WD Mybook. Seems they do not like serial number queries.

Submitted by: Jason Harris
PR: 107495
Approved by: re@ (blanket)


171116 30-Jun-2007 imp

Quirk for ChipsBnk usb stick

Submitted by: Mark Andrews
PR: 103702
Approved by: re@ (blanket)


171115 30-Jun-2007 imp

Add quirk for JoyFly 128mb USB Flash Drive

submitted by: Toni Schmidbauer
PR: 96133
Approved by: re@ (blanket)


171109 30-Jun-2007 imp

quirk for I/O Magic USB flash drive "Giga Bank"

Submitted by: Jeff Anton
PR: 108810
Approved by: re@ (blanket)


171108 30-Jun-2007 imp

Samsung MP0402H quirk

Submitted by: Gipsy<wint3r@securimail.com>
PR: 108427
Approved by: re@ (blanket)


171106 30-Jun-2007 imp

Add support for JNC MP3 Player

Submitted by: User & <dhenin@cypries.cyclopes.org>
PR: 94439
Approved by: re (blanket)


171102 30-Jun-2007 imp

Philips USB Key Audio KEY013

Submitted by: Arnoud Engelfriet
PR: 68412
Approved by: re (blanket)


171075 28-Jun-2007 imp

Support for iRiver U10 USB connection

PR: 92306
Submitted by: Soren Dossing
Approved by: re (blanket)


171072 28-Jun-2007 imp

Quirk for Denver MP3 player usb.

Submitted by: Ed Schouten
PR: 107101
Approved by: re (blanket for device supprot)


170872 17-Jun-2007 scottl

Prepare for future integration between CAM and newbus. xpt_bus_register
now takes a device_t to be the parent of the bus that is being created.
Most SIMs have been updated with a reasonable argument, but a few exceptions
just pass NULL for now. This argument isn't used yet and the newbus
integration likely won't be ready until after 7.0-RELEASE.


170831 16-Jun-2007 scottl

Revert an accidental change from the previous rev.


170830 16-Jun-2007 scottl

Work around the other uses of M_WAITOK.


170829 16-Jun-2007 scottl

Work around a malloc locking problem.


170485 10-Jun-2007 mjacob

Commit for Nate his "guidelines for submitting quirks".


170289 04-Jun-2007 dwmalone

Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported. In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.


170118 29-May-2007 mjacob

Add a placeholder document to be filled out by Nate which will describe
in detail the procedure for getting device quirks into the CAM subsystem.


170116 29-May-2007 mjacob

Back out 1.212 at Nate's request in order to go through the
actual formal process he's trying to get established for quirks..


170080 29-May-2007 mjacob

Use the Hitachi 2.5" HD, 120 GB as a USB device.

Submitted by: Joakim Bentholm`
MFC after: 3 days


169901 23-May-2007 cognet

Remove duplicate includes.

Submitted by: Cyril Nguyen Huu <cyril ci0 org>


169687 18-May-2007 mjacob

Zero scsi_readcapacity allocations so we can really
tell if there has been data returned (for some broken
residual checking points).

MFC after: 3 days


169607 16-May-2007 scottl

Release the bus reference that is acquired when doing a CAMIOCOMMAND
ioctl. This should make SIM removal a bit more robust.


169606 16-May-2007 scottl

Remove an assertion in xpt_print_path() that makes debugging code much more
difficult.


169605 16-May-2007 scottl

Add a helper function for registering async callbacks. Besides
eliminating a lot of duplicated code, this also fixes a locking edge case.


169562 14-May-2007 scottl

Eliminate the use of M_TEMP.


169071 27-Apr-2007 scottl

Only schedule the xpt_finishconfig_task once. This fixes some potential
panics on boot.


168982 23-Apr-2007 scottl

Remove obsolete headers. Move kernel specific headers under #ifdefs


168882 19-Apr-2007 scottl

Retire the spl() markers. Add in some minor missed locking as a result.


168876 19-Apr-2007 scottl

Inline cam_periph_lock|unlock to make debugging easier. Use more
CAM_SIM_LOCK() more uniformly.


168874 19-Apr-2007 scottl

Fix a leaked lock in dashutdown.


168872 19-Apr-2007 scottl

Avoid problems with make_dev.


168865 19-Apr-2007 scottl

Zero the CCBs when mallocing them.


168864 19-Apr-2007 scottl

Split the camisr into per-SIM done queues. This optimizes the locking a
little bit and allows for direct dispatch of the doneq from certain
contexts that would otherwise face recursive locking problems.


168832 18-Apr-2007 scottl

Missed locking the dump and shutdown entry points in the scsi_da driver.


168831 18-Apr-2007 scottl

Revert a driver API change to xpt_alloc_ccb that isn't necessary. Fix a
couple of associated error checks.


168797 17-Apr-2007 scottl

Don't delete the devalias, as per the man page.

Submitted by: jmg


168788 16-Apr-2007 scottl

For the XPT_SASYNC_CB operation, only decouple the broadcast to the bus
and device lists instead of decoupling the whole operation. This avoids
problems with SIMs going away.


168787 16-Apr-2007 scottl

Drop the topology lock before calling the periph oninvalidate and dtor
vectors.


168786 16-Apr-2007 scottl

Drop the periph/sim lock when calling disk_destroy().


168785 16-Apr-2007 scottl

Destroy the devalias before destroying the dev.


168752 15-Apr-2007 scottl

Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM will
use to synchornize and protect all data objects that are used for that
SIM. Drivers that are not yet MPSAFE register Giant and operate as
usual. RIght now, no drivers are MPSAFE, though a few will be changed
in the coming week as this work settles down.

The driver API has changed, so all CAM drivers will need to be recompiled.
The userland API has not changed, so tools like camcontrol do not need to
be recompiled.


168598 10-Apr-2007 scottl

A fix for the SG_GET_TIMEOUT function slipped into a previous commit by
accident. Remove the text describing the problem as it is no longer
relevant. Also give real implementations for the GET and SET ioctls.


168527 09-Apr-2007 scottl

Make use of M_ZERO in various malloc calls.


168526 09-Apr-2007 scottl

Fix a logic bug that slipped in at the last minute and apparently escaped
testing.


168477 07-Apr-2007 scottl

Add the CAM 'SG' peripheral device. This device implements a subset of the
Linux SCSI SG passthrough device API. The intention is to allow for both
running of Linux apps that want to talk to /dev/sg* nodes, and to facilitate
porting of apps from Linux to FreeBSD. As such, both native and linuxolator
entry points and definitions are provided.

Caveats:
- This does not support the procfs and sysfs nodes that the Linux SG
driver provides. Some Linux apps may rely on these for operation,
others may only use them for informational purposes.
- More ioctls need to be implemented.
- Linux uses a naming scheme of "sg[a-z]" for devices, while FreeBSD uses a
scheme of "sg[0-9]". Devfs aliasis (symlinks) are automatically created
to link the two together. However, tools like camcontrol only see the
native names.
- Some operations were originally designed to return byte counts or other
data directly as the syscall return value. The linuxolator doesn't appear
to support this well, so this driver just punts for these cases.

Now that the driver is in place, others are welcome to add missing
functionality. Thanks to Roman Divacky for pushing this work along.


167591 15-Mar-2007 mjacob

A silly buglet found by Coverity- check the return value from
cam_periph_acquire.


167082 27-Feb-2007 jhb

Use tsleep() rather than msleep() with a NULL mtx.


166896 23-Feb-2007 mjacob

Add an xpt_rescan function and a thread that will field
rescan requests. The purpose of this is to allow a SIM
(or other entities) to request a bus rescan and have it
then fielded in a different (process) context from the
caller.

There are probably better ways to accomplish this, but
it's a very small change that helps solve a number of
problems.

Reviewed by: Justin, Ken and Scott.
MFC after: 2 weeks


166861 21-Feb-2007 n_hibma

Reduce the noise when plugging in (USB) mass storage devices, like a 4 port
flash card reader.
Also remove an 'Opened da0 -> <random number>' which is not needed on a daily
basis (available through bootverbose).

Reviewed by: phk, ken
MFC after: 1 week


166196 23-Jan-2007 imp

Use the more specific 'EM732X' designation rather than * to disable sync
cache commands, per request from njl@.


166166 22-Jan-2007 imp

Add quirk for EasyMP3 EM732X usb 2.0 flash mp3 player.
(It appears that the quirk proceedures link has disappeared and that
this PR complied with it, if there's a problem, please contact me).

PR: usb/96546


165456 21-Dec-2006 mjacob

fix botch


165448 21-Dec-2006 mjacob

Pay attention to return value from xpt_bus_register in xpt_init.

Obtained from: Xin Li (Coverity)
MFC after: 3 days


165066 10-Dec-2006 mjacob

Make cam_xpt's pronouncements match camcontrol
(Tagged -> Command) Queueing.


164906 05-Dec-2006 mjacob

Add an xpt_print function to reduce most of the xpt_print_path/printf
pairs. Convert the core code to use it.

Reviewed by: scsi (various folks weighing in with good advice)
MFC after: 2 weeks


164894 04-Dec-2006 mjacob

Initial cut at Basic Domain Validation- just add some states to
traverse through during probing.

Reviewed by: scsi (scottl)


164844 03-Dec-2006 mjacob

Remove CTS_SPI_FLAGS_TAG_ENB. Nobody is using it and at least one
author can't remember why it was there.

The CTS_SCSI_FLAGS_TAG_ENB remains in place, and makes sense, and is
checked all over the place.

The CTS_SPI_FLAGS_TAG_ENB was probably an attempt to distinguish
protocol and transport tag capabilities. At the very least this can
be confusing and prone to many bugs, so let's just assume that the
transport tag case just flows from the protocol (and vice versa)
for now.


164624 26-Nov-2006 maxim

o Style: remove a w/space before a comma.


164623 26-Nov-2006 maxim

o Style(9): trim eol w/spaces, w/spaces to tabs, kill an empty line.


164622 26-Nov-2006 maxim

o Add a quirk for X-Micro Flash Disk.

PR: usb/96901
Submitted by: Szalai Andras
Reviewed by: nate (a half of year ago)
MFC after: 3 weeks


164082 07-Nov-2006 mjacob

XPT_GET_TRAN_SETTINGS can fail- so check for an error and
don't blindly assume it succeeded.


164055 07-Nov-2006 mjacob

Fix the hanging chad if the NEW_TRAN_CODE change and change the
qualifier to force async from cur_spi to spi.


163931 03-Nov-2006 njl

Remove extra whitespace


163923 02-Nov-2006 mjacob

Add a tunable that allows one to turn off the automatic sending of
the ORDERED tag. This recoups significant performance gains for many
arrays.

The default is still to send out the ORDERED tag periodically.

Reviewed by: scsi (justin+timeout)


163896 02-Nov-2006 mjacob

2nd and final commit that moves us to CAM_NEW_TRAN_CODE
as the default.

Reviewed by multitudes.


163834 31-Oct-2006 pjd

Implement BIO_FLUSH handling for da(4), amr(4), ata(4) and ataraid(4).

Sponsored by: home.pl


163816 31-Oct-2006 mjacob

The first of 3 major steps to move the CAM layer forward to using
the CAM_NEW_TRAN_CODE that has been in the tree for some years now.

This first step consists solely of adding to or correcting
CAM_NEW_TRAN_CODE pieces in the kernel source tree such
that a both a GENERIC (at least on i386) and a LINT build
with CAM_NEW_TRAN_CODE as an option will compile correctly
and run (at least with some the h/w I have).

After a short settle time, the other pieces (making
CAM_NEW_TRAN_CODE the default and updating libcam
and camcontrol) will be brought in.

This will be an incompatible change in that the size of structures
related to XPT_PATH_INQ and XPT_{GET,SET}_TRAN_SETTINGS change
in both size and content. However, basic system operation and
basic system utilities work well enough with this change.

Reviewed by: freebsd-scsi and specific stakeholders


163101 07-Oct-2006 flz

Add a SCSI da(4) quirk for Rekam USB Camera.

PR: usb/98713
Submitted by: Alex <goo@t72.ru>
MFC after: 3 days


163097 07-Oct-2006 flz

Add SCSI da(4) quirk for the iRiver H10.

PR: usb/102547
Submitted by: Sven Esbjerg <freebsd-pr@xbsd.net>
MFC after: 3 days


162938 01-Oct-2006 mjacob

Put a bit of hysteresis into both BUSY SCSI status returns
and CAM_RESRC_UNAVAIL returns. Delay a tunable amount for
either between retries.

This came up because the MPT IOC was returning "IOC out of
resources" for some user and this caused a CAM_RESRC_UNAVAIL
return. Putting a bit of delay between retries helped them
out.

There was some discussion that an async event should be used
to clear CAM_RESRC_UNAVAIL. That's probably a better notion
eventually.

Reviewed by: scsi@freebsd.org (ade, scott)
MFC after: 1 week


162365 16-Sep-2006 mjacob

Don't allow attachment of disks that could cause GEOM to panic.


162362 16-Sep-2006 mjacob

New Dell 1950/2950 SES backplane drops off the bus if you poke
at greater then lun 0.

MFC after: 1 week


162218 11-Sep-2006 mjacob

null commit to provide commit message to previous
at the request of Sam Leffler: The previous commit
established min and maxtags for VMware pseudo disks
to fix a submitted PR.


162217 11-Sep-2006 mjacob

PR: 103130
Submitted by: Shusuke Shinomiya
MFC after: 1 day


161506 21-Aug-2006 ken

Implement 'camcontrol reportluns'. This allows users to send the SCSI
REPORT LUNS command to a device.

camcontrol.[c8]: Implement reportluns. This tries to print the LUNs
out in a reasonable format. Only the periph
addressing method has been tested, since very little
hardware that I know of supports the other methods.

scsi_all.[ch]: Revamp the report luns CDB structure and helper
functions. This constitutes a little bit of an API
change, but since the old CDB length was 10 bytes,
and the REPORT LUNS CDB length is actually 12 bytes,
it's clear that no one was using this API in the
first place.

MFC After: 1 week


161290 14-Aug-2006 jhb

access only has 2 esses.

MFC after: 3 days


160345 14-Jul-2006 delphij

Drop Giant before returning in error path, thus eliminates
two mutex leaks.

Submitted by: Beyond Luo <fedora ercist iscas ac cn>
PR: kern/100046
Reviewed by: ken, scottl


159941 26-Jun-2006 mjacob

Grumble. VMWare ESX and VMWare WorkStation have *slightly* different
inquiry data (pointlessly different I might add). Pick the common
parts.

MFC after: 1 day


159914 24-Jun-2006 mjacob

VMware disk volumes are only on LUN 0, and
some VMware HBAs have known bugs with commands
sent to other than LUN 0.

MFC after: 1 day


159311 05-Jun-2006 mjacob

Add PIM_SEQSCAN for HBA misc flags and code that understands
what to do with it.

This forces us to scan targets sequentially, not in parallel.
The reason we might want to do this is that SPI negotiation
might not work right at the SIM level if we try to do it
in parallel. We *could* fix this for each SIM where this is
broken, but it's a lot harder to do that when we can simply
ask CAM to probe sequentially.

If PIM_SEQSCAN is not set (default), the original behaviour for
probing is unchanged.

LUN probing is still done in parallel for each target in either
case.

While we're at it, clean up some resource leakage for error
cases.

Reviewed by: ken, scott, scsi@
MFC after: 1 week


159086 30-May-2006 mjacob

Handle some of the inquiry flags that have come into
usage as of SPC2r20. Specifically, handle the BQueue
flag which will indicate that a device supports the
Basic Queueing model (no Head of Queue or Ordered tags).
When this flag is set, SID_CmdQueue is clear. This has
causes FreeBSD to assume that the device did not support
tagged operations.

MFC after: 1 month


158885 24-May-2006 mjacob

Forced commit - last checkin got away from me.

This version of scsi_target.c removes all SMP locking until
we have a lock-aware CAM stack. This allows us to use KNOTE
without a panic at least.

It's not yet clear whether target mode is working yet or not.

Discussed with: Scott, Ken, Nate, Justin


158884 24-May-2006 mjacob

Sorry- last delta was checked in by mistake.


158883 24-May-2006 mjacob

Make physical buffers in cam_periph_mapmem owned by the kernel in case we
return to user space w/o waiting for I/O to complete.

I tried to get several folks who know this code better than me to review it
with no luck. I *do* know that w/o this code, using the SCSI target driver
panics in userret (if it doesn't panic in knote first).


158651 16-May-2006 phk

Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.


157856 18-Apr-2006 mjacob

Actually check to see if XPT_CALC_GEOMETRY had an error
and pick a bogus geometry if it had so we don't later
get a divide by zero trap.


157854 18-Apr-2006 mjacob

Do more guarding against zero divide traps for the geom subroutine.


157806 17-Apr-2006 maxim

o Do not double i/o stats for cd(4) already acounted in g_disk_done().

PR: kern/95707
Submitted by: Andre Albsmeier
Reviewed by: phk
MFC after: 2 weeks


156852 18-Mar-2006 joerg

Add reference to PR to TOSHIBA TransMemory quirk entry.


156844 18-Mar-2006 flz

- Add a PR number for future reference.

Approved by: njl


156692 13-Mar-2006 joerg

Add the TOSHIBA TransMemory USB sticks to the list of devices that
hate "Synchronize cache" commands.

MFC after: 1 day


155063 30-Jan-2006 flz

- Add a scsi_da.c and a umass.c quirk for Genesys 6-in-1 Card Reader.

Reported by: anders on freebsd-usb@
Tested by: anders
Approved by: ssouhlal
MFC after: 3 days


154831 26-Jan-2006 flz

Add Product IDs :
- Sandisk Cruzer Micro 128MB [5]
- DANE-ELEC zMate 512MB USB flash drive [7]
- Attache 256MB USB 2.0 Flash Drive [8]
- Sandisk Cruzer Micro 256MB [9]

Add scsi_da.c quirks :
- Samsung USB key 128Mb [1]
- Kingston DataTraveler 2.0 [2]
- Creative MuVo Slim [3]
- United MP 5512 Portable MP3 Player [4]
- Sandisk Cruzer Micro 128MB [5], [9]
- PNY USB Flash keys [6], [7], [8]

Add umass.c quirks :
- Sandisk Cruzer Micro 128MB [5]
- DANE-ELEC zMate 512MB USB flash drive [7]
- Attache 256MB USB 2.0 Flash Drive [8]
- Sandisk Cruzer Micro 256MB [9]

PR: usb/90081 [1],
usb/89196 [2],
kern/86131 [3],
usb/80487 [4],
usb/75970 [5],
usb/75578 [6],
usb/72344 [7],
usb/65436 [8],
usb/70835 [9]
Submitted by: Henri-Pierre CHARLES <hpc@prism.uvsq.fr> [1],
Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua> [2],
Erich Rickheit KSC <rickheit-fbp@numachi.com> [3],
tnu@chania.di.uoa.gr [4],
Bram Abbekerk <bram@abbekerk.demon.nl> [5],
Thomas Pornin <pornin@bolet.org> [6],
parv <parv@pair.com> [7],
Peter D. Quilty <pdquilty@adelphia.net> [8],
Raymundo M. Vega <rvega@ms-smtp-03-eri0.socal.rr.com> [9]
Approved by: iedowse
MFC after: 3 days


154593 20-Jan-2006 mjacob

CAM_NEW_TRAN_CODE placeholders for SAS support.

Reviewed by: nate, ken, justin
MFC after: 1 month


154504 18-Jan-2006 mjacob

Fix ioctl to not get swallowed by ioctl code (i.e., make sure the darned
code sticks within 8 bits)

MFC after: 1 week


154360 14-Jan-2006 mjacob

Incorporate the O_NONBLOCK open semantics of Linux and Solaris. This allows
an application to upon a tape (yea, even the non-control device) even if
it cannot establish a mount session. If the open cannot establish a mount
session and O_NONBLOCK was specified, the tape becomes 'open pending mount'.
All I/O operations that would require access to a tape thereafter until
a close attempt to initiate the mount session. If the mount session succeeds,
the tape driver transitions to full open state, else returns an appropriate
I/O error (ENXIO).

At the same time, add a change that remembers whether tape is being opened
read-only. If so, disallow 'write' operations like writing filemarks that
bypass the normal read-only filtering operations that happen in the write(2)
syscall.

Reviewed by: ken, justin, grog
MFC after: 2 weeks
Suggested by: The Bacula Team


154297 13-Jan-2006 mnag

Allow to use Time DPA20B 1GB MP3 Player [1]
Allow to use Qware BeatZkey! Pro [2]

PR: usb/81846 [1], usb/79164 [2]
Submitted by: Ruben de Groot <rdg@bzerk.org> [1], Radek Kozlowski <radek@raadradd.com> [2]
Approved by: njl
MFC: 1 week


154207 11-Jan-2006 iedowse

When deregistering a bus, attempt to flush out all outstanding
operations before returning. Point the bus at a dummy cam_sim
structure so that any CCBs will complete immediately with a
CAM_DEV_NOT_THERE status, and ensure that any xpt_schedule() calls
on the bus's devices will immediately call the peripheral's
periph_start() routine. Also repeat the async messages because
devices that were part of the way through being probed may appear
after the original AC_LOST_DEVICE was sent, and would otherwise
never go away.

These changes make it possible to deregister a bus and free the SIM
at most stages during bus probing without the usual crashes in
camisr(). In particular, plugging in a umass device and then
unplugging it as soon as the first probe messages appeared would
almost always result in a crash. Now the device just goes away with
a few CAM errors and all references to the CAM bus, target and
device are dropped correctly.


154119 08-Jan-2006 iedowse

There should be no need to retry when the CCB status code is
CAM_LUN_INVALID or CAM_TID_INVALID. Retries were being triggered
here when a umass device was unplugged, and while the retries
themselves are probably harmless, they complicated finding the real
SIM removal problems.


153529 19-Dec-2005 pjd

Style nit.


153527 19-Dec-2005 pjd

Allow to use TransFlash drive, which can be found in Motorola E398 Mobile Phone.

PR: usb/89889
Submitted by: Wojciech A. Koszek <dunstan@freebsd.czest.pl>
MFC after: 1 week


152565 18-Nov-2005 jdp

Fix a bug that caused some /dev entries to continue to exist after
the underlying drive had been hot-unplugged from the system. Here
is a specific example. Filesystem code had opened /dev/da1s1e.
Subsequently, the drive was hot-unplugged. This (correctly) caused
all of the associated /dev/da1* entries to be deleted. When the
filesystem later realized that the drive was gone it closed the
device, reducing the write-access counts to 0 on the geom providers
for da1s1e, da1s1, and da1. This caused geom to re-taste the
providers, resulting in the devices being created again. When the
drive was hot-plugged back in, it resulted in duplicate /dev entries
for da1s1e, da1s1, and da1.

This fix adds a new disk_gone() function which is called by CAM when a
drive goes away. It orphans all of the providers associated with the
drive, setting an error condition of ENXIO in each one. In addition,
we prevent a re-taste on last close for writing if an error condition
has been set in the provider.

Sponsored by: Isilon Systems
Reviewed by: phk
MFC after: 1 week


150201 16-Sep-2005 mjacob

Make the exploring of all luns supported by an HBA more of a
tunable (until we get REPORT LUNS in place).

If we're probing luns, and each probe succeeds, we keep going past
lun 7 if we're a SCSI3 or better device (until we fail to probe).

If we're probing luns, and a probe fails, we only keep going if
we're quirked *for* it (CAM_QUIRK_HILUNS), and if we're not quirked
*against* it (CAM_QUIRK_NOHILUNS), or we're a SCSI3 or better device
and the tunable (kern.cam.cam_srch_hi) is set non-zero.

Reviewed by: nate@rootlabs.org, gibbs@scsiguy.com, ken@kdm.com, scottl@samsco.org
MFC after: 1 week


148868 08-Aug-2005 rwatson

Merge the dev_clone and dev_clone_cred event handlers into a single
event handler, dev_clone, which accepts a credential argument.
Implementors of the event can ignore it if they're not interested,
and most do. This avoids having multiple event handler types and
fall-back/precedence logic in devfs.

This changes the kernel API for /dev cloning, and may affect third
party packages containg cloning kernel modules.

Requested by: phk
MFC after: 3 days


147730 01-Jul-2005 ssouhlal

Fix the recent panics/LORs/hangs created by my kqueue commit by:

- Introducing the possibility of using locks different than mutexes
for the knlist locking. In order to do this, we add three arguments to
knlist_init() to specify the functions to use to lock, unlock and
check if the lock is owned. If these arguments are NULL, we assume
mtx_lock, mtx_unlock and mtx_owned, respectively.

- Using the vnode lock for the knlist locking, when doing kqueue operations
on a vnode. This way, we don't have to lock the vnode while holding a
mutex, in filt_vfsread.

Reviewed by: jmg
Approved by: re (scottl), scottl (mentor override)
Pointyhat to: ssouhlal
Will be happy: everyone


147723 01-Jul-2005 avatar

- Providing fine-grained malloc statistic by replacing M_DEVBUF with
module-specific malloc types. These should help us to pinpoint the
possible memory leakage in the future.
- Implementing xpt_alloc_ccb_nowait() and replacing all malloc/free based
CCB memory management with xpt_alloc_ccb[_nowait]/xpt_free_ccb. Hopefully
this would be helpful if someday we move the CCB allocator to use UMA
instead of malloc().

Encouraged by: jeffr, rwatson
Reviewed by: gibbs, scottl
Approved by: re (scottl)


147571 24-Jun-2005 avatar

Fixing a memory leak in xpt_release_device(), which can be quickly
(depends on how many memory you have) observed through "tar -tvf /dev/sa0."

Without this patch, RELENG_5 and HEAD panics with something like:

kmem_malloc(4096): kmem_map too small: 42258432 total allocated

RELENG_4 doesn't panic but spews following errors:

camq_init: - cannot malloc array!

Reviewed by: gibbs, scottl
Approved by: re (scottl)
MFC after: 3 days


147176 09-Jun-2005 pjd

Add a quirk for my pen-drive.


146108 11-May-2005 kan

Do not initialize path variable with useless value just before
xpt_create_path overwrites it anyway.

Noticed by: Coverity Prevent analysis tool


145916 05-May-2005 dwhite

Add quirk for TEAC USB floppy drives.


145050 14-Apr-2005 mjacob

Make sure we look at the correct sub op codes when
deciding whether it's an operation we can perform
via the control device.

PR: kern/72010
MFC after: 1 week


145049 14-Apr-2005 mjacob

Take constructive advice from njl && reformat
previously added quirks slightly.


145048 14-Apr-2005 njl

Quirk for ZICPlay USB MP3 Player.

PR: kern/75057
Submitted by: Aurelien Nephtali <aurelien.nephtali wanadoo.fr>


145046 14-Apr-2005 mjacob

Apply quirk.

PR: 57469
Submitted by: walter@pelissero.de
MFC after: 1 week


145045 14-Apr-2005 mjacob

Applied conservative version of suggested quirk.

PR: 57468
Submitted by: walter@pelissero.de
MFC after: 1 week


145044 14-Apr-2005 mjacob

Apply quirk suggested by submitter.

PR: 75486
Submitted by: no_bs@web.de
MFC after: 1 week


145042 14-Apr-2005 mjacob

The divide by zero panic must have been due to a bogus
period value. I suppose the BT adapter driver should be
fixed, but more importantly we should protect against
dividing by zero.

PR: kern/75603
MFC after: 1 week


144430 31-Mar-2005 sam

avoid use after free

Submitted by: gibbs
Reviewed by: mdodd
Approved by: Coverity Prevent analysis tool


144429 31-Mar-2005 sam

avoid use after free

Submitted by: gibbs
Reviewed by: mdodd
Noticed by: Coverity Prevent analysis tool


144389 31-Mar-2005 phk

Explicitly hold a reference to the cdev we have just cloned. This
closes the race where the cdev was reclaimed before it ever made it
back to devfs lookup.


144135 26-Mar-2005 ken

Fix a problem with the cd(4) driver -- the CAMGETPASSTHRU ioctl wouldn't
succeed if there was no media in the drive.

This was broken in rev 1.72 when the media check was added to cdioctl().

For now, check the ioctl group to decide whether to check for media or not.
(We only need to check for media on CD-specific ioctls.)

Reported by: bland
MFC after: 3 days


144132 26-Mar-2005 ken

Fix a place where we were referencing a pointer after it had been freed.

Submitted by: "Henry Miller" <hank@blackhole.com>
MFC after: 3 days


144030 23-Mar-2005 gibbs

Restore queue depth settings across tag disable events. The system often
disables tag queuing temporarily in order to allow controllers a window
to safely perform transfer negotiation with non-compliant devices. Before
this change, CAM would restore the queue depth to the controller specified
maximum or device quirk level rather than any depth determined by reactions
to QUEUE FULL/BUSY events or an explicit user setting.

During device probe, initialize the flags field for XPT_SCAN_BUS.
The uninitialized value often confused CAM into not bothering to
issue an AC_FOUND_DEVICE async event for new devices. The reason
this bug wasn't reported earlier is that CAM manually announces
devices after the initial system bus scans.

MFC: 3 days


143839 19-Mar-2005 scottl

Don't free the SIM object twice.

Submitted by: Coverity Prevent analysis tool


142159 21-Feb-2005 scottl

Reference a pointer correctly when copying to it's location.

Submitted by: Coverity Prevent analysis tool


142158 20-Feb-2005 scottl

Check the correct periph pointer after search for it.

Submitted by: Coverity Prevent analysis tool


142157 20-Feb-2005 scottl

Protect against trying to free a non-existant peripheral.

Submitted by: Coverity Prevent analysis tool
MFC After: 3 days


141713 12-Feb-2005 scottl

Remove a shadow declaration of 'error' that caused certain tests to be
pointless.

Submitted by: Coverity Prevent analysis tool


141566 09-Feb-2005 scottl

Provide locking for the ccb_bioq. This allows xpt_done() to be called without
Giant held. In camisr(), move the ccb_bioq elements to a temporary local list
and then process the elements off of that list. This enables the list to be
processed by only taking the ccb_bioq_lock once and only for a very short
time.

ccb_bioq_lock is a leaf mutex, so it's fine to call xpt_done() with other
locks held. This is just a very minor step in the work to lock CAM, but
it allows us to avoid some messy locking/unlock dances in certain drivers.


141031 30-Jan-2005 sobomax

Boot away another stackgap (one of the lest ones in linuxlator/i386) by
providing special version of CDIOCREADSUBCHANNEL ioctl(), which assumes that
result has to be placed into kernel space not user space. In the long run
more generic solution has to be designed WRT emulating various ioctl()s
that operate on userspace buffers, but right now there is only one such
ioctl() is emulated, so that it makes little sense.

MFC after: 2 weeks


140799 25-Jan-2005 mr

Add quirk for easyRAID ER5 alias areca ARC-6010.
It reports itself as SCSI-3 but doesnt like getting probed on high luns
because it hangs hard after finding itself again on lun 32...

Suggested by: Kenneth Merry


140644 22-Jan-2005 mjacob

This is a somewhat imperfect means to try and bring FreeBSD forward in
its ability to automatically scan and attach luns for modern storage
which has luns in the 0..1000 range, not 0..7.

The correct thing would be to do REPORT LUNS for devices whose LUN0
version shows a version >= SCSI3, but lacking that we should be able
to search higher than LUN 7 if we're >= SCSI3 with no ill effects.

This change keeps all of the QUIRK_HILUNS quirks, obeys the QUIRK_NOLUNS,
and introduces a QUIRK_NOHILUNS which will keep searches above LUN 7
happening for devices that report >= SCSI3 compliance. I doubt the latter
will be needed, but you never know.

This allowed me to randomly scan and attach > 500 disks at a time in
a situation where quirking for QUIRK_HILUNS wasn't practical (the
vendor id and product id changes of the virtualization changes
constantly).

Reviewed by: ken@freebsd.org, scottl@freebsd.org, gibbs@freebsd.org
MFC after: 2 weeks


140608 22-Jan-2005 mjacob

Don't pass unadulterated unit numbers to make_dev and its ilk- if you
have more than 256 units, you die. Horribly. Convert them using
unit2minor.

MFC after: 1 week


139743 05-Jan-2005 imp

Start each of the license/copyright comments with /*-


137844 18-Nov-2004 gibbs

Correct another location where inquiry length as calculated from the
inquiry additional length field is off by one.

MFC: 3 days


137842 18-Nov-2004 gibbs

Correct an off-by-one in the calculation of the inquiry buffer length
to request from devices during the "long inquiry" portion of our probe.
This same bug was fixed in the 4.x stream a few years ago, but the fix
was never propogated to -current.

This fix is slightly different than in -stable:

o Use offsetof() instead of a hard coded constant so as the make
the code more self-explainatory.

o Round odd long inquiry lengths up so as to avoid tickling ignore
wide residue bugs in broken parallel SCSI devices running with a
wide transfer negotiation.

MFC: 3 days


136481 13-Oct-2004 bms

Remove references to the second byte of a CCB containing the LUN, as this
is valid only for SCSI-2 and older devices.
Rename the second byte of the VERIFY CCB from 'lun' to 'byte2'.

Submitted by: ken
MFC after: 2 weeks


136423 12-Oct-2004 bms

Add necessary data structures and definitions for the 12-byte SCSI
commands READ_FORMAT_CAPACITIES, WRITE_AND_VERIFY, and VERIFY.

Reviewed by: ken, scottl
Source: USB Mass Storage UFI Specification v1.0
MFC after: 2 weeks


136132 05-Oct-2004 scottl

Remove the camnet swi and CAM_PERIPH_NET. It has never been used, and given
that netowrk-over-scsi never really took off, there is little chance that
it will ever be needed.


134824 05-Sep-2004 phk

For removable devices without media we set a zero mediasize but a non-zero
sectorsize in order to avoid a lot of checks around various divisions etc.

Enforce the sectorsize being > 0 with a KASSERT on successful open.

Fix scsi_cd.c to return 2k sectors when no media inserted.


134530 30-Aug-2004 gibbs

Correct a typo in a comment: alloation->allocation

Reported by: Jens Schweikhardt <schweikh@schweikhardt.net>


134479 29-Aug-2004 des

Remove the HW_WDOG option; it serves no purpose.

MFC after: 3 days


133741 15-Aug-2004 jmg

Add locking to the kqueue subsystem. This also makes the kqueue subsystem
a more complete subsystem, and removes the knowlege of how things are
implemented from the drivers. Include locking around filter ops, so a
module like aio will know when not to be unloaded if there are outstanding
knotes using it's filter ops.

Currently, it uses the MTX_DUPOK even though it is not always safe to
aquire duplicate locks. Witness currently doesn't support the ability
to discover if a dup lock is ok (in some cases).

Reviewed by: green, rwatson (both earlier versions)


133662 13-Aug-2004 mjacob

When printing out an unknown sense code we should print it in hex, not
decimal.

Reviewed by: gibbs, nate, kdm


133601 12-Aug-2004 sanpei

add support Frontier Labs NEX IA+ Digital Audio Player with USB CF card reader/writer

PR: kern/70158
Submitted by: Bernd Strau. <no_bs@web.de>
MFC after: 1 week


133321 08-Aug-2004 sanpei

Add support iRiver iFP MP3 player

PR: kern/54881, i386/63941, kern/66124
Submitted by: Magnus <bsdhead.at.spray.dot.se@FreeBSD.org>,
Dmitry Dyomin <old@old.com.ua>,
Dmitry Sivachenko <mitya@demos.su>
MFC after: 1 week


132339 18-Jul-2004 sanpei

Quirk for SEGRAND NP-900 USB MP3Player

PR: kern/64563
Submitted by: Kunitada Kokubun <unix_grandy@yahoo.co.jp>
MFC after: 1 week


132199 15-Jul-2004 phk

Do a pass over all modules in the kernel and make them return EOPNOTSUPP
for unknown events.

A number of modules return EINVAL in this instance, and I have left
those alone for now and instead taught MOD_QUIESCE to accept this
as "didn't do anything".


131910 10-Jul-2004 marcel

Update for the KDB framework:
o Call kdb_enter() instead of Debugger().


130866 21-Jun-2004 ps

Revert rev 1.140, it was a bit pre-mature.


130864 21-Jun-2004 ps

Add a quirk for ciss to stop trying to read the serial number off
of logical volumes.


130640 17-Jun-2004 phk

Second half of the dev_t cleanup.

The big lines are:
NODEV -> NULL
NOUDEV -> NODEV
udev_t -> dev_t
udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.


130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


130200 07-Jun-2004 scottl

Reformat the comments for cam_hdr so that they can be read.


128840 02-May-2004 njl

Quirk for Neuros USB audio device.

PR: kern/63645
Submitted by: Aron Stansvik <elvstone@osdever.net>


128426 19-Apr-2004 mux

The opt_da.h file doesn't exist anymore since the DA_OLD_QUIRKS option
has been removed. Unbreak the build by not including it anymore.


128416 19-Apr-2004 njl

Add miscellaneous USB device quirks.

PR: kern/53067
PR: kern/54737
PR: kern/54786
PR: kern/57046

MFC after: 1 day


128415 19-Apr-2004 njl

Remove all quirks hidden under DA_OLD_QUIRKS.


126348 28-Feb-2004 cperciva

Compare the *number* of patterns to zero, not the *pointer* to the
patterns. (These lines are correct the other two times they appear.)

Reported by: "Ted Unangst" <tedu@coverity.com>
Approved by: rwatson (mentor), ken (scsi)


126104 22-Feb-2004 cperciva

Check that periph is non-NULL before dereferencing it.

Reported by: "Ted Unangst" <tedu@coverity.com>
Approved by: rwatson (mentor), ken (scsi@)


126080 21-Feb-2004 phk

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


126076 21-Feb-2004 phk

Device megapatch 1/6:

Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.


125975 18-Feb-2004 phk

Change the disk(9) API in order to make device removal more robust.

Previously the "struct disk" were owned by the device driver and this
gave us problems when the device disappared and the users of that device
were not immediately disappearing.

Now the struct disk is allocate with a new call, disk_alloc() and owned
by geom_disk and just abandonned by the device driver when disk_create()
is called.

Unfortunately, this results in a ton of "s/\./->/" changes to device
drivers.

Since I'm doing the sweep anyway, a couple of other API improvements
have been carried out at the same time:

The Giant awareness flag has been flipped from DISKFLAG_NOGIANT to
DISKFLAG_NEEDSGIANT

A version number have been added to disk_create() so that we can detect,
report and ignore binary drivers with old ABI in the future.

Manual page update to follow shortly.


124645 18-Jan-2004 johan

Fix type in comment, 's/writtent/written/'

PR: 56954
Submitted by: Dan Langille <dan@langille.org>


123285 08-Dec-2003 ps

Move the ciss quirk to the right section, also update the comment
stating that the controllers do not support SYNC CACHE since ciss
only supports a small subset of the scsi spec.


123283 08-Dec-2003 ps

ciss doesn't like scsi SYNC CACHE. turn it off


123083 01-Dec-2003 obrien

SS_FATAL|ENXIO rather than SS_RDEF for illegal track mode.
This reduces the 90+ lines boot output of spewage GEOM does for my
Plextor SCSI burner.

Submitted by: scottl
Approved by: scottl


122352 09-Nov-2003 tanimura

- Implement selwakeuppri() which allows raising the priority of a
thread being waken up. The thread waken up can run at a priority as
high as after tsleep().

- Replace selwakeup()s with selwakeuppri()s and pass appropriate
priorities.

- Add cv_broadcastpri() which raises the priority of the broadcast
threads. Used by selwakeuppri() if collision occurs.

Not objected in: -arch, -current


122347 09-Nov-2003 scottl

Sprinkle GIANT_REQUIRED asserts around the xpt layer to aid with locking the
SCSI drivers.


122307 08-Nov-2003 scottl

Don't be so chatty when performing manual sense. This should make ATAPICAM
devices a lot more quiet.


121602 27-Oct-2003 ken

In camperiphdone(), make sure we check for fatal errors and bail out
instead of retrying them blindly.

This should fix some of the problems people have been having with cdrom
drives taking a long time to probe. This should also eliminate the need
for the initial TUR in cdsize().

cam_periph.c: Don't keep retrying if the error we get back is a fatal
error. This should help us detect the transition from
"Logical unit not ready, cause not reportable" to "Medium
not present" in the "TUR many" handler. (The TUR many
handler gets triggered for Logical unit not ready, cause
not reportable errors.)

scsi_cd.c: Remove the initial test unit ready in cdsize(). Hopefully
it isn't necessary after the above change.

Submitted by: gibbs (mostly)
Tested by: peter
MFC After: 2 weeks


121209 18-Oct-2003 phk

Use bio_offset instead of bio_blkno


121194 18-Oct-2003 phk

There is no need to muck about with the B_PHYS flag here. We never even
get close to DEV_STRATEGY() which is the only place it is relevant.


120906 08-Oct-2003 thomas

(dacleanup, dasysctlinit): Defend against calling sysctl_ctx_free on
an uninitialized sysctl_ctx, using flag DA_FLAG_SCTX_INIT. This
prevents a panic encoutered with some umass units that probe correctly
but fail to attach. Same problem, and same fix, as scsi_cd.c rev. 1.86.

Reviewed by: njl, ken


120884 07-Oct-2003 thomas

(cdcleanup): Defend against calling sysctl_ctx_free before the sysctl_ctx
has been initialized.
(cdsysctlinit): Set flag CD_FLAG_SCTX_INIT after sysctl_ctx has been
initialized.

This resolves a panic encountered when a cd drive is sucessfully probed
but fails to attach.

Reviewed by: ken


120854 06-Oct-2003 phk

Add disk_destroy() call to detach processing.

Add short tempered TUR to cdsize() as a workaround.


120663 02-Oct-2003 simokawa

Be kind to 64bit architectures.


120601 30-Sep-2003 simokawa

- Pick up a correct path_id for the bus on AC_PATH_REGISTERED.
- Call cam_periph_invalidate() only if the periph is found.


120599 30-Sep-2003 phk

GEOMify.


120426 25-Sep-2003 simokawa

Detach black hole device on AC_PATH_DEREGISTERED.


120314 21-Sep-2003 thomas

(scsi_request_sense): Set allocation length in REQUEST_SENSE CCB.

Reviewed by: ken


120313 21-Sep-2003 thomas

(camperiphdone): When the cam_periph layer performs sense recovery,
completion of recovery is indicated by positioning the CAM_AUTOSNS_VALID
bit in the status field of the CCB, not in the flags field.
This fixes an endless loop of sense recovery actions.

Reviewed by: ken


120019 13-Sep-2003 mjacob

I forgot whom I got this from- only set single initiator buffered mode
if we've recorded in our softc that we should set it.


119994 11-Sep-2003 phk

Disable the use of cloning use in floppy and CD drivers.

This commit puts the relevant code snippets under #ifdef GONE_IN_5
(rather than #ifndef BURN_BRIDGES) thereby disabling the code now.

The code wil be entirely removed before 5.2 unless we find reasons
why this would be a bad idea.

Approach suggested by: imp


119957 10-Sep-2003 alc

In case vmapbuf() fails, release all of the held resources.

Submitted by: tegge


119761 05-Sep-2003 phk

Put the device cloning functions for disk-drivers under #ifndef BURN_BRIDGES.

For the floppy driver, use fdcontrol to manipulate density selection.

For the CD drivers, the 'a' and 'c' suffix is without actual effect and
any applications insisting on it can be satisfied with a symlink:
ln -s /dev/cd0 /dev/cd0a

Ongoing discussion may result in these pieces of code being removed before
the 5-stable branch as opposed to after.


119742 04-Sep-2003 njl

Calling KNOTE with locks held may result in recursion when it calls back
into targreadfilt(). Unlock around calls to notify_user(). If an application
is sending CCBs while the endpoint is shutting down, this may result in
incomplete disable. A more complete solution will come with a "dying" flag.

Submitted by: simokawa


119741 04-Sep-2003 njl

Upon receiving a CCB for a LUN that is not enabled, be sure to unlock the
softc on exit.

Submitted by: simokawa


119728 04-Sep-2003 njl

Remove the quirk for the FujiFilm camera. Submitter indicates it is now
working without the quirk.

PR:
Submitted by: guido
Reviewed by:
Approved by:
Obtained from:
MFC after: 30 days


119718 03-Sep-2003 ken

Unbreak buildworld. sys/taskqueue.h is a kernel-only include.

Pointy Hat to: ken


119708 03-Sep-2003 ken

Move dynamic sysctl(8) variable creation for the cd(4) and da(4) drivers
out of cdregister() and daregister(), which are run from interrupt context.

The sysctl code does blocking mallocs (M_WAITOK), which causes problems
if malloc(9) actually needs to sleep.

The eventual fix for this issue will involve moving the CAM probe process
inside a kernel thread. For now, though, I have fixed the issue by moving
dynamic sysctl variable creation for these two drivers to a task queue
running in a kernel thread.

The existing task queues (taskqueue_swi and taskqueue_swi_giant) run in
software interrupt handlers, which wouldn't fix the problem at hand. So I
have created a new task queue, taskqueue_thread, that runs inside a kernel
thread. (It also runs outside of Giant -- clients must explicitly acquire
and release Giant in their taskqueue functions.)

scsi_cd.c: Remove sysctl variable creation code from cdregister(), and
move it to a new function, cdsysctlinit(). Queue
cdsysctlinit() to the taskqueue_thread taskqueue once we
have fully registered the cd(4) driver instance.

scsi_da.c: Remove sysctl variable creation code from daregister(), and
move it to move it to a new function, dasysctlinit().
Queue dasysctlinit() to the taskqueue_thread taskqueue once
we have fully registered the da(4) instance.

taskqueue.h: Declare the new taskqueue_thread taskqueue, update some
comments.

subr_taskqueue.c:
Create the new kernel thread taskqueue. This taskqueue
runs outside of Giant, so any functions queued to it would
need to explicitly acquire/release Giant if they need it.

cd.4: Update the cd(4) man page to talk about the minimum command
size sysctl/loader tunable. Also note that the changer
variables are available as loader tunables as well.

da.4: Update the da(4) man page to cover the retry_count,
default_timeout and minimum_cmd_size sysctl variables/loader
tunables. Remove references to /dev/r???, they aren't used
any longer.

cd.9: Update the cd(9) man page to describe the CD_Q_10_BYTE_ONLY
quirk.

taskqueue.9: Update the taskqueue(9) man page to describe the new thread
task queue, and the taskqueue_swi_giant queue.

MFC after: 3 days


119465 25-Aug-2003 njl

Remove quirk for Apacer Handydrive. Kevin Oberman <oberman@es.net> reports
that it works without the quirk. This and any other quirk changes will be
MFCd after the release unless they fix a known problem.

MFC after: 1 month


119461 25-Aug-2003 njl

Sort quirks into sections.


119308 22-Aug-2003 njl

Add the DA_Q_NO_PREVENT quirk which keeps da(4) from sending PREVENT/ALLOW
commands. Add a quirk for the Creative Nomad MuVo USB device that uses
it as well as NO_SYNCHRONIZE_CACHE.

PR: kern/53094
Submitted by: Richard Nyberg <rnyberg@it.su.se>
MFC after: 3 days


119279 22-Aug-2003 njl

Quirk for Jungsoft NEXDISK USB flash key. Fails to mount without
NO_SYNCHRONIZE_CACHE.

PR: kern/54737
Submitted by: David Thiel <lx@redundancy.redundancy.org>
MFC after: 3 days


119275 22-Aug-2003 njl

Add quirks for the EXATELECOM i-Bead mp3 player.

PR: kern/51675
Submitted by: Nicolas Jombart <ecu@ipv42.net>
MFC after: 3 days


118556 06-Aug-2003 njl

Remove all USB quirks that only specify DA_Q_NO_6_BYTE. They are no longer
needed. Other USB quirks remain in hopes that user testing will reveal
which ones are also no longer needed.

Courtesy of: USENIX lunch break


118546 06-Aug-2003 njl

Remove unused cmd6workaround() calls.

MFC after: 1 day


118179 29-Jul-2003 njl

Fix the new DA_OLD_QUIRKS option for normal and module compiles.

Pointed out by: bde


118140 29-Jul-2003 njl

Deprecate USB and Firewire quirks. We should now never send 6 byte commands
to such devices. If a device fails due to this commit, add:
options DA_OLD_QUIRKS
to the kernel config and recompile. Then send the output of "camcontrol
inquiry da0" to scsi@freebsd.org so the quirk can be re-enabled.


118105 28-Jul-2003 njl

Add a PATH_INQ flag, PIM_NO_6_BYTE, which indicates the SIM never wishes to
receive 6 byte commands. Add a check for this flag to da(4) and cd(4) so
that they honor it. This is a quick workaround for many devices (especially
USB) that require da(4) quirks to operate. The more complete approach is
to finish the new transport code which will be aware of the SCSI version a
transport implements.

MFC after: 1 day


117739 18-Jul-2003 thomas

Reference PR for IntelligentStick quirk entry.

PR: kern/53005


117690 17-Jul-2003 thomas

Add quirk entry for IntelligentStick disc-on-key USB devices.
Reported by Samuel Tardieu <sam@rfc1149.net>.

Reviewed by: roberto
MFC after: 1 week


116351 14-Jun-2003 njl

Merge common XPT_CALC_GEOMETRY functions into a single convenience function.
Devices below may experience a change in geometry.

* Due to a bug, aic(4) never used extended geometry. Changes all drives
>1G to now use extended translation.
* sbp(4) drives exactly 1 GB in size now no longer use extended geometry.
* umass(4) drives exactly 1 GB in size now no longer use extended geometry.

For all other controllers in this commit, this should be a no-op.

Looked over by: scottl


116350 14-Jun-2003 njl

Merge common XPT_CALC_GEOMETRY functions into a single convenience function.
Devices below may experience a change in geometry.

* Due to a bug, aic(4) never used extended geometry. Changes all drives
>1G to now use extended translation.
* sbp(4) drives exactly 1 GB in size now no longer use extended geometry.
* umass(4) drives exactly 1 GB in size now no longer use extended geometry.

For all other controllers in this commit, this should be a no-op.

PR:
Submitted by:
Looked over by: scottl
Approved by:
Obtained from:
MFC after:


116162 10-Jun-2003 obrien

Use __FBSDID().


116161 10-Jun-2003 obrien

Use __FBSDID().


115660 02-Jun-2003 mjacob

Check in some months long pending minor debug output changes.

Clarify that the implicit fallthrough was *not* intentional (thanks, Poul!)
and reorganize the code so a correct fallthrough (with /* FALLTHROUGH */)
occurs.


115608 01-Jun-2003 phk

Remove unused variables.
Remove break after return.
Add XXX comment where intent is unclear.

Found by: FlexeLint


115606 01-Jun-2003 phk

Add /* FALLTHROUGH */

Found by: FlexeLint


115562 31-May-2003 phk

Add /* FALLTHROUGH */
Move /* FALLTHROUGH */ to correct location.
Remove unused variable(s).

Found by: FlexeLint


115561 31-May-2003 phk

Add /* FALLTHROUGH */
Remove unused variable(s).
Order switch in canonical order.

Found by: FlexeLint


115476 31-May-2003 phk

Add /* FALLTHROUGH */

Found by: FlexeLint


115464 31-May-2003 phk

Use symbolic constants instead of "4".
Use arrays instead of relying on struct packing.

Identical md5(scsi_ch.o).


115454 31-May-2003 phk

Don't use return(foo(...)); in a function returning void.

Found by: FlexeLint


115031 15-May-2003 njl

Add a quirk for OTi USB flash key.

PR: kern/51825
Approved by: re (rwatson)


114559 03-May-2003 ken

Fix three problems in large (>2TB) device handling:
- Make sure we don't release the READ CAPACITY CCB twice
- If we have a device that needs a 16 byte READ CAPACITY command, make
sure we call xpt_schedule() so we can get a CCB.
- Don't unlock the peripheral until we're fully probed.

Many thanks to Julian Elischer for providing hardware and testing this.

Tested by: julian


114388 01-May-2003 ken

Fix compile errors on ia64 in dagetcapacity. Set block_len and maxsector
to 0 initially. It seems that the ia64 backend isn't as "smart" as the
i386 backend, which realized that those variables were only set or used
when error == 0, and thus were not used uninitialized.


114294 30-Apr-2003 phk

Use %j instead of %q in printf to unbreak sparc64.


114261 30-Apr-2003 ken

Add support to CAM for devices with more than 2^32 blocks. (2TB if you're
using 512 byte blocks).

cam_ccb.h: Bump up volume_size and cylinders in ccb_calc_geometry to
64 bits and 32 bits respectively, so we can hold larger
device sizes. cylinders would overflow at about 500GB.
Bump CAM_VERSION for this change. Note that this will
require a recompile of all applications that talk to the
pass(4) driver.

scsi_all.c: Add descriptions for READ/WRITE(16), update READ/WRITE(12)
descriptions, add descriptions for SERVICE ACTION IN/OUT.
Add a new function, scsi_read_capacity_16(), that issues
the read capacity service action. (Necessary for arrays
larger than 2^32 sectors.) Update scsi_read_write() to use
a 64 bit LBA and issue READ(16) or WRITE(16) if necessary.
NOTE the API change. This should be largely transparnet
to most userland applications at compile time, but will
break binary compatibility. The CAM_VERSION bump, above,
also serves the purpose of forcing a recompile for any
applications that talk to CAM.

scsi_all.h: Add 16 byte READ/WRITE structures, structures for 16 byte
READ CAPACITY/SERVICE ACTION IN. Add scsi_u64to8b() and
scsi_8btou64.

scsi_da.c: The da(4) driver probe now has two stages for devices
larger than 2TB. If a standard READ CAPACITY(10) returns
0xffffffff, we issue the 16 byte version of read capacity
to determine the true array capacity. We also do the same
thing in daopen() -- use the 16 byte read capacity if the
device is large enough.

The sysctl/loader code has also been updated to accept
16 bytes as a minimum command size.


114216 29-Apr-2003 kan

Deprecate machine/limits.h in favor of new sys/limits.h.
Change all in-tree consumers to include <sys/limits.h>

Discussed on: standards@
Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>


114130 27-Apr-2003 njl

SCSI Quirks for:
Casio QV-R3 USB camera, which appears to use a Pentax chipset
M-Systems DiskOnKey USB flash key
Feiya "slider" dual-slot flash reader
SmartDisk (Mitsumi) USB floppy drive

PR: kern/46545, kern/47793, kern/50020, kern/50226


113391 12-Apr-2003 phk

Remove the unused ioctl routine.


113186 06-Apr-2003 alc

Sufficient access checks are performed by vmapbuf() that calling useracc()
is pointless. Remove the calls to useracc().


112946 01-Apr-2003 phk

Use bioq_flush() to drain a bio queue with a specific error code.
Retain the mistake of not updating the devstat API for now.

Spell bioq_disksort() consistently with the remaining bioq_*().

#include <geom/geom_disk.h> where this is more appropriate.


112668 26-Mar-2003 ken

Clean up dynamically allocated sysctl variables when we run dacleanup() and
cdcleanup(). This fixes sysctl problems ("can't re-use a leaf") when
someone adds another peripheral at the same unit number. (e.g. rescan da0,
it goes away, then rescan again and da0 comes back, but since we haven't
cleaned up the sysctl variables from the last da0 instance, we can't
register the variables for the new instance under the same name.)

Reported by: njl
Tested by: njl


112288 15-Mar-2003 phk

Run a revision of the devstat interface:

Kernel:

Change statistics to use the *uptime() timescale (ie: relative to
boottime) rather than the UTC aligned timescale. This makes the
device statistics code oblivious to clock steps.

Change timestamps to bintime format, they are cheaper.

Remove the "busy_count", and replace it with two counter fields:
"start_count" and "end_count", which are updated in the down and
up paths respectively. This removes the locking constraint on
devstat.

Add a timestamp argument to devstat_start_transaction(), this will
normally be a timestamp set by the *_bio() function in bp->bio_t0.
Use this field to calculate duration of I/O operations.

Add two timestamp arguments to devstat_end_transaction(), one is
the current time, a NULL pointer means "take timestamp yourself",
the other is the timestamp of when this transaction started (see
above).

Change calculation of busy_time to operate on "the salami principle":
Only when we are idle, which we can determine by the start+end
counts being identical, do we update the "busy_from" field in the
down path. In the up path we accumulate the timeslice in busy_time
and update busy_from.

Change the byte_* and num_* fields into two arrays: bytes[] and
operations[].

Userland:

Change the misleading "busy_time" name to be called "snap_time" and
make the time long double since that is what most users need anyway,
fill it using clock_gettime(CLOCK_MONOTONIC) to put it on the same
timescale as the kernel fields.

Change devstat_compute_etime() to operate on struct bintime.

Remove the version 2 legacy interface: the change to bintime makes
compatibility far too expensive.

Fix a bug in systat's "vm" page where boot relative busy times would
be bogus.

Bump __FreeBSD_version to 500107

Review & Collaboration by: ken


112262 15-Mar-2003 phk

Don't use the devstat->busy_count for state decisions in the device
drivers. Doing so imposes atomicity and locking constraints on the
devstat API.

By: ken


112260 15-Mar-2003 phk

Call devstat_start_transaction_bio() instead of devstat_start_transaction()


112076 11-Mar-2003 njl

Quirk for SanDisk ImageMate II compact flash reader

PR: kern/47877
Submitted by: Mike Durian <durian@boogie.com>
MFC after: 3 days


112075 11-Mar-2003 njl

Quirk for Pentax Optio 230 USB camera. Note that other products probably
use the underlying AsahiOptical USB chip and thus this quirk may need to
be generalized in the future.

PR: kern/46369
Submitted by: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
MFC After: 3 days


112006 08-Mar-2003 phk

Allocate the devstat structure with devstat_new_entry().


111979 08-Mar-2003 phk

Centralize the devstat handling for all GEOM disk device drivers
in geom_disk.c.

As a side effect this makes a lot of #include <sys/devicestat.h>
lines not needed and some biofinish() calls can be reduced to
biodone() again.


111821 03-Mar-2003 phk

Make nokqfilter() return the correct return value.

Ditch the D_KQFILTER flag which was used to prevent calling NULL pointers.


111815 03-Mar-2003 phk

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


111571 26-Feb-2003 phk

msg


111504 25-Feb-2003 phk

NO_GEOM cleanup:

Move to "struct disk *" centric api.


111220 21-Feb-2003 phk

NO_GEOM cleanup:

Retire the "d_dump_t" and use the "dumper_t" type instead.

Dumper_t takes a void * as first arg which is more general than the
dev_t taken by d_dump_t. (Remember: we could have net-dumpers if
somebody wrote us one!)

Define the convention for GEOM controlled disk devices to be that the
first argument to the dumper function is the struct disk pointer.

Change device drivers accordingly.


111216 21-Feb-2003 phk

NO_GEOM cleanup:

Change the argument to disk_destroy() to be the same struct disk * as
disk_create() takes.

This enables drivers to ignore the (now) bogus dev_t which disk_create()
returns.


111206 21-Feb-2003 ken

Fix ATAPI/USB/Firewire CDROM drive handling in cd(4) and hopefully fix
a number of related problems along the way.

- Automatically detect CDROM drives that can't handle 6 byte mode
sense and mode select, and adjust our command size accordingly.
We have to handle this in the cd(4) driver (where the buffers are
allocated), since the parameter list length is different for the
6 and 10 byte mode sense commands.

- Remove MODE_SENSE and MODE_SELECT translation removed in ATAPICAM
and in the umass(4) driver, since there's no way for that to work
properly.

- Add a quirk entry for CDROM drives that just hang when they get a 6
byte mode sense or mode select. The reason for the quirk must be
documented in a PR, and all quirks must be approved by
ken@FreeBSD.org. This is to make sure that we fully understand why
each quirk is needed. Once the CAM_NEW_TRAN_CODE is finished, we
should be able to remove any such quirks, since we'll know what
protocol the drive speaks (SCSI, ATAPI, etc.) and therefore whether
we should use 6 or 10 byte mode sense/select commands.

- Change the way the da(4) handles the no_6_byte sysctl. There is
now a per-drive sysctl to set the minimum command size for that
particular disk. (Since you could have multiple disks with
multiple requirements in one system.)

- Loader tunable support for all the sysctls in the da(4) and cd(4)
drivers.

- Add a CDIOCCLOSE ioctl for cd(4) (bde pointed this out a long
time ago).

- Add a media validation routine (cdcheckmedia()) to the cd(4)
driver, to fix some problems bde pointed out a long time ago. We
now allow open() to succeed no matter what, but if we don't detect
valid media, the user can only issue CDIOCCLOSE or CDIOCEJECT
ioctls.

- The media validation routine also reads the table of contents off
the drive. We use the table of contents to implement the
CDIOCPLAYTRACKS ioctl using the PLAY AUDIO MSF command. The
PLAY AUDIO TRACK INDEX command that we previously used was
deprecated after SCSI-2. It works in every SCSI CDROM I've tried,
but doesn't seem to work on ATAPI CDROM drives. We still use the
play audio track index command if we don't have a valid TOC, but
I suppose it'll fail anyway in that case.

- Add _len() versions of scsi_mode_sense() and scsi_mode_select() so
that we can specify the minimum command length.

- Fix a couple of formatting problems in the sense printing code.

MFC after: 4 weeks


111119 19-Feb-2003 imp

Back out M_* changes, per decision of the TRB.

Approved by: trb


110730 11-Feb-2003 phk

Announce our ability to do DFLTPHYS sized transfers.


110599 09-Feb-2003 njl

Quirk for Lexar Media Jumpdrive

PR: kern/47006
Tested by: George Hartzell <hartzell@kestrel.alerce.com>
MFC after: 1 week


110517 07-Feb-2003 phk

Rename bio_linkage to the more obvious bio_parent.
Add bio_t0 timestamp, and include <sys/time.h> where needed


110232 02-Feb-2003 alfred

Consolidate MIN/MAX macros into one place (param.h).

Submitted by: Hiten Pandya <hiten@unixdaemons.com>


110116 30-Jan-2003 phk

NO_GEOM cleanup: retire disk_invalidate()


109759 23-Jan-2003 njl

Remove redundant printf from targbhasync() since all places that return an
error do their own, more useful printf.


109623 21-Jan-2003 alfred

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


109577 20-Jan-2003 gibbs

Add definitions for the task management codes sent in SPI4
command information units.


109572 20-Jan-2003 dillon

Close the remaining user address mapping races for physical
I/O, CAM, and AIO. Still TODO: streamline useracc() checks.

Reviewed by: alc, tegge
MFC after: 7 days


109345 16-Jan-2003 njl

kernel:
* Fix a bug where devices weren't cleaned up on close(): CAM_REQ_CMP != 0

user:
* Increase timeout in usermode to CAM_TIME_INFINITY. The initiator is in
charge of timeouts and the value was in ms, not seconds.
* Bring two debugging printfs under the debug flag
* Clean up man page to show increased testing on isp(4)

Submitted by: gibbs (bugfixes)


109160 13-Jan-2003 njl

Quirk for Sony USB disk-on-key device.

PR: kern/46386
Submitted by: dillon
MFC after: 3 days


108814 06-Jan-2003 peter

Back out last commit.


108784 06-Jan-2003 peter

Move dashutdown from SHUTDOWN_PRI_DEFAULT to SHUTDOWN_PRI_FIRST.
Otherwise, the scsi devices that it is trying to issue commands to may
have gone away. This is what caused shutdown to hang on ia64 systems
with mpt scsi controllers. The bus system has torn down the device tree
and reset the mpt controller etc, and suddenly along comes dashutdown
and wants to issue a few more scsi commands.... <HANG!>

This shouldn't work on i386 either, but it seems to work solely due
to luck.


108470 30-Dec-2002 schweikh

Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.


108059 18-Dec-2002 njl

Quirk for Memorybird pen drive

PR: kern/34712
Submitted by: Oliver Fromme <olli@lurza.secnetix.de>
MFC after: 3 days


107943 16-Dec-2002 trhodes

The HP DAT 40 tape drive should be able to handle variable block sizes.
But for some reason the block size is different when a different type of
tape is placed in the drive. This commit fixes that.

PR: 46209
Submitted by: Alex Wang <alex@alexwang.com>
Approved by: mjacob


107790 12-Dec-2002 yar

Clear the "device open" flag in daopen() before returning a error,
so the device won't stay marked as open whereas it isn't.

Approved by: re, njl
MFC after: 1 week


107386 29-Nov-2002 yar

Release the reference to the peripheral if returning a error.
That reference is to be held only if daopen() has been successful
and until daclose() releases it. daclose() won't be called if
daopen() has failed, though.

Approved by: re, njl
MFC after: 1 week


107240 25-Nov-2002 njl

Remove unnecessary includes and add sys/{lock,mutex}.h

Submitted by: bde
Approved by: re (previously)


107196 23-Nov-2002 njl

Whitespace cleanup that was missed by quirks commit 1.114


107193 23-Nov-2002 njl

Allow acd(4) and cd(4) to support old behavior for CDRIOC*SPEED ioctls.
If the value from the user is less than 177, assume it is a multiple of
a single speed CDROM and convert to KB/sec.

No complaints from: sos
Reviewed by: ken
Approved by: re
MFC after: 1 day


107192 23-Nov-2002 njl

Update quirks, adding PR references and fixing a capitalization mismatch.

PR: kern/45494
Approved by: re


107178 22-Nov-2002 njl

New SCSI target emulator code

This code allows a user program to enable target mode on a SIM and
then emulate any number of devices (disks, tape drives, etc.) All
decisions about device behavior (UA, CA, inquiry response) are left
to the usermode program and the kernel driver is merely a conduit
for CCBs. This enables multiple concurrent target emulators, each
using its own backing store and IO model.

Also included is a user program that emulates a disk (RBC) using a
file as a backing store. This provides functionality similar to
md(4) at the CAM layer.

Code has been tested on ahc(4) and should also work on isp(4) (and
other SIMs that gain target mode support). It is a complete rewrite
of /sys/cam/scsi_target* and /usr/share/examples/scsi_target.

Design, comments from: gibbs
Supported by: Cryptography Research
Approved by: re


106902 14-Nov-2002 imp

Panic message strings do not need a trailing \n.

Reviewed by: ken


106890 14-Nov-2002 imp

Panic message should end with \n.

Reviewed by: ken a while ago.


106696 09-Nov-2002 alfred

Fix instances of macros with improperly parenthasized arguments.

Verified by: md5


105421 18-Oct-2002 njl

* Add CDRIOC{READ,WRITE}SPEED ioctls to cd(4). Units are in KB/sec.
* Change atapi-cd ioctls to use the same units.
* Change burncd, cdcontrol to convert CDROM speed to KB/sec before
calling the ioctl. Add a "max" speed option for their command lines.

This change does not break ABI but does change the units passed through
the ioctl so 3rd party software that uses cdrio.h will have to convert
(most likely by multiplying CDROM speed by 177 to get KB/s).

PR: kern/36845
Submitted by: Philipp Mergenthaler <p@i609a.hadiko.de> (CAM ioctls)
Reviewed by: sos, ken
MFC after: 1 month


105378 18-Oct-2002 pirzyk

Backout my previous "brain cramp" commit.

Requested by: Most developers
Apologies to: Most developers, with special note to <ken@kdm.org>
Collabroation in the future with: Kenneth D. Merry <ken@kdm.org>


105363 17-Oct-2002 pirzyk

Changed the scsi mode command to use 10 bytes scsi commands instead
of the 6 byte ones. This helps with using a IDE cdrom behind a USB
interface.

PR: kern/43885


105343 17-Oct-2002 njl

Quirk for HP 315 USB Digital Camera

Submitted by: Keith White <kwhite@uottawa.ca>
PR: kern/41010

MFC after: 1 week


104880 11-Oct-2002 phk

Trapdoor access to cd%da and cd%c so they still work, but do not let them
show up in /dev.


104877 11-Oct-2002 phk

Use malloc(9)'s M_ZERO rather than explicit bzero(9) call.


104681 08-Oct-2002 ken

Fix the location of the length bytes in the 12-byte read/write CDB
structure. This has been broken since 1998, but probably hasn't been
noticed because it takes a read/write of 64K blocks (32MB with 512 byte
blocks) to trigger using the 12 byte read/write CDB in scsi_read_write().

Submitted by: "Moore, Eric Dean" <emoore@lsil.com>
MFC after: 3 days


104611 07-Oct-2002 phk

Correctly convert to appropriate blocksize.

note to self:
Never check block-size sensitive patches on Sun compatible CD drives.

Sponsored by: DARPA & NAI Labs.


104456 04-Oct-2002 phk

Unhook the SCSI CD driver from the disk "mini-layer" and/or GEOM.

SCSI disks are too square pegs for the round holes in both of these.

And since atapi-cd has clearly shown that there are better acccess
models for CD media than trying to pretend to be a classical disk,
we stop the masquerade rather than patch up the costume.

But do implement the DIOCGMEDIASIZE and DIOCGSECTORSIZE so it will
be possible to manually attach to GEOM, should some the need arise.

Ideally, this driver should do media-detection and call make_dev()
when a CD is inserted and destroy_dev() when it is removed, this
would allow our future devd(8) to automount etc etc but coding that
takes SCSI-clue beyond anything I posses.

Tested on: sparc64


104421 03-Oct-2002 ken

Fix style problems in the quirk entry section.

MFC after: 2 weeks


104301 01-Oct-2002 sobomax

Add quirks for DaisyTechnology PhotoClip camera.

Submitted by: Olexander Kunitsa <kunia@istc.kiev.ua>
MFC after: 3 days


104200 30-Sep-2002 guido

Add quirk for Apacer HandyDrive

MFC after: 1 week


104094 28-Sep-2002 phk

Be consistent about "static" functions: if the function is marked
static in its prototype, mark it static at the definition too.

Inspired by: FlexeLint warning #512


103870 23-Sep-2002 alfred

use __packed.


103818 23-Sep-2002 mjacob

A SCSI_DELAY of zero is a legitimate value to have.
The notion that you must "always" have a delay is at best misinformed.


103817 23-Sep-2002 mjacob

Note that the large Hitachi's are also CAM_QUIRK_HILUNS


103714 20-Sep-2002 phk

(This commit touches about 15 disk device drivers in a very consistent
and predictable way, and I apologize if I have gotten it wrong anywhere,
getting prior review on a patch like this is not feasible, considering
the number of people involved and hardware availability etc.)

If struct disklabel is the messenger: kill the messenger.

Inside struct disk we had a struct disklabel which disk drivers used to
communicate certain metrics to the disklayer above (GEOM or the disk
mini-layer). This commit changes this communication to use four
explicit fields instead.

Amongst the benefits is that the fields do not get overwritten by
wrong or bogus on-disk disklabels.

Once that is clear, <sys/disk.h> which is included in the drivers
no longer need to pull <sys/disklabel.h> and <sys/diskslice.h> in,
the few places that needs them, have gotten explicit #includes for
them.

The disklabel inside struct disk is now only for internal use in
the disk mini-layer, so instead of embedding it, we malloc it as
we need it.

This concludes (modulus any mistakes) the series of disklabel related
commits.

I belive it all amounts to a NOP for all the rest of you :-)

Sponsored by: DARPA & NAI Labs.


103687 20-Sep-2002 phk

Don't use dkunit() to find out unit, we already have our softc pointer
where we can find it.

Don't call dkpart() just to print the result, it is constant.

Sponsored by: DARPA & NAI Labs.


102862 02-Sep-2002 brooks

Make SCSI_DELAY setable at boot time and runtime via the
kern.cam.scsi_delay tunable/sysctl.

Reviewed by: mdodd, njl


102496 27-Aug-2002 njl

Add \n to various printfs. grep shows these should be the last ones.


102443 26-Aug-2002 gibbs

Adjust scsi_calc_syncparam() to the exception table changing from 10ths to
100ths of ns. This should correct a problem with camcontrol "ignoring"
requests to negotiate to slower speeds.


102412 25-Aug-2002 charnier

Replace various spelling with FALLTHROUGH which is lint()able


102342 24-Aug-2002 peter

Add some \n's to printf()s


102341 24-Aug-2002 peter

Fix unit wiring. Also, change the variable "hit" to "wired" so that it
is more obvious.

Obtained from: gibbs/ken


101998 16-Aug-2002 njl

Updates to cmd6workaround:
* Only update cdb in place if not CDB_POINTER
* Correctly check for QFRZ before restarting CCB
* More accurate printf message
* style(9) changes at end

Patch tested successfully on Maxtor 4 G120J6 GAK8.


101942 15-Aug-2002 njl

Remove cam_extend.[ch] after all references to them were removed.

PR: kern/39809
Approved by: gibbs


101940 15-Aug-2002 njl

Remove usage of cam_extend.c, replace with dev->si_drv1

PR: kern/39809
Approved by: gibbs


98449 19-Jun-2002 robert

Correct spelling of 'supplied'.

PR: misc/39528


98026 07-Jun-2002 mjacob

If we boot verbose, then print out 'interesting' CAM errors that otherwise
would hide problems (like Selection Timeout).


97882 05-Jun-2002 gibbs

Add the 160MHz syncrate to scsi_calc_syncrate() sync period exception table.


97881 05-Jun-2002 gibbs

scsi_message.h:
Include PPR option bits defined in SPI4.

scsi_iu.h:
Add data structures releated to parallel SCSI information units
for use in SPI4 packetized protocol.


97825 04-Jun-2002 mjacob

Add REPORT LUNS basic infrastructure.


97513 29-May-2002 dillon

PR: kern/38208
X-MFC after: immediate w/ release eng approval.


96959 19-May-2002 dillon

Add a Quirk entry for the USB SimpleTech UCF-100 compact flash reader.
Note that even with the quirk entry the reader typically only works if
the USB device is recognized by UHCI instead of the generic OHCI driver.


95333 24-Apr-2002 mjacob

Make Veritas Storage Appliance a HILUNS device.

MFC after: 1 day


95302 23-Apr-2002 marcel

Remove unused static variable quantum.


93505 01-Apr-2002 ken

Fix 3 of the four problems with my last indentation fix. ("fixing" the
fourth would be a divergence from the prevailing style.)

Thanks to bde for catching this.

Pointed out by: bde


93502 01-Apr-2002 ken

Fix an indentation problem.


93493 31-Mar-2002 phk

DA (scsi) and AD (ata) diskdrivers:
Make the dump routine do just writing of data.


93059 24-Mar-2002 simokawa

Maxtor Personal Storage 3000XT (Firewire) hangs upon
serial number probing.

MFC after: 1 week


93038 23-Mar-2002 simokawa

Automatically detect devices that do not support READ(6)/WRITE(6)
and upgrade to using 10 byte cdbs.

As far as I tested, this works efficiently for most of the
SBP-II/Firewire devices but most of the umass devices still need
ad-hoc work around because umass-sim doesn't return any SCSI errors.

A sysctl nob is also added for the last resort.
I hope we don't need DA_Q_NO_6_BYTE quirks anymore.

Reviewed by: gibbs
MFC after: 1 week


92770 20-Mar-2002 alfred

Remove __P.


92072 11-Mar-2002 phk

Mark some arguments __unused.


92052 11-Mar-2002 simokawa

Add support for Simplified Direct Access Device in scsi_op_desc().


91406 27-Feb-2002 jhb

Simple p_ucred -> td_ucred changes to start using the per-thread ucred
reference.


91062 22-Feb-2002 phk

GC: BIO_ORDERED going away.


91016 21-Feb-2002 simokawa

- Add support for Simplified Direct Access Device, mostly for
Firewire/SBP-II devices.

- Add quirk for Logitec USB/Firewire HDD.

MFC after: 3 days.


90868 18-Feb-2002 mike

o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
complexities associated with having MD (asm and inline) versions, and
having to prevent exposure of these functions in other headers that
happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on: alpha, i386
Reviewed by: bde, jake, tmm


90848 18-Feb-2002 bsd

Add NO_6_BYTE quirk entry for the LaCie Ltd. 105311 80 Gig USB2 drive.

Submitted by: Brian Schellenberger <bts@babbleon.org>


90484 10-Feb-2002 phk

Remove spurious ';'

Obtained from: ~bde/sys.dif.gz


90015 31-Jan-2002 sobomax

Add support of PhotoClip USB Camera (http://www.myphotoclip.com):
- Vendor&Device IDs for USB product,
- quirk for SCSI CAM.

PR: 34481
Submitted by: Olexander Kunytsa <kunia@x-telecom.net>
MFC in: 3 days


89114 09-Jan-2002 msmith

Define the kern.cam sysctl in the cam layer, rather than multiply in several
peripheral drivers. Remove Ken's comment to the effect that this needed
to be done.

Staticise camnet_ih and cambio_ih.


89113 09-Jan-2002 msmith

Staticise a debugging variable.

Submitted by: non


89105 08-Jan-2002 sobomax

Add quirk for DIVA USB Mp3 Player.

PR: kern/33638
Submitted by: Olexander Kunytsa <kunia@x-telecom.net>
MFC after: 3 days
(pending re's approval)


88975 07-Jan-2002 kbyanc

Extend Olympus E-100RS quirk to cover entire E series of digital cameras.


88900 05-Jan-2002 jhb

Change the preemption code for software interrupt thread schedules and
mutex releases to not require flags for the cases when preemption is
not allowed:

The purpose of the MTX_NOSWITCH and SWI_NOSWITCH flags is to prevent
switching to a higher priority thread on mutex releease and swi schedule,
respectively when that switch is not safe. Now that the critical section
API maintains a per-thread nesting count, the kernel can easily check
whether or not it should switch without relying on flags from the
programmer. This fixes a few bugs in that all current callers of
swi_sched() used SWI_NOSWITCH, when in fact, only the ones called from
fast interrupt handlers and the swi_sched of softclock needed this flag.
Note that to ensure that swi_sched()'s in clock and fast interrupt
handlers do not switch, these handlers have to be explicitly wrapped
in critical_enter/exit pairs. Presently, just wrapping the handlers is
sufficient, but in the future with the fully preemptive kernel, the
interrupt must be EOI'd before critical_exit() is called. (critical_exit()
can switch due to a deferred preemption in a fully preemptive kernel.)

I've tested the changes to the interrupt code on i386 and alpha. I have
not tested ia64, but the interrupt code is almost identical to the alpha
code, so I expect it will work fine. PowerPC and ARM do not yet have
interrupt code in the tree so they shouldn't be broken. Sparc64 is
broken, but that's been ok'd by jake and tmm who will be fixing the
interrupt code for sparc64 shortly.

Reviewed by: peter
Tested on: i386, alpha


88765 01-Jan-2002 jedgar

Add support for Nikon Coolpix E775 and E885 cameras.

PR: 33407 (E885)
Submitted by: Brian Behlendorf <brian@hyperreal.org> (E885)


87983 15-Dec-2001 non

o Add KLD support for scsi_low.
o Add KLD dependency of ncv, nsp and stg drivers to scsi_low.

Submitted by: takawata


87582 10-Dec-2001 non

Remove PAO3 dependent part where I missed to remove at last commit.


87577 09-Dec-2001 iedowse

Add a NO_6_BYTE quirk for the D-series olympus digital cameras.

PR: kern/31250
Submitted by: Bryan Liesner <bleez@bellatlantic.net>


86940 27-Nov-2001 ken

Bring the probe inquiry code in line with the SCSI spec.

It is legal to have a device with device type 0x1f, that just means
that the device is of unknown type. Instead, only check the peripheral
qualifier when deciding whether or not to reject a device based on its
inquiry information.

Tested by: julian
MFC after: 3 weeks


86913 26-Nov-2001 iedowse

Back out 1.88 (NO_SYNC_CACHE quirk for Infortrend IFT-3102). Since
this device properly reports that the sync cache command is
unsupported, the bug is that we still complain about it on the
console.

Noticed by: gibbs


86633 19-Nov-2001 dg

Disabled tagged commands for Hitachi Jura-C series with J8A8 firmware.

PR: 23536
Submitted by: amagai@nue.org


86623 19-Nov-2001 iedowse

Back out revision 1.117; the correct solution is to upgrade the
firmware on the drive in question. The pattern also matched far
too many Hitachi drives.

Spotted by: dg


86564 19-Nov-2001 iedowse

Hitachi DK32 disks have problems with tagged queuing under load.

PR: kern/23536
Submitted by: Y.Amagai <amagai@nue.org>
MFC after: 1 week


86503 17-Nov-2001 mjacob

Be very generous with timeouts for synchronize cache. We may wait a very long
time in the cases where it really sends the drive out to lunch, but it also
allows us to catch very wierd edge cases of strange drives that might take
a very long time (emulated disk drives over a network, e.g.).


86502 17-Nov-2001 iedowse

The Infortrend IFT-3102 multihost U2 SCSI to U2 SCSI controller
doesn't support the synchronise cache command.

PR: kern/21752
Submitted by: Nick R. Colakovic <nickc@corp.firstindustrial.com>
MFC after: 1 week


86500 17-Nov-2001 iedowse

Add quirk for Fujitsu M2513A MO drives. These drives hang at various
operations due to the synchronize cache command.

PR: kern/21674
Submitted by: W.Scholten <whs@xs4all.nl>
MFC after: 1 week


86313 13-Nov-2001 ps

Fix a signed bug in the crashdump code for systems with > 2GB of ram.

Reviewed by: peter


86177 07-Nov-2001 kbyanc

Add quirk for Minolta 2330 Zoom digital camera.

Submitted by: Jan Stocker <Jan.Stocker@t-online.de>


86174 07-Nov-2001 kbyanc

Add quirk for Nikon Coolpix 995.

Submitted by: Jos Vissers <jos@tunix.nl>


86161 06-Nov-2001 kbyanc

Fix bug in scsi_read_write() where it might use 6-byte commands when
10/12-byte-specific flags where specified.

Reviewed by: ken
MFC after: 1 day


86115 05-Nov-2001 kbyanc

Add quirk entry for Olympus E-100RS digital camera. This and the existing
quirk regarding the C- series makes me suspect that all Olympus models have
the same quirks, but I cannot prove it.

Submitted by: Bernd Walter <ticso@cicely8.cicely.de>


85962 03-Nov-2001 non

Remove PAO3 dependent part.
This will not affect either -current nor -stable.


84953 15-Oct-2001 scottl

Add a quirk entry so that the Maxtor 3000LE USB drive will work.

Submitted by: merry, Randy Bush <randy@psg.com>
MFC after: 3 days


83974 26-Sep-2001 rwatson

o Modify access control code for the CAM SCSI pass-through device to
use securelevel_gt() instead of direct securelevel variable test.

Obtained from: TrustedBSD Project


83917 25-Sep-2001 rwatson

s/securelvel/securelevel/


83657 19-Sep-2001 scottl

Add a quirk entry for the Sony CLIE memory stick device. This will become
useful once ATAPI support is turned on in the umass driver.


83473 14-Sep-2001 mjacob

The code that sees a drive (at mount time) not in buffered mode and
attempts to set buffered mode was printing out "unable to set buffered
mode" no matter what. Oops.

Spotted by: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
MFC after: 3 weeks


83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


82850 03-Sep-2001 ken

Attach to a CD device even when the SCSI status is 'busy'.

Reported by: Thomas Quinot <thomas@cuivre.fr.eu.org>
MFC after: 3 weeks


82826 02-Sep-2001 n_hibma

Add quirk entry for FujiFilm camera.

Submitted by: Guido van Rooij <guido@gvr.org>


82787 02-Sep-2001 n_hibma

Add quirks for Kingbyte USB Pen drive.

Submitted by: Eugene M. Kim <gene@nttmcl.com>
PR: 29530


82592 30-Aug-2001 mjacob

Take CAM_REQUEUE_REQ out of the class of things we were trying to honor
retry count on.

MFC after: 4 weeks


82575 30-Aug-2001 mjacob

Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases.
Clear residual counts after a successful samount (the user doesn't
care that we got an N-kbyte residual on our test read).

Change a lot of error handling code.

1. If we end up in saerror, check more carefully about the kind of
error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write
command, we'll be handling this in saerror. If it isn't a read/write
command, check to see whether this is just an EOM/EOP check condition-
if it is, just set residual and return normally. A residual and
then a NO SENSE check condiftion with the ASC of 0 and ASCQ of
between 1 and 4 are normal 'signifying' events, not errors per se,
and we shouldn't give the command to cam_periph_error to do something
relatively unpredictable with.

2. If we get a Bus Reset, had a BDR sent, or get the cam status of
CAM_REQUEUE_REQ, check the retry count on the command. The default
error handler, cam_periph_error, doesn't honor retry count in these
cases. This may change in the future, but for now, make sure we
set EIO and return without calling cam_periph_error if the retry
count for the command with an error is zero.

3. Clean up the pending error case goop and handle cases more
sensibly.

The rules are:

If command was a Write:

If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is
propagated and we set ENOSPC as the error.

Else if we got an EOM condition- just mark EOM pending.

And set a residual of zero. For the longest time I was just
propagating residual from the sense data- but my tape
comparison tests were always failing because all drives I
tested with actually *do* write the data anyway- the EOM
(early warning) condition occurred *prior* to all of the
data going out to media- that is, it was still buffered by
the drive. This case is described in SCSI-2, 10.2.14,
paragraph #d for the meaning of 'information field'. A
better fix for this would be to issue a WFM command of zero
to cause the drive to flush any buffered data, but this
would require a fairly extensive rewrite.

Else if the command was a READ:

If we got a SSD_KEY_BLANK_CHECK-
If we have a One Filemark EOT model- mark EOM as pending,
otherwise set EIO as the erorr.
Else if we found a Filemark-
If we're in Fixed Block mode- mark EOF pending.

If we had an ILI (Incorrect Length Indicator)-
If the residual is less than zero, whine about tape record
being too big for user's buffer, otherwise if we were in
Fixed Block mode, mark EIO as pending.

All 'pending' conditions mean that the command in question completes
without error indication. It had succeeded, but a signifying event
occurred during its execution which will apply to the *next* command
that would be exexcuted. Except for the one EOM case above, we always
propagate residual.

Now, way back in sastart- if we notice any of the PENDING bits set,
we don't run the command we've just pulled off the wait queue. Instead,
we then figure out it's disposition based upon a previous command's
association with a signifying event.

If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete
the command with residual set to the request count (not data moved,
but no error). We continue on.

If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in
Fixed Block mode- in which case we traverse all waiting buffers (which
we can get in fixed block mode because physio has split things up) and
mark them all as no error, but no data moved and complete them.

If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error
and complete it.

Then we clear all of the pending state bits- we're done.

MFC after: 4 weeks


82384 27-Aug-2001 kbyanc

Add interfaces for SCSI LOG SELECT and LOG SENSE commands.

Reviewed by: ken


82106 21-Aug-2001 n_hibma

Add quirks for the Olympus Digital Camera.

PR: 26295

Add quirks for the Microtech CameraMate.


81448 10-Aug-2001 phk

Eliminate the hot-spare 'r' in Arrray.

Submitted by: Søren Schrøder <sch@chaos.dk>


80578 30-Jul-2001 mjacob

Kill the command (don't rerun it) if we had an AUTOSENSE failure.
If we had an AUTOSENSE failure, we don't know what SENSE DATA
we had for a CHECK CONDITION. It's far better to assume failure
in this case.


80577 30-Jul-2001 mjacob

(Forced commit- last one missed the comments)

Handle both old and new TARGIOALLOCUNIT/TARGIOFREEUNIT cases- the new
one allows us to specify inquiry data we want to use.

Handle more of the CAM_DIS_DISCONNECT case.


80576 30-Jul-2001 mjacob

(Forced commit- last commit was inadvertant in that it missed the comments)

Move TARGCTLIOALLOCUNIT to OTARGCTLIOALLOCUNIT, TARGCTLIOFREEUNIT
to OTARGCTLIOFREEUNIT and redefine old associated structure to be
old_ioc_alloc_unit- deprecation but preservation of binaries.

Add new structure for same- but this one contains a pointer to
user defined INQUIRY data so you can define what the target
device looks like to the outside world.


80575 30-Jul-2001 mjacob

backout last commit- inadvertant


80574 30-Jul-2001 mjacob

scsi_targetio.h


80573 30-Jul-2001 mjacob

Propagate CAM_DIS_DISCONNECT on through:

1. If we get frozen, unfreeze for disable disconnects.
2. Put CAM_DIS_DISCONNECT commands at the head of the work queue
(we have a target still connected and we can't run anything else
until this command completes).

If we had an error sending the last CTIO, unfreeze the queue anyway.


80033 20-Jul-2001 n_hibma

Support for USB floppies based upon SMSC USB FDD controller.

PR: 28877
Submitted by: Larry Baird <lab@gta.com>
MFC after: 1 week


79697 14-Jul-2001 non

Catch up with NetBSD/pc98.
o Much cleanly separate NetBSD(XS) / FreeBSD(CAM) codes.
o Improve tagged queing support (full QTAG).
o Improve quirk support.
o Improve parity error retry.
o Impliment wide negotheation.
o Cmd link support.
o Add copyright of CAM part.
o Change for CAM_NEW_TRAN_CODE.
o Work around for buggy KME UJDCD450.

o stg: add disconnet condition.
o nsp: use suspend I/O.
and more. I thank Honda-san.

conf/options.pc98: add CT_USE_RELOCATE_OFFSET and CT_BUS_WEIGHT
dev/{ct,ncv,nsp,stg}/*_{pccard,isa}.c: add splcam() before calling
attach/detach functions.

Tested by: bsd-nomads
Obtained from: NetBSD/pc98


79575 11-Jul-2001 dd

Call disk_destroy in cdcleanup() as appropriate.

PR: 24596
Reviewed by: ken


79483 09-Jul-2001 mjacob

Add SYSCTL ints for default normal I/O timeout && retry counts.

This is useful if you want to dynamically move into a Fibre Channel
or Multi-initiator environment that happens to be particularly noisy
and ugly that requires a lot of retries (with shorter I/O timeouts)
for commands destried by LIPs or Bus Resets.

Reviewed by: deafening silence on audit && scsi on the retry counts
MFC after: 2 weeks


79177 04-Jul-2001 mjacob

Check the void * argument in the AC_FOUND_DEV case against NULL. Whether
correctly or not, this sometimes is propagated up via XPT.


79100 02-Jul-2001 mjacob

A slightly more complete change to timeouts:

1. Add SA_IO_TIMEOUT as an option (4 minutes default) to cover reads,
writes, wfm, test unit ready.

2. Add internal SCSIOP_TIMEOUT (e.g., for mode sense) at 1 minute. This
should not require an option, but is cleaner to parameterize.

MFC after: 1 week


79094 02-Jul-2001 lars

Reviewed by: Matthew Jacob
Changed the timeout to wait for writing of filemarks to complete from 1
minute to 3 minutes. This should probably be enhanced to be a sysctl variable.


78710 24-Jun-2001 mjacob

cleanup some of the XPORT_FC code


78709 24-Jun-2001 mjacob

Add a transport settings variant for Fibre Channel.


78230 15-Jun-2001 peter

Fix warnings:
1267: warning: suggest parentheses around comparison in operand of &
2087: warning: unused variable `li'


78135 12-Jun-2001 peter

Hints overhaul:
- Replace some very poorly thought out API hacks that should have been
fixed a long while ago.
- Provide some much more flexible search functions (resource_find_*())
- Use strings for storage instead of an outgrowth of the rather
inconvenient temporary ioconf table from config(). We already had a
fallback to using strings before malloc/vm was running anyway.


77810 06-Jun-2001 non

Sorry, an "ARCHIVE Python 06408" does not need SA_QUIRK_NOCOMP.


77710 04-Jun-2001 mjacob

first blush at some FC path inquiry settings


77709 04-Jun-2001 mjacob

Do NOLUNS dance for oddball Exabyte. We *really* need to do this as hints.

Correct match for A5000 SES instance.

PR: 19887
MFC after: 2 weeks


77708 04-Jun-2001 mjacob

first blush at some FC path inquiry settings


77581 01-Jun-2001 non

Add a quirk entry for ARCHIVE Python 06408.

Approved by: mjacob


77254 27-May-2001 ken

Print out the asc/ascq and description even when both the asc and ascq
are zero. This is so that users will see the "no addtional sense" printout
and know that they have the full sense information.


76650 15-May-2001 jhb

Remove unneeded includes of sys/ipl.h and machine/ipl.h.


76362 08-May-2001 phk

Exploit recent improvements in the disk minilayer to simplify error
handling a bit.

Dogmatic lingupurists can celebrate that a number of gotos got removed.

Reviewed by: mjacob, ken


76322 06-May-2001 phk

Actually biofinish(struct bio *, struct devstat *, int error) is more general
than the bioerror().

Most of this patch is generated by scripts.


76293 05-May-2001 joerg

Add q quirk for the old SONY SMO drive i've been sitting upon in my
private tree for too long now. This (pre SCSI-2) drive returns a
mystic code when the medium is inserted but not spun up.


76192 01-May-2001 ken

Fix up unit attention and selection timeout handling in various peripheral
drivers.

- change daprevent() to set CAM_RETRY_SELTO and SF_RETRY_UA when it calls
cam_periph_runccb().
- change the pt(4) driver to ignore unit attentions
- change the targ(4) driver to retry selection timeouts
- clean up a few formatting glitches in the targ(4) driver

Reviewed by: gibbs


76162 30-Apr-2001 ken

Add sense key table entries for DATA PROTECT and BLANK CHECK. This will
prevent scsi_sense_desc() from deferencing a NULL pointer when a drive
happens to return one of these sense keys.

Reported by: Michael Samuel <michael@miknet.net>


76158 30-Apr-2001 ken

In camperiphscsisenseerror(), don't return an error when the error action
is SS_NOP.

Submitted by: joerg


76153 30-Apr-2001 ken

Fix an errant search and replace that broke SCSI start unit commands.

This should fix automatic spinups as well as 'camcontrol start'.


75840 22-Apr-2001 joerg

Fix the `tape drive spinning indefinately upon mt stat' problem.

With the recent changes in the CAM error handling, some problems in
the error handling of sa(4) have been uncovered. Basically, a number
of conditions that are not actually errors have been mistreated as
genuine errors. In particular:

. Trying to read in variable length mode with a mismatched blocksize
between the on-tape (virtual) blocks and the read(2) supplied buffer
size, causing an ILI SCSI condition, have caused an attempt to retry
the supposedly `errored' transfer, causing the tape to be read
continuously until it eventually hit EOM. Since by default any
simple mt(1) operation does an initial test read, an `mt stat' was
sufficient to trigger this bug.

Note that it's Justin's opinion that treating a NO SENSE as an EIO
is another bug in CAM. I feel not authorized to fix cam_periph.c
without another confirmation that i'm on the right track, however.

. Hitting a filemark caused the read(2) syscall to return EIO, instead
of returning a `short read'. Note that the current fix only solves
this problem in variable length mode. Fixed length mode uses a
different code path, and since i didn't grok all the intentions behind
that handling, i did not touch it (IOW: it's still broken, and you get
an EIO upon hitting a filemark).

The solution is to keep track of those conditions inside saerror(),
and upon completion to not call cam_periph_error() in that case. We
need to make sure that the device gets unfrozen if needed though (in
case of actual errors, cam_periph_error() does this on our behalf).

Not objected by: mjacob (who currently doesn't have the time to
review the patch)


75549 16-Apr-2001 ken

Fix an off-by-2 error in periphdriver_register(). The read side of the
bcopy would go off the end of the array by two elements, which sometimes
causes a panic if it happens to cross into a page that isn't mapped.

Submitted by: gibbs
Reviewed by: peter


75190 04-Apr-2001 mjacob

If we have and error and are booting verbosely, don't be complaining
if this was a non-retryable selection timeout- wading through 256 targets
worth of Fibre Channel 'selection timeouts' is tedious at best.


75030 31-Mar-2001 murray

comment typo: subsytem -> subsystem

PR: 26219
Submitted by: Andre <andre@akademie3000.de>, chern@osd.bsdi.com


74914 28-Mar-2001 jhb

Catch up to header include changes:
- <sys/mutex.h> now requires <sys/systm.h>
- <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>


74890 28-Mar-2001 ps

Last commit was broken.. It always prints '[CTRL-C to abort]'.
Move duplicate code for printing the status of the dump and checking
for abort into a separate function.

Pointy hat to: me


74841 27-Mar-2001 ps

Change the dump routines to only abort if control-c is pressed.
If any other key is pressed, print a message stating that control-c
is how to abort.

Reviewed by: peter


74840 27-Mar-2001 ken

Rewrite of the CAM error recovery code.

Some of the major changes include:

- The SCSI error handling portion of cam_periph_error() has
been broken out into a number of subfunctions to better
modularize the code that handles the hierarchy of SCSI errors.
As a result, the code is now much easier to read.

- String handling and error printing has been significantly
revamped. We now use sbufs to do string formatting instead
of using printfs (for the kernel) and snprintf/strncat (for
userland) as before.

There is a new catchall error printing routine,
cam_error_print() and its string-based counterpart,
cam_error_string() that allow the kernel and userland
applications to pass in a CCB and have errors printed out
properly, whether or not they're SCSI errors. Among other
things, this helped eliminate a fair amount of duplicate code
in camcontrol.

We now print out more information than before, including
the CAM status and SCSI status and the error recovery action
taken to remedy the problem.

- sbufs are now available in userland, via libsbuf. This
change was necessary since most of the error printing code
is shared between libcam and the kernel.

- A new transfer settings interface is included in this checkin.
This code is #ifdef'ed out, and is primarily intended to aid
discussion with HBA driver authors on the final form the
interface should take. There is example code in the ahc(4)
driver that implements the HBA driver side of the new
interface. The new transfer settings code won't be enabled
until we're ready to switch all HBA drivers over to the new
interface.

src/Makefile.inc1,
lib/Makefile: Add libsbuf. It must be built before libcam,
since libcam uses sbuf routines.

libcam/Makefile: libcam now depends on libsbuf.

libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the
sbuf sources from sys/kern.

bsd.libnames.mk: Add LIBSBUF.

camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically
linked, we can't depend on the dynamic linker
to pull in libsbuf.

camcontrol.c: Use cam_error_print() instead of checking for
CAM_SCSI_STATUS_ERROR on every failed CCB.

sbuf.9: Change the prototypes for sbuf_cat() and
sbuf_cpy() so that the source string is now a
const char *. This is more in line wth the
standard system string functions, and helps
eliminate warnings when dealing with a const
source buffer.

Fix a typo.

cam.c: Add description strings for the various CAM
error status values, as well as routines to
look up those strings.

Add new cam_error_string() and
cam_error_print() routines for userland and
the kernel.

cam.h: Add a new CAM flag, CAM_RETRY_SELTO.

Add enumerated types for the various options
available with cam_error_print() and
cam_error_string().

cam_ccb.h: Add new transfer negotiation structures/types.

Change inq_len in the ccb_getdev structure to
be "reserved". This field has never been
filled in, and will be removed when we next
bump the CAM version.

cam_debug.h: Fix typo.

cam_periph.c: Modularize cam_periph_error(). The SCSI error
handling part of cam_periph_error() is now
in camperiphscsistatuserror() and
camperiphscsisenseerror().

In cam_periph_lock(), increase the reference
count on the periph while we wait for our lock
attempt to succeed so that the periph won't go
away while we're sleeping.

cam_xpt.c: Add new transfer negotiation code. (ifdefed
out)

Add a new function, xpt_path_string(). This
is a string/sbuf analog to xpt_print_path().

scsi_all.c: Revamp string handing and error printing code.
We now use sbufs for much of the string
formatting code. More of that code is shared
between userland the kernel.

scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly
useful in the first place.

Add a new error action, SS_REQSENSE. (Send a
request sense and then retry the command.)
This is useful when the controller hasn't
performed autosense for some reason.

Change the default actions around a bit.

scsi_cd.c,
scsi_da.c,
scsi_pt.c,
scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection
timeouts shouldn't be covered by a sense flag.

scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO.

Get rid of the last vestiges of a read/write
interface.

libkern/bsearch.c,
sys/libkern.h,
conf/files: Add bsearch.c, which is needed for some of the
new table lookup routines.

aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if
CAM_NEW_TRAN_CODE is defined.

sbuf.h,
subr_sbuf.c: Add the appropriate #ifdefs so sbufs can
compile and run in userland.

Change sbuf_printf() to use vsnprintf()
instead of kvprintf(), which is only available
in the kernel.

Change the source string for sbuf_cpy() and
sbuf_cat() to be a const char *.

Add __BEGIN_DECLS and __END_DECLS around
function prototypes since they're now exported
to userland.

kdump/mkioctls: Include stdio.h before cam.h since cam.h now
includes a function with a FILE * argument.

Submitted by: gibbs (mostly)
Reviewed by: jdp, marcel (libsbuf makefile changes)
Reviewed by: des (sbuf changes)
Reviewed by: ken


74810 26-Mar-2001 phk

Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.


74368 16-Mar-2001 ken

Fix inquiry length detection for the ses(4) driver. It was using the
inq_len member of the ccb_getdev structure, but we've never filled that
value in..

So we now get the length from the inquiry data returned by the drive.
(Since we will fetch as much inquiry data as the drive claims to support.)

Reviewed by: mjacob
Reported by: Andrzej Tobola <san@iem.pw.edu.pl>


74222 13-Mar-2001 ken

In xpt_set_transfer_settings(), force async if either the period or the
offset is set to 0.

Re-arrange the DT limiting code so that we don't end up setting the period
to 0xa if the user really wants async. The previous behavior seemed to
confuse the aic(4) driver.

PR: kern/22733
Reviewed by: gibbs


73025 25-Feb-2001 non

o Support AUTO SENSE correctly.
o Offset and period in synch messages and width negotiation should be
done for per target not per lun. Move these from *lun_info to
*targ_info.
o Change in handling XPT_RESET_DEV and XPT_GET_TRAN_SETTINGS .
o Change CAM_* xpt_done return values.
o Busy loop did not timeout. Change this to timeout as original NetBSD/pc98.

Reviewed by: bsd-nomads ML


72992 24-Feb-2001 gibbs

In the SCSI_NO_SENSE_STRINGS case, properly fill the table with the
asc and ascq pair rather than asc, asc.

PR: 25291
Submitted by: Stephen Ferrari <sferrari@yahoo.com>


72850 22-Feb-2001 mjacob

Restore a print_sense=FALSE that got nuked by accident in last delta.
Noticed by: Dan Nelson <dnelson@emsphone.com>


72804 21-Feb-2001 mjacob

Use the correct device names (now that we have devfs to embarrass us).
PR: 25254


72375 11-Feb-2001 mjacob

1. The key SSD_KEY_RECOVERED_ERROR is not an error at all and should
not be retried. It is an indication that there was an error that was
corrected during the execution of the command. This is per ANSI SCSI2
spec.

It's possible that these should also be noted to the console (as indicative,
perhaps, of growing media defect lists in drives), but the default of
printing errors out if bootverbose in this case is probably enough.

Also, there'd been a missing ERESTART for that clause anyway.

2. If you have an ABORTED COMMAND, it's almost invariably a SCSI parity
error. You should never be silent about these since users should do something
about this if it occurs (moving that power cord *away* from the SCSI cable is
always a good first start). This should print irrespective of bootverbose
because it's an actual real error even if we retry a transmission.

Reviewed by: audit@freebsd.org, gibbs@freebsd.org


72238 09-Feb-2001 jhb

- Catch up to the new swi API changes:
- Use swi_* function names.
- Use void * to hold cookies to handlers instead of struct intrhand *.
- In sio.c, use 'driver_name' instead of "sio" as the name of the driver
lock to minimize diffs with cy(4).


72119 07-Feb-2001 peter

Change the peripheral driver list from a linker set to module driven
driver registration. This should allow things like da, sa, cd etc to be
in seperate KLD's to the cam core and make them preloadable.


72012 04-Feb-2001 phk

Another round of the <sys/queue.h> FOREACH transmogriffer.

Created with: sed(1)
Reviewed by: md5(1)


71999 04-Feb-2001 phk

Mechanical change to use <sys/queue.h> macro API instead of
fondling implementation details.

Created with: sed(1)
Reviewed by: md5(1)


71772 29-Jan-2001 ken

Back out rev 1.102. The IBM DNES drives work fine for me, jedgar and other
folks.

My guess is that reducing the number of tags is just masking the real
problem for the PR submitter. I'll re-open the PR and see if I can work
with the submitter to diagnose the problem.

PR: 21139


71752 28-Jan-2001 ken

Fix region code reporting.

Reported by: Andrew Gordon <arg@arg1.demon.co.uk>


71508 24-Jan-2001 jhb

#ifdef a local variable only used in debugging code.

Reviewed by: -scsi


71507 24-Jan-2001 jhb

Const'ify cam_sim.sim_name to quiet warnings.

Reviewed by: -scsi


71493 24-Jan-2001 mjacob

"Rejected with status" is better than "Rejected for status".


71421 23-Jan-2001 joerg

Mark the (ancient) MaxOptix Tahiti 1 drive as a known rogue that would
respond to all LUNs.

Reviewed by: ken


71268 19-Jan-2001 mjacob

Make some attempt to accomodate kern/24221- propate residual to mt_resid
even if it might overflow.

If we do a read or set of hardware or logical block position, we also
clear Tape Frozen status.


71117 16-Jan-2001 mjacob

Add tags quirk for IBM DNES drives.

PR: 21139
Obtained from: campt@miralink.com


71087 16-Jan-2001 mjacob

Use the residual from a spacing operation to try and figure out where
we *really* are.

It should be noted that there is a degenerate case where soft tape
location will be lost (not causing a frozen state- but causing
the loss of reporting fileno/blockno)- that's where you backspace
over a filemark- you stop backspacing as soon as you cross the
filemark, but you have no idea what the record number now is because
you have no idea how many records you are into the file you just
backed into. Such is life.

While I'm at it, also pick up residuals from writing filemarks.

PR: 24222


71086 16-Jan-2001 mjacob

Get rid of those pesky "driver mistake" messages... destroy the create_d dev_t
when you take down the device.

Reviewed by: audit@freebsd.org (Warner, Justin)


71082 15-Jan-2001 mjacob

Fix PR 24220 by using the periph private field0 for a CCB for not
only CCB type but also extra flags- one of which can be "position
updated".

In other changes: Add in a SA_QUIRK_NO_CPAGE quirk so that it's possible
to avoid using a (broken) device's implementation of he DEVICE COMPRESSION
page.

Also do a couple of printout cleanups.

As per some discussion on FreeBSD-scsi, skip doing tape flushing
if we're reading tape logical block location (MTIOCRDSPOS).


70992 13-Jan-2001 nyan

Check __i386__, not i386.


70946 12-Jan-2001 steve

Spell declarations correctly.


70832 09-Jan-2001 wollman

select() DKI is defined in <sys/selinfo.h> now.


70780 08-Jan-2001 n_hibma

Add the 'No 6 byte commands' quirk for the Yano ATAPI USB bridge.

Submitted by: Iwasa Kazmi <kzmi@ca2.so-net.ne.jp>


70032 14-Dec-2000 imp

Generalize quirk for Sony Memory Sticks. Any device that starts with
MS will be treated as having this quirk. In the event that we falsely
identify one that doesn't need it, no harm will be done. Ken
suggested that we make this more generic since there may be more
needed in the future.

Reported by: TERAMOTO Masahiro <teramoto@comm.eng.osaka-u.ac.jp>
PR: kern/23378
Reviewed by: ken


69979 13-Dec-2000 non

Move `#include <sys/devicestat.h>' into #ifdef/#endif to keep
comaptibility with NetBSD/pc98.


69729 07-Dec-2000 phk

Add needed include of <sys/devicestat.h>


69577 04-Dec-2000 joerg

Turn off the load_eject bit in cdstartunit(). It causes an `Invalid
field in CDB' error when attempting to start a caddy-type CD drive,
since those drives apparently in general refuse to load a medium. Since
we never advertised the feature to load the medium upon calling
cdstartunit() (i. e. upon receipt of a CDIOCSTART ioctl command), nobody
should have relied on it. Besides, nobody noticed so far at all that
this command is failing for caddy-type drives... Only few applications
seem to use it at all (among them is workman, which made me notice it).

Reviewed by: ken


68500 08-Nov-2000 mjacob

Add special quirk for this ancient Viper drive. This is all creeping
driver bloat -I really *have* to do a quirk table that can be loaded
by the loader.

Submitted by: Hellmuth Michaelis <hm@kts.org>


68403 06-Nov-2000 gibbs

Fix async notifications for listners registered to wildcard nodes. For
example, a client registered to receive specific events for bus 0, target *,
lun *, was not receiving notifications.

Reviewed by: ken@FreeBSD.org


68294 04-Nov-2000 ken

Fix a problem with the previous revision (1.42) that showed up with audio
CDs.

With audio CDs, you can't just do a READ(10) call on most drives without
first setting the blocksize with a mode select command. The disklabel code
does a read of the first sector of the media to find a label if it exists.

This caused drives to return an error when an audio CD was in the drive,
due to the problem described above.

The solution is to read the table of contents on the CD, and only attempt
to read the disklabel if the first track is a data track.

This works on all the various CD and DVD media I have tried, but further
testing (especially with Video CDs and other mode 2 media) will be
needed to determine if this is a universal solution.


68116 31-Oct-2000 mjacob

1. Oops on last commit: note a few SCSI-3 items for data compression page.
2. Change copyright to me- per practive of scsi_sa.c that Justin had
me do a while back.


68114 31-Oct-2000 mjacob

scsi_sa.h


68108 31-Oct-2000 gibbs

Treat engine inquiry the same as path inquiry in xptioctl().
Return ENOTSUP for any opcode that is not supported by the XPT
device.

Add back a missing local declaration that seems to have been deleted
by my last commit.


68085 31-Oct-2000 gibbs

0x03F -> 0x3F for consistancy with the rest of the file.


68084 31-Oct-2000 gibbs

Allow async transfer negotiation updates to modify tagging behavior.
The XPT uses this to prevent tags from being used on parallel SCSI
interfaces immediately after a bus reset or BDR so that controllers
have an oportunity to renegotiate without tag messages in the way.
Somehow this got disabled... the functionality has been here for
quite some time.

Noticed by: my SCSI bus analyzer


68009 30-Oct-2000 scottl

Allow XPT_PATH_INQ to be performed on the XPT device, as per the CAM spec.
Return ENOTSUP for XPT_ENG_INQ and XPT_ENG_EXEC when performed on the XPT
device.

Reviewed by: gibbs


67964 30-Oct-2000 non

Remove unused #includes.

Submitted by: phk@FreeBSD.ORG


67932 30-Oct-2000 phk

Remove unused #includes

Reviewed by: ken


67928 30-Oct-2000 ken

Write support for the cd(4) driver.

This allows writing to DVD-RAM, PD and similar drives that probe as CD
devices. Note that these are randomly writeable devices, not
sequential-only devices like CD-R drives, which are supported by cdrecord.

Add a new flag value for dsopen(), DSO_COMPATLABEL. The cd(4) driver now
uses this flag instead of the DSO_NOLABELS flag. The DSO_NOLABELS always
used a "fake" disklabel for the entire disk, provided by the caller.

With the DSO_COMPATLABEL flag, dsopen() will first search the media for a
label, and if it finds a label, it will use that label. Otherwise it will
use the fake disklabel provided by the caller. This provides backwards
compatibility, since we will still have labels for ISO9660 media.

It also provides new functionality, since you can now have a regular BSD
disklabel on read-only media, or on writeable media (e.g. DVD-RAM).

Bruce and I both think that we should eventually (in a few years) get
away from using disklabels for ISO9660 media, and just use the whole disk
device (/dev/cd0). At that point disklabel handling in the cd(4) driver
could follow the "normal" model, as used in the da(4) driver.

Also, clean up the path in a couple of places in cdregister(). (Thanks to
Nick Hibma for catching that bug.)

Reviewed by: bde


67888 29-Oct-2000 dwmalone

Add the use of M_ZERO to some malloc calls.

Submitted by: josh@zipperup.org
Submitted by: Robert Drehmel <robd@gmx.net>
Approved by: gibbs


67882 29-Oct-2000 phk

Remove unneeded #include <sys/proc.h> lines.


67847 29-Oct-2000 non

Changed not to use struct isa_device in the argument of scsi_low_activate().
You will not need COMPAT_OLDISA in config file.
This interface may have to change in future.


67752 28-Oct-2000 ken

Add a quirk entry for Nakamichi MJ-* changers. The changer in question is
a <NAKAMICH MJ-5.16S 1.06>.

Submitted by: Kevin Van Maren <vanmaren@fast.cs.utah.edu>


67723 27-Oct-2000 mjacob

Add usage of M_ZERO to malloc calls where the result was just bzeroed.

PR: 22186
Submitted (partially) by: josh@zipperup.org


67708 27-Oct-2000 phk

Convert all users of fldoff() to offsetof(). fldoff() is bad
because it only takes a struct tag which makes it impossible to
use unions, typedefs etc.

Define __offsetof() in <machine/ansi.h>

Define offsetof() in terms of __offsetof() in <stddef.h> and <sys/types.h>

Remove myriad of local offsetof() definitions.

Remove includes of <stddef.h> in kernel code.

NB: Kernelcode should *never* include from /usr/include !

Make <sys/queue.h> include <machine/ansi.h> to avoid polluting the API.

Deprecate <struct.h> with a warning. The warning turns into an error on
01-12-2000 and the file gets removed entirely on 01-01-2001.

Paritials reviews by: various.
Significant brucifications by: bde


67551 25-Oct-2000 jhb

- Overhaul the software interrupt code to use interrupt threads for each
type of software interrupt. Roughly, what used to be a bit in spending
now maps to a swi thread. Each thread can have multiple handlers, just
like a hardware interrupt thread.
- Instead of using a bitmask of pending interrupts, we schedule the specific
software interrupt thread to run, so spending, NSWI, and the shandlers
array are no longer needed. We can now have an arbitrary number of
software interrupt threads. When you register a software interrupt
thread via sinthand_add(), you get back a struct intrhand that you pass
to sched_swi() when you wish to schedule your swi thread to run.
- Convert the name of 'struct intrec' to 'struct intrhand' as it is a bit
more intuitive. Also, prefix all the members of struct intrhand with
'ih_'.
- Make swi_net() a MI function since there is now no point in it being
MD.

Submitted by: cp


67468 23-Oct-2000 non

Add PC-Card/ISA SCSI host adpater drivers from NetBSD/pc98
(a NetBSD port for NEC PC-98x1 machines). They are ncv for NCR 53C500,
nsp for Workbit Ninja SCSI-3, and stg for TMC 18C30 and 18C50.

I thank NetBSD/pc98 and bsd-nomads people.

Obtained from: NetBSD/pc98


67345 20-Oct-2000 n_hibma

Add the quirk entry for the Sony Memory Stick Adapter.

Add NO_SYNQ_CACHE to the Sony DSC camera entry.


67320 19-Oct-2000 jhb

Quiet a silly warning.

Pointy-hat to: ps


67247 17-Oct-2000 ps

Implement write combining for crashdumps. This is useful when
write caching is disabled on both SCSI and IDE disks where large
memory dumps could take up to an hour to complete.

Taking an i386 scsi based system with 512MB of ram and timing (in
seconds) how long it took to complete a dump, the following results
were obtained:

Before: After:
WCE TIME WCE TIME
------------------ ------------------
1 141.820972 1 15.600111
0 797.265072 0 65.480465

Obtained from: Yahoo!
Reviewed by: peter


67164 15-Oct-2000 phk

Remove unneeded #include <machine/clock.h>


67159 15-Oct-2000 peter

Slight cleanup - this is logically equivalent code but means one less
use of the evil resource_locate() function.


66927 10-Oct-2000 n_hibma

Add a quirk entry for the USB Sony DSC drive.


66698 05-Oct-2000 jhb

- Heavyweight interrupt threads on the alpha for device I/O interrupts.
- Make softinterrupts (SWI's) almost completely MI, and divorce them
completely from the x86 hardware interrupt code.
- The ihandlers array is now gone. Instead, there is a MI shandlers array
that just contains SWI handlers.
- Most of the former machine/ipl.h files have moved to a new sys/ipl.h.
- Stub out all the spl*() functions on all architectures.

Submitted by: dfr


66678 05-Oct-2000 mjacob

Grab the ccb *after* writing filemarks.

PR: 21723
Submitted by: razuwaev@relex.ru


66677 05-Oct-2000 mjacob

Don't do destroy_dev on devices which were just aliases.


66266 22-Sep-2000 gibbs

Remove duplicate FreeBSD RCSID.


66172 21-Sep-2000 mjacob

Remove unneeded include
(from phk@freebsd.org)


65861 14-Sep-2000 mjacob

With the help of 'Eric Christeson <echriste@ssesco.com>', determined
that QIC 525 really should be 512 byte fixed blocksize.


65838 14-Sep-2000 mjacob

Follow the hints from PHK's new messages- only make_dev for a device
once. Alias names use the make_dev_alias function.


65822 13-Sep-2000 jhb

- Remove the inthand2_t type and use the equivalent driver_intr_t type from
newbus for referencing device interrupt handlers.
- Move the 'struct intrec' type which describes interrupt sources into
sys/interrupt.h instead of making it just be a x86 structure.
- Don't create 'ithd' and 'intrec' typedefs, instead, just use 'struct ithd'
and 'struct intrec'
- Move the code to translate new-bus interrupt flags into an interrupt thread
priority out of the x86 nexus code and into a MI ithread_priority()
function in sys/kern/kern_intr.c.
- Remove now-uneeded x86-specific headers from sys/dev/ata/ata-all.c and
sys/pci/pci_compat.c.


65225 29-Aug-2000 ken

Change the "Duplicate Wired Device entry" printout in camperiphnextunit to
also mention the peripheral name, bus, target and lun of the device we
attempted to put in that slot. This gives the user a little more
information about what is going on.

Tested by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
Discussed with: gibbs


65224 29-Aug-2000 ken

Add quirk entries from Andre Albsmeier to disable the sync cache command
for the Quantum "MAVERICK 540S" and "LPS525S".

Also, add common string variables, since we seem to have a few Quantum and
Micropolis drives in here.

Fix the 'quantum' variable usage in scsi_all.c that likely got broken when
someone staticized things in cam_xpt.c. (That particular problem would
cause Quantum Fireball ST drives to not get spun up if they were not
already spinning.)

Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>


65061 24-Aug-2000 peter

Quick fix. <sys/conf.h> now depends on <sys/time.h>, which is not present
when libcam is building this in userland.


64621 13-Aug-2000 n_hibma

CAM, the module: scbus, da, cd, and st wrapped in one module.

Make the umass driver depend on this module.

Makes it possible to compile the kernel without SCSI support and load it
when for example a USB floppy is conencted.


64419 08-Aug-2000 mjacob

Don't attempt to actually read SAF-TE temperature objects- nobody seems
to be obeying the original spec as to what the numeric value means.

Temperature flags are unaffected- these are still the 'pseudo-thermometers'
and overtemp/undertemp warnings will be caught and translated to SES objects
here.

PR: 20475


64383 08-Aug-2000 ken

The Yamaha CDR100 doesn't seem to like multi-LUN probing.

PR: kern/20347
Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>


64382 08-Aug-2000 kbyanc

This is an overhaul of the mode page handling in camcontrol as well as
related patches. These include:
* Mode page editting can be scripted. This involves two
things: first, if stdin is not a tty, changes are read from
stdin rather than invoking $EDITOR. Second, and more
importantly, not all modepage entries must be included in the
change set. This means that camcontrol can now gracefully handle
more intrusive editting from the $EDITOR, including removal or
rearrangement of lines. It also means that you can do stuff
like:
# echo "WCE: 1" | camcontrol modepage da3 -m 8 -e
# newfs /dev/da3
# echo "WCE: 0" | camcontrol modepage da3 -m 8 -e
* Range-checking on user-supplied input values. modeedit.c now
uses the field width specifiers to determine the maximum
allowable value for a field. If the user enters a value larger
than the maximum, it clips the value to the max and warns the
user. This also involved patching cam_cmdparse.c to be more
consistent with regards to the "count" parameter to arg_put
(previously is was the length of strings and 1 for all integral
types). The cam_cdbparse(3) man page was also updated to reflect
the revised semantics.
* In the process, I removed the 64 entry limit on mode pages (not
that we were even close to hitting that limit). This was a nice
side-effect of the other changes.
* Technically, the new mode editting functionality allows editting
of character array entries in mode pages (type 'c' or 'z'),
however since buff_encode doesn't grok them it is currently
useless.
* Camcontrol gained two new options related to mode pages: -l and
-b. The former lists all available mode pages for a given
device. The latter forces mode page display in binary format
(the default when no mode page definition was found in
scsi_modes).
* Added support for mode page names to scsi_modes. Allows names to
be displayed alongside mode numbers in the mode page
listing. Updated scsi_modes to use the new functionality. This
also adds the semicolon into the scsi_modes syntax as an
optional mode page definition terminator. This is needed to name
pages without providing a page format definition.
* Updated scsi_all.h to include a structure describing mode page
headers.
* Added $FreeBSD$ line to scsi_modes.

Inspired by: dwhite
Reviewed by: ken


64058 31-Jul-2000 n_hibma

Support for the Panasonic / Matshita USB FDD.

Submitted by: SAKIYAMA Nobuo <sakichan@lares.dti.ne.jp>
PR: kern/20300


63456 18-Jul-2000 gibbs

scsi_all.c:
Clean up the comments related to the high speed
sync rate table for SPI.

scsi_message.h:
Bring in some SCSI3 message terminology. All SCSI2 names
are still preserved for backwards compatibility.


63455 18-Jul-2000 gibbs

cam_ccb.h:
Bring back the CAM_NEGOTIATE ccb flag. This flag indicates
that SPI transfer negotiation should occur concurrently with the
execution of this CCB. The flag is not yet used by the XPT but
is required for proper support of multi-initiator configurations
where topology scans cannot rely on a bus reset to invalidate
prior negotiations.

cam_xpt.c:
Don't allow DT transmission rates to be specified for devices
that don't have the DT feature listed in their inquiry data.


63289 17-Jul-2000 mjacob

Preserve CAM_DIS_DISCONNECT as passed up from SIM (like
CAM_TAG_ACTION_VALID and CAM_DIR_MASK). Remove redundant
CAM_DEBUG line. Spiff up CAM_DEBUG printout for commands
and move the printout up to the top where we can see it,
even for the pending_ua/pending_ca cass. Add missing
newline in a CAM_DEBUG.


63287 17-Jul-2000 mjacob

Whoops- forgot to commit this other pearl from Justin- only set or
clear CAM_TAG_ACTION_VALID if this is an XPT_SCSI_IO CCB (otherwise,
the peripheral driver knows best...)..
Obtained from:gibbs@freebsd.org


63190 14-Jul-2000 mjacob

Don't, when doing cam_fill_ctio, add a SIMPLE Q tag unless
TAG_ACTION_VALID is set.


63174 14-Jul-2000 mjacob

Pick up some changes from Justin (add tagged queing support, remember
to splx(s) if cam_extend_get fails and we return ENXIO, reset ccb flags
when we push ATIOs back to the SIM, do some data increment fixes, set
priority of command based on whether CAM_DIS_DISCONNECT is set and related
changes).

Add in some more CAM_DEBUG_PERIPH debug statements and also add in support
for TARGIODEBUG which then will enable or disable CAM_DEBUG_PERIPH tracing
for an instance.


63173 14-Jul-2000 mjacob

Add a TARGIODEBUG ioctl to allow for CAM_DEBUG_PERIPH tracing on
an opened target instance.


63172 14-Jul-2000 mjacob

Properly initialize softc. Do some minor SCSI_CDB6_LEN changes.
Obtained from:gibbs@freebsd.org


63171 14-Jul-2000 mjacob

Add SCSI_CDB6_LEN macro (where 0 ==> 256).
Obtained from:gibbs@freebsd.org


63065 13-Jul-2000 dg

Quirk entry for TeraSolutions TRC-22 RAID controller to keep mintags
from dropping below 55 due to temporary resource shortages.


62828 08-Jul-2000 mjacob

Use %p to print a pointer.


61763 18-Jun-2000 mjacob

Fix breakage where we never were attaching SES devices because inq_len
was not being set > 0.


61234 04-Jun-2000 ken

Disable multi-lun probing on Hitachi DK31* drives.

PR: misc/18793
Submitted by: Paul Haddad <paul@pth.com>


61074 29-May-2000 dfr

Brucify the pmap_enter_temporary() changes.


61036 28-May-2000 dfr

Add a new pmap entry point, pmap_enter_temporary() to be used during
dumps to create temporary page mappings. This replaces the use of CADDR1
which is fairly x86 specific.

Reviewed by: dillon


60938 26-May-2000 jake

Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by: msmith and others


60833 23-May-2000 jake

Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by: phk
Reviewed by: phk
Approved by: mdodd


60806 22-May-2000 joerg

Apply a `fixup' to the blocksize gathered from the device after a READ
CAPACITY operation. SCSI-3 mandates this to be 2048, but some older
drives like my old Plasmon CD-R report weird numbers between 2048 and
up to 2352 bytes depending on the mode of the last track etc. This in
turn confuses stuff like the slice code since it refuses to work with
devices that do not have a blocksize which is a multiple of 512 bytes.

Reviewed by: ken


60767 21-May-2000 ken

Implement a new camcontrol function, 'camcontrol format'.

libcam/Makefile: Add scsi_da.c to libcam for the new
scsi_format_unit() function.

camcontrol.8: Update the man page for the new format
functionality, and take out the examples section
describing how to do it with 'camcontrol cmd'.

camcontrol.c: New format functionality. Note that unlike the
rest of the camcontrol subcommands, this one is
interactive by default. Because of the potential
destructiveness of the format command, I thought
it necessary to get confirmation from the user
before spamming a disk. You can disable the
interactive behavior, and the status meter with
command line arguments.

scsi_da.c: Add the new scsi_format_unit() cdb building
function and use #ifdef _KERNEL to make this file
compile in both the kernel and userland. The
format unit function is currently only defined in
the non-kernel case, because nothing in the kernel
is using it. If that changes, it should be
un-ifdefed and compiled in both cases.

scsi_da.h: New function declaration, CDB structure and format
data structures.

Thanks to Nick Hibma for providing some valuable input on these changes.


60755 21-May-2000 peter

Implement an optimization of the VM<->pmap API. Pass vm_page_t's directly
to various pmap_*() functions instead of looking up the physical address
and passing that. In many cases, the first thing the pmap code was doing
was going to a lot of trouble to get back the original vm_page_t, or
it's shadow pv_table entry.

Inspired by: John Dyson's 1998 patches.

Also:
Eliminate pv_table as a seperate thing and build it into a machine
dependent part of vm_page_t. This eliminates having a seperate set of
structions that shadow each other in a 1:1 fashion that we often went to
a lot of trouble to translate from one to the other. (see above)
This happens to save 4 bytes of physical memory for each page in the
system. (8 bytes on the Alpha).

Eliminate the use of the phys_avail[] array to determine if a page is
managed (ie: it has pv_entries etc). Store this information in a flag.
Things like device_pager set it because they create vm_page_t's on the
fly that do not have pv_entries. This makes it easier to "unmanage" a
page of physical memory (this will be taken advantage of in subsequent
commits).

Add a function to add a new page to the freelist. This could be used
for reclaiming the previously wasted pages left over from preloaded
loader(8) files.

Reviewed by: dillon


60422 12-May-2000 ken

Add support for the DVD ioctl interface.


60235 09-May-2000 mjacob

Some prettifying for the quirk comments.

Add a SA_QUIRK_NO_MODESEL type and use it for the OnStream real SCSI
device (not the broken one). This one is still broken in that it can't
be set to the same fixed block size it reports [ unflattering comments
about this company elided ].

If we're unable to set buffered mode on, complain, but drive on. It's
not a fatal error to not be in buffered mode.


60168 07-May-2000 n_hibma

*sigh* I must have been on something that night. Make xpt_periph an
extern with the original in cam_xpt.c instead of replicating
xpt_periph in all the sources using it (and hence not initialising it)


60041 05-May-2000 phk

Separate the struct bio related stuff out of <sys/buf.h> into
<sys/bio.h>.

<sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall
not be made a nested include according to bdes teachings on the
subject of nested includes.

Diskdrivers and similar stuff below specfs::strategy() should no
longer need to include <sys/buf.> unless they need caching of data.

Still a few bogus uses of struct buf to track down.

Repocopy by: peter


59883 02-May-2000 mjacob

Add in include of <machine/clock.h> which defines DELAY.


59874 01-May-2000 peter

Add $FreeBSD$


59760 29-Apr-2000 phk

Remove unneeded #include <sys/kernel.h>


59368 18-Apr-2000 phk

Remove unneeded <sys/buf.h> includes.

Due to some interesting cpp tricks in lockmgr, the LINT kernel shrinks
by 924 bytes.


59365 18-Apr-2000 phk

Don't include <sys/buf.h> twice.


59275 16-Apr-2000 phk

Overlooked a s/b_act/bio_queue/ substitution due to targ not being in LINT.

Spotted by: mjacob


59249 15-Apr-2000 phk

Complete the bio/buf divorce for all code below devfs::strategy

Exceptions:
Vinum untouched. This means that it cannot be compiled.
Greg Lehey is on the case.

CCD not converted yet, casts to struct buf (still safe)

atapi-cd casts to struct buf to examine B_PHYS


58972 03-Apr-2000 n_hibma

Add a hack to cam that makes the cam_xpt available to the rest of the
kernel. Justin agress that there is no other reasonable alternative to
do automatic rescans on connect.

The problem is that when a new device attaches to a SIM (SCSI host
controller) we need to send a XPT_SCAN_BUS command to the SIM using
xpt_action. This requires however that there is a peripheral available
to take the command (otherwise xpt_done and later bomb). The RESCAN
ioctl uses the same periph.

This enables a USB mass storage drive to do an automatic rescan on
connection of the drive.

The automatic dropping of a CAM entry on disconnection was already
working (asynchronous event).

The next thing to do is find someone to commit a change to vpo to do the
same thing. Just port umass_cam_rescan and friends across to that
driver.

Approved by: gibbs


58934 02-Apr-2000 phk

Move B_ERROR flag to b_ioflags and call it BIO_ERROR.

(Much of this done by script)

Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED.

Move b_pblkno and b_iodone_chain to struct bio while we transition, they
will be obsoleted once bio structs chain/stack.

Add bio_queue field for struct bio aware disksort.

Address a lot of stylistic issues brought up by bde.


58921 02-Apr-2000 ken

Fix two problems in the ch(4) driver.

- Mike Smith discovered a panic in the changer probe code if the probe
command (mode sense) fails. So we need to release the CCB used in the
probe before we unlock the peripheral. (i.e. the same fix mjacob put in
the CD and DA drivers)

- A newline was missing in a warning message. (PR kern/17512)

PR: kern/17512
Submitted by: Louis Mamakos <louie@uu.net> (newline fix)


58345 20-Mar-2000 phk

Remove B_READ, B_WRITE and B_FREEBUF and replace them with a new
field in struct buf: b_iocmd. The b_iocmd is enforced to have
exactly one bit set.

B_WRITE was bogusly defined as zero giving rise to obvious coding
mistakes.

Also eliminate the redundant struct buf flag B_CALL, it can just
as efficiently be done by comparing b_iodone to NULL.

Should you get a panic or drop into the debugger, complaining about
"b_iocmd", don't continue. It is likely to write on your disk
where it should have been reading.

This change is a step in the direction towards a stackable BIO capability.

A lot of this patch were machine generated (Thanks to style(9) compliance!)

Vinum users: Greg has not had time to test this yet, be careful.


58252 18-Mar-2000 gibbs

o clear the ccb_flags field before sending an accept target I/O ccb to
an HBA. Garbage in this field confuses the driver in targdone().

o When completing a CCB on behalf of a user process, we need to
*de-queue* the ccb from our pending ccb list, not queue it again.

o All continue target I/O operations need to have a timeout set.
We use 5 seconds throughout this driver.

o Remove some logging printfs.

o During abort processing, remove ccbs that are on the pending queue
from the pending queue, not the work queue.


58251 18-Mar-2000 mjacob

Per Justin's request- remove his name from Copyright.


58123 15-Mar-2000 n_hibma

Add a quirk entry for Y-E Data USB floppy drive.
Driver follows in the next few days.


58111 15-Mar-2000 n_hibma

Various typo's.

One minor nit. The speed was displayed wrong when below 1Mb/s.


57581 29-Feb-2000 mjacob

Some minor fixing - final for 4.0. Debugging messages toned down a bit.
Approved: jkh


57349 20-Feb-2000 ken

Fix 'camcontrol inquiry'. The inquiry data structure changes (increased to
256 bytes) caused it to break on many devices.

The SCSI spec says that for commands with 8-bit length fields, a value of 0
means 256 bytes. As it turns out, many devices don't deal with that
properly. Some interpret the 0 as 0, and return no data. Others return
more than 256 bytes of data, and cause an overrun.

The fix is to tell the device we've only allocated SHORT_INQUIRY_LENGTH (36
bytes) of inquiry data, instead of sizeof(struct scsi_inquiry_data).

camcontrol.c: Change inq_len in the call to scsi_inquiry() to
SHORT_INQUIRY_LENGTH, and add a long comment
explaining the reason for the change.

scsi_all.h: Add a comment above the definitinon of
SHORT_INQUIRY_LENGTH alerting people that it is
both the initial probe inquiry length, and the
minimum amount of data needed for scsi_print_inquiry()
to function.

scsi_all.c: Add a comment about SHORT_INQUIRY_LENGTH being the
minimum amount of data needed for
scsi_print_inquiry() to function.

Reviewed by: gibbs
Approved by: jkh
Reported by: "John W. DeBoskey" <jwd@unx.sas.com>


56981 03-Feb-2000 mjacob

Add a quirk type (and one for ARCHIVE Python's) that disables the
dummy read at sa_mount that attempts to latch up density. This breaks
on at least one drive and sends it into the weeds.

Approved: jkh


56614 25-Jan-2000 mjacob

Because we added 4 bytes to the inquiry data size, we need to
rev the CAM revision too. Tsk.
Submitted by: ken@freebsd.org


56601 25-Jan-2000 mjacob

Redo the SHORT INQUIRY length stuff to be a bit cleaner.
Obtained from:gibbs@freebsd.org


56596 25-Jan-2000 ken

When autosense fails, make sure we retry the command.

PR: kern/15975
Submitted by: Carl Mascott <cmascott@world.std.com>, n_hibma


56595 25-Jan-2000 mjacob

Propagate sense data through from SIM (if there) and mark the CTIO
that there's sense to send with status (if the SIM does it), and
then clear any pending contingent allegiance state for this initiator
if the SIM actually did send the sense data.

Widen MAX_INITITATORS to 256- that's still not quite right, but will
accomodate the widest Fibre Channel support in FreeBSD now.

Obtained from:(partially) gibbs@freebsd.org


56594 25-Jan-2000 mjacob

Propagate sense data through from SIM (if there) and mark the CTIO
that there's sense to send with status (if the SIM does it).
Reviewed by: gibbs@freebsd.org


56593 25-Jan-2000 mjacob

Go for the gusto and do the full 256 bytes for inquiry data.
Obtained from:gibbs@freebsd.org


56470 23-Jan-2000 peter

A minimal update to the device wiring code so that it looks at the
dynamic resource tables rather than relying on a duplicated cam-specific
table generated by config(8) in ioconf.c. This was a major holdup to
getting loader / userconfig driven configuration of scsi wiring.


56382 21-Jan-2000 mjacob

Clean up some of the SAF-TE matching code. Add
a few missing newlines in printouts.


56148 17-Jan-2000 mjacob

Do the minor changes needed because of change to ccb_getdev structure.
JKH Trading Stamps applied.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56147 17-Jan-2000 mjacob

Increase size of the scsi_inquiry_data structure to it's nearly
full size. Define a SHORT_INQUIRY_LENGTH for use during initial
probing (covers the size used previously). Define some SPC-2 related
fields (and define the revision code for SPC-2) which includes some
further SPI-3 defines. Don't go all the way (256 bytes) for the structure-
stop 4 bytes short- because we haven't auditted the source base to find
any u_int8_t potential overflow issues. Add RBC (single byte device)
and OCR (Optical Character Reader) device type codes.

Approved by JKH.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56146 17-Jan-2000 mjacob

Remove garbage collected tags from their usage in the ccb_getdev
structure. Remove usage of the (now gone) pd_type tag of same.

Add an extra probing state such that if we successfully run an
initial inquiry (36 bytes), rerun another one with a longer data
size as informed by the 'additional length' field in the first
returned inquiry data (making sure not to get bigger than the
actual scsi_inquiry_data structure- which has also been modified-
see separate checkin of scsi_all.h). This allows devices such
as SAF-TE devices (which have identifying marks in offsets 48-53
in inquiry data) to be successfully found without special case
inquiry commands. There are also a lot of other things such as
version codes that are coming in in the SPC2 specification that it
would be useful to get our hands on.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56145 17-Jan-2000 mjacob

Shift bits for CAM flags so that the top bit isn't set in an enum
(at request of Ken Merry). Garbage collect items out of the ccb_getdev
structure and and a length field so that consumes will know how much
of the inq_data tag is valid. Clean up a few misspellings. Add
a CAM_SEND_STATUS target mode flag.

All of this necessitated a CAM_VERSION bump.

JHK approved.

Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56143 17-Jan-2000 mjacob

Add a CAM_SENT_STATUS for use in target mode. JHK approved.
Reviewed by: gibbs@freebsd.org, ken@freebsd.org


56136 17-Jan-2000 mjacob

Do not propagate the ENCI_SVALID bit for overall enclosure status
to userland apps- they get confused.


56130 17-Jan-2000 mjacob

Add in SAF-TE handling code and do some minor consistency cleanups.


56073 15-Jan-2000 mjacob

buglet fix


56070 15-Jan-2000 mjacob

Do a wad of cleanup and put into place at least *one* functional
portion of SES retrieval (native SES itself) and implement all
the appropriate ioctls. Seems to work...


56069 15-Jan-2000 mjacob

Move the kernel specific stuff into scsi_ses.c. Redo the ioctls
to be more platform independent. Add a ses_hlptxt structure definition
and retrieval ioctl for when we are able to retrieve object help text

SES Objects can have up to 64 KBytes of associated 'help' text- the
Sun A5000 uses this, for example, to give physical location information
(e.g., 'left power supply').


56053 15-Jan-2000 mjacob

add SEND/RECEIVE diagnostic opcodes, SEND is a Mandatory command


56031 15-Jan-2000 mjacob

Remove inclusion of dkbad.h- seems like a bug, but I had a stale
dkbad.h in /usr/include/sys- the local build process shouldn't have
been happy with that, but not finding dkbad.h in ../../sys. Hmm.


56027 15-Jan-2000 mjacob

add functional but stub SES/SAF-TE driver


55995 14-Jan-2000 gibbs

Clean up the xpt_sim creation to mirror how HBA drivers perform this task.

Clean up node creation in the EDT so that initialization follows member
declaration.

Sort registered paths by pathid so that we probe busses in order of
ascending pathid. This makes hardwiring of busses without wiring
individual targets do what the user expects. (submitted by tegge@FreeBSD.org)

Fix an EDT node leak. Target nodes would never go away.

Implement xpt_bus_deregister().
(prodded by some patches from T. Ichinoseki, but implemented differently.)


55328 03-Jan-2000 mjacob

Widen width of tag && initiator ids to u_int
(from u_int8_t) in ccb_accept_tio structure. This
matches usage elsewhere and also allows me to
overload the tag id with the RX_ID for fibre
channel target mode.
Reviewed by: gibbs@freebsd.org


55251 30-Dec-1999 mjacob

Change error message make sense and add a missing
periph_release on a failed open so that the periph
dtor for it will get called when we deallocate the
instance from targioctl.


55248 29-Dec-1999 mjacob

Restore this driver to a working state. The control device has
to be created at init time. The unit devices are created at
ctor when new instances are created and bound and destroyed
when that instance is closed. As such, there is just s single
static control dev_t for this driver (the per-unit dev_t's are
still in the softc).

When we have decommissionable periph drivers, a destroy_device
on the control device will have to called.


55206 29-Dec-1999 peter

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


55205 29-Dec-1999 peter

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


54896 20-Dec-1999 mjacob

Make sure we don't look at an edt entry that could go away when we try
and figure out whether to probe higher than logical unit 7.
Obtained from:gibbs@freebsd.org


54685 16-Dec-1999 obrien

Add FAST-80 timing to the scsi syncrates table.

Submitted by: Gerard Roudier <groudier@club-internet.fr>


54572 13-Dec-1999 mjacob

minor comment update


54451 11-Dec-1999 ken

Quirk all Pioneer changers as changers up front, instead of waiting for the
second LUN to show up.

mjacob's change (which is correct) in rev 1.21 of cam_periph.c to elminiate
infinite retries of the SCSI busy status bit seems to have broken probing
of Pioneer changers that aren't already quirked.

The right way to fix this is probably to change things around so we can
guarantee 100% sequential probing of LUN-based changers even if they aren't
quirked. This should fix things for now, though.


54279 08-Dec-1999 ken

Revamp the devstat priority system. All disks now have the same priority.
The same goes for CD drivers and tape drivers. In systems with mixed IDE
and SCSI, devices in the same priority class will be sorted in attach
order.

Also, the 'CCD' priority is now the 'ARRAY' priority, and a number of
drivers have been modified to use that priority.

This includes the necessary changes to all drivers, except the ATA drivers.
Soren will modify those separately.

This does not include and does not require any change in the devstat
version number, since no known userland applications use the priority
enumerations.

Reviewed by: msmith, sos, phk, jlemon, mjacob, bde


54246 07-Dec-1999 ken

Recognize the Pioneer CD-ROM DRM-6324X as a changer.

PR: kern/15198
Submitted by: Don Lewis <truckman@FreeBSD.org>


54105 04-Dec-1999 mjacob

Add back in a prefatory TUR when the tape is *not* mounted. This seems
to help with some older tape drives.


54099 03-Dec-1999 mjacob

Correct some botched timeout defines. Allocate only 8KB for the test read
in samount. Make things a lot quieter in samount (and other places). Fix
ridiculous and not so ridiculous bugs in compression related code in both
sagetparams and sasetparams.


53522 21-Nov-1999 mjacob

Don't clear the SA_FLAG_TAPE_LOCKED prior to calling
saprevent when we're doing an OFFLINE ioctl- saprevent
won't unlock the door, which then causes the unload to
fail on some units.

If we've already unloaded the tape, don't try and rewind and
unload in saclose. This is a slightly riskier change because
we're now going to depend on SA_FLAG_TAPE_MOUNTED to say whether
we've really unloaded the tape. This involved changing the
setting in sadone for tape errors to SA_FLAG_TAPE_FROZEN (which
is more accurate anyway-if you get an EIO you've probably lost
tape position anyway) where it used to just clear the mounted
flag.


53520 21-Nov-1999 mjacob

Add make_dev functions. Tested with only one changer (sigh- all my others
are broken).
Submitted by: ken@freebsd.org


53283 17-Nov-1999 mjacob

Fix a couple of boo-boos in the last delta.


53259 17-Nov-1999 mjacob

Fix for 11815 (at mount time do a throwaway read of the front of the
tape to force the drive to do a media access so it knows what media
may be inserted).

Also Ken's make_dev patches- relatively untested.


53258 17-Nov-1999 ken

Get rid of some trailing commas in enumerated types that cause gcc to
complain when some warnings are turned on.

Requested by: Bertrand Petit <elrond@phoe.frmug.org>


53257 17-Nov-1999 ken

Convert the xpt, pass, pt and target drivers to use the new
make_dev()/destroy_dev() interface.


52703 31-Oct-1999 ken

Fix Bus Device Resets from userland, and specifically from camcontrol.

camcontrol was setup to use the old scheme of going through the xpt(4)
device, which never worked properly (and has been disabled for a while).

camcontrol now sends BDRs through the pass(4) device, and XPT_RESET_DEV
CCBs are put on the device queue in the transport layer, as they should be.

Submitted by: luoqi
Reviewed by: ken


52644 30-Oct-1999 phk

Change useracc() and kernacc() to use VM_PROT_{READ|WRITE|EXECUTE} for the
"rw" argument, rather than hijacking B_{READ|WRITE}.

Fix two bugs (physio & cam) resulting by the confusion caused by this.

Submitted by: Tor.Egge@fast.no
Reviewed by: alc, ken (partly)


52635 29-Oct-1999 phk

useracc() the prequel:

Merge the contents (less some trivial bordering the silly comments)
of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts
the #defines for the vm_inherit_t and vm_prot_t types next to their
typedefs.

This paves the road for the commit to follow shortly: change
useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE}
as argument.


52575 27-Oct-1999 mjacob

Mark path for deallocation only *after* you've successfully allocated it.


52326 16-Oct-1999 mjacob

Put an upper bound on the number of BUSY status retries we'll do (use the
retry count for the ccb). This is probably not quite the right thing, but it
is better than silently hanging on (possibly broken) h/w which is what we
do now.

Reviewed by:Justin/Ken: they weren't entirely happy about it but didn't say no.


52324 16-Oct-1999 mjacob

Protect xpt_run_dev_sendq in xpt_release_devq_device with splsoftcam. This
seems to handle the case of timeouts firing during probe but after a device
has gone away. It really does help.
Obtained from:gibbs@freebsd.org


51957 05-Oct-1999 n_hibma

Removal of sys/device.h

- Move intrhook stuff into kernel.h
- Remove all occurrences of #device <device.h>
- Add kernel.h were necessary (nowhere)
- delete device.h

This file contained the structures for cfdata (old style config) and is no
longer used. It was included by most drivers.

It confuses the remote debugger as the definition of 'struct device' in
device.h is found before the one in bus_private.h.


51875 02-Oct-1999 mjacob

Another 1FM@EOD quirk (from mike@sentex.net for a Seagate STT20000),
and add a config option that allows one to default to 1FM@EOD for tapes
otherwise unquirked or unknown as to which to prefer. Note that tcopy
will be broken for these tapes until tcopy is fixed.


51836 01-Oct-1999 phk

Introduce the disk mini-layer and devstat_end_transaction_buf() in cam/scsi.

Somewhat reviewed by: ken


51744 28-Sep-1999 mjacob

Ooops- forgot to commit this.
PR: 14009
Submitted by: jreynold@primenet.com


51658 25-Sep-1999 phk

Remove five now unused fields from struct cdevsw. They should never
have been there in the first place. A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags


51196 12-Sep-1999 phk

Remove unneeded disk-related includes.


51092 08-Sep-1999 phk

Don't register a block major for tapes.

Reviewed by: mjacob


50511 28-Aug-1999 phk

We don't need to pass the diskname argument all over the diskslice/label
code, we can find the name from any convenient dev_t


50477 28-Aug-1999 peter

$Id$ -> $FreeBSD$


50270 24-Aug-1999 bde

Cast pointers to uintptr_t instead of casting them to u_long. Don't
depend on gcc's feature of casting lvalues. Cosmetic.


50254 23-Aug-1999 phk

Convert DEVFS hooks in (most) drivers to make_dev().

Diskslice/label code not yet handled.

Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers)

Add the correct hook for devfs to kern_conf.c

The net result of this excercise is that a lot less files depends on DEVFS,
and devtoname() gets more sensible output in many cases.

A few drivers had minor additional cleanups performed relating to cdevsw
registration.

A few drivers don't register a cdevsw{} anymore, but only use make_dev().


50253 23-Aug-1999 bde

Use devtoname() to print dev_t's instead of casting them to long or u_long
for misprinting in %lx format.


50107 21-Aug-1999 msmith

Implement a new generic mechanism for attaching handler functions to
events, in order to pave the way for removing a number of the ad-hoc
implementations currently in use.

Retire the at_shutdown family of functions and replace them with
new event handler lists.

Rework kern_shutdown.c to take greater advantage of the use of event
handlers.

Reviewed by: green


50073 20-Aug-1999 ken

Fix short timeout problems with the pt(4) driver:

- increase the default timeout from 10 seconds to 60 seconds
- add a new kernel option, SCSI_PT_DEFAULT_TIMEOUT, that lets users specify
the default timeout for the pt driver to use
- add two new ioctls, one to get the timeout for a given pt device, the
other to set the timeout for a given pt device. The idea is that
userland applications using the device can set the timeout to suit their
purposes. The ioctls are defined in a new header file, sys/ptio.h

PR: 10266
Reviewed by: gibbs, joerg


49982 17-Aug-1999 billf

Welcome devtoname(), to most likely be used when printing information
about a dev_t.

printf("%x", dev) now becomes printf("%s", devtoname(dev)) because
printing actual information about the device is much more useful then
printing a pointer to an address that would never help the developer debug.

Submitted by: phk, bde


49936 16-Aug-1999 gibbs

Bump CAM version number.


49929 16-Aug-1999 gibbs

Checkpoint work on handling error conditions.

Handle errors reported through immediate notify ccbs. This includes
bus resets, BDR messages, and abort messages.

Properly setup CA conditions for errors such as uncorectable parity
in data phases, reselection failure, and IDE message received.

Add a mechanism for stalling the queue of transactions to a particular
initiator while a CA is in progress. Since we don't yet support
tagged I/O, this is largely just for show right now.

Properly bzero our softc at init time (oops).

Add more documentation on what all of the queues in our softc do.


49928 16-Aug-1999 gibbs

xpt_release_devq now takes a count.


49927 16-Aug-1999 gibbs

Implement the guts of the XPT_ABORT function code.

Clear residuals for XPT_TARGET_IO/XPT_CONT_TARGET_IO calls just
as we do for XPT_SCSI_IO calls.

Make xpt_release_devq a proper reciprocal of xpt_freeze_devq by
allowing the caller to decrement the count more than once per call.

Change the semantics of xpt_path_cmp to return 1 for a match
with a wildcard from path1 and 2 for a match with wildcards
from path2. This change doesn't affect most callers as they
only check for >=0 (exact match or one containing a wildcard).

When cleaning up a device node, ensure that there are no timeouts
outstanding that reference it.


49926 16-Aug-1999 gibbs

Add another flag for debugging just peripheral drivers. The whole debugging
mechanism should be completely revamped, but this will serve for the time
being.

Take advantage of some new behavior in xpt_path_comp which allows the
caller to determine which path, if any, had wildcards in it that allowed
for a match to succeed. We can now use this to filter out wildcard
nodes in the EDT.

Make the amount of time we pause after writing a debug message
configurable.


49925 16-Aug-1999 gibbs

Add another command characteristic flag for commands that are queued
on physical devices as oposed to just in the XPT. This is used to
mark XPT_SCSI_IO, XPT_RESET_DEV, XPT_ENG_EXEC, XPT_TARGET_IO, and
XPT_CONT_TARGET_IO function codes.

Change tag_id and init_id to be u_int from u_int8_t. Some topologies
supported by CAM support much larger ID and tag ID address spaces
than parallel SCSI.

Kill some unused fields in the IMMED_NOTIFY ccb type.


49897 16-Aug-1999 mjacob

Put in a limit (8) for lun width- do not exceed probing this unless a device
is quirked for allowing it. This will allow SCSI cards to specify their true
correct lun width (32 for Qlogic SCSI, 16 or 65536 for Qlogic Fibre Channel)
without crippling the system because of f/w breakage of a lot of drives.
Reviewed by: gibbs@freebsd.org


49862 16-Aug-1999 gibbs

Fix a long standing bug in the camq teardown code.


49856 15-Aug-1999 mjacob

Move initialization of announce_buf up to make
sure it is initialized in all cases.


49771 14-Aug-1999 phk

Spring cleaning around strategy and disklabels/slices:

Introduce BUF_STRATEGY(struct buf *, int flag) macro, and use it throughout.
please see comment in sys/conf.h about the flag argument.

Remove strategy argument from all the diskslice/label/bad144
implementations, it should be found from the dev_t.

Remove bogus and unused strategy1 routines.

Remove open/close arguments from dssize(). Pick them up from dev_t.

Remove unused and unfinished setgeom support from diskslice/label/bad144 code.


49558 09-Aug-1999 phk

Merge the cons.c and cons.h to the best of my ability. alpha may or
may not compile, I can't test it.


48750 11-Jul-1999 jmg

disable tag queing for the MICROP 4421-07 drive. It's an old 2gig drive.

convert MICROP to a static string


48668 07-Jul-1999 mjacob

Fix my complete botch. I hope. Tested this time


48612 06-Jul-1999 mjacob

suggestions from bde to clean up last checkin slighty


48532 03-Jul-1999 mjacob

Make the change similar to that suggested by Nick Hibma to avoid divide by
zero traps. I actually can't believe that this compiler is *sooooo* stupid
that it did a divide when there was 1024L*1024L instead of a right shift by
20. When we get quad type modifiers in kernel printf we can change to this
too (to avoid overflow on > terabyte disk sizes).


48520 03-Jul-1999 peter

A minor tweak to shut up gcc (on the Alpha) for two (false) warnings.

How it can think that something that is initialized at declaration can
be used while uninitialized is beyond me.


48410 01-Jul-1999 peter

int/long printf format problems on the Alpha.


48225 26-Jun-1999 mckusick

Convert buffer locking from using the B_BUSY and B_WANTED flags to using
lockmgr locks. This commit should be functionally equivalent to the old
semantics. That is, all buffer locking is done with LK_EXCLUSIVE
requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will
be done in future commits.


48192 24-Jun-1999 mjacob

Quirk Tandberg 4100 like Tandberg 4200.
PR: 11675
Reviewed by: msmith@FreeBSD.ORG
Submitted by: blank@uni-trier.de


48053 20-Jun-1999 mjacob

Quirk NOLUNS cabletron device.
PR: 11677
Submitted by: "Matthew N. Dodd" <winter@jurai.net>


47640 31-May-1999 phk

Simplify cdevsw registration.

The cdevsw_add() function now finds the major number(s) in the
struct cdevsw passed to it. cdevsw_add_generic() is no longer
needed, cdevsw_add() does the same thing.

cdevsw_add() will print an message if the d_maj field looks bogus.

Remove nblkdev and nchrdev variables. Most places they were used
bogusly. Instead check a dev_t for validity by seeing if devsw()
or bdevsw() returns NULL.

Move bdevsw() and devsw() functions to kern/kern_conf.c

Bump __FreeBSD_version to 400006

This commit removes:
72 bogus makedev() calls
26 bogus SYSINIT functions

if_xe.c bogusly accessed cdevsw[], author/maintainer please fix.

I4b and vinum not changed. Patches emailed to authors. LINT
probably broken until they catch up.


47625 30-May-1999 phk

This commit should be a extensive NO-OP:

Reformat and initialize correctly all "struct cdevsw".

Initialize the d_maj and d_bmaj fields.

The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format. Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.


47519 25-May-1999 mjacob

Add TDC 3800 to quirk list for fixed mode device.
PR:11866
Submitted by: Helge Oldach hmo@sep.hamburg.com


47509 25-May-1999 gibbs

Run xpt_action at splsoftcam() so that it cannot be re-entered by our SWI.
The XPT doesn't have a problem with this itself, but some controllers
drivers may have been caught off guard by the old behavior.

XPT_CONT_TARGET_IO is also a valid ccb type for cam_periph_unmapmem.


47497 25-May-1999 ken

Fix the read/write permission checks in cam_periph_mapmem(). If we're
writing, we want to be able to read the buffer. If we're reading, we want
to be able to write to the buffer.

PR: kern/11870
Submitted by: Andrew Mobbs <amobbs@allstor-sw.co.uk>


47434 23-May-1999 gibbs

Rely on the statistics in XPT_GDEV_STATS instead of the versions still
retained in XPT_GDEV_TYPE for binary compatibility. Mark the legacy
structure values for removal when we bump the major CAM revision.


47413 22-May-1999 gibbs

Add a default async handler funstion to cam_periph.c to remove duplicated
code in all initiator type peripheral drivers.

scsi_target.c:
Release ATIO structures that wind up in the 'unkown command queue'
for consumption by our userland counterpart, back to the controller
when the exception for that command is cleared.


47412 22-May-1999 gibbs

Add the XPT_PATH_STATS and XPT_GDEV_STATS function codes. These ccb
types allow the reporting of error counts and other statistics. Currently
we provide information on the last BDR or bus reset as well as active
transaction inforamtion, but this will be expanded as more information is
added to aid in error recovery.

Use the 'last reset' information to better handle bus settle delays.
Peripheral drivers now control whether a bus settle delay occurs and
for how long. This allows target mode peripheral drivers to avoid
having their device queue frozen by the XPT for what shoudl only be
initiator type behavior.

Don't perform a bus reset if the target device is incapable of performing
transfer negotiation (e.g. Fiber Channel).

If we don't perform a bus reset but the controller is capable of transfer
negotiations, force negotiations on the first transaction to go to the
device. This ensures that we aren't tripped up by a left over negotiation
from the prom, BIOS, loader, etc.

Add a default async handler funstion to cam_periph.c to remove duplicated
code in all initiator type peripheral drivers.

Allow mapping of XPT_CONT_TARGET_IO ccbs from userland. They are
itentical to XPT_SCSI_IO ccbs as far as data mapping is concerned.


47282 18-May-1999 gibbs

Make xpt_path_comp work on wildcarded paths again.


47020 11-May-1999 mjacob

Quirk this drive- all luns show up the same.
Submitted by: Stephen McKay <syssgm@detir.qld.gov.au>


46962 11-May-1999 mjacob

Add a SA_FLAG_COMP_SUPP flag (to quirk compression as
SUPPORTED). Add a SA_FLAG_TAPE_FROZEN for (see below).
Add a queue_count field to softc.

Add HP T20* Travan-5 like tape device as a FIXED/512 type device.
Works for me. Add TANDBERG SLR5 as a variable SA_QUIRK_1FM device.
Change VIPER 2525 to 1024 byte blocksize. It's possible other
drives should change too, but see below..

Change argument to sagetparams to be pointer to a sa_comp_t union-
this can be either a DATA COMPRESSION or a DEVICE CONFIGURATION
page. In general compression now tries to use the DATA COMPRESSION
page and if that fails tries the DEVICE CONFIGURATION page.

Change close routine to not rewind tape if there's a failure in either
writing filemarks or in backing over one of two filemarks for a 2FM
at EOT tape- instead mark the tape as 'frozen' and print a message
saying that either an OFFLINE or REWIND or an MTEOM command is needed
to clear this state (all bring certainty back to tape position). Fix
sastrategy to not allow I/O to a frozen tape.

Add MTIOCGETEOTMODEL/MTIOCSETEOTMODEL ioctls that get and set the EOT
model for a tape drive (you can now dynamically change whether it's
a 2 FM @ EOT or 1FM at EOT tape device). This ought to give folks
something to handle the QIC drives we don't know about. Correctly propagate
record of compression algorithm back. Clear FROZEN flag for EOM, REWIND
and OFFLINE (and RETENSION and ERASE) cases.

Fix an egregious bug in sadone that had left the device queue frozen
for deferred (for fixed mode case) errors.

Add comment in samount about how useless the test unit ready is for
invalidating a mount (this has to be fixed later).

Fix residual calculation (per Eivind) in saerror so that negative values
for tape records being too large for the supplied buffer get caught. Do
some other saerrro cleanup.

Per Ken && Justin, add my name to copyright comment.


46952 11-May-1999 mjacob

Quirk NOLUNS CALIPER CP150.


46950 11-May-1999 mjacob

Make clear that the DATA COMPRESSION page is a SCSI-3 entity- not a SCSI-2
entity. Add the Device Configuration page data structure- this structure
should be used if you fail to fetch the DATA COMPRESSION page. Make a union
type of a mode header, a device configuration page and the data compression
page.

Add a couple of QIC density defines (QIC 2G/QIC 4GB).


46747 09-May-1999 ken

Add a facility in the CAM error handling code to retry selection timeouts.
If the client requests that the error recovery code retry a selection
timeout, it will be retried after half a second. The delay is to give the
device time to recover.

For most of these drivers, I only added selection timeout retries where
they were also retrying unit attention type errors. The sa(4) driver calls
saerror() in a number of places, but most of them don't request retrying
unit attentions.

Also, bump the default minimum CD changer timeout from 2 to 5 seconds and
the maximum timeout from 10 to 15 seconds. Some Pioneer changers seem to
have trouble with the shorter timeout.

Reviewed by: gibbs


46625 07-May-1999 phk

Introduce two functions: physread() and physwrite() and use these directly
in *devsw[] rather than the 46 local copies of the same functions.

(grog will do the same for vinum when he has time)


46581 06-May-1999 ken

Add a number of interrelated CAM feature enhancements and bug fixes.

NOTE: These changes will require recompilation of any userland
applications, like cdrecord, xmcd, etc., that use the CAM passthrough
interface. A make world is recommended.

camcontrol.[c8]:
- We now support two new commands, "tags" and "negotiate".

- The tags commands allows users to view the number of tagged
openings for a device as well as a number of other related
parameters, and it allows users to set tagged openings for
a device.

- The negotiate command allows users to enable and disable
disconnection and tagged queueing, set sync rates, offsets
and bus width. Note that not all of those features are
available for all controllers. Only the adv, ahc, and ncr
drivers fully support all of the features at this point.
Some cards do not allow the setting of sync rates, offsets and
the like, and some of the drivers don't have any facilities to
do so. Some drivers, like the adw driver, only support enabling
or disabling sync negotiation, but do not support setting sync
rates.

- new description in the camcontrol man page of how to format a disk
- cleanup of the camcontrol inquiry command
- add support in the 'devlist' command for skipping unconfigured devices if
-v was not specified on the command line.
- make use of the new base_transfer_speed in the path inquiry CCB.
- fix CCB bzero cases

cam_xpt.c, cam_sim.[ch], cam_ccb.h:

- new flags on many CCB function codes to designate whether they're
non-immediate, use a user-supplied CCB, and can only be passed from
userland programs via the xpt device. Use these flags in the transport
layer and pass driver to categorize CCBs.

- new flag in the transport layer device matching code for device nodes
that indicates whether a device is unconfigured

- bump the CAM version from 0x10 to 0x11

- Change the CAM ioctls to use the version as their group code, so we can
force users to recompile code even when the CCB size doesn't change.

- add + fill in a new value in the path inquiry CCB, base_transfer_speed.
Remove a corresponding field from the cam_sim structure, and add code to
every SIM to set this field to the proper value.

- Fix the set transfer settings code in the transport layer.

scsi_cd.c:

- make some variables volatile instead of just casting them in various
places
- fix a race condition in the changer code
- attach unless we get a "logical unit not supported" error. This should
fix all of the cases where people have devices that return weird errors
when they don't have media in the drive.

scsi_da.c:

- attach unless we get a "logical unit not supported" error

scsi_pass.c:

- for immediate CCBs, just malloc a CCB to send the user request in. This
gets rid of the 'held' count problem in camcontrol tags.

scsi_pass.h:

- change the CAM ioctls to use the CAM version as their group code.

adv driver:

- Allow changing the sync rate and offset separately.

adw driver

- Allow changing the sync rate and offset separately.

aha driver:

- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

ahc driver:

- Allow setting offset and sync rate separately

bt driver:

- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

NCR driver:

- Fix the ultra/ultra 2 negotiation bug
- allow setting both the sync rate and offset separately

Other HBA drivers:
- Put code in to set the base_transfer_speed field for
XPT_GET_TRAN_SETTINGS CCBs.

Reviewed by: gibbs, mjacob (isp), imp (aha)


46437 04-May-1999 gibbs

Don't touch a path after we've free'd it.


45963 23-Apr-1999 gibbs

Release bus entries in the EDT when a path is released.
Null out path entries when the path is released to catch bugs.
Free our configuration hook when we're done with it.


45897 21-Apr-1999 peter

Stage 1 of a cleanup of the i386 interrupt registration mechanism.
Interrupts under the new scheme are managed by the i386 nexus with the
awareness of the resource manager. There is further room for optimizing
the interfaces still. All the users of register_intr()/intr_create()
should be gone, with the exception of pcic and i386/isa/clock.c.


45845 19-Apr-1999 gibbs

Use macros for accessing the head of the heap so that code
is isolated from implementation details of the heap.


45844 19-Apr-1999 gibbs

cam_periph.c:
Move handling of CAM_AUTOSENSE_FAIL into block dealing with
all other scsi status errors.

cam_queue.c:
cam_queue.h:
Fix 'off by one' heap bug in a more efficient manner. Since
heap algorithms like to deal with indexes started from 1,
offset our heap array pointer at allocation time to make this
so for a C environment. This makes the implementation of the
algorithm a bit more efficient.

cam_xpt.c:
Use macros for accessing the head of the heap so that code
is isolated from implementation details of the heap.


45752 18-Apr-1999 mjacob

Make WangTek 51000 a fixed block device.
PR: kern/11194
Obtained from:naddy@mips.rhein-neckar.de


45739 17-Apr-1999 peter

Well folks, this is it - The second stage of the removal for build support
for LKM's..


45442 07-Apr-1999 gibbs

Remove camq_regen(). We already perform modular comparisons
for generation counts, so no further steps to deal with generation
count wrap are required.


45441 07-Apr-1999 gibbs

Remove camq_regen(). We already perform modular comparisons
for generation counts, so no further steps to deal with generation
count wrap are required.

Fix an off by one problem in the camq heap code.


45359 06-Apr-1999 peter

Use PHOLD/PRELE rather than P_PHYSIO.


44731 14-Mar-1999 ken

Disable tagged queueing for the IBM DCAS drives. These drives have poor
write performance when tagged queueing is enabled.

Although the PR was submitted for the 4 gig version of this drive, the
assumption is that the 2 gig version has the same problem. Therefore
tagged queueing is disabled for both.

Also, update the comment for the Western Digital Enterprise drives to note
that the best performance for those drives is achieved when tagged queueing
is disabled and write caching is enabled.

PR: kern/10398
Submitted by: Hideaki Okada <hokada@isl.melco.co.jp>


44661 11-Mar-1999 jkh

People who wanted the "tagged opening" message can boot -v. The rest
of us, who appear to have complained incessantly about this message since
it appeared, can now stop.


44567 07-Mar-1999 ken

The 4 gig version of the Seagate Medalist Pro seems to have the same
trouble with tagged queueing as the 6.5 gig version.

So, I've added a quirk entry for it to limit it to two outstanding
transactions at a time, just like the 6.5G version. While I'm at it, add a
quirk for the 9G version of the drive, since it most likely has the same
problem.

Submitted by: Jeremy Lea <reg@shale.csir.co.za>


44504 05-Mar-1999 gibbs

Implement the control device for the "targ" target mode processor target
emulator so that instances can be dynamically added and removed from the
system.

Properly reference count peripheral instances so they are cleaned up when
destroyed by the control device.

Set a timeout for test unit ready commands. Before it was uninitialized
and could cause us to drop off the bus when no real timeout had occurred.


44503 05-Mar-1999 gibbs

Silence errors.

Reduce the number of accept target I/O entries we allow to better
exercise the resource shortage handling code in controller drivers.


44502 05-Mar-1999 gibbs

Silence complaints about synchronize cache requests that fail with illegal
request.


44501 05-Mar-1999 gibbs

xpt_done has no reason to take a volatile ccb *.


44500 05-Mar-1999 gibbs

Protect access to the EDT with splcam() to protect against corruption
caused by temporary EDT allocations performed by controller drivers in
their interrupt routiens.

Reference count bus entries in the EDT in preparation for support for
dynamic controller arrival and departure.

Have children of the EDT hold references to their parents.

Correct routing of the XPT_IMMED_NOTIFY ccb type for use in
target mode applications.

Fix a few cases where the generation count for EDT data members was
not being updated when a modification occurred.

splcam() problem Noticed by: Tor Egge <tegge@FreeBSD.org>


44499 05-Mar-1999 gibbs

Add constants and macros for dealing with XPT opcode group types.


44354 01-Mar-1999 mjacob

+Match against T4000* for HP QIC quirks (not T4000S* where it doesn't then
catch a T4000s)
+ Set *some* kind of error at EOM if we're in fixed mode and have pending errs.
Do not clear the ERR_PENDING bit if more buffers are queued.
+ Release the start_ccb in this case also, else we hang forever on rewinding.
+ Any kind of error for load to BOT in samount should then cause an attempt
to use REWIND to come back to BOT. Do the initial load command quietly.
+ In samount, if we succeed, set the relative position markers.


44300 26-Feb-1999 ken

Add a quirk entry for the Seagate Medalist Pro 6 gig drive. It seems this
drive has very poor write performance (1.4MB/sec vs. 12MB/sec) with anything
more than two oustanding transactions.

So, this limits the number of tagged commands to two for that drive.
Thanks to Paul van der Zwan for doing a whole lot of testing to confirm
this.

Reported by: Paul van der Zwan <paulz@trantor.xs4all.nl>


44117 18-Feb-1999 ken

Fix sync rate and transfer rate printouts in xpt_announce_periph().
Sync rates like 4.032MHz were getting printed as 4.32MHz.

Also, add a quirk entry for the 18G Quantum Atlas III. Like most other
recent Quantum drives, it bogusly reports queue full. Thanks to Andre
Albsmeier <andre.albsmeier@mchp.siemens.de> for the Atlas III inquiry
information.

Reviewed by: gibbs


43879 11-Feb-1999 gibbs

Completely set information in the transaction description before performing
a selwakeup for it. Cosmetic.


43819 10-Feb-1999 ken

Add a prioritization field to the devstat_add_entry() call so that
peripheral drivers can determine where in the devstat(9) list they are
inserted.

This requires recompilation of libdevstat, systat, vmstat, rpc.rstatd, and
any ports that depend on the devstat code, since the size of the devstat
structure has changed. The devstat version number has been incremented as
well to reflect the change.

This sorts devices in the devstat list in "more interesting" to "less
interesting" order. So, for instance, da devices are now more important
than floppy drives, and so will appear before floppy drives in the default
output from systat, iostat, vmstat, etc.

The order of devices is, for now, kept in a central table in devicestat.h.
If individual drivers were able to make a meaningful decision on what
priority they should be at attach time, we could consider splitting the
priority information out into the various drivers. For now, though, they
have no way of knowing that, so it's easier to put them in an easy to find
table.

Also, move the checkversion() call in vmstat(8) to a more logical place.

Thanks to Bruce and David O'Brien for suggestions, for reviewing this, and
for putting up with the long time it has taken me to commit it. Bruce did
object somewhat to the central priority table (he would rather the
priorities be distributed in each driver), so his objection is duly noted
here.

Reviewed by: bde, obrien


43651 05-Feb-1999 mjacob

quiet the alpha compiler


43636 05-Feb-1999 mjacob

Extend unit numbers to a full 10 bits (split into sections
of the minor). Establish and use a control mode open. Control
mode opens may open the device without locking, but are prohibited
from all but some ioctls. MTIOCGET always works. MTIOCERRSTAT
works, but the clearing of latched error status is contingent
upon whether another application has the device open, in which
case an interruptible perip acquire is done. MTSETBSIZ, MTSETDNSTY
and MTCOMP also require a periph aquire.

Relative fileno and blkno are tracked. Note that just about any
error will make these undefined, and if you space to EOD or use
hardware block positioning, these are also lost until the next
UNLOAD or REWIND.

Driver state is also tracked and recorded in the unit softc
to be passed back in mt_dsreg for a MTIOCGET call.
Thanks to Dan Strick for suggesting this.

Reintroduce 2 filemarks at EOD for all but QIC devices. I
really think it's wrong, but there is a lot of 3rd party
software that depends upon this (not the least of which is
tcopy). Introduce a SA_QUIRK_1FM to ensure that some devices
can be marked as only being able to do 1 FM at EOD.

At samount time force a load to BOT if we aren't mounted. If the
LOAD command fails, use the REWIND command (e.g., for the IBM 3590
which for some gawdawful reason doesn't support the LOAD (to BOT)
command).

Also at samount time, if you don't know fixed or variable, try to
*set* to one of the known fixed (or variable, for special case)
density codes. We only have to do this once per boot, so it's not
that painful. This is another way to try and figure out the wierd
QIC devices without having to quirk everything in the universe.

A substantial amount of cleanup as to what operations can and what
operations cannot be retried. Don't retry space operations if they
fail- it'll just lead to lossage.

Not yet done is invalidating mounts correctly after errors. ENOTIME.


43635 05-Feb-1999 mjacob

add QIC 525,320,1320,3080 codes


43295 27-Jan-1999 dillon

Fix warnings preparing for -Wall -Wcast-qual

Also disable one usb module in LINT due to fatal compilation errors,
temporary.


42957 21-Jan-1999 dillon

This is a rather large commit that encompasses the new swapper,
changes to the VM system to support the new swapper, VM bug
fixes, several VM optimizations, and some additional revamping of the
VM code. The specific bug fixes will be documented with additional
forced commits. This commit is somewhat rough in regards to code
cleanup issues.

Reviewed by: "John S. Dyson" <root@dyson.iquest.net>, "David Greenman" <dg@root.com>


42920 20-Jan-1999 mjacob

put it back the way it was


42909 20-Jan-1999 mjacob

temporary fix so alpha stays working while configure code is fixed


42872 20-Jan-1999 ken

By popular demand, back out the CONNER CFP* quirk entry, and return it to
its original form. (Originally, it only applied to the CFP 2107.)

Hopefully we can come to some conclusion about which Conner drives are
broken for tagged queueing.


42838 19-Jan-1999 ken

The Samsung WN34324U is broken for tagged queueing.

PR: kern/9535
Submitted by: NAKAJI Hiroyuki <nakaji@zeisei.dpri.kyoto-u.ac.jp>


42823 19-Jan-1999 ken

Generalize the quirk entry for the Conner CFP* drives. It did just cover
the CFP2107, but it appears (not surprisingly) that the 1 gig and 4 gig
versions of that drive have the same problem with tagged queueing.

Also, fix the problem reported in PR kern/9482. The XPT_DEV_MATCH case in
xptioctl() wasn't putting a proper path in the CCB before it called
xpt_action(). When CAMDEBUG is defined, and CAM_DEBUG_TRACE debugging is
turned on, the CAM_DEBUG statement at the beginning of xpt_action would end
up deferencing a NULL path pointer. That of course caused a panic.

My solution is to just stick the xpt peripheral's path in the CCB.

PR: kern/9482
Reviewed by: gibbs


42818 19-Jan-1999 peter

Call the xpt_init() hook during at the start of the configure() process
via SYSINIT(). This gets a little closer to making cam useable as a
module.


42735 16-Jan-1999 mjacob

Sascha Blank <blank@uni-trier.de> convinced me I was an
idiot about testing SA_QUIRK_2FM in samount. Fixed.

Removed the NORRLS quirk (to save quirk space) and left
the behaviour of being quiet about failed reserve/release
(failed due Illegal Request) the same.

Added a SF_QUIET_IR for prevent/allow for the same purposes.


42716 16-Jan-1999 mjacob

More bandaids. One important one from Sascha Blank
(<blank@fox.uni-trier.de>) about quirks being set as
arithmetic values, not as bitfields. Add HP, Kennedy
and M4 1/2" reel quirk entries.

Do a lot of gratuitous source changing.

Audit all functions that build ccbs for the tape driver
and decide whether each one can be retried or not.

Still to do is some more state management post errors.


42654 14-Jan-1999 jdp

Replace includes of <sys/kernel.h> with includes of
<sys/linker_set.h> in those files that use only the linker set
definitions.


42651 14-Jan-1999 gibbs

Add support for wildcard device entries in the EDT. The target mode
'Black Hole' device uses this feature to schedule itself against any
target or lun attached to a controller that receives an unwanted request
from an initiator instead of having an instance per potential target/lun
request.

Use the wildcard entries to simplify wildcard async callback storage.

Don't announce devices twice to peripheral drivers. The devices will
be announced as soon as the AC_PATH_REGISTERED event is registered by
the peripheral driver, so no manaul push of this event is required.

Reviewed by: Kenneth Merry <ken@FreeBSD.org>


42650 14-Jan-1999 gibbs

The target mode 'Black Hole' device. This peripheral driver provides inquiry
data and sense information for target mode devices for which no other
peripheral driver is attached. This simplifies the task of dealing with
luns that are not otherwise enabled for target mode if the controller
does not have firmware that automatically deals with this case (e.g.
the aic7xxx driver).


42648 14-Jan-1999 gibbs

Properly handle transfers that only consume partial buffers.


42590 12-Jan-1999 eivind

Make dsopen() and dsioctl() use cdstrategy1 instead of cdstrategy.
This silence the warnings and makes it more obvious where the bugs
have to be fixed.


42563 12-Jan-1999 mjacob

Clean up and fix quirk table (was missing necessary wildcards) and add a couple
from the old driver. Change format of quirk table to have a preferred block
size for devices that need to be QUIRK_FIXED- this is loaded into the
last_media_blocksize tag at saregister time and will be used in the first
samount case.

Change sasetparams to take a sense_flags argument so that probe time testing
can be quieter (e.g. with SF_NO_PRINT).

Fix a couple of silly bugs in the fixed/variable determination in samount- one
was where there was a check against 'guessing' AND the density code being
default density- *SMACK* - you're only guessing if you find the media code
to be *other* than default density. Second bug was a test against current
blocksize being zero- should be a test against whether current blocksize
is not equal to the last blocksize if you had wanted to be fixed (suppose
you came up in fixed, but not the preferred size?). And if you don't
know what the fixed size should be, select 512 as the starting point,
not BLKDEV_IOSIZE (reality wins). Finally, in doing the test set to variable
mode, make sasetparams non-chatty.


42533 11-Jan-1999 mjacob

Make HP T4000S quirk to FIXED mode


42531 11-Jan-1999 eivind

Add 'static' to the declaration, too.


42378 07-Jan-1999 mjacob

Like the problems just fixed in scsi_da.c, make sure
to release the probe ccb before taking down the periph.
Also, don't do cdscheduling if you're not going to
attach the device after all.
Reviewed by: ken@freebsd.org


42377 07-Jan-1999 mjacob

A better fix to avoid race conditions between failed probes
and peripheral removal.
Obtained from:gibbs@freebsd.org


42363 07-Jan-1999 ken

The Quantum Atlas III evidently has an identical problem to the Atlas II.
It keeps returning queue full until we have reduced the number of tagged
openings to the minimum.

So, put in a quirk entry with the same work-around. This quirk entry is
only for the 9G Atlas III, once someone comes up with inquiry information
for the 18G version of that drive, we can quirk it as well.

Submitted by: "Johan Granlund" <johan@granlund.nu>


42319 05-Jan-1999 ken

The Conner CFP2107 is a fixed-media drive, not removable media. This fixes
the quirk that disables tagged queueing for those drives.

Also, silence a warning by disabling xpt_for_all_targets() and
xpt_for_all_periphs(). These two functions are not currently used, but
they should not be removed. They're part of a set of functions that
provide a way to execute a function for every {bus,target,device,periph} in
the system.

If anyone needs to use either function in the future, they can be
un-#ifdefed.


42317 05-Jan-1999 mjacob

Add a quirk that disables SYNCHRONIZE CACHE
PR: 8882
Obtained from: Hellmuth Michaelis hm@kts.org


42271 03-Jan-1999 mjacob

Temporary workaround (bandaid) for case where you have READ
CAPACITY fail for a non-removable media device. There's a race
condition where the device entry is removed and then
xpt_release_ccb is called which attempts to give back the ccb
to a device that's now gone. In this bandaid release the ccb
early and then remember to not call xpt_release_ccb later.


42130 28-Dec-1998 mjacob

Force ARCHIVE Vipers to be FIXED


42038 24-Dec-1998 mjacob

a more correct change that should meet the sniff test


42036 24-Dec-1998 mjacob

Unstaticize swi_camnet && swi_cambio so Alpha kernels can build again.


42033 23-Dec-1998 mjacob

you can retry SYNC CACHE on UA errors


42017 22-Dec-1998 eivind

Staticize.

Reviewed by: gibbs


42009 22-Dec-1998 mjacob

Add a quirk NORRLS (no reserve/release) which can (and
will) get set for the devices that don't actually support
reserve/release (so we don't keep trying it).

Add softc storage and manage storing last I/O and CTL
commands that had errors (for correlative purposes).

In saclose clear the 'MOUNTED' bit if we either rewind or
unload (yes, this shouldn't be necessary since the next open
should catch whether a tape change occurred, but I'm having
some questions about that actually working so this is
safer for the moment). Oh, forgot to mention in previous
commit messages that some of the failures particularly at
close time cause the tape to be ejected (for the sake
of safety)- all this prior to redoing the state machine
(which is in progress) which will try and handle this better.

Complete the addition of the setmark support
(from Martin.Birgmeier@aon.at).


41948 19-Dec-1998 mjacob

1) Fix some serious bugs (1 botch on my part which caused a filemark to be
written even it the tape was opened readonly- 2 botches in deferred error
handling for FIXED LENGTH mode which caused panic && hand resp.). Fixed
a memory leak in sa_mount.
2) Fixed an annoying bug when turning of compression to actually reflect
this for future status calls.
3) Implement the MTIOCERRSTAT call where latched control and I/O residuals
and sense data are returned to the application asking for them.


41918 18-Dec-1998 mjacob

Add in block position/block locate functions.


41917 18-Dec-1998 mjacob

Add structures and function definitions pertinent for hardware locate support.


41910 17-Dec-1998 gibbs

Correct the definition of the changer device capabilities page. The
previous definition confused some reserved bytes for exchange capabilities.


41907 17-Dec-1998 mjacob

Add some tape specific density codes- only enough of them here to recognize
some specific older units so we can choose 2FM@EOD or FIXED blocksize
quirks.


41906 17-Dec-1998 mjacob

Several changes having to do blocksize- mostly to force variable as the default.
Attempt to determine (at mount time if not done so already) via density code
whether a device should default to fixed mode or not. Attempts to set to
variable that fail will cause fixed to be selected.

Similarly, the '2 filemarks at EOM' quirk is now determined (or attempted to
be determined) via density code. Some as yet not entirely tested code for
coping with 2FM@EOD position is now also in place.


41886 17-Dec-1998 gibbs

Correctly track allocated accept target I/O ccbs so that they can be
aborted prior to disabling our lun. This requires a second set of
links since we use the ones in the ccb_hdr during normal operations.

Nuke some unused variables.


41885 16-Dec-1998 ken

At Justin's request, limit the size of buffers that can be mapped into
and out of kernel address space (via the pass(4) and xpt(4) peripheral
drivers) to 64K (DFLTPHYS). Some controllers, like the Adaptec 1542,
don't support more than 64K transactions.

We plan on eventually having the capability of limiting this size based
on min(MAXPHYS, controller max), but since that capability isn't here yet,
limit things to the lowest common denominator.


41877 16-Dec-1998 ken

Probable fix for the "cdda2wav" panics that various people have been
reporting since this past summer. (I think Daniel O'Conner was the first.)

The problem appears to have been something like this:

- cdda2wav by default passes in a buffer that is close to the 128K MAXPHYS
limit.
- many times, the buffer is not page aligned
- vmapbuf() truncates the address, so that it is page aligned
- that causes the total size of the buffer to be greater than MAXPHYS,
which of course is a bad thing.

Here's a quote from the PR (kern/9067):

==================
In particular, note bp->b_bufsize = 0x0001f950 and bp->b_data = 0xf2219960
(which does not start on a page boundary). vunmapbuf() loops through all
the pages without any difficulty until addr reaches 0xf2239000, and then
the panic occurs. This seems to indicate that we are exceeding MAXPHYS
since we actually started from the middle of a page (the data is being
transfered to a non page aligned location).

To complete the description, note that the system call originates from
ReadCddaMMC12() (in scsi_cmds.c of cdda2wav) with a request to read 55
audio sectors of 2352 bytes (which is calculated to fall under MAXPHYS).
This in turn ends up calling scsi_send() (in scsi-bsd.c) which calls
cam_fill_csio() and cam_send_ccb(). This results in a CAMIOCOMMAND ioctl
with a ccb function code of XPT_SCSI_IO.
==================

The fix is to change the size check in cam_periph_mapmem() so that it is
like the one in minphys(). In particular, it is something like:

if ((buffer_length + (buf_ptr & PAGE_MASK)) > MAXPHYS)
buffer is too big

My fix is based on the one in the PR, but I cleaned up a fair number of
things in cam_periph_mapmem(). The checks for each buffer to be mapped
are now in a separate loop from the actual mapping operation. With the new
arrangement, we don't have to bother with unmapping any previously mapped
buffers if one of the checks fails.

Many thanks to James Liu for tracking this down. I'd appreciate it if some
vm-savvy folks would look this over. I believe this fix is correct, but I
could be wrong.

PR: kern/9067 (also, kern/8112)
Reviewed by: gibbs
Submitted by: "James T. Liu" <jtliu@phlebas.rockefeller.edu>


41815 15-Dec-1998 gibbs

Enable/Disable our lun on open/close. Track resources kept at the controller
level so they can be reclaimed before attempting to disable our lun.
Correctly free descriptors. Add periph locking and spl protection
around open and close.


41814 15-Dec-1998 gibbs

Wire up the XPT_ABORT and XPT_RESET_DEV ccb function codes so they can
be delivered to controller drivers.

Adjust for changes to the ccb_hdr list types in cam_queue.h


41813 15-Dec-1998 gibbs

Add definitions for TAILQ, LIST, and SLIST ccb_hdr queues.


41708 12-Dec-1998 gibbs

Return ENODEV instead of EINVAL when a particular exchange or move
operation exceeds the capabilities of the changer device.


41674 11-Dec-1998 mjacob

Some fixes to handle fixed mode and variable mode more sensibly- and also
incorporate some notion of which revision the device is. If it's < SCSI2, for
example, READ BLOCK LIMITS is not a MANDATORY command.

At any rate, the initial state is to try and read block limits to get a notion
of the smallest and largest record size as well as the granularity. However,
this doesn't mean that the device should actually *in* fixed block mode should
the max && min be equal... *That* choice is (for now) determined by whether
the device comes up with a blocksize of nonzero. If so, then it's a fixed block
preferred device, otherwise not (this will change again soon).

When actually doing I/O, and you're in fixed length mode, the block count is
*not* the byte count divided by the minimum block size- it's the byte count
divided by the current blocksize (or use shift/mask shortcuts if that worked
out...).

Then when you *change* the blocksize via an ioctl, make sure this actually
propagates to the stored notion of blocksize (and update the shift/mask
shortcuts).

Misc Other:
When doing a mode select, only use the SCSI_SAME_DENSITY (0x7f) code if
the device is >= SCSI2- otherwise just use the saved density code.

Recover from the ripple of ILLEGAL REQUEST not being 'retried' in that
RESERVE/RELEASE is not a mandatory command for < SCSI2 (so ignore it if it
fails).


41671 11-Dec-1998 gibbs

Convert dadump to use reasonable data types so that some casting is unecessary.


41670 11-Dec-1998 gibbs

Do not attempt to retry commands that fail with ILLEGAL REQUEST status.


41645 10-Dec-1998 gibbs

Convert debugging printfs to the CAM_DEBUG macro.

Allow sync transfers if the controller supports it. Wide will follow
as soon as I get the kinks worked out of wide target transfers in the
aic7xxx driver (currently the only target mode driver in the tree).


41644 10-Dec-1998 gibbs

Expand the hba_misc fied in the Path Inquiry ccb to allow a controller driver
to specify that it does not provide initiator services (PIM_NOINITIATOR)
and that the initial bus reset for device probing should be avoided
(PIM_NOBUSRESET).

Modify the XPT layer to honor these flags.


41550 06-Dec-1998 mjacob

use CAM_DEBUG_XPT to track XPT; correct a misspelling


41549 06-Dec-1998 mjacob

print the appropriate SCSI revision (with CCS as a proper name for the announce message


41546 05-Dec-1998 mjacob

Add a CAM_DEBUG_XPT define (to debug XPT layer only). Add a CAM_DEBUGGED
macro to be like the CAM_DEBUG macro but to instead provide a predicate
result.


41542 05-Dec-1998 mjacob

Add in named SID field revision names (including CCS).
Add in named defines for DEFAULT and NOCHANGE densities (for sequential
access devices).


41514 04-Dec-1998 archie

Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.

These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.

Reviewed by: Bruce Evans <bde@zeta.org.au>
Reviewed by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Mike Spengler <mks@networkcs.com>


41458 02-Dec-1998 ken

"Fix" a problem with the Quantum Viking. It appears that this drive does
not like the 6-byte read and write commands! It returns illegal request,
with the field pointer pointing to byte 9 of a 6 byte CDB.

In any case, the work around is to put in a quirk mechanism that makes sure
that we don't send 6-byte reads or writes to this device. It's rather sad
that this is necessary. You'd think that they would be able to get
something that basic to work right in their firmware...

Reviewed by: gibbs
Reported by: Adam McDougall <bsdx@spawnet.com>


41351 26-Nov-1998 joerg

...nor does this old TDC3620 like to be asked for compression.

But well, now it's running again!


41330 25-Nov-1998 joerg

This old firmware of the TDC3620 hangs the SCSI bus upon serial
number requests. Don't ask it so.


41297 22-Nov-1998 ken

Fix a few problems that Bruce noticed about a month ago, and fix oup one
other problem.

- Hold onto splsoftcam() in the peripheral driver open routines until we
have locked the periph. This eliminates a race condition.

- Disallow opening the pass driver when securelevel > 1.

- If a user tries to open the pass driver with O_NONBLOCK set, return
EINVAL instead of ENODEV. (noticed by gibbs)


40912 04-Nov-1998 ken

Generalize the quirk entry that disables multi-lun probing for Sony CDROM
drives. It seems that quite a few (possibly all?) of their drives respond
to inquiries on multiple luns. Hopefully we can detect problems like this
in the probe phase at some point. For now, this is a pretty functional
solution.


40603 22-Oct-1998 ken

Fix a problem with the way we handled device invalidation when attaching
to a device failed.

In theory, the same steps that happen when we get an AC_LOST_DEVICE async
notification should have been taken when a driver fails to attach. In
practice, that wasn't the case.

This only affected the da, cd and ch drivers, but the fix affects all
peripheral drivers.

There were several possible problems:
- In the da driver, we didn't remove the peripheral's softc from the da
driver's linked list of softcs. Once the peripheral and softc got
removed, we'd get a kernel panic the next time the timeout routine
called dasendorderedtag().
- In the da, cd and possibly ch drivers, we didn't remove the
peripheral's devstat structure from the devstat queue. Once the
peripheral and softc were removed, this could cause a panic if anyone
tried to access device statistics. (one component of the linked list
wouldn't exist anymore)
- In the cd driver, we didn't take the peripheral off the changer run
queue if it was scheduled to run. In practice, it's highly unlikely,
and maybe impossible that the peripheral would have been on the
changer run queue at that stage of the probe process.

The fix is:
- Add a new peripheral callback function (the "oninvalidate" function)
that is called the first time cam_periph_invalidate() is called for a
peripheral.

- Create new foooninvalidate() routines for each peripheral driver. This
routine is always called at splsoftcam(), and contains all the stuff
that used to be in the AC_LOST_DEVICE case of the async callback
handler.

- Move the devstat cleanup call to the destructor/cleanup routines, since
some of the drivers do I/O in their close routines.

- Make sure that when we're flushing the buffer queue, we traverse it at
splbio().

- Add a check for the invalid flag in the pt driver's open routine.

Reviewed by: gibbs


40417 15-Oct-1998 gibbs

Add a mechanism to send a non-tagged transaction even if a device is
currently operating in a tagged mode. The SIM driver should determine
if a device is in tag mode by looking at the CAM_TAG_ACTION_VALID flag
in the ccb header. If the flag is set, the tag_action field is either
a SCSI II tag message (simple, ordered, head) or CAM_TAG_ACTION_NONE
to specify that no tagging should be performed.


40401 15-Oct-1998 ken

Fix several potential buffer overrun conditions. These changes have been
tested both in the kernel and in userland. Also, fix a couple of printf
warnings that show up when CAMDEBUG is defined.

Reviewed by: imp
Partially submitted by: imp


40398 15-Oct-1998 ken

Clean up some unused variables.

Reviewed by: ken
Submitted by: phk


40363 14-Oct-1998 ken

Narrow the quirk entry for the Seagate Elite 9 a bit to just cover drives
with 71* firmware revisions. Scott Mace <smace@intt.ORG> reports that
drives with 00* firmware revisions do tagged queueing just fine.


40360 14-Oct-1998 ken

Disable tagged queueing for the Seagate Elite 9GB drives. They tend to get
hung up when you send tags to them too quickly. (CAM is able to recover
from the problem, but this just avoids it altogether.)

Reviewed by: gibbs
Reported by: Bret Ford <bford@uop.cs.uop.edu>
and: Martin Renters <martin@tdc.on.ca>


40324 13-Oct-1998 ken

Disable cache syncs for a broken NEC drive.

Reviewed by: gibbs
Submitted by: Blaz Zupan <blaz@gold.amis.net>


40318 13-Oct-1998 ken

Fix a bug in the error recovery code. It was possible to have more than
one error recovery action oustanding for a given peripheral.

This is bad for several reasons. The first problem is that the error
recovery actions would likely be to fix the same problem. (e.g., we
queue 5 CCBs to a disk, and the first one comes back with 0x04,0x02. We
start error recovery, and the second one comes back with the same status.
Then the third one comes back, and so on. Each one causes the drive to get
nailed with a start unit, when we really only need one.)

The other problem is that we only have space to store one CCB while we're
doing error recovery. The subsequent error recovery actions that got
started were over-writing the CCBs from previous error recovery actions,
but we still tried to call the done routine N times for N error recovery
actions. Each call to dadone() was done with the same CCB, though. So on
the second one, we got a "biodone: buffer not busy" panic, since the buffer
in question had already been through biodone().

In any case, this fixes things so that any any given time, there's only one
error recovery action outstanding for any given peripheral driver.

Reviewed by: gibbs
Reported by: Philippe Regnauld <regnauld@deepo.prosa.dk>
[ Philippe wins the "bug finder of the week" award ]


40313 13-Oct-1998 ken

Fix a bug in the scan lun code that showed up when we did the following
sequence of things:

- spin up a disk
- send an async event to refresh the inquiry data
- run through xpt_scan_lun() to re-probe the device
- eventually finish the probe, but panic in xpt_done() because the
periph pointer wasn't set.

Reviewed by: gibbs
Reported by: Philippe Regnauld <regnauld@deepo.prosa.dk>


40286 13-Oct-1998 dg

Fixed two potentially serious classes of bugs:

1) The vnode pager wasn't properly tracking the file size due to
"size" being page rounded in some cases and not in others.
This sometimes resulted in corrupted files. First noticed by
Terry Lambert.
Fixed by changing the "size" pager_alloc parameter to be a 64bit
byte value (as opposed to a 32bit page index) and changing the
pagers and their callers to deal with this properly.
2) Fixed a bogus type cast in round_page() and trunc_page() that
caused some 64bit offsets and sizes to be scrambled. Removing
the cast required adding casts at a few dozen callers.
There may be problems with other bogus casts in close-by
macros. A quick check seemed to indicate that those were okay,
however.


40271 12-Oct-1998 ken

Add a "dummy light" (actually two dummy lights) to catch people who don't
have the passthrough device configured in their kernel.

This will hopefully reduce the number of people complaining that they can't
get {camcontrol, xmcd, tosha, cdrecord, etc.} to work.

Reviewed by: gibbs


40263 12-Oct-1998 ken

Add quirk entries to disable the synchronize cache command for Micropolis
2217's (reported by Matthew Jacob in NetBSD PR kern/6027) and Fujitsu
M2954's (reported by Tom Jackson).

Some of the Fujitsus at least hang when they get a cache sync command.
(Others just return illegal request.)

Also, make error printing in dashutdown() a little more selective. Don't
print any error when the sense key is illegal request. Drives that don't
support the synchronize cache command usually return illegal request.
Also, make sure the scsi status is check condition before going into
scsi_sense_print().

Reviewed by: gibbs


40262 12-Oct-1998 ken

Bring over a quirk entry from the old SCSI code for a Chinon CDROM drive
that returns track numbers in BCD.

Reviewed by: gibbs


40194 10-Oct-1998 gibbs

If the bus delay is >= 2 seconds, notify the user that we are waiting
for devices to settle. This will hopefully allay any 'first installation'
fears that the machine has hung.


40051 08-Oct-1998 ken

Add the quirk entry framework to handle disabling the synchronize cache
command on drives that don't like it. Right now, there's just a bogus
quirk entry in the table that doesn't do anything, but that should be
changed once we get actual inquiry data for drives that don't like the
synchronize cache command.

Also, add a shutdown hook that runs through all direct access peripherals
and runs a synchronize cache on them if they're still open, and if
synchronize cache isn't disabled via a quirk entry.

Add a synchronize cache call at the end of dadump() (again, conditionalized
on the quirk entry), so we can insure that the disk cache contents get
flushed to physical media after a dump.

Check the new quirk entry in daclose() to decide whether or not to
synchronize the cache for a disk at final close.

Reviewed by: gibbs


40025 07-Oct-1998 gibbs

Add a quirk entry for the CFP2107, another drive with broken
tagged queuing support.

Ensure that we report that a device supports tagged queuing even if
the system is waiting a "command count delay" before starting to use
them.

If a user disables disconnects on a device ensure that tagged queuing
is also turned off. We did the right thing during initial configuration,
but could be confused by manual changes.


40021 07-Oct-1998 imp

Up the read capacity timeout from 20 seconds to 60 seconds to keep my
JAZ drive happy. This shouldn't impact fast drives, and will keep cam
from failing on very slow ones (that are spinning up, say). 20
seconds was almost long enough, but not in all cases.

Suggested by: gibbs


40020 07-Oct-1998 ken

Some fixes for the CD and DA drivers from bde. (and some of my own as
well) Among them:

[ cd driver ]
1. Old labeling code was still there.
2. Error handling for dsopen() was broken (no test for the `error'
returned by dsopen(); bogus test of an `error' that is known to be 0).
3. cdopen() closed the physical device after certain errors although there
may still be open partitions on it.
4. cdclose() closed the physical device although there may still be open
partitions on it.
5. Some printf format fixes was incomplete or missing.
6. cdioctl() truncated unit numbers mod 256.
7. cdioctl() was missing locking.

[ da driver ]
1. daclose() closed the physical device although there may still be open
partitions on it. This was fixed many years ago in sd.c rev.1.57.
2. A minor optimization (the dk_slices != NULL test) in sdopen() became
uglier in daopen(). It is not worth doing. da only regressed compared
with od and my version of sd, since I never committed the change to sd.
daopen() should probably do less if some partition is already open.
This is not addressed by the diffs.
[ ... ]
5. "opt_hw_wdog.h" was not included, so the HW_WDOG code was unreachable.

- Added a getdev CCB call in the cdopen() and daopen() calls so that the
vendor name and device name are available for the disklabel. (suggested
by bde)

- Removed vestigal devfs support in both drivers, since we can't properly
work with devfs yet. (ask bde for details on this)

- Cleaned up the probe code in both drivers in the failure cases. There
were a number of things wrong here. The peripheral driver instances
weren't getting properly cleaned up. Sometimes the wrong probe message
would get printed out (with the failure message appended), so it wasn't
very clear that we failed to attach. SCSI sense information was printed,
even when the error in question wasn't a SCSI error. I put similar fixes
into the changer driver in revision 1.2 of scsi_ch.c.

Reviewed by: gibbs
Submitted by: bde (partially)


40007 06-Oct-1998 ken

Disable multi-lun probing and serial number inquiries for the Exabyte 8200.


39904 02-Oct-1998 ken

Fix a printf format warning that shows up when CAMDEBUG is defined.


39903 02-Oct-1998 ken

Add a new CAM debugging mode, CAM_DEBUG_CDB. This causes the kernel to
print out a one line description/dump of every SCSI CDB sent to a
particular debugging target or targets.

This is a good bit more useful than the other debugging modes, I think.

Change some things in LINT to note the availability of this new option.

Fix an erroneous argument to scsi_cdb_string() in scsi_all.c

Reviewed by: gibbs


39885 02-Oct-1998 ken

Modify the changer driver so it can handle (hopefully!) changers that need
block descriptors enabled on mode sense commands.

Basically, we try sending a mode sense with block descriptors disabled (the
previous default), and if it fails, we try sending the mode sense with
block descriptors enabled. If that works, we note that in a runtime quirk
entry, so we don't bother disabling block descriptors again for the device.

This problem was first reported by Chris Jones <cjones@honors.montana.edu>
on one of the NetBSD lists, but I'd imagine that some FreeBSD users would
have run into it eventually as well, since our changer driver is derived
form the NetBSD changer driver.

Also, change some of the probe logic so that we do the right thing in the
case of a failure to attach.

Fix a memory leak in chgetparams().

Add a couple of inline helper functions to scsi_all.h to correctly return
the start of a mode page.

NetBSD PR: kern/6214
Reviewed by: gibbs


39884 02-Oct-1998 ken

Patches from DES to create three new kernel config options to control
timeouts in the SA driver (timeouts for space, rewind and erase). Folks
can lengthen the timeouts if their hardware is especially slow, or shorten
them if they want to be notified of errors a little sooner.

Also, get rid of two OD driver options. The od driver has been made
obsolete by the da driver.

Reviewed by: ken, gibbs
Submitted by: Dag-Erling Coidan Smørgrav <des@FreeBSD.ORG>


39787 29-Sep-1998 ken

In the bootverbose case, print out error messages for all errors that will
not be retried again, even if the SF_NO_PRINT flag is set.

Reviewed by: gibbs


39758 29-Sep-1998 bde

Fixed printf format errors. u_long is not necessarily suitable for casting
pointers to, and %d is not suitable for printing uint32_t's.


39657 25-Sep-1998 gibbs

Correct problems with xpt_set_transfer_settings and async transfer
negotiation changes with wildcarded paths.


39633 24-Sep-1998 gibbs

Fix a few problems with the tag delay code:

- Tagged devices were limited to one transaction (oops)
- We revert to untagged with a tag delay if the user changed the
transfer negotiation values (via perhaps camcontrol some day).
- xpt_async did not use the expanded path in some cases which could
cause a panic.


39580 23-Sep-1998 ken

Treat not ready errors (asc 0x04) as non-fatal errors for attach. We
already allowed medium not present type errors (0x3a), but some Philips and
HP WORM drives return 0x04,0x00 when you issue a read capacity without
media in the drive.


39579 23-Sep-1998 gibbs

Allow 5 untagged commands to go to a device before enabling tags after
enabling transfer negotiations, a BDR, or a bus reset to allow the controller
driver to negotiate without tagged messages getting in the way. Some
devices are confused by attempts to negotiate and tag at the same time.
Some controllers (e.g. BT MultiMaster with certain firmware revs) will
never negotiate if you don't give them an untagged "window" to perform
negotiation in.

Bump the maximum tag count to 255. The system reclaims unused tag space
as the tag count is dropped anyway, so we might as well try the max.

We should probably use a larger type than u_int8_t to hold our tag value
as SCSI over certain mediums allows for higher values.

Reviewed by: Kenneth Merry <ken@FreeBSD.org>


39573 22-Sep-1998 ken

Add several quirks:

Western Digital Enterprise drives have sorry performance (1.5MB/sec versus
8MB/sec) when doing tagged queueing. Disable tagged queueing for them.

Submitted by: Andrew Gallatin <gallatin@cs.duke.edu>

Some Sony CDROM drives don't like it when we probe more than one LUN.

Verified by: Jean-Marc Zucconi <jmz@FreeBSD.ORG>

Some Sony CD-R's don't like multi-LUN probing either.

Submitted by: Parag Patel <parag@cgt.com>


39552 22-Sep-1998 gibbs

cam.c:
Clear up trailing NULs in cam_strvis.

cam_xpt.c:
Nuke an experimental quirk entry for the Toshiba 3401. The real
problem with this device turned out to be a bug in the aic7xxx
driver that was fixed months ago.

Add a quirk entry to inhibit multiple lun scanning and serial number
probing of DPT RAID volumes. My DPT controller hangs up solid when
I do either of these things to a RAID 1 volume.


39531 20-Sep-1998 ken

Some fixes to the CD driver that may fix PR kern/7996. The data direction
flags on some of the operations in the driver weren't quite right. Also,
clean up scsi_cd.h, change u_char to u_int8_t.

I'm surprised this problem didn't show up sooner. (the code has been in
there almost a year and a half)

PR: 7996
Reviewed by: ken
Submitted (mostly) by: gibbs


39514 20-Sep-1998 gibbs

Don't invalidate devices due to unexpected unit attention errors. In
a perfect world, we'd notice the UA and do some device validation to ensure
that the device hasn't changed. We may get this before the year ends,
but not before 3.0R. This change gives the adminstrator ample ammunition
to take off a foot or two, but hey this *is* UN*X.


39513 20-Sep-1998 gibbs

cam_xpt.c:
Add quirk entry for a Samsung drive that doesn't like experiencing
the queue full condition.

Bump the timeouts for all probe activities to 60s. We don't know
what the seletion timeout (or equivelent on other mediums) is
for controllers, which can make the transactions at the tail
end of a parallel probe take a while to complete. The DPT
seems to be a card that takes a long time to see a selection timeout.

cam_periph.c:
Don't call a device "gone" after a single selection timeout. We
need to come up with a better policy. Until that time, you'll
have to manually re-scan a bus via camcontrol for the system to
decide that a device is really gone. This should give devices
experiencing temporary insanity to escape death.


39504 20-Sep-1998 gibbs

Only deregister out configuration hook manually if there are no SCSI
busses to configure.


39477 19-Sep-1998 gibbs

Don't leave the device queue in a frozen state if the Synchronize Cache
command on close fails.


39471 19-Sep-1998 ken

Fix error recovery in scsi_interpret_sense(). It turns out that ERESTART
wasn't getting sent back for most errors, even if there were retries left
on the command. I'm not sure how I ever let this slip by before...

In any case, we now send back ERESTART if there are retries left for the
command, and send back the default error code when there are no retries
left.

Reviewed by: gibbs


39466 18-Sep-1998 ken

Fix the CAM code so that people can compile kernels with the CD driver but
without the DA driver.

The problem was that the CD driver depended on scsi_read_write() and
scsi_start_stop(), which were defined in scsi_da.c.

I moved both functions, and their associated data structures and defines
from scsi_da.* to scsi_all.*. This is technically the "wrong" thing to do
since those commands are really only for direct-access type devices, not
for all SCSI devices. I think, though, that the advantage (allowing people
to compile kernels without the disk driver) outweighs any architectural
purity arguments.

PR: kern/7969
Reviewed by: gibbs


39460 18-Sep-1998 ken

Change the Atlas II quirk entries so they work with differential Atlas
II's. Also, add a quirk entry for the 2 gig Atlas II.

Partially Submitted by: Ted Buswell <tbuswell@mediaone.net>


39442 17-Sep-1998 ken

Fix a formatting error.

Fix a problem reported by bde: setting SCSI_DELAY to 0 doesn't work. Now,
when the user sets SCSI_DELAY to 0, we re-set it to the minimum allowable
bus settle delay (100ms).

Fix a potential panic in xptfinishconfigfunc() if the CCB passed in is
NULL. Reported by, I think, Nicolas Souchu. Fix a memory leak in the same
function (we created a path, but didn't free it) by allocating the getdev
CCB and path on the stack.

Reviewed by: gibbs


39388 16-Sep-1998 ken

Some Alpha patches for CAM from Doug Rabson.

Reviewed by: gibbs
Submitted by: dfr


39360 16-Sep-1998 gibbs

Properly allocate our, per lun, probe peripheral softc from
the TEMP malloc pool.

Noticed by: Don Lewis <Don.Lewis@tsc.tdk.com>


39317 16-Sep-1998 ken

Check to make sure that this device is opened read-write, not just read
only. Previously, if the device was chmoded 644, someone could open it
with the O_RDONLY flag and issue any ioctl to the device.

Reviewed by: imp, gibbs


39310 15-Sep-1998 gibbs

Correct printf format bugs.


39213 15-Sep-1998 gibbs

SCSI Peripheral drivers for CAM:

da - Direct Access Devices (disks, optical devices, SS disks)
cd - CDROM (or devices that can act like them, WORM, CD-RW, etc)
ch - Medium Changer devices.
sa - Sequential Access Devices (tape drives)
pass - Application pass-thru driver
targ - Target Mode "Processor Target" Emulator
pt - Processor Target Devices (scanners, cpus, etc.)

Submitted by: The CAM Team


39212 15-Sep-1998 gibbs

CAM Transport Layer (XPT).

Submitted by: The CAM Team