History log of /freebsd-9.3-release/sys/dev/amr/
Revision Date Author Comments
267654 20-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


254306 13-Aug-2013 scottl

Merge r254263:

Update PCI drivers to no longer look at the MEMIO-enabled bit in the PCI
command register. The lazy BAR allocation code in FreeBSD sometimes
disables this bit when it detects a range conflict, and will re-enable
it on demand when a driver allocates the BAR. Thus, the bit is no longer
a reliable indication of capability, and should not be checked. This
results in the elimination of a lot of code from drivers, and also gives
the opportunity to simplify a lot of drivers to use a helper API to set
the busmaster enable bit.

This changes fixes some recent reports of disk controllers and their
associated drives/enclosures disappearing during boot.

Candidate for 9.2

Submitted by: jhb
Reviewed by: jfv, marius, adrian, achim


251874 18-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


249132 05-Apr-2013 mav

MFC r227293 (by ed):
Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

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


247420 27-Feb-2013 jhb

MFC 240692,241228:
Adjust the ioctl workaround from r234501:
- Ensure the native ioctl path always allocates a 4kb buffer if a request
uses a buffer size of 0.
- 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.


236318 30-May-2012 jhb

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


235743 21-May-2012 jhb

Toss bogus mergeinfo.


235738 21-May-2012 sbruno

MFC r235634

Fix and update battery status bits according to linux driver


233024 16-Mar-2012 scottl

MFC 232854,232874,232882,232883,232886 for bus_get_dma_tag()


229093 31-Dec-2011 hselasky

MFC r226173, r227843, r227848 and r227908:
Use DEVMETHOD_END to mark end of device methods.
Remove superfluous device methods.
Add some missing __FBSBID() macros.


225736 23-Sep-2011 kensmith

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

Approved by: re (implicit)


224778 11-Aug-2011 rwatson

Second-to-last commit implementing Capsicum capabilities in the FreeBSD
kernel for FreeBSD 9.0:

Add a new capability mask argument to fget(9) and friends, allowing system
call code to declare what capabilities are required when an integer file
descriptor is converted into an in-kernel struct file *. With options
CAPABILITIES compiled into the kernel, this enforces capability
protection; without, this change is effectively a no-op.

Some cases require special handling, such as mmap(2), which must preserve
information about the maximum rights at the time of mapping in the memory
map so that they can later be enforced in mprotect(2) -- this is done by
narrowing the rights in the existing max_protection field used for similar
purposes with file permissions.

In namei(9), we assert that the code is not reached from within capability
mode, as we're not yet ready to enforce namespace capabilities there.
This will follow in a later commit.

Update two capability names: CAP_EVENT and CAP_KEVENT become
CAP_POST_KEVENT and CAP_POLL_KEVENT to more accurately indicate what they
represent.

Approved by: re (bz)
Submitted by: jonathan
Sponsored by: Google Inc


210570 28-Jul-2010 mdf

Fix clang warning on empty statement.

Reviewed by: rdivacky, zml
Approved by: zml (mentor)


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


176041 06-Feb-2008 scottl

Remove an errant definition for AMR_CONFIG_ENQ3_SOLICITED NOTIFY that was
accidently reverted in the previous commit.


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.


174193 02-Dec-2007 scottl

Refactor completion handlers so that they can be combined into a single
function. Add missing locking.


174186 02-Dec-2007 scottl

Make a pass at style.9 compliance


174185 02-Dec-2007 scottl

Fix a typo that was hidden by AMR_DEBUG.


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.


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.


166901 23-Feb-2007 piso

o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@


165102 11-Dec-2006 mjacob

Add MODULE_DEPENDS for cam, pci, mca, eisa and isa where needed.

PR: 106543
MFC after: 3 days


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


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.


157755 14-Apr-2006 ambrisko

Reduce the Linux ioctl range to what is needed. I didn't know what
I was doing when I first set the range up.


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


155953 23-Feb-2006 jhb

Check the return value of copyin() and return an error if it fails.

Coverity ID: 839
Found by: Coverity Prevent
MFC after: 1 week
Reviewed by: ps, scottl


155317 04-Feb-2006 imp

Use void * for pointer rather than u_int8_t *, since it doesn't
matter. Well it does for type punning warnings.


155223 02-Feb-2006 ps

Enable 64bit SGL's on PERC 4/DC


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


154789 24-Jan-2006 ambrisko

Add in the Linux IOCTL shim and create the megadev0 device so
Linux LSI MegaRaid tools can run on FreeBSD until Linux emulation.

Add in the Linux IOCTL shim and create the megadev0 device so
Linux LSI MegaRaid tools can run on FreeBSD until Linux emulation.

Add glue to build the modules but don't tie it into the build
yet until I test it from the CVS repo. via the mirror on an
amd64 machine.

Tie this into the Linux32 emulation on amd64 so the tools can
run on amd64 kernel.

Cleaned up by: ps (amr_linux.c)


154370 14-Jan-2006 scottl

Check the return value of copyin.

Found by: Coverity Prevent (tm)


154321 13-Jan-2006 jkim

- Correct amr_enquiry3 structure[1].
- Remove redundant AMR_CONFIG_ENQ3_SOLICITED_NOTIFY from the previous
commit while I am here.

PR: kern/29727 [1]


154156 10-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.


148841 07-Aug-2005 scottl

Remove a stale __FreeBSD_version check.


148840 07-Aug-2005 scottl

The presence of a on __FreeBSD_version flagged some code that hasn't been in
the right spot since the FreeBSD 3.x days, if not earlier.


148499 29-Jul-2005 ps

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


148498 29-Jul-2005 ps

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


147536 23-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


143164 05-Mar-2005 imp

Use BUS_PROBE_DEFAULT for pci probe return value


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


141576 09-Feb-2005 scottl

Remove some unused variables.


141567 09-Feb-2005 scottl

Remove the messy locking dance around xpt_done()


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.


139952 10-Jan-2005 dwhite

Free the shared devq last since CAM expects it to be there if
xpt_alloc_device() gets called, which can happen during detach in
certain situations. Fixes module unload.

MFC after: 3 days


139749 06-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)


133706 14-Aug-2004 ambrisko

Add new PCI device ID for PERC4/DI.


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.


129879 30-May-2004 phk

Add missing <sys/module.h> includes


127135 17-Mar-2004 njl

Convert callers to the new bus_alloc_resource_any(9) API.

Submitted by: Mark Santcroos <marks@ripe.net>
Reviewed by: imp, dfr, bde


126116 22-Feb-2004 cperciva

Check that amrd_sc is non-NULL before dereferencing it, not after.

Reported by: "Ted Unangst" <tedu@coverity.com>
Approved by: rwatson (mentor)


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.


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.


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>


119690 02-Sep-2003 jhb

Use PCIR_BAR(x) instead of PCIR_MAPS.

Glanced over by: imp, gibbs
Tested by: i386 LINT


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.


117126 01-Jul-2003 scottl

Mega busdma API commit.

Add two new arguments to bus_dma_tag_create(): lockfunc and lockfuncarg.
Lockfunc allows a driver to provide a function for managing its locking
semantics while using busdma. At the moment, this is used for the
asynchronous busdma_swi and callback mechanism. Two lockfunc implementations
are provided: busdma_lock_mutex() performs standard mutex operations on the
mutex that is specified from lockfuncarg. dftl_lock() is a panic
implementation and is defaulted to when NULL, NULL are passed to
bus_dma_tag_create(). The only time that NULL, NULL should ever be used is
when the driver ensures that bus_dmamap_load() will not be deferred.
Drivers that do not provide their own locking can pass
busdma_lock_mutex,&Giant args in order to preserve the former behaviour.

sparc64 and powerpc do not provide real busdma_swi functions, so this is
largely a noop on those platforms. The busdma_swi on is64 is not properly
locked yet, so warnings will be emitted on this platform when busdma
callback deferrals happen.

If anyone gets panics or warnings from dflt_lock() being called, please
let me know right away.

Reviewed by: tmm, gibbs


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


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


111252 22-Feb-2003 phk

Use nullclose(), not noclose().


111250 22-Feb-2003 phk

Use the standard DISKFLAG_OPEN instead of implementing our own.
Use noclose() instead now that our close method is empty.


111249 22-Feb-2003 phk

Use system noioctl() instead of homerolled.


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.


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


107141 21-Nov-2002 emoore

Added support for DELL Perc4/DI.

Reviewed by: ps
Approved by: jhb
MFC after: 5 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


103870 23-Sep-2002 alfred

use __packed.


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.


103675 20-Sep-2002 phk

Make FreeBSD "struct disklabel" agnostic, step 311 of 723:

Rename diskerr() to disk_err() for naming consistency.

Drop the by now entirely useless struct disklabel argument.

Add a flag argument for new-line termination.

Fix a couple of printf-format-casts to %j instead of %l.

Correctly print the name of all bio commands.

Move the function from subr_disklabel.c to subr_disk.c,
and from <sys/disklabel.h> to <sys/disk.h>.

Use the new disk_err() throughout, #include <sys/disk.h> as needed.

Bump __FreeBSD_version for the sake of the aac disk drivers #ifdefs.

Remove unused disklabel members of softc for aac, amr and mlx, which seem
to originally have been intended for diskerr() use, but which only rotted
and got Copy&Pasted at least two times to many.

Sponsored by: DARPA & NAI Labs.


102633 30-Aug-2002 gibbs

Add IDs for upcoming LSI U320 products that use the MegaRAID interface.

Adjust format of one comment so it doesn't wrap at 80 columns.
Submitted by: "Moore, Eric Dean" <emoore@lsil.com>


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.


87796 13-Dec-2001 jhb

Comment tokens after #undef <macroname> and #endif.

Reported by: gcc30


87599 10-Dec-2001 obrien

Update to C99, s/__FUNCTION__/__func__/,
also don't use ANSI string concatenation.


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


78231 15-Jun-2001 peter

Fix warning: 179: warning: label `done' defined but not used


76324 06-May-2001 phk

Make the disk mini-layer check for and handle zero-length transfers
instead of the underlying drivers.


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.


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.


73280 01-Mar-2001 markm

Turn on interrupt-entropy harvesting for all/any mass storage devices
I could find. I have no doubt missed a couple.

Interrupt entropy harvesting is still conditional on the
kern.random.sys.harvest_interrupt sysctl.


70285 22-Dec-2000 msmith

Probe generic i960 devices for the old AMI signature as well as the current
one, in order to support adapters with older firmware.

Submitted by: "Prasanth S." <prasanths@ami.co.in>


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


67782 28-Oct-2000 msmith

Return -10 from the PCI probe to allow room for an updated driver to
override one built into the kernel.


67739 27-Oct-2000 msmith

Fix typo in the 4.x case.


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.


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


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.


59391 19-Apr-2000 phk

Remove ~25 unneeded #include <sys/conf.h>
Remove ~60 unneeded #include <sys/malloc.h>


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 01-Apr-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.


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


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>


52274 16-Oct-1999 msmith

Save the drive device_t so that we can print it later.


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.