History log of /freebsd-11-stable/sys/dev/amr/amr.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

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


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 298955 03-May-2016 pfg

sys/dev: minor spelling fixes.

Most affect comments, very few have user-visible effects.


# 298646 26-Apr-2016 pfg

sys/dev: extend use of the howmany() macro when available.

We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.


# 296592 09-Mar-2016 imp

Don't assume that bio_cmd is a bitfield.

Differential revision: https://reviews.freebsd.org/D5590


# 269711 08-Aug-2014 imp

Set but not used variables eliminated.


# 241228 05-Oct-2012 jhb

Further adjust the workaround in r234501. Rounding all small requests up
to 32k swamped the controller causing firmware hangs. Instead, round
requests smaller than 64k up to the next power of 2 as a general rule.
To handle the one known special case of a command that accepts a 12k
buffer returning a 24k-ish reply, round requests between 8k and 16k up
to 32k rather than 16k. The result is that commands less than 8k should
now be rounded up to a smaller size (either 4k or 8k) rather than 32k.

PR: kern/155658
Tested by: Andreas Longwitz
MFC after: 1 week


# 240692 19-Sep-2012 jhb

As a followup to r234501, ensure that the native ioctl path always allocates
a 4kb buffer if a request uses a buffer size of 0. (The Linux ioctl path
already did this.)

PR: kern/155658
Submitted by: Andreas Longwitz
MFC after: 1 week


# 239939 31-Aug-2012 scottl

Essentially revert r239912. The amr_periodic function hadn't been armed in
over 10 years and was dead code; the previous revision exposed it as such to
CLANG. The solution is to cull the whole thing.


# 239912 30-Aug-2012 jhb

Use callout(9) rather than timeout(9). Note that the periodic timer in
amr(4) is never started, so this should be even more of a NOP than
normal.


# 234501 20-Apr-2012 jhb

The amr(4) firmware contains a rather dubious "feature" where it
assumes for small buffers (< 64k) that the OS driver is actually using
a buffer rounded up to the next power of 2. It also assumes that the
buffer is at least 4k in size. Furthermore, there is at least one
known instance of megarc sending a request with a 12k buffer where the
firmware writes out a 24k-ish reply.

To workaround the data corruption triggered by this "feature", ensure
that buffers for user commands use a minimum size of 32k, and that
buffers between 32k and 64k use a 64k buffer.

PR: kern/155658
Submitted by: Andreas Longwitz longwitz incore de
Reviewed by: scottl
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.


# 201758 07-Jan-2010 mbr

Remove extraneous semicolons, no functional changes.

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


# 198546 28-Oct-2009 brueffer

Remove spurious `)`

PR: 137758
Submitted by: Henning Petersen <henning.petersen@t-online.de>
MFC after: 1 week


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


# 196403 20-Aug-2009 jhb

Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.

Approved by: re (kib), attilio


# 196037 02-Aug-2009 attilio

Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.

Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.

For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.

Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.

Bump __FreeBSD_version in order to reflect the newbus lock introduction.

Reviewed by: ed, hps, jhb, imp, mav, scottl
No answer by: ariff, thompsa, yongari
Tested by: pho,
G. Trematerra <giovanni dot trematerra at gmail dot com>,
Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by: Yahoo! Incorporated
Approved by: re (ksmith)


# 192450 20-May-2009 imp

We no longer need to use d_thread_t, migrate to struct thread *.


# 184573 02-Nov-2008 scottl

Move the CAM passthrough code into a true module so that it doesn't have to be
compiled into the main AMR driver. It's code that is nice to have but not
required for normal operation, and it is reported to cause problems for some
people.


# 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


# 180633 20-Jul-2008 scottl

While spin-waiting for the mailbox semaphore to update, do flushing reads of
PCI bus so that we don't have to wait more than needed.


# 175622 24-Jan-2008 scottl

Many improvements that have been collected over time:

- Improve error handling for load operations.
- Fix a memory corruption bug when using certain linux management apps.
- Allocate all commands up front to avoid OOM deadlocks later on.


# 174544 12-Dec-2007 scottl

Rewrite the DMA code paths from being an impenitrable maze of special cases
to a much saner and simplier unified code path. Along the way, fix various
CAM nits and bugs so that the passthrough works correctly for all cases.


# 174194 02-Dec-2007 scottl

Provide unqiue malloc types instead of using M_DEVBUF.


# 174184 02-Dec-2007 scottl

Fix printf format bugs that where hidden by AMR_DEBUG.


# 174030 28-Nov-2007 scottl

Turn the CAM passthroug interface to AMR back ON. Adjust the
T_DIRECT filtering so that disk drives can be attached via the
pass driver. Add CAM locking. Don't mark CAM commands as SG64
since the hardware isn't designed to deal with 64-bit passthru
commands. Hopefully the bounce buffer changes that were done
for the management/ioctl interface are robust enough to handle
this deficiency for CAM as well.


# 163834 31-Oct-2006 pjd

Implement BIO_FLUSH handling for da(4), amr(4), ata(4) and ataraid(4).

Sponsored by: home.pl


# 160443 17-Jul-2006 jhb

Chain the bus_dmamap_load() calls when mapping a command with a data CCB
instead of doing the first load with the BUS_DMA_NOWAIT flag. On 4.x with
PAE and > 4gb of RAM this proved disastrous if there weren't enough bounce
pages as amr_mapcmd() would return failure but the callback would later
fire once enough bounce pages were available and would then overwrite
another command's S/G list.

MFC after: 3 days
Submitted by: scottl (4.x version)
Reviewed by: scottl (port from 4.x to HEAD)


# 158267 03-May-2006 ambrisko

Make amr_linux work as a module by avoiding calling amr_linux_ioctl_int
from the amr_linux. This simplifies the amr_linux shim and puts the
smarts into amr.c.

I tested this with 2 amr controllers in one box. It seems to work
okay with them.


# 157586 08-Apr-2006 scottl

After further review and discussion, partially revert the previous commit.
The real problem was that ioctl handlers needed to call amr_wait_command()
with the list lock held. This not only solves the completion race, it also
prevents bounce buffer corruption that could arise from amr_start() being
called without the proper locks held.

Discussed with: ps
MFC After: 3 days


# 157585 08-Apr-2006 ps

Close a pesky race where after checking the BUSY flag in amr_wait_command,
the completion of the command can occur before tsleep is called and
the command ends up blocking forever since the wakeup has already
been called.

Submitted by: ups


# 155222 02-Feb-2006 ps

- Move the command setup from amr_start1 into the card specific submit
routines.
- Add or replace cpu_spinwait() with DELAY(1) to a few of the busy
loops when reading from the controller to work around firmware bugs
which can crash the controller.


# 154876 26-Jan-2006 ambrisko

When the RAID firmware returns a failure, don't hard error the result.
This is important with MegaLib, when issuing a GET_REBUILD_PROG since
it returns an error if the drive is not in rebuild state.

This will be MFC'ed shortly.

Submitted by: ps
Reviewed by: scottl
Found by: ambrisko


# 154370 14-Jan-2006 scottl

Check the return value of copyin.

Found by: Coverity Prevent (tm)


# 154156 09-Jan-2006 scottl

Don't free the ap object if it was never created.

Submitted by: jkim


# 153409 14-Dec-2005 scottl

Mega update to the LSI MegaRAID driver:

1. Implement a large set of ioctl shims so that the Linux management apps
from LSI will work. This includes infrastructure to support adding, deleting
and rescanning arrays at runtime. This is based on work from Doug Ambrosko,
heavily augmented by LSI and Yahoo.

2. Implement full 64-bit DMA support. Systems with more than 4GB of RAM
can now operate without the cost of bounce buffers. Cards that cannot do
64-bit DMA will automatically revert to using bounce buffers. This option
can be forced off by setting the 'hw.amr.force_sg32" tunable in the loader.
It should only be turned off for debugging purposes. This work was sponsored
by Yahoo.

3. Streamline the command delivery and interrupt handler paths after
much discussion with Dell and LSI. The logic now closely matches the
intended design, making it both more robust and much faster. Certain
i/o failures under heavy load should be fixed with this.

4. Optimize the locking. In the interrupt handler, the card can be checked
for completed commands without any locks held, due to the handler being
implicitely serialized and there being no need to look at any shared data.
Only grab the lock to return the command structure to the free pool. A
small optimization can still be made to collect all of the completions
together and then free them together under a single lock.

Items 3 and 4 significantly increase the performance of the driver. On an
LSI 320-2X card, transactions per second went from 13,000 to 31,000 in my
testing with these changes. However, these changes are still fairly
experimental and shouldn't be merged to 6.x until there is more testing.

Thanks to Doug Ambrosko, LSI, Dell, and Yahoo for contributing towards
this.


# 152817 26-Nov-2005 scottl

The CAM interface is broken and seems to be causing lockups on boot. It
doesn't appear to have worked in a long time, so just disable it completely
for now.

MFC After: 3 days


# 152119 06-Nov-2005 scottl

Remove spl markers from AMR.

MFC After: 3 days


# 148850 08-Aug-2005 scottl

Complete the removal of __FreeBSD_version checks from the amr driver. The
driver had advanced enough over the years that direct sharing of code with
FreeBSD 4.x was in no way possible anymore.


# 148499 28-Jul-2005 ps

Print the actual disk device we failed to complete i/o on.


# 148498 28-Jul-2005 ps

Don't allow ioctl commands to be interrupted by the user.


# 147536 22-Jun-2005 ps

polled commands can read or write, so bus_dmamap_sync properly
according to the type of request.

Approved by: re


# 146734 29-May-2005 nyan

Remove bus_{mem,p}io.h and related code for a micro-optimization on i386
and amd64. The optimization is a trivial on recent machines.

Reviewed by: -arch (imp, marcel, dfr)


# 144369 31-Mar-2005 sam

handle potential null ptr

Noticed by: Coverity Prevent analysis tool


# 143488 13-Mar-2005 scottl

Fix a null pointer de-ref when passthrough ioctls are issued. This
involves some code shuffle to avoid locking problems.

MFC After: 3 days


# 143121 04-Mar-2005 scottl

Fix the ioctl path by ensuring that amr_start1() gets called for commands
with no associated data. Also revert previous changes that allocate off
of the stack instead of using malloc, as it's not needed. Many thanks to
LSI for investigating and fixing these problems.

Submitted by: rajeshpr @ lsil . com


# 140688 23-Jan-2005 scottl

Add support for the LSI 320-2E PCI-Express controller. Fix a couple of bugs
in the ioctl handler. Update the LSI copyrights for these.

Obtained from: LSI, Corp


# 140687 23-Jan-2005 scottl

Add my copyright for the locking and busdma work.


# 140340 16-Jan-2005 scottl

Lock the AMR driver:
- Introduce the amr_io_lock to control access to command queues, bio queues,
and the hardware.
- Eliminate the taskqueue and do all completion processing in the ithread.
- Assign a static slot number to each command instead of doing a linear
search for free slots each time a command is needed.
- Modify the interrupt handler to more closely match what Linux does, for
safety.


# 139749 05-Jan-2005 imp

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


# 138422 05-Dec-2004 scottl

Fix a number of bugs and significantly alter the command execution path to
properly support bounce buffers and resource shortages. This allows the
driver to work properly and reliably with more than 4GB of RAM. Of the
three data paths that exist in the driver, (block, CAM, ioctl), the ioctl
path has not been well tested with these changes due to difficulty with
finding an application that uses it that actually works.

Sponsored by: The FreeBSD Foundation and FreeBSD Systems, Inc.


# 135236 14-Sep-2004 scottl

Set up the data flow flag correctly so that bounced buffers have a chance of
working in amr_enquire().


# 133870 16-Aug-2004 ambrisko

Allow i386 binaries to do amr ioctls such as LSI's megamgr on amd64 and
ia64.

PR: 63155
Submitted by: Mikhail Teterin
Tested on: i386, amd64 (via 64bit Xeon system)


# 131394 01-Jul-2004 ps

Use a separate flag when doing a kernel coredump when polling for
completion instead of abusing the interrupt enable flag.


# 130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


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


# 125594 08-Feb-2004 scottl

Allow amr(4) to get a dynamic major number instead of a static one.

Submitted by: Andre Guibert de Bruet


# 120988 10-Oct-2003 ps

crashdump support.

Some bits by: Rajesh Prabhakaran <rajeshpr@lsil.com>


# 119418 24-Aug-2003 obrien

Use __FBSDID().
Also some minor style cleanups.


# 119277 22-Aug-2003 imp

Prefer new location of pci include files (which have only been in the
tree for two or more years now), except in a few places where there's
code to be compatible with older versions of FreeBSD.


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


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


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


# 111528 26-Feb-2003 scottl

Introduce a new taskqueue that runs completely free of Giant, and in
turns runs its tasks free of Giant too. It is intended that as drivers
become locked down, they will move out of the old, Giant-bound taskqueue
and into this new one. The old taskqueue has been renamed to
taskqueue_swi_giant, and the new one keeps the name taskqueue_swi.


# 111441 24-Feb-2003 phk

NO_GEOM cleanup:

Move to new "struct disk *" centered API".

OK'ed by: emoore


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


# 109031 09-Jan-2003 emoore

Fix for DELL PERC firmware. Driver was hanging
during load time; this attributed to the mailbox
busy byte not being set prior to issuing a
polling command.

Approved by: ps
MFC: 7 days


# 108470 30-Dec-2002 schweikh

Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.


# 107827 13-Dec-2002 emoore

Problem: Hang while bootup on Perc2/SC.
Fix: Error handling wasn't implemented
in newly implemented polling code for quartz
controllers.

Approved by: re@


# 107756 11-Dec-2002 emoore

(1) Problem: PANIC when loading/unloading driver
as module. This also fix's issue kern/45713.
Fix - polling was implemented incorrectly for
adapter enquiry and adapter flush.
(2) Problem: PANIC when unloading driver
as module.
Fix - device nodes are not destroyed for amr0,
and amrd* when driver is unloaded
(3) Problem: PANIC from loading driver when
3ware adapter present, error message "Warning
"amrd is usurping twed's bmaj"
Fix - put #idef freebsd version < 500000 for
bmaj -1 -> amrd_cdevsw
(4) Problem: warnings in driver when compiling
with DAMR_DEBUG param enabled in Makefile
Fix - fix the warnings so driver can compile
when -Werror is present in Makefile.

Approved by: jhb
MFC: 7 days


# 106252 31-Oct-2002 emoore

Incorrect typecast.


# 106225 30-Oct-2002 emoore

amr.c,
amr_cam.c,
amrreg.h,
amrvar.h:
- added support for 12/16 byte cdb's, effecting CAM branch only ( non-disk support )

amrreg.h:
- increased number of scatter gather elements from 16 to 26.

amr_pci.c:
- amr_pci_free(), incorrect bus tag meant for 'amr_mailbox_dmat' was being freed

all:
- copyright change requested by scottl

Reviewed by: ps,scottl
MFC after: 1 week


# 105419 18-Oct-2002 emoore

(1) added LSI Logic copyright, and legal line 3 in license, and string
changes for "LSILogic"
(2) enabled non-disk support through CAM interface
(3) HA_INQ (a) enabled tagged queuing (b) disable reset during
driver loading (b) renamed BSDi string to LSI
(4) disabled detecting disk devices during SCSI INQUIRY
(5) changed dcdb single element sglist to send one entire buffer chunk
(6) nsgelem not set in sglist
(7) ap_data_transfer_length not set for dcdb
(8) changed "struct thread" to "d_thread_t" for compatibliity { xxx_open,
xxx_close, xxx_ioctl }
(9) miscellaneous compatiblity fixes
(10) bug fix for 0x0409/0x1000 card
(11) added compiling amr_cam.c in sys/conf/files
(12) added compiling amr_cam.c in sys/modules/amr/Makefile

Reviewed by:ps
MFC after:1 week
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


# 92610 18-Mar-2002 bde

Fixed printf format errors in previous commit. %llu is no more suitable
than %u for printing signed 64-bit types. It fails on different machines,
and has the wrong signdness.

Fixed old printf format error on the same line. %u is not suitable for
printing 32-bit types on all machines.


# 92608 18-Mar-2002 imp

Formats that print the block number need to be changed from %u to
%llu due to recent changes in bio_pblkno's type.


# 89055 08-Jan-2002 msmith

Staticise the amr devclass.


# 85560 26-Oct-2001 jhb

- Change the taskqueue locking to protect the necessary parts of a task
while it is on a queue with the queue lock and remove the per-task locks.
- Remove TASK_DESTROY now that it is no longer needed.
- Go back to inlining TASK_INIT now that it is short again.

Inspired by: dfr


# 85521 26-Oct-2001 jhb

Add locking to taskqueues. There is one mutex per task, one mutex per
queue, and a mutex to protect the global list of taskqueues. The only
visible change is that a TASK_DESTROY() macro has been added to mirror
the TASK_INIT() macro to destroy a task before it is free'd.

Submitted by: Andrew Reiter <awr@watson.org>


# 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


# 74936 28-Mar-2001 hm

In case the driver runs on an HP NetRaid controller, attempt to properly
decode the BIOS and firmware version and announce the board as HP NetRaid.

This has been tested with a NetRaid 3si controller, the BIOS/firmware
printout should also work for other NetRaid controllers but the type
detection for other NetRaids (such as the 1si) will not work due to the
lack of hardware.

Reviewed by: msmith


# 74810 26-Mar-2001 phk

Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.


# 69326 28-Nov-2000 msmith

(Last commit accidentally missed a message)

Remove some over-zealous debugging code.


# 69325 28-Nov-2000 msmith

Remove some over-


# 69319 28-Nov-2000 msmith

MFS:
Fix amr_map_command so that 40LD-specific commands get the scatter-gather
list count in the right place. I don't understand why AMI did it like
this, but now the AMI MegaManager can talk to the newer (1600 and later)
controllers.

Remove an unused variable.

Include <machine/clock.h> when necessary.

Tweak some debugging levels to make things more intelligible.


# 68990 21-Nov-2000 msmith

Don't test the return value from the actual command when determining
success/failure for submission of the command. The caller will want
to deal with this itself.


# 68877 18-Nov-2000 dwmalone

Further use of M_ZERO.

Submitted by: josh@zipperup.org
Submitted by: Robert Drehmel <robd@gmx.net>
Approved by: msmith


# 67164 15-Oct-2000 phk

Remove unneeded #include <machine/clock.h>


# 65763 11-Sep-2000 msmith

Whoops. The AMR_QUARTZ_GOFASTER option is meant to disable, not enable
this check. It looks like it doesn't work on at least the 466 controllers.


# 65245 30-Aug-2000 msmith

Major update to the AMI MegaRAID driver.

- New support for 40LD firmware found in Series 475 and 471 adapters.
- Better support for 8LD firmware adapters
- Ioctl passthrough interface for userland utilities.
- Improved error handling and queueing.
- Several bugfixes (including the 'still open' shutdown bug and
closing some small race conditions).
- Zone-style command allocator, reducing memory wasted under heavy
load conditions.
- CAM interface (disabled and not fully working) for SCSI passthrough
access to non-disk devices

Thanks to AMI for supplying a pile of new adapters and various other
help in making this happen.


# 61508 10-Jun-2000 msmith

The AMI MegaRAID's internal memory map conflicts with scatter/gather
map physical addresses below 0x2000 (accoding to AMI). If we
allocate our s/g tables and get an address below this point, leak the
memory and try again.

This should fix booting from these controllers.


# 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


# 59610 24-Apr-2000 msmith

Disable the returning of "wedged" commands; this is wrong and needs to be
rethought.


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


# 58883 31-Mar-2000 msmith

Update to latest working version.

- Add periodic status monitoring routine. Currently just detects
lost commands, further functionality pending data from AMI.
Add some new commands states; WEDGED (never coming back) and
LATE (for when a command that wasmarked as WEDGED comes bacj,

- Remove a number of redundant efforts to poll the card for completed
commands. This is what interrupt handlers are for.

- Limit the maximum number of outstanding I/O transactions. It seems
that some controllers report more than they can really handle,
and exceding this limit can cause the controller to lock up.

- Don't use 'wait' mode for anything where the controller might not
be able to generate interrupts. (Keep the 'wait' mode though sa it
will become useful when we start taking userspace commands.

- Use a similar atomic locking trategy to the Mylex driver to prevent
some reentrancy problems.

- Correctly calculate the block count for non-whoile-bloch transfers
(actually illegal).

- Use the dsik device's si_drv1 field instead of b_driver1 in the
buf struct to pass the driver identifier arond.

- Rewrite amr_start and amr_done() along the lines of the Mylex driver
in order to improve robustnes.

- Always force the PCI busmaster bit on.


# 58496 23-Mar-2000 msmith

Fix detection of the card-ready-for-command state. Use an ultimate
timeout closer to the 1-second value that AMI use in their Linux
driver, and mark the mailbox structures as volatile so that gcc
doesn't over-optimise access to them.

This should fix the "controller wedged" bug.

Submitted by: Brian Dean <brdean@unx.sas.com>


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


# 57297 17-Feb-2000 msmith

Increase the time we spend waiting for the controller to become ready to
accept a new command; in high load cases it may be too busy for the old
value.

This loop needs something to tie it to real time, rather than just the CPU's
ability to fetch from the L1 data cache, but this hack works for now.

Approved by: jkh


# 54512 12-Dec-1999 peter

Fix a printf format problem on the Alpha, where size_t == unsigned long,
not unsigned int as on the x86.


# 54073 03-Dec-1999 mdodd

Remove the 'ivars' arguement to device_add_child() and
device_add_child_ordered(). 'ivars' may now be set using the
device_set_ivars() function.

This makes it easier for us to change how arbitrary data structures are
associated with a device_t. Eventually we won't be modifying device_t
to add additional pointers for ivars, softc data etc.

Despite my best efforts I've probably forgotten something so let me know
if this breaks anything. I've been running with this change for months
and its been quite involved actually isolating all the changes from
the rest of the local changes in my tree.

Reviewed by: peter, dfr


# 52784 02-Nov-1999 msmith

Don't print the chipset value; it's not useful.
Now we know what some of the state values are, print the current array
state.


# 52543 26-Oct-1999 msmith

Change the queueing model used by the controller to drastically reduce
the time spent at splbio(). We now avoid it unless we are actually
manipulating the command queues themselves. This doesn't improve
performance noticeably, but should improve concurrency somewhat.


# 52439 22-Oct-1999 msmith

Use the physical block number, not the logical block number, for I/O
operations. The latter only works where the partion begins at the bottom
of the disk. Whoops.

Submitted by: Chris Csanady <cc@137.org>


# 51974 07-Oct-1999 msmith

This is a driver for the AMI MegaRAID family of controllers. It all of
the AMI PCI controllers using the 8LD firmware interface (40LD firmware
will be supported as soon as I have hardware to test with).

These controllers are rebadged by Dell as the PERC, as well as by HP
and possibly other vendors.