History log of /freebsd-9.3-release/sys/dev/ata/atapi-cam.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

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

# 253037 08-Jul-2013 mav

MFC r249468:
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.


# 251874 17-Jun-2013 scottl

Big MFC of the physbio changes necessary for unmapped I/O. These changes
have been in production at Netflix for several months with significant
success.

MFC r246713:

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.

MFC r249538:
Some compilers issue a warning when wider integer is casted to narrow
pointer. Supposedly shut down the warning by casting through
uintptr_t.

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

MFC r251837:
MFC r251842:
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.

Submitted by: kib, jeffr
Approved by: kib
Obtained from: Netflix


# 233717 30-Mar-2012 marius

MFC: r233282

- First pass at const'ifying ata(4) as appropriate.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.


# 231772 15-Feb-2012 ken

MFC r229997, r230033, and r230334

Bring the CAM Target Layer into stable/9.

r230334 | ken | 2012-01-19 11:42:03 -0700 (Thu, 19 Jan 2012) | 19 lines

Quiet some clang warnings when compiling CTL.

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

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

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

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

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

r230033 | ken | 2012-01-12 15:08:33 -0700 (Thu, 12 Jan 2012) | 5 lines

Silence some unnecessary verbosity.

Reported by: mav
MFC after: 1 month

r229997 | ken | 2012-01-11 17:34:33 -0700 (Wed, 11 Jan 2012) | 170 lines

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


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 208822 05-Jun-2010 mav

Fix possible use after free.

Found with: Coverity Prevent(tm)
CID: 4634


# 203449 03-Feb-2010 mav

Implement poll method for atapicam.
It is not perfect, but better then nothing.


# 203445 03-Feb-2010 mav

Report to CAM unit number of underlying ataX bus device, instead of this
atapicamX. It is more apropriate and useful together with "ata" name.


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


# 198488 26-Oct-2009 mav

Report SATA speeds to CAM, to not confuse users with low numbers logged.


# 198487 26-Oct-2009 mav

Round timeout up when converting CAM milliseconds to ATA seconds.


# 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


# 192020 12-May-2009 trasz

Remove dead code.

Found with: Coverity Prevent(tm)
CID: 556


# 189195 28-Feb-2009 mav

Revert my ata_identify()/ata_reinit() related changes: r189166, r189091
and partially r188903. Revert breaks new drives detection on reinit to the
state as it was before me, but fixes series of new bugs reported by some
people.

Unconditional queueing of ata_completed() calls can lead to deadlock if
due to timeout ata_reinit() was called at the same thread by previous
ata_completed(). Calling of ata_identify() on ata_reinit() in current
implementation opens numerous races and deadlocks.

Problems I was touching here are still exist and should be addresed, but
probably in different way.


# 189166 28-Feb-2009 mav

Rework device probing by moving ata_getparam() call from ata_identify() to
drivers' probe routines. It allows not to sleep and so not drop Giant inside
ata_identify() critical section and so avoid crash if it reentered on
request timeout. Reentering of probe call checked inside of it.

Give device own knowledge about it's type (ata/atapi/atapicam). It is not
a good idea to ask channel status for device type inside ata_getparam().

Add softc memory deallocation on device destruction.


# 188125 04-Feb-2009 imp

Correct signature for the identify routine. The bad parameter wasn't
used at all, so this is just a tidiness excersize.


# 186905 08-Jan-2009 trasz

Make "kldunload atapicam" return EBUSY instead of deadlocking when a device
created by atapicam is being kept opened or mounted. This is probably just
a temporary solution until we invent something better.

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation
Reported by: Jaakko Heinonen


# 178278 17-Apr-2008 sos

Go back to preallocating everything possible on init.
This avoids calling busdma in the request processing path which caused a traumatic performance degradation.
Allocation has be postponed to after we know how many devices we possible can have on portmulitpliers to save some space.


# 178114 11-Apr-2008 sos

Fix the brokenness in the former commit, sorry for the mess.
The problem is that the PM support is part of a much larger WIP here, but due to popular demand I decided to get some of it imported.

Also I forgot the mention:

HW sponsored by: Vitsch Electronics / VEHosting


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


# 169214 02-May-2007 scottl

MPSAFE atapi-cam


# 169116 30-Apr-2007 thomas

(atapi_action, case XPT_SCSI_IO): Enable DMA only for READ and WRITE commands
as some combinations of chipset, controller and target do not behave
correctly when DMA is enabled for other commands.

PR: kern/103602
MFC after: 2 weeks


# 169115 30-Apr-2007 thomas

(atapi_cb): Fix test for the presence of sense data. An incorrect condition
was being tested, which would result in a system hang in some configurations.

PR: kern/112119
Reviewed by: scottl
MFC after: 3 days


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


# 167513 13-Mar-2007 kevlo

Make it compile


# 167508 13-Mar-2007 thomas

(atapi_action): Improve error reporting by removing ATA_R_QUIET flag
from ATAPI requests. If CAM debugging is enabled, also mark ATAPI
requests with ATA_R_DEBUG flag.

(atapi_cb): Report ATAPI timeouts to the CAM layer.
Fix incorrect debugging traces in the presence of ATAPI errors.

PR: kern/103602
MFC after: 2 weeks


# 167507 13-Mar-2007 thomas

(reinit_bus): When the ATAPI bus is reset, do not schedule an automated
CAM rescan if the ATAPI device entries have not changed.

The ATAPI bus may be reset for a variety of reasons, including any time an
ATAPI request times out. It is not necessary to rescan at the CAM level
in such a case, unless a device has appeared or disappeared, or has
otherwise changed.

PR: kern/103602
MFC after: 2 weeks


# 167061 27-Feb-2007 thomas

(cam_rescan): Do not reference ccb->ccb_h.path in CAM_DEBUG call before
it is initialized; use path instead.

This change fixes a panic when using atapicam in conjunction with CAMDEBUG,
which has been described under kern/103602.

Thanks to Josh Carroll <josh.carroll@gmail.com> for providing the traces
that allowed identifying this problem.

PR: kern/103602
MFC after: 1 week


# 163896 01-Nov-2006 mjacob

2nd and final commit that moves us to CAM_NEW_TRAN_CODE
as the default.

Reviewed by multitudes.


# 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


# 157329 31-Mar-2006 sos

Make the ATAPI sense data accessible when using the ioctl interface

MFC candidate.


# 151897 31-Oct-2005 rwatson

Normalize a significant number of kernel malloc type names:

- Prefer '_' to ' ', as it results in more easily parsed results in
memory monitoring tools such as vmstat.

- Remove punctuation that is incompatible with using memory type names
as file names, such as '/' characters.

- Disambiguate some collisions by adding subsystem prefixes to some
memory types.

- Generally prefer lower case to upper case.

- If the same type is defined in multiple architecture directories,
attempt to use the same name in additional cases.

Not all instances were caught in this change, so more work is required to
finish this conversion. Similar changes are required for UMA zone names.


# 146266 16-May-2005 sos

Change the way ioctls are issue to ATA.
The most prominent part is that its now possible to issue ata_requests
directly to say acd0, instead of going through the cumbersome /dev/ata
device.


# 145713 30-Apr-2005 sos

Take newbusification one step further, ie use the device_t more consequently
all way through the code down the layers, instead of the mix'n'match that
resulted from the conversion done earlier.

Sponsored by: pair.com


# 145102 15-Apr-2005 sos

Move the creation of ata_channel child devices to the channel code.
This allows to attach to the children (ATA devices) even without a
driver being attached. This allows atapi-cam to do its work both
with and without the pure ATAPI driver being present.

ATA patches by /me
ATAPI-cam pathes by Thomas


# 144822 08-Apr-2005 scottl

Explicity make atapi-cam depend on CAM.

Submitted by: Michal Mertl


# 144669 05-Apr-2005 scottl

Fix a use-after-free problem in atapi_cb(). Add some necessary synchronization
to the XPT_PATH_INQ op. Don't leak locks on failure in XPT_SCSIIO. Correctly
fix the CAMDEBUG message.


# 144662 05-Apr-2005 phk

Push some faulty debugging aside so LINT compiles.


# 144644 05-Apr-2005 scottl

Commit ATAPI-CAM for ATAmkIII. Improvements and changes:

- newbus plumbing. Each atapicam bus is a child off of a parent ata channel
bus. This is somewhat of a hack, but allows the ata core to be completely
free of atapicam knowledge.
- No more global lists of softc's and no more groping around in internal ata
structures on each command.
- Giant-free operation of the completion handler.
- Per-bus mutex for protecting the busy list and synchronizing detach.
- Lots of streamlining and dead code elimination, better adherence to the
CAM locking protocol.

This feature still requires that the appropriate atapi-* driver be present
for each atapi device that you want to talk to (i.e. atapi-cd for cdroms).
It does work both compiled into the kernel and as a loadable module.

Reviewed by: thomas, sos


# 130627 17-Jun-2004 green

atapicam(4) is currently off by three orders of magnitude regarding the
timeout values in the CAM CCBs. Divide by 1000 to get values in seconds
which are what ata(4) timeouts internally use.

This does lose granularity, though, and small values can now round down
to zero. It's probably worth making all ata(4) timeouts in terms of
hz/ticks/milliseconds/something.


# 126604 04-Mar-2004 thomas

Use auto-sense data provided by the lowlevel ATA code.


# 125701 11-Feb-2004 thomas

(atapi_cb): Reenable automatic retrieve of sense data on error, making
it asynchronous to avoid incorrect use of ata_atapicmd within an
ATAPI callback.

Tested by: harti


# 124679 18-Jan-2004 ru

Fixed a memory leak.


# 124534 14-Jan-2004 sos

Use UMA instead of plain malloc for getting ATA request storage.
This gives +10% performance on simple tests, so definitly worth it.
A few percent more could be had by not using M_ZERO'd alloc's, but
we then need to clear fields all over the place to be safe, and
that was deemed not worth the trouble (and it makes life dangerous).


# 124416 12-Jan-2004 sos

#include sema.h is now required.


# 123153 04-Dec-2003 scottl

Fix a potential problem with atapi-cam where an incorrect flag is passed
into the ata queueing layer.

Approved by: re


# 122484 11-Nov-2003 sos

Centralise mode setting. Instead of doing it in all subdrivers, do
it in ata-all.c where it belongs.

Prime controller HW by always setting PIO mode first in attach.


# 122366 09-Nov-2003 scottl

Free the ata_request struct after we are done using it. This should stop
the memory leak seen when using ATAPICAM.


# 120410 24-Sep-2003 thomas

Enable DMA for ATAPI/CAM input/output operations.

Reviewed by: scottl


# 120316 21-Sep-2003 thomas

(atapi_cb): Reorganize error handling circuitry.
Fix to the messages output under CAM_DEBUG_CCB: the summary sense
information (error bits and sense key) is in the error field, not
in the result field, of struct ata_request. No other functional change.


# 120315 21-Sep-2003 thomas

(atapi_cb): Disable autosense for now as it causes a missed ATA interrupt.
Minor reformatting.


# 120234 19-Sep-2003 thomas

(atapi_action): avoid memory leak in a marginal invalid ccb case.
(free_hcb): defend against calling TAILQ_REMOVE on an hcb that was
not inserted on pending_hcbs.


# 119993 11-Sep-2003 thomas

(atapi_action, case XPT_PATH_INQ): Handle properly the case of
CAM_TARGET_WILDCARD (target_id_t is an unsigned integer type).
Fixes boot-time crash on Alpha.

Reviewed by: roberto
Approved by: re (murray)
MFC after: 1 week


# 119518 28-Aug-2003 thomas

Add missing braces. Fixes boot-time kernel panic with ATAng and ATAPI/CAM.

Reviewed by: roberto


# 119418 24-Aug-2003 obrien

Use __FBSDID().
Also some minor style cleanups.


# 119404 24-Aug-2003 sos

This is a major rework of the ATA driver (ATAng)

Restructure the way ATA/ATAPI commands are processed, use a common
ata_request structure for both. This centralises the way requests
are handled so locking is much easier to handle.

The driver is now layered much more cleanly to seperate the lowlevel
HW access so it can be tailored to specific controllers without touching
the upper layers. This is needed to support some of the newer
semi-intelligent ATA controllers showing up.

The top level drivers (disk, ATAPI devices) are more or less still
the same with just corrections to use the new interface.

Pull ATA out from under Gaint now that locking can be done in a sane way.

Add support for a the National Geode SC1100. Thanks to Soekris engineering
for sponsoring a Soekris 4801 to make this support.

Fixed alot of small bugs in the chipset code for various chips now
we are around in that corner anyways.


# 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


# 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


# 114994 14-May-2003 thomas

In atapi_cam_reinit_bus, only call reinit_bus if the ATAPI channel
has already been registered with ATAPI/CAM (else there is nothing
to do). atapi_cam_reinit_bus may be called before the bus is
registered if an ATAPI command times out during the boot sequence.

PR: i386/51421
Reviewed by: roberto
Approved by: re (rwatson)
MFC after: 1 week


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


# 111643 27-Feb-2003 njl

Zero cpi->target_sprt since atapi-cam does not support target mode. This
gets rid of annoying messages when targbh tries to attach to the ATA bus
and gets rejected.

MFC after: 1 day


# 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


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


# 105742 22-Oct-2002 thomas

Fill in missing parts of the ATAPI/CAM XPT: implement XPT_RESET_BUS
and XPT_RESET_DEV.

In order to properly handle reset requests whether they originate in the
ATA layer (atacontrol reinit) or from the CAM layer (camcontrol reset)
ata_reinit does not cause the SIM to be deallocated anymore. The SIM
is now unconditionnally created for each ATAPI bus.

This change may cause existing bus ids to change on some setups.

Reviewed by: roberto
Approved by: sos


# 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


# 103253 12-Sep-2002 thomas

Change a couple of splcam() calls that do not make sense in atapi-cam
(what we want to mask is the ATA interrupts, which run at level splbio),
and add interrupt masking around the statement that modifies the
request queue for a SIM.

This resolves problems reported by users under heavy ATAPI load.

Reviewed by: roberto


# 102509 28-Aug-2002 njl

printf -> CAM_DEBUG so debugging prints are tunable.

MFC after: 1 week


# 102508 28-Aug-2002 njl

Use csio pointer instead of dereferencing hcb.

MFC after: 1 week


# 102125 19-Aug-2002 sos

Fix typo.


# 101754 12-Aug-2002 sos

Shut up warning in debug code.


# 101648 10-Aug-2002 scottl

Fix the GET_TRAN_SETTINGS and SET_TRAN_SETTINGS ops to be more correct.


# 101637 10-Aug-2002 sos

Minor corrections.

Suggested by: scottl <Scott Long>


# 101606 09-Aug-2002 sos

Add the ability to use ATAPI devices via CAM.

The CAM<>ATAPI layer was submitted by "Thomas Quinot <thomas@cuivre.fr.eu.org>"
changes form the version on the net by me (formatting, ability to be used
alone without the ATAPI native device driver, proper speed reporting...)

See /sys/conf/NOTES for usage.

Submitted by: Thomas Quinot <thomas@cuivre.fr.eu.org>