History log of /freebsd-10-stable/sys/dev/aac/aac_cam.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 315813 23-Mar-2017 mav

MFC r311305 (by asomers):
Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)

The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

This change null-terminates those fields everywhere they're set in the
kernel. It also shortens a few strings to ensure they'll fit within the
16-character field.

PR: 215474
Reported by: Coverity
CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID: 1010035 1010036 1010042 1010041 1010040 1010039


# 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

# 251115 29-May-2013 marius

- Remove pointless returns.
- Make cm_data a void pointer and cm_flags unsigned as appropriate.

MFC after: 3 days


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


# 247570 01-Mar-2013 marius

- Make tables, device ID strings etc const. This includes #ifdef'ing 0
aac_command_status_table, which is actually unused since r111532.
While at it, make aac_if a pointer to the now const interface tables
instead of copying them over to the softc (this alone already reduces the
size of aac.ko on amd64 by ~1 KiB).
- Remove redundant softc members.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.
- Remove redundant bzero(9)'ing of the softc.
- Use pci_enable_busmaster(9) instead of duplicating it.
- Remove redundant checking for PCIM_CMD_MEMEN (resource allocation will
just fail).
- Canonicalize the error messages in case of resource allocation failures.
- Add support for using MSI instead of INTx, controllable via the tunable
hw.aac.enable_msi (defaulting to on).

MFC after: 1 month


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


# 240923 25-Sep-2012 rstone

Some aac(4) adapters will always report that a direct access device is
offline in response to a INQUIRY command that does not retreive vital
product data(I personally have observed the behaviour on an Adaptec 2405
and a 5805). Force the peripheral qualifier to "connected" so that upper
layers correctly recognize that a disk is present.

This bug was uncovered by r216236. Prior to that fix, aac(4) was
accidentally clearing the peripheral qualifier for all inquiry commands.

This fixes an issue where passthrough devices were not created for
disks behind aac(4) controllers suffering from the bug. I have
verified that if a disk is not present that we still properly detect
that and not create the passthrough device.

Sponsored by: Sandvine Incorporated
MFC after: 1 week


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


# 226350 13-Oct-2011 marius

Merge from r225950:

Set the sense residual properly.

Reviewed by: ken


# 216236 06-Dec-2010 jhb

When masking direct and processor devices during an inquiry, properly
preserve the upper bits of the first data byte.

Reviewed by: scottl
MFC after: 1 week


# 213272 29-Sep-2010 emaste

Previously, the aac driver did not handle enclosure management AIFs,
which were raised during hot-swap events. Now such events trigger cam
rescans, as is done in the mps driver.

Submitted by: Mark Johnston <mjohnston at sandvine dot com>


# 212773 16-Sep-2010 emaste

Use device_printf where possible, and otherwise at least include the
driver name in printf strings.

Reported by: Mark Johnston


# 206534 12-Apr-2010 emaste

Whitespace cleanup, in advance of next sync with Adaptec's driver. No
functional change.


# 204264 23-Feb-2010 emaste

Minor diff reduction with Adaptec's driver: in aac_release_command() set
cm_queue to AAC_ADAP_NORM_CMD_QUEUE by default. In every place it was set,
it was set to AAC_ADAP_NORM_CMD_QUEUE anyhow.


# 203885 14-Feb-2010 emaste

Diff reduction with Adaptec's vendor driver.

Driver version 2.1.9 chosen as that Adaptec version roughly corresponds
with the current feature set merged to the in-tree driver.


# 200251 08-Dec-2009 jkim

- Try pre-allocating all FIBs upfront. Previously we tried pre-allocating
128 FIBs first and allocated more later if necessary. Remove now unused
definitions from the header file[1].
- Force sequential bus scanning. It seems parallel scanning is in fact
slower and causes more harm than good[1]. Adjust a comment to reflect that.

PR: kern/141269
Submitted by: Alexander Sack (asack at niksun dot com)[1]
Reviewed by: scottl


# 198617 29-Oct-2009 emaste

Rename aac_srb32 to aac_srb, to match Adaptec's vendor driver.


# 198525 27-Oct-2009 emaste

Whitespace fixup: 8 spaces -> tab


# 177567 24-Mar-2008 emaste

Diff reduction to Adaptec's driver (around build 15317): catch up with a
change in debugging routines.

The fwprintf macro in the AAC_DEBUG case (mapping to printf) isn't from the
Adaptec driver.


# 174417 07-Dec-2007 emaste

Merge from Adaptec a 64 bit fix and a workaround for luns != 0 returning
CAM_SEL_TIMEOUT on SAS controllers, which prevented passthrough devices
from being created.


# 173264 01-Nov-2007 emaste

Rework aac locking for MPSAFE CAM. This fixes a Giant mutex assertion
reported on freebsd-current [1].

Also dequeue all events in aac_release_command (instead of just one)
so that there's no risk of them getting stranded.

Reported by: Steven Brown [1]
Submitted by: scottl@

[1] http://lists.freebsd.org/pipermail/freebsd-current/2007-October/077928.html


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


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


# 166025 15-Jan-2007 scottl

Add a missing mutex unlock to an error path.

Submitted by: Yuxiang Luo
PR: 107943


# 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


# 160344 14-Jul-2006 delphij

Unlock aac_io_lock before returning, thus eliminates a mutex
leak.

Submitted by: Beyond Luo <fedora ercist iscas ac cn>
PR: kern/100046
Reviewed by: scottl


# 151086 08-Oct-2005 scottl

Mega Update to the aac driver to support a whole new family of cards and
the modified interface that they use. Changes include:

- Register a different interrupt handler for the new interface. This one is
INTR_MPSAFE, not INTR_FAST, and directly processes completions and AIFs.
- Add an event registration and callback mechanism for the ioctl and CAM
modules can know when a resource shortage clears. This condition was
previously fatal in CAM due to programming oversights.
- Fix locking to play better with newbus.
- Provide access methods for talking to cards with the NEWCOMM interface.
- Fix up the CAM module to be better suited for dealing with newer firmware
on the PERC Si/Di series that requires talking to plain SCSI via aac.
- Add a whole slew of new PCI Id's.

Thanks to Adaptec for providing an initial version of this work and for
answering countless questions about it. There are still some rough edges in
this, but it works well enough to commit and test for now.

Obtained from: Adaptec, Inc.


# 150120 14-Sep-2005 scottl

Bring aac_cam into line with using time_uptime instead of time_second.


# 141567 09-Feb-2005 scottl

Remove the messy locking dance around xpt_done()


# 139749 05-Jan-2005 imp

Start each of the license/copyright comments with /*-, minor shuffle of lines


# 138635 09-Dec-2004 scottl

Complete the repo-copy of aac_ioctl.h from sys/dev/aac/to sys/sys.


# 133540 12-Aug-2004 scottl

Remove the AAC_LOCK macros. They no longer abstract anything and only
obfuscate the code. No functional differences.


# 130006 02-Jun-2004 scottl

Collapse sync fib locking into normal i/o locking. The former didn't
protect the registers so it was trivially possible for a sync command and
i/o command to fight each other and confuse the controller. Make the
sync fib alloc/release functions inline and remove the somewhat worthless
AAC_SYNC_LOCK_FORCE flag. Thanks to Adil Katchi for helping me to track
this down in RELENG_4.


# 129879 30-May-2004 phk

Add missing <sys/module.h> includes


# 123128 03-Dec-2003 scottl

Temporary workaround for aac_cam to deal with CAM requiring Giant. This
should fix the panics on boot with newer Adaptec RAID cards.

Approved by: re (rwatson)


# 119418 24-Aug-2003 obrien

Use __FBSDID().
Also some minor style cleanups.


# 119146 19-Aug-2003 scottl

Make aac(4) compile cleanly on 64-bit machines. The code was already 64-bit
safe, but some (unneeded and/or harmless) downcasts were generating warnings.
The driver still is not endian-clean.


# 112679 26-Mar-2003 scottl

Begin support for 64-bit address support and workarounds for newer cards:
- Add data structuress for doing 64-bit scatter/gather
- Move busdma tag creations around so that only the parent is
created in aac_pci.c.
- Retrieve the capabilities word from the firmware before setting
up command structures and tags. This allows the driver to decide
whether to do 64-bit commands, and if work-arounds are needed for
systems with >2GB of RAM.
- Only enable the SCSI passthrough if it's enabled in the capabilities
word in the firmware.

This should fix problems with the 2120S and 2200S cards in systems with more
than 2GB of RAM. Full 64-bit support is forthcoming.

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.


# 111691 01-Mar-2003 scottl

The aac driver has evolved enough over the last few months that it no
longer resembles the 4.x version very much. Garbage collect the legacy
bits.


# 111532 26-Feb-2003 scottl

Bring aac out from under Giant:
- the mutex aac_io_lock protects the main codepaths which handle queues and
hardware registers. Only one acquire/release is done in the top-half and
the taskqueue. This mutex also applies to the userland command path and
CAM data path.
- Move the taskqueue to the new Giant-free version.
- Register the disk device with DISKFLAG_NOGIANT so the top-half processing
runs without Giant.
- Move the dynamic command allocator to the worker thread to avoid locking
issues with bus_dmamem_alloc().

This gives about 20% improvement in most of my benchmarks.


# 110432 06-Feb-2003 scottl

Teach the CAM module how to deregister itself so it can be unloaded.


# 110426 05-Feb-2003 scottl

Various cleanups:
- Move the command timeout check from a separate repeating timeout to the
kthread since the kthread is already running periodically.
- Move printing the hardware print buffer to the kthread.
- Properly shut down the kernel thread on detach.
- Detach the child array devices on detach.
- Don't issue a controller halt command on detach. Doing so requires a PCI
reset to wake the controller back up. The driver can now be unloaded as
long as CAM support is not enabled.


# 109208 13-Jan-2003 scottl

Since reseting the SCSI busses via the passthrough interface usually
confuses the controller, tell CAM not to do it. Also report the
correct error condition to CAM when it tries to probe a target that
doesn't exists.
This should make the CAM interface less risky to use.

MFC After: 3 days


# 101649 10-Aug-2002 scottl

Fix GET_TRAN_SETTINGS to be more correct.
Don't allow SCSI resets on the 5400S card, it seems to cause problems with
certain backplanes.

Submitted by: lnb@freebsdsystems.com
MFC after: 3 days


# 95966 02-May-2002 scottl

bzero out the sync command buffer when sending commands. This was causing
problems when enumerating multiple arrays.

This is an MFC candidate.


# 95827 30-Apr-2002 scottl

Fix a bug where the aacp device would only talk to bus 0 on the
controller.


# 95536 26-Apr-2002 scottl

Add a CAM interface to the aac driver. This is useful in case you should
ever connect a SCSI Cdrom/Tape/Jukebox/Scanner/Printer/kitty-litter-scooper
to your high-end RAID controller. The interface to the arrays is still
via the block interface; this merely provides a way to circumvent the
RAID functionality and access the SCSI buses directly. Note that for
somewhat obvious reasons, hard drives are not exposed to the da driver
through this interface, though you can still talk to them via the pass
driver. Be the first on your block to low-level format unsuspecting
drives that are part of an array!

To enable this, add the 'aacp' device to your kernel config.

MFC after: 3 days