Commit Graph

87 Commits

Author SHA1 Message Date
Scott Long
64c71632bf 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.
2008-11-03 00:53:54 +00:00
Ed Schouten
6bfa9a2d66 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
2008-09-27 08:51:18 +00:00
Scott Long
92130a8f2e 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.
2008-07-20 16:50:14 +00:00
Scott Long
74018414bf 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.
2008-01-24 07:26:53 +00:00
Scott Long
281017a577 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.
2007-12-12 05:55:03 +00:00
Scott Long
cdc03cc897 Provide unqiue malloc types instead of using M_DEVBUF. 2007-12-02 19:54:45 +00:00
Scott Long
3002614d91 Fix printf format bugs that where hidden by AMR_DEBUG. 2007-12-02 18:45:37 +00:00
Scott Long
0a5c91d058 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.
2007-11-28 19:40:17 +00:00
Pawel Jakub Dawidek
9cd394ea96 Implement BIO_FLUSH handling for da(4), amr(4), ata(4) and ataraid(4).
Sponsored by:	home.pl
2006-10-31 21:19:25 +00:00
John Baldwin
44daafbccc 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)
2006-07-17 19:45:47 +00:00
Doug Ambrisko
d279e43442 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.
2006-05-03 16:45:15 +00:00
Scott Long
dce223cfb6 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
2006-04-08 05:08:17 +00:00
Paul Saab
026d2aa333 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
2006-04-08 02:23:27 +00:00
Paul Saab
447c943f68 - 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.
2006-02-02 17:50:59 +00:00
Doug Ambrisko
4302d37921 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
2006-01-26 22:39:12 +00:00
Scott Long
a4d3c74487 Check the return value of copyin.
Found by: Coverity Prevent (tm)
2006-01-14 17:59:28 +00:00
Scott Long
174cda8010 Don't free the ap object if it was never created.
Submitted by: jkim
2006-01-10 01:55:17 +00:00
Scott Long
5351742ea2 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.
2005-12-14 03:26:49 +00:00
Scott Long
da7851e1e6 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
2005-11-26 07:30:09 +00:00
Scott Long
fceb189d65 Remove spl markers from AMR.
MFC After:	3 days
2005-11-06 15:13:42 +00:00
Scott Long
9cf8dd43cf 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.
2005-08-08 12:16:21 +00:00
Paul Saab
6c9f6695fd Print the actual disk device we failed to complete i/o on. 2005-07-29 01:53:45 +00:00
Paul Saab
8c61487b21 Don't allow ioctl commands to be interrupted by the user. 2005-07-29 01:47:36 +00:00
Paul Saab
ee515ed0d9 polled commands can read or write, so bus_dmamap_sync properly
according to the type of request.

Approved by:	re
2005-06-23 00:21:25 +00:00
Yoshihiro Takahashi
d4fcf3cba5 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)
2005-05-29 04:42:30 +00:00
Sam Leffler
fd1700dc03 handle potential null ptr
Noticed by:	Coverity Prevent analysis tool
2005-03-31 04:58:10 +00:00
Scott Long
e8447f7027 Fix a null pointer de-ref when passthrough ioctls are issued. This
involves some code shuffle to avoid locking problems.

MFC After: 3 days
2005-03-13 06:25:53 +00:00
Scott Long
55a0283961 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
2005-03-04 06:11:00 +00:00
Scott Long
35e050281e 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
2005-01-23 23:25:41 +00:00
Scott Long
a56d2b5a51 Add my copyright for the locking and busdma work. 2005-01-23 23:22:34 +00:00
Scott Long
5b4a781b96 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.
2005-01-16 07:34:26 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Scott Long
dc0ff2140b 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.
2004-12-05 23:48:17 +00:00
Scott Long
0dde762cb8 Set up the data flow flag correctly so that bounced buffers have a chance of
working in amr_enquire().
2004-09-14 16:36:12 +00:00
Doug Ambrisko
05f1103b26 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)
2004-08-16 17:23:09 +00:00
Paul Saab
2673a44621 Use a separate flag when doing a kernel coredump when polling for
completion instead of abusing the interrupt enable flag.
2004-07-01 06:56:10 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Poul-Henning Kamp
dc08ffec87 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.
2004-02-21 21:10:55 +00:00
Scott Long
777a986004 Allow amr(4) to get a dynamic major number instead of a static one.
Submitted by:	Andre Guibert de Bruet
2004-02-08 16:07:22 +00:00
Paul Saab
6728a38bf2 crashdump support.
Some bits by:	Rajesh Prabhakaran <rajeshpr@lsil.com>
2003-10-10 22:49:40 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +00:00
Warner Losh
4fbd232c86 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.
2003-08-22 05:54:52 +00:00
Poul-Henning Kamp
891619a66d 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.
2003-04-01 15:06:26 +00:00
Poul-Henning Kamp
60794e0478 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.
2003-03-08 08:01:31 +00:00
Poul-Henning Kamp
7ac40f5f59 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)
2003-03-03 12:15:54 +00:00
Scott Long
7874f606d5 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.
2003-02-26 03:15:42 +00:00
Poul-Henning Kamp
7d6ddd1027 NO_GEOM cleanup:
Move to new "struct disk *" centered API".

OK'ed by:	emoore
2003-02-24 21:49:27 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Eric Moore
d163d5b8c8 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
2003-01-09 21:02:28 +00:00