History log of /freebsd-10.1-release/sys/cam/scsi/
Revision Date Author Comments
272461 03-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

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


271903 20-Sep-2014 mav

MFC r271700: Fix typo in defined ROD types in r269497.

Approved by: re (gjb)


271748 18-Sep-2014 mav

MFC r271644:
Add quirks to disable READ CAPACITY (16) for PNY USB 3.0 Flash Drives.

Submitted by: Sean Fagan <sef@ixsystems.com>
Approved by: re (kib)


271530 13-Sep-2014 mav

MFC r271407: Extend UNMAP blacklist on all STEC SSD models.

None of existing STEC devices need UNMAP or even support it well,
having many limitations and even hanging sometimes executing those
commands. New devices that may use UNMAP going to be released under
HGST name.

Approved by: re (delphij)


271238 07-Sep-2014 smh

MFC r256956:
Improve ZFS N-way mirror read performance by using load and locality
information.

MFC r260713:
Fix ZFS mirror code for handling multiple DVA's

Also make the addition of the d_rotation_rate binary compatible. This allows
storage drivers compiled for 10.0 to work by preserving the ABI for disks.

Approved by: re (gjb)
Sponsored by: Multiplay


270313 21-Aug-2014 smh

MFC r269974 - Added 4K quirks for Corsair Force GT and Samsung 840 SSDs

Sponsored by: Multiplay


270108 17-Aug-2014 mav

MFC r269622:
Fix several issues and inconsistencies in UNMAP capabilities reporting.

This makes Windows 2012 to start using UNMAP on our disks.


270106 17-Aug-2014 mav

MFC r269497:
Add support for Windows dialect of EXTENDED COPY command, aka Microsoft ODX.

This allows to avoid extra network traffic when copying files on NTFS iSCSI
disks within one storage host by drag'n'dropping them in Windows Explorer
of Windows 8/2012. It should also accelerate Hyper-V VM operations, etc.


269717 08-Aug-2014 joerg

Merge r269353:

Fix breakage introduced by r256843: removing the SA_CCB_WAITING bit
left some of the decisions based on its counterpart, SA_CCB_BUFFER_IO
being random. As a result, propagation of the residual information
for the SPACE command was broken, so the number of filemarks
encountered during a SPACE operation was miscalculated. Consequently,
systems relying on properly tracked filemark counters (like Bacula)
fell apart.

The change also removes a switch/case in sadone() which r256843
degraded to a single remaining case label.

PR: 192285


269296 30-Jul-2014 mav

MFC r268767:
Add support for VMWare dialect of EXTENDED COPY command, aka VAAI Clone.

This allows to clone VMs and move them between LUNs inside one storage
host without generating extra network traffic to the initiator and back,
and without being limited by network bandwidth.

LUNs participating in copy operation should have UNIQUE NAA or EUI IDs set.
For LUNs without these IDs VMWare will use traditional copy operations.

Beware: the above LUN IDs explicitly set to values non-unique from the VM
cluster point of view may cause data corruption if wrong LUN is addressed!

Sponsored by: iXsystems, Inc.


268816 17-Jul-2014 imp

MFC:

>r267118 | imp | 2014-06-05 11:13:42 -0600 (Thu, 05 Jun 2014) | 9 lines
>The code that combines adjacent ranges for BIO_DELETEs to optimize
>trims to the device assumes the list is sorted. Don't apply the
>optimization of not sorting the queue when we have SSDs to the
>delete_queue, since it causes more discard traffic to the drive. While
>one could argue that the higher levels should coalesce the trims,
>that's not done today, so some optimization at this level is needed.
>CR: https://phabric.freebsd.org/D142


268700 15-Jul-2014 mav

MFC r268240 (by ken):
Add persistent reservation support to camcontrol(8).

camcontrol(8) now supports a new 'persist' subcommand that allows users to
issue SCSI PERSISTENT RESERVE IN / OUT commands.


268697 15-Jul-2014 mav

MFC r268418:
Enable TAS feature: notify initiator if its command was aborted by other.

That should make operation more kind to multi-initiator environment.
Without this, other initiators may find out that something bad happened
to their commands only via command timeout.


268687 15-Jul-2014 mav

MFC r268309:
Add support for SCSI Ports (88h) VPD page.


268675 15-Jul-2014 mav

MFC r268103:
Add support for REPORT TIMESTAMP command.


268674 15-Jul-2014 mav

MFC r268096, r268306, r268361:
Add more formal and strict command parsing and validation.

For every supported command define CDB length and mask of bits that are
allowed to be set. This allows to remove bunch of checks through the code
and still make the validation more strict. To properly do it for commands
supporting multiple service actions, formalize their parsing by adding
subtables for each of such commands.

As visible effect, this change allows to add support for REPORT SUPPORTED
OPERATION CODES command, reporting to client all the data about supported
SCSI commands, except timeouts.


268551 12-Jul-2014 mav

MFC r267906:
Allow MODE SENSE commands through Write Exclusive persistent reservation,
as required by SPC-4.

Report that fact in persistent reservation capabilities.


268255 04-Jul-2014 mav

MFC r267051:
- Add support for SG_GET_SG_TABLESIZE IOCTL to report that we don't support
scatter/gather lists.
- Return error for still unsupported SG 3.x API read/write calls.


268151 02-Jul-2014 mav

MFC r267537:
Add support for VERIFY(10/12/16) and COMPARE AND WRITE SCSI commands.

Make data_submit backends method support not only read and write requests,
but also two new ones: verify and compare. Verify just checks readability
of the data in specified location without transferring them outside.
Compare reads the specified data and compares them to received data,
returning error if they are different.

VERIFY(10/12/16) commands request either verify or compare from backend,
depending on BYTCHK CDB field. COMPARE AND WRITE command executed in two
stages: first it requests compare, and then, if succeesed, requests write.
Atomicity of operation is guarantied by CTL request ordering code.

Sponsored by: iXsystems, Inc.


268139 02-Jul-2014 mav

MFC r266981:
Overhaul CAM SG driver IOCTL interfaces.

Make it really work for native FreeBSD programs. Before this it was broken
for years due to different number of pointer dereferences in Linux and
FreeBSD IOCTL paths, permanently returning errors to FreeBSD programs.
This change breaks the driver FreeBSD IOCTL ABI, making it more strict,
but since it was not working any way -- who bother.

Add shims for 32-bit programs on 64-bit host, translating the argument
of the SG_IO IOCTL for both FreeBSD and Linux ABIs.

With this change I was able to run 32-bit Linux sg3_utils tools and simple
32 and 64-bit FreeBSD test tools on both 32 and 64-bit FreeBSD systems.


265644 08-May-2014 mav

MFC r265159:
Respect MAXIMUM TRANSFER LENGTH field of Block Limits VPD page.

Nobody yet reported disk supporting I/Os less then our MAXPHYS value, but
since we any way have code to read Block Limits VPD page, that is easy.


265643 08-May-2014 mav

MFC r265150:
Do not reread SCSI disk VPD pages on every device open.

Instead of rereading VPD pages on every device open, do it only on initial
device probe, and in cases when device reported via UNIT ATTENTIONs that
something has changed. Capacity is still rereaded on every open because
it is more critical for operation and more probable to change in run time.

On my tests with Intel 530 SSDs on mps(4) HBA this change reduces time
GEOM needs to retaste the device (that includes few open/close cycles)
from ~150ms to ~30ms.


265638 08-May-2014 mav

MFC r264834:
Disable UNMAP support for STEC 842 SSDs.

In some unknown cases UNMAP commands make device firmware stuck.


265634 08-May-2014 mav

MFC r264274, r264279, r264283, r264296, r264297:
Add support for SCSI UNMAP commands to CTL.

This patch adds support for three new SCSI commands: UNMAP, WRITE SAME(10)
and WRITE SAME(16). WRITE SAME commands support both normal write mode
and UNMAP flag. To properly report UNMAP capabilities this patch also adds
support for reporting two new VPD pages: Block limits and Logical Block
Provisioning.

UNMAP support can be enabled per-LUN by adding "-o unmap=on" to `ctladm
create` command line or "option unmap on" to lun sections of /etc/ctl.conf.

At this moment UNMAP supported for ramdisks and device-backed block LUNs.
It was tested to work great with ZFS ZVOLs. For file-backed LUNs UNMAP
support is unfortunately missing due to absence of respective VFS KPI.

Sponsored by: iXsystems, Inc


265632 08-May-2014 mav

MFC r260509:
Replace several instances of -1 with appropriate CAM_*_WILDCARD and types.

It was equal before r259397, but for good or bad, not any more for LUNs.

This change fixes at least CAM debugging.


264541 16-Apr-2014 mav

MFC r264311 (by smh):
Fix build breakage caused by r264295


264522 16-Apr-2014 mav

MFC r264295:
Remove support of LUN-based CD changers from cd(4) driver.

This code was heavily broken few months ago during CAM locking changes.
Fixing it would require almost complete rewrite. Since there are no
known devices on market using this interface younger then ~15 years, and
they are CD, not even DVD, I don't see much reason to rewrite it.

This change does not mean those devices won't work. They will just work
slower due to inefficient disks load/unload schedule if several LUNs
accessed same time.


261255 29-Jan-2014 mav

MFC r260267 (by smh), r261042:
Correct short delete issue in SCSI UNMAP support
Correct missing \n's in xpt_print's
Correct incorrect count being passed to short delete xpt_print


260958 20-Jan-2014 mav

MFC r260407:
Allow delete_method sysctl to be set to "DISABLE".


260626 14-Jan-2014 mav

MFC r260541, r260547:
Take additional reference on SCSI probe periph to cover its freeze count.

Otherwise periph may be invalidated and freed before single-stepping freeze
is dropped, causing use after free panic.


260475 09-Jan-2014 mav

MFC r256547 (by smh):
Added 4K quirks for Corsair Neutron GTX SSD's


260387 07-Jan-2014 scottl

MFC Alexander Motin's direct dispatch, multi-queue, and finer-grained
locking support for CAM

r256826:
Fix several target mode SIMs to not blindly clear ccb_h.flags field of
ATIO CCBs. Not all CCB flags there belong to them.

r256836:
Remove hard limit on number of BIOs handled with one ATA TRIM request.

r256843:
Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack,
preparing the ground for the coming next GEOM direct dispatch support.

r256888:
Unconditionally acquire periph reference on CCB allocation failure.

r256895:
Fix memory and references leak due to unfreed path.

r256960:
Move CAM_UNQUEUED_INDEX setting to the last moment and under the periph lock.
This fixes race condition with cam_periph_ccbwait(), causing use-after-free.

r256975:
Minor (mostly cosmetical) addition to r256960.

r257054:
Some microoptimizations for da and ada drivers:
- Replace ordered_tag_count counter with single flag;
- From da remove outstanding_cmds counter, duplicating pending_ccbs list;
- From da_softc remove unused links field.

r257482:
Fix lock recursion, triggered by `smartctl -a /dev/adaX`.

r257501:
Make getenv_*() functions and respectively TUNABLE_*_FETCH() macros not
allocate memory and so not require sleepable environment. getenv() has
already used on-stack temporary storage, so just use it more rationally.
getenv_string() receives buffer as argument, so don't need another one.

r257914:
Some CAM locks polishing:
- Fix LOR and possible lock recursion when handling high-power commands.
Introduce new lock to protect left power quota and list of frozen devices.
- Correct locking around xpt periph creation.
- Remove seems never used XPT_FLAG_OPEN xpt periph flag.

Again, Netflix assisted with testing the merge, but all of the credit goes
to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems


260385 07-Jan-2014 scottl

MFC Alexander Motin's GEOM direct dispatch work:

r256603:
Introduce new function devstat_end_transaction_bio_bt(), adding new argument
to specify present time. Use this function to move binuptime() out of lock,
substantially reducing lock congestion when slow timecounter is used.

r256606:
Move g_io_deliver() out of the lock, as required for direct dispatch.
Move g_destroy_bio() out too to reduce lock scope even more.

r256607:
Fix passing uninitialized bio_resid argument to g_trace().

r256610:
Add unmapped I/O support to GEOM RAID.

r256830:
Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping
temporary mapped buffer. That fixes double unmap if biodone() called twice
for the same BIO (but with different done methods).

r256880:
Merge GEOM direct dispatch changes from the projects/camlock branch.

When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.

r259247:
Fix bug introduced at r256607. We have to recalculate bp_resid here since
sizes of original and completed requests may differ due to end of media.

Testing of the stable/10 merge was done by Netflix, but all of the credit
goes to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems


259721 22-Dec-2013 mav

MFC r259108:
When comparing device IDs, make sure that they have the same type
(like NAA assigned) and identify the same entity (like device or port).
Otherwise there can be false positives since at least some models of
Seagate disks use same IDs for the whole device and one of its ports.


259204 10-Dec-2013 nwhitehorn

MFC r257345,257382,257388:

Implement extended LUN support. If PIM_EXTLUNS is set by a SIM, encode
the upper 32-bits of the LUN, if possible, into the target_lun field as
passed directly from the REPORT LUNs response. This allows extended LUN
support to work for all LUNs with zeros in the lower 32-bits, which covers
most addressing modes without breaking KBI. Behavior for drivers not
setting PIM_EXTLUNS is unchanged. No user-facing interfaces are modified.

Extended LUNs are stored with swizzled 16-bit word order so that, for
devices implementing LUN addressing (like SCSI-2), the numerical
representation of the LUN is identical with and without PIM_EXTLUNS. Thus
setting PIM_EXTLUNS keeps most behavior, and user-facing LUN IDs, unchanged.
This follows the strategy used in Solaris. A macro (CAM_EXTLUN_BYTE_SWIZZLE)
is provided to transform a lun_id_t into a uint64_t ordered for the wire.

This is the second part of work for full 64-bit extended LUN support and is
designed to a bridge for stable/10 to the final 64-bit LUN code. The
third and final part will involve widening lun_id_t to 64 bits and will
not be MFCed. This third part will break the KBI but will keep the KPI
unchanged so that all drivers that will care about this can be updated now
and not require code changes between HEAD and stable/10.

Reviewed by: scottl


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)


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


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


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


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.


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


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


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


254329 14-Aug-2013 smh

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


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.


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.


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


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


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


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.


250460 10-May-2013 eadler

Fxi a bunch of typos.

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


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


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.


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


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


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


249582 17-Apr-2013 gabor

- Correct mispellings of the word occurrence

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


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


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


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


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.


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


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.


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


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


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.


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


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.


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.


241844 22-Oct-2012 eadler

remove duplicate semicolons where possible.

Approved by: cperciva
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


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)


241455 11-Oct-2012 mav

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


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


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.


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


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.


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


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


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


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


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


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


236613 05-Jun-2012 mav

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


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.


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


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


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.


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


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


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


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


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


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


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.


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.


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


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


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.


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


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


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


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


220644 14-Apr-2011 mav

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


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


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


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


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.


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.


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.


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.


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.


208800 04-Jun-2010 avg

scsi_cd: pass correct pointer to free()

Found with: Coverity Prevent(tm)
CID: 2986
MFC after: 4 days


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


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


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


205252 17-Mar-2010 mjacob

We actually can generate a host number.

MFC after: 1 month


204220 22-Feb-2010 mav

Virtualize transport part of periph announcement.


203931 15-Feb-2010 mav

Make CD driver a bit more robust and predictable to unreported errors.


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.


201758 07-Jan-2010 mbr

Remove extraneous semicolons, no functional changes.

Submitted by: Marc Balmer <marc@msys.ch>
MFC after: 1 week


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.


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


199279 14-Nov-2009 mav

MFp4:
Fix several device freeze counting bugs.


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.


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.


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.


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.


198382 23-Oct-2009 mav

Replace most of priority numbers with defines. No logical changes.


198381 23-Oct-2009 mav

Remove some obsoleted comments.


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


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


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.


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)


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


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.


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)


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


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


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


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


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


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


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


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


186371 21-Dec-2008 scottl

Fix refcount locking in cd, pass, and sg periphs.


186319 19-Dec-2008 trasz

Periph driver fixes, second try.

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


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


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


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


176426 20-Feb-2008 scottl

Fix a couple of locking mistakes in the ses_ioctl path.

Submitted by: Matt Jacob


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


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.


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.


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)


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.


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.


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


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.


168982 23-Apr-2007 scottl

Remove obsolete headers. Move kernel specific headers under #ifdefs


168874 19-Apr-2007 scottl

Fix a leaked lock in dashutdown.


168872 19-Apr-2007 scottl

Avoid problems with make_dev.


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


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.


167082 27-Feb-2007 jhb

Use tsleep() rather than msleep() with a NULL mtx.


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


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)


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


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


162365 16-Sep-2006 mjacob

Don't allow attachment of disks that could cause GEOM to panic.


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


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


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


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.


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


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


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


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)


147176 09-Jun-2005 pjd

Add a quirk for my pen-drive.


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


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


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


141713 12-Feb-2005 scottl

Remove a shadow declaration of 'error' that caused certain tests to be
pointless.

Submitted by: Coverity Prevent analysis tool


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


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 /*-


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


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.


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


131910 10-Jul-2004 marcel

Update for the KDB framework:
o Call kdb_enter() instead of Debugger().


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.


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.


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


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


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


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


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


116162 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


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


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.


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


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.


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.


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


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.


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


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.


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.


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


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.


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.


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.


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>


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


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>


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.


78230 15-Jun-2001 peter

Fix warnings:
1267: warning: suggest parentheses around comparison in operand of &
2087: warning: unused variable `li'


77810 06-Jun-2001 non

Sorry, an "ARCHIVE Python 06408" does not need SA_QUIRK_NOCOMP.


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.


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>


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)


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>


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


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)


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


71493 24-Jan-2001 mjacob

"Rejected with status" is better than "Rejected for status".


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.


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>


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


68085 31-Oct-2000 gibbs

0x03F -> 0x3F for consistancy with the rest of the file.


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


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>


66927 10-Oct-2000 n_hibma

Add a quirk entry for the USB Sony DSC drive.


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.


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.


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


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.


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.


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


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.


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.


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$


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


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


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


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


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


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.


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.


54685 16-Dec-1999 obrien

Add FAST-80 timing to the scsi syncrates table.

Submitted by: Gerard Roudier <groudier@club-internet.fr>


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.


53257 17-Nov-1999 ken

Convert the xpt, pass, pt and target drivers to use the new
make_dev()/destroy_dev() interface.


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.


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


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.


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.


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.


48192 24-Jun-1999 mjacob

Quirk Tandberg 4100 like Tandberg 4200.
PR: 11675
Reviewed by: msmith@FreeBSD.ORG
Submitted by: blank@uni-trier.de


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


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.


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.


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.


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.


45752 18-Apr-1999 mjacob

Make WangTek 51000 a fixed block device.
PR: kern/11194
Obtained from:naddy@mips.rhein-neckar.de


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.


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.


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.


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


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.


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


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


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.


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.


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


41549 06-Dec-1998 mjacob

print the appropriate SCSI revision (with CCS as a proper name for the announce message


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!


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)


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


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


40324 13-Oct-1998 ken

Disable cache syncs for a broken NEC drive.

Reviewed by: gibbs
Submitted by: Blaz Zupan <blaz@gold.amis.net>


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.


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


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


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)


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


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.


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.


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


39388 16-Sep-1998 ken

Some Alpha patches for CAM from Doug Rabson.

Reviewed by: gibbs
Submitted by: dfr


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