1999-10-07 02:23:12 +00:00
|
|
|
/*-
|
2000-08-30 07:52:50 +00:00
|
|
|
* Copyright (c) 1999,2000 Michael Smith
|
|
|
|
* Copyright (c) 2000 BSDi
|
1999-10-07 02:23:12 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2003-08-24 17:55:58 +00:00
|
|
|
*/
|
2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2002-10-30 22:00:11 +00:00
|
|
|
* Copyright (c) 2002 Eric Moore
|
2005-01-23 23:25:41 +00:00
|
|
|
* Copyright (c) 2002, 2004 LSI Logic Corporation
|
2002-10-30 22:00:11 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2002-10-18 21:29:14 +00:00
|
|
|
* 3. The party using or redistributing the source code and binary forms
|
2002-10-30 22:00:11 +00:00
|
|
|
* agrees to the disclaimer below and the terms and conditions set forth
|
2002-10-18 21:29:14 +00:00
|
|
|
* herein.
|
|
|
|
*
|
2002-10-30 22:00:11 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2004-05-30 20:08:47 +00:00
|
|
|
#include <sys/module.h>
|
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
|
|
|
#include <sys/sysctl.h>
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2005-08-08 12:16:21 +00:00
|
|
|
#include <sys/bio.h>
|
1999-10-07 02:23:12 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
2003-08-22 05:54:52 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
#include <dev/amr/amrio.h>
|
|
|
|
#include <dev/amr/amrreg.h>
|
|
|
|
#include <dev/amr/amrvar.h>
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
static int amr_pci_probe(device_t dev);
|
|
|
|
static int amr_pci_attach(device_t dev);
|
|
|
|
static int amr_pci_detach(device_t dev);
|
|
|
|
static int amr_pci_shutdown(device_t dev);
|
|
|
|
static int amr_pci_suspend(device_t dev);
|
|
|
|
static int amr_pci_resume(device_t dev);
|
|
|
|
static void amr_pci_intr(void *arg);
|
|
|
|
static void amr_pci_free(struct amr_softc *sc);
|
2007-12-12 05:55:03 +00:00
|
|
|
static void amr_sglist_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error);
|
2000-08-30 07:52:50 +00:00
|
|
|
static int amr_sglist_map(struct amr_softc *sc);
|
|
|
|
static int amr_setup_mbox(struct amr_softc *sc);
|
2007-12-12 05:55:03 +00:00
|
|
|
static int amr_ccb_map(struct amr_softc *sc);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
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
|
|
|
static u_int amr_force_sg32 = 0;
|
|
|
|
SYSCTL_DECL(_hw_amr);
|
|
|
|
SYSCTL_UINT(_hw_amr, OID_AUTO, force_sg32, CTLFLAG_RDTUN, &amr_force_sg32, 0,
|
|
|
|
"Force the AMR driver to use 32bit scatter gather");
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
static device_method_t amr_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, amr_pci_probe),
|
|
|
|
DEVMETHOD(device_attach, amr_pci_attach),
|
2000-08-30 07:52:50 +00:00
|
|
|
DEVMETHOD(device_detach, amr_pci_detach),
|
|
|
|
DEVMETHOD(device_shutdown, amr_pci_shutdown),
|
|
|
|
DEVMETHOD(device_suspend, amr_pci_suspend),
|
|
|
|
DEVMETHOD(device_resume, amr_pci_resume),
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2011-11-22 21:28:20 +00:00
|
|
|
DEVMETHOD_END
|
1999-10-07 02:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t amr_pci_driver = {
|
|
|
|
"amr",
|
|
|
|
amr_methods,
|
|
|
|
sizeof(struct amr_softc)
|
|
|
|
};
|
|
|
|
|
2002-01-08 06:47:02 +00:00
|
|
|
static devclass_t amr_devclass;
|
1999-10-07 02:23:12 +00:00
|
|
|
DRIVER_MODULE(amr, pci, amr_pci_driver, amr_devclass, 0, 0);
|
2006-12-11 18:28:31 +00:00
|
|
|
MODULE_DEPEND(amr, pci, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(amr, cam, 1, 1, 1);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
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
|
|
|
static struct amr_ident
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
|
|
|
int vendor;
|
|
|
|
int device;
|
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
|
|
|
int flags;
|
|
|
|
#define AMR_ID_PROBE_SIG (1<<0) /* generic i960RD, check signature */
|
|
|
|
#define AMR_ID_DO_SG64 (1<<1)
|
|
|
|
#define AMR_ID_QUARTZ (1<<2)
|
1999-10-07 02:23:12 +00:00
|
|
|
} amr_device_ids[] = {
|
|
|
|
{0x101e, 0x9010, 0},
|
|
|
|
{0x101e, 0x9060, 0},
|
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
|
|
|
{0x8086, 0x1960, AMR_ID_QUARTZ | AMR_ID_PROBE_SIG},
|
|
|
|
{0x101e, 0x1960, AMR_ID_QUARTZ},
|
2006-02-02 17:51:47 +00:00
|
|
|
{0x1000, 0x1960, AMR_ID_QUARTZ | AMR_ID_DO_SG64 | AMR_ID_PROBE_SIG},
|
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
|
|
|
{0x1000, 0x0407, AMR_ID_QUARTZ | AMR_ID_DO_SG64},
|
|
|
|
{0x1000, 0x0408, AMR_ID_QUARTZ | AMR_ID_DO_SG64},
|
|
|
|
{0x1000, 0x0409, AMR_ID_QUARTZ | AMR_ID_DO_SG64},
|
|
|
|
{0x1028, 0x000e, AMR_ID_QUARTZ | AMR_ID_DO_SG64 | AMR_ID_PROBE_SIG}, /* perc4/di i960 */
|
|
|
|
{0x1028, 0x000f, AMR_ID_QUARTZ | AMR_ID_DO_SG64}, /* perc4/di Verde*/
|
|
|
|
{0x1028, 0x0013, AMR_ID_QUARTZ | AMR_ID_DO_SG64}, /* perc4/di */
|
1999-10-07 02:23:12 +00:00
|
|
|
{0, 0, 0}
|
|
|
|
};
|
2002-10-18 21:29:14 +00:00
|
|
|
|
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
|
|
|
static struct amr_ident *
|
|
|
|
amr_find_ident(device_t dev)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
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
|
|
|
struct amr_ident *id;
|
|
|
|
int sig;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
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
|
|
|
for (id = amr_device_ids; id->vendor != 0; id++) {
|
|
|
|
if ((pci_get_vendor(dev) == id->vendor) &&
|
|
|
|
(pci_get_device(dev) == id->device)) {
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/* do we need to test for a signature? */
|
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
|
|
|
if (id->flags & AMR_ID_PROBE_SIG) {
|
2000-12-22 22:23:56 +00:00
|
|
|
sig = pci_read_config(dev, AMR_CFG_SIG, 2);
|
|
|
|
if ((sig != AMR_SIGNATURE_1) && (sig != AMR_SIGNATURE_2))
|
|
|
|
continue;
|
|
|
|
}
|
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
|
|
|
return (id);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
amr_pci_probe(device_t dev)
|
|
|
|
{
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
if (amr_find_ident(dev) != NULL) {
|
|
|
|
device_set_desc(dev, LSI_DESC_PCI);
|
|
|
|
return(BUS_PROBE_DEFAULT);
|
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
amr_pci_attach(device_t dev)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc;
|
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
|
|
|
struct amr_ident *id;
|
1999-10-07 02:23:12 +00:00
|
|
|
int rid, rtype, error;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(1);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise softc.
|
|
|
|
*/
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
bzero(sc, sizeof(*sc));
|
|
|
|
sc->amr_dev = dev;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* assume failure is 'not configured' */
|
|
|
|
error = ENXIO;
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Determine board type.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
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
|
|
|
if ((id = amr_find_ident(dev)) == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if (id->flags & AMR_ID_QUARTZ) {
|
2000-08-30 07:52:50 +00:00
|
|
|
sc->amr_type |= AMR_TYPE_QUARTZ;
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
if ((amr_force_sg32 == 0) && (id->flags & AMR_ID_DO_SG64) &&
|
|
|
|
(sizeof(vm_paddr_t) > 4)) {
|
|
|
|
device_printf(dev, "Using 64-bit DMA\n");
|
|
|
|
sc->amr_type |= AMR_TYPE_SG64;
|
|
|
|
}
|
|
|
|
|
2000-04-01 00:35:15 +00:00
|
|
|
/* force the busmaster enable bit on */
|
2013-08-12 23:30:01 +00:00
|
|
|
pci_enable_busmaster(dev);
|
2000-04-01 00:35:15 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
|
|
|
* Allocate the PCI register window.
|
|
|
|
*/
|
2003-09-02 17:30:40 +00:00
|
|
|
rid = PCIR_BAR(0);
|
2000-08-30 07:52:50 +00:00
|
|
|
rtype = AMR_IS_QUARTZ(sc) ? SYS_RES_MEMORY : SYS_RES_IOPORT;
|
2004-03-17 17:50:55 +00:00
|
|
|
sc->amr_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE);
|
1999-10-07 02:23:12 +00:00
|
|
|
if (sc->amr_reg == NULL) {
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "can't allocate register window\n");
|
|
|
|
goto out;
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
sc->amr_btag = rman_get_bustag(sc->amr_reg);
|
|
|
|
sc->amr_bhandle = rman_get_bushandle(sc->amr_reg);
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Allocate and connect our interrupt.
|
|
|
|
*/
|
|
|
|
rid = 0;
|
2004-03-17 17:50:55 +00:00
|
|
|
sc->amr_irq = bus_alloc_resource_any(sc->amr_dev, SYS_RES_IRQ, &rid,
|
|
|
|
RF_SHAREABLE | RF_ACTIVE);
|
2000-08-30 07:52:50 +00:00
|
|
|
if (sc->amr_irq == NULL) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate interrupt\n");
|
|
|
|
goto out;
|
|
|
|
}
|
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
|
|
|
if (bus_setup_intr(sc->amr_dev, sc->amr_irq,
|
2007-02-23 12:19:07 +00:00
|
|
|
INTR_TYPE_BIO | INTR_ENTROPY | INTR_MPSAFE, NULL, amr_pci_intr,
|
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
|
|
|
sc, &sc->amr_intr)) {
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "can't set up interrupt\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug(2, "interrupt attached");
|
|
|
|
|
|
|
|
/* assume failure is 'out of memory' */
|
|
|
|
error = ENOMEM;
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
|
|
|
* Allocate the parent bus DMA tag appropriate for PCI.
|
|
|
|
*/
|
2012-03-12 08:03:51 +00:00
|
|
|
if (bus_dma_tag_create(bus_get_dma_tag(dev), /* PCI parent */
|
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
|
|
|
1, 0, /* alignment,boundary */
|
|
|
|
AMR_IS_SG64(sc) ?
|
|
|
|
BUS_SPACE_MAXADDR :
|
2000-08-30 07:52:50 +00:00
|
|
|
BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
|
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
|
|
|
MAXBSIZE, AMR_NSEG, /* maxsize, nsegments */
|
|
|
|
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
|
2004-12-05 23:48:17 +00:00
|
|
|
0, /* flags */
|
2003-07-01 15:52:06 +00:00
|
|
|
NULL, NULL, /* lockfunc, lockarg */
|
2000-08-30 07:52:50 +00:00
|
|
|
&sc->amr_parent_dmat)) {
|
|
|
|
device_printf(dev, "can't allocate parent DMA tag\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create DMA tag for mapping buffers into controller-addressable space.
|
|
|
|
*/
|
|
|
|
if (bus_dma_tag_create(sc->amr_parent_dmat, /* parent */
|
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
|
|
|
1, 0, /* alignment,boundary */
|
2004-12-05 23:48:17 +00:00
|
|
|
BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
|
2000-08-30 07:52:50 +00:00
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
|
|
|
MAXBSIZE, AMR_NSEG, /* maxsize, nsegments */
|
2004-12-05 23:48:17 +00:00
|
|
|
MAXBSIZE, /* maxsegsize */
|
2007-12-12 05:55:03 +00:00
|
|
|
0, /* flags */
|
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
|
|
|
busdma_lock_mutex, /* lockfunc */
|
|
|
|
&sc->amr_list_lock, /* lockarg */
|
2000-08-30 07:52:50 +00:00
|
|
|
&sc->amr_buffer_dmat)) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate buffer DMA tag\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (bus_dma_tag_create(sc->amr_parent_dmat, /* parent */
|
|
|
|
1, 0, /* alignment,boundary */
|
|
|
|
BUS_SPACE_MAXADDR, /* lowaddr */
|
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
|
|
|
MAXBSIZE, AMR_NSEG, /* maxsize, nsegments */
|
|
|
|
MAXBSIZE, /* maxsegsize */
|
2007-12-12 05:55:03 +00:00
|
|
|
0, /* flags */
|
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
|
|
|
busdma_lock_mutex, /* lockfunc */
|
|
|
|
&sc->amr_list_lock, /* lockarg */
|
|
|
|
&sc->amr_buffer64_dmat)) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate buffer DMA tag\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug(2, "dma tag done");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate and set up mailbox in a bus-visible fashion.
|
|
|
|
*/
|
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
|
|
|
mtx_init(&sc->amr_list_lock, "AMR List Lock", NULL, MTX_DEF);
|
|
|
|
mtx_init(&sc->amr_hw_lock, "AMR HW Lock", NULL, MTX_DEF);
|
2000-08-30 07:52:50 +00:00
|
|
|
if ((error = amr_setup_mbox(sc)) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
debug(2, "mailbox setup");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build the scatter/gather buffers.
|
|
|
|
*/
|
2012-02-28 15:09:56 +00:00
|
|
|
if ((error = amr_sglist_map(sc)) != 0)
|
2000-08-30 07:52:50 +00:00
|
|
|
goto out;
|
|
|
|
debug(2, "s/g list mapped");
|
|
|
|
|
2012-02-28 15:09:56 +00:00
|
|
|
if ((error = amr_ccb_map(sc)) != 0)
|
2007-12-12 05:55:03 +00:00
|
|
|
goto out;
|
|
|
|
debug(2, "ccb mapped");
|
|
|
|
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Do bus-independant initialisation, bring controller online.
|
|
|
|
*/
|
|
|
|
error = amr_attach(sc);
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (error)
|
|
|
|
amr_pci_free(sc);
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Disconnect from the controller completely, in preparation for unload.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_pci_detach(device_t dev)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = device_get_softc(dev);
|
|
|
|
int error;
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
if (sc->amr_state & AMR_STATE_OPEN)
|
|
|
|
return(EBUSY);
|
|
|
|
|
|
|
|
if ((error = amr_pci_shutdown(dev)))
|
|
|
|
return(error);
|
|
|
|
|
|
|
|
amr_pci_free(sc);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Bring the controller down to a dormant state and detach all child devices.
|
|
|
|
*
|
|
|
|
* This function is called before detach, system shutdown, or before performing
|
|
|
|
* an operation which may add or delete system disks. (Call amr_startup to
|
|
|
|
* resume normal operation.)
|
|
|
|
*
|
|
|
|
* Note that we can assume that the bioq on the controller is empty, as we won't
|
|
|
|
* allow shutdown if any device is open.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_pci_shutdown(device_t dev)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = device_get_softc(dev);
|
2005-11-06 15:13:42 +00:00
|
|
|
int i,error;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
/* mark ourselves as in-shutdown */
|
|
|
|
sc->amr_state |= AMR_STATE_SHUTDOWN;
|
|
|
|
|
|
|
|
|
|
|
|
/* flush controller */
|
|
|
|
device_printf(sc->amr_dev, "flushing cache...");
|
|
|
|
printf("%s\n", amr_flush(sc) ? "failed" : "done");
|
|
|
|
|
2002-12-11 20:59:46 +00:00
|
|
|
error = 0;
|
|
|
|
|
|
|
|
/* delete all our child devices */
|
|
|
|
for(i = 0 ; i < AMR_MAXLD; i++) {
|
|
|
|
if( sc->amr_drive[i].al_disk != 0) {
|
|
|
|
if((error = device_delete_child(sc->amr_dev,sc->amr_drive[i].al_disk)) != 0)
|
|
|
|
goto shutdown_out;
|
|
|
|
sc->amr_drive[i].al_disk = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* XXX disable interrupts? */
|
2002-12-11 20:59:46 +00:00
|
|
|
|
|
|
|
shutdown_out:
|
|
|
|
return(error);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Bring the controller to a quiescent state, ready for system suspend.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_pci_suspend(device_t dev)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
sc->amr_state |= AMR_STATE_SUSPEND;
|
|
|
|
|
|
|
|
/* flush controller */
|
|
|
|
device_printf(sc->amr_dev, "flushing cache...");
|
|
|
|
printf("%s\n", amr_flush(sc) ? "failed" : "done");
|
|
|
|
|
|
|
|
/* XXX disable interrupts? */
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Bring the controller back to a state ready for operation.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_pci_resume(device_t dev)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
sc->amr_state &= ~AMR_STATE_SUSPEND;
|
|
|
|
|
|
|
|
/* XXX enable interrupts? */
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Take an interrupt, or be poked by other code to look for interrupt-worthy
|
|
|
|
* status.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
amr_pci_intr(void *arg)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = (struct amr_softc *)arg;
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
debug_called(3);
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/* collect finished commands, queue anything waiting */
|
|
|
|
amr_done(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Free all of the resources associated with (sc)
|
|
|
|
*
|
|
|
|
* Should not be called if the controller is active.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
amr_pci_free(struct amr_softc *sc)
|
|
|
|
{
|
2007-12-02 18:47:31 +00:00
|
|
|
void *p;
|
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
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
amr_free(sc);
|
|
|
|
|
|
|
|
/* destroy data-transfer DMA tag */
|
|
|
|
if (sc->amr_buffer_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->amr_buffer_dmat);
|
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
|
|
|
if (sc->amr_buffer64_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->amr_buffer64_dmat);
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
/* free and destroy DMA memory and tag for passthrough pool */
|
2014-06-13 18:20:44 +00:00
|
|
|
if (sc->amr_ccb) {
|
|
|
|
bus_dmamap_unload(sc->amr_ccb_dmat, sc->amr_ccb_dmamap);
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dmamem_free(sc->amr_ccb_dmat, sc->amr_ccb, sc->amr_ccb_dmamap);
|
2014-06-13 18:20:44 +00:00
|
|
|
}
|
2007-12-12 05:55:03 +00:00
|
|
|
if (sc->amr_ccb_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->amr_ccb_dmat);
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* free and destroy DMA memory and tag for s/g lists */
|
2014-06-13 18:20:44 +00:00
|
|
|
if (sc->amr_sgtable) {
|
|
|
|
bus_dmamap_unload(sc->amr_sg_dmat, sc->amr_sg_dmamap);
|
2000-08-30 07:52:50 +00:00
|
|
|
bus_dmamem_free(sc->amr_sg_dmat, sc->amr_sgtable, sc->amr_sg_dmamap);
|
2014-06-13 18:20:44 +00:00
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
if (sc->amr_sg_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->amr_sg_dmat);
|
|
|
|
|
|
|
|
/* free and destroy DMA memory and tag for mailbox */
|
2006-02-04 22:14:20 +00:00
|
|
|
p = (void *)(uintptr_t)(volatile void *)sc->amr_mailbox64;
|
2000-08-30 07:52:50 +00:00
|
|
|
if (sc->amr_mailbox) {
|
2014-06-13 18:20:44 +00:00
|
|
|
bus_dmamap_unload(sc->amr_mailbox_dmat, sc->amr_mailbox_dmamap);
|
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
|
|
|
bus_dmamem_free(sc->amr_mailbox_dmat, p, sc->amr_mailbox_dmamap);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
2002-10-30 22:00:11 +00:00
|
|
|
if (sc->amr_mailbox_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->amr_mailbox_dmat);
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/* disconnect the interrupt handler */
|
|
|
|
if (sc->amr_intr)
|
|
|
|
bus_teardown_intr(sc->amr_dev, sc->amr_irq, sc->amr_intr);
|
|
|
|
if (sc->amr_irq != NULL)
|
|
|
|
bus_release_resource(sc->amr_dev, SYS_RES_IRQ, 0, sc->amr_irq);
|
|
|
|
|
|
|
|
/* destroy the parent DMA tag */
|
|
|
|
if (sc->amr_parent_dmat)
|
|
|
|
bus_dma_tag_destroy(sc->amr_parent_dmat);
|
|
|
|
|
|
|
|
/* release the register window mapping */
|
|
|
|
if (sc->amr_reg != NULL)
|
|
|
|
bus_release_resource(sc->amr_dev,
|
|
|
|
AMR_IS_QUARTZ(sc) ? SYS_RES_MEMORY : SYS_RES_IOPORT,
|
2003-09-02 17:30:40 +00:00
|
|
|
PCIR_BAR(0), sc->amr_reg);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Allocate and map the scatter/gather table in bus space.
|
|
|
|
*/
|
|
|
|
static void
|
2007-12-12 05:55:03 +00:00
|
|
|
amr_sglist_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
2000-08-30 07:52:50 +00:00
|
|
|
{
|
2007-12-12 05:55:03 +00:00
|
|
|
uint32_t *addr;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
addr = arg;
|
|
|
|
*addr = segs[0].ds_addr;
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
amr_sglist_map(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
size_t segsize;
|
2006-02-04 22:14:20 +00:00
|
|
|
void *p;
|
2000-08-30 07:52:50 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a single tag describing a region large enough to hold all of
|
|
|
|
* the s/g lists we will need.
|
|
|
|
*
|
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
|
|
|
* Note that we could probably use AMR_LIMITCMD here, but that may become
|
|
|
|
* tunable.
|
2000-08-30 07:52:50 +00:00
|
|
|
*/
|
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
|
|
|
if (AMR_IS_SG64(sc))
|
|
|
|
segsize = sizeof(struct amr_sg64entry) * AMR_NSEG * AMR_MAXCMD;
|
|
|
|
else
|
|
|
|
segsize = sizeof(struct amr_sgentry) * AMR_NSEG * AMR_MAXCMD;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
error = bus_dma_tag_create(sc->amr_parent_dmat, /* parent */
|
2007-12-12 05:55:03 +00:00
|
|
|
512, 0, /* alignment,boundary */
|
2004-12-05 23:48:17 +00:00
|
|
|
BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
|
1999-10-07 02:23:12 +00:00
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
2000-08-30 07:52:50 +00:00
|
|
|
segsize, 1, /* maxsize, nsegments */
|
1999-10-07 02:23:12 +00:00
|
|
|
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
|
2000-08-30 07:52:50 +00:00
|
|
|
0, /* flags */
|
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
|
|
|
NULL, NULL, /* lockfunc, lockarg */
|
2000-08-30 07:52:50 +00:00
|
|
|
&sc->amr_sg_dmat);
|
1999-10-07 02:23:12 +00:00
|
|
|
if (error != 0) {
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "can't allocate scatter/gather DMA tag\n");
|
1999-10-07 02:23:12 +00:00
|
|
|
return(ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Allocate enough s/g maps for all commands and permanently map them into
|
|
|
|
* controller-visible space.
|
|
|
|
*
|
|
|
|
* XXX this assumes we can get enough space for all the s/g maps in one
|
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
|
|
|
* contiguous slab. We may need to switch to a more complex arrangement
|
|
|
|
* where we allocate in smaller chunks and keep a lookup table from slot
|
|
|
|
* to bus address.
|
2000-08-30 07:52:50 +00:00
|
|
|
*
|
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
|
|
|
* XXX HACK ALERT: at least some controllers don't like the s/g memory
|
|
|
|
* being allocated below 0x2000. We leak some memory if
|
|
|
|
* we get some below this mark and allocate again. We
|
|
|
|
* should be able to avoid this with the tag setup, but
|
|
|
|
* that does't seem to work.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
retry:
|
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
|
|
|
error = bus_dmamem_alloc(sc->amr_sg_dmat, (void **)&p, BUS_DMA_NOWAIT, &sc->amr_sg_dmamap);
|
2000-08-30 07:52:50 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate s/g table\n");
|
|
|
|
return(ENOMEM);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dmamap_load(sc->amr_sg_dmat, sc->amr_sg_dmamap, p, segsize, amr_sglist_helper, &sc->amr_sgbusaddr, 0);
|
2000-08-30 07:52:50 +00:00
|
|
|
if (sc->amr_sgbusaddr < 0x2000) {
|
|
|
|
debug(1, "s/g table too low (0x%x), reallocating\n", sc->amr_sgbusaddr);
|
|
|
|
goto retry;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
if (AMR_IS_SG64(sc))
|
|
|
|
sc->amr_sg64table = (struct amr_sg64entry *)p;
|
|
|
|
sc->amr_sgtable = (struct amr_sgentry *)p;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Allocate and set up mailbox areas for the controller (sc)
|
|
|
|
*
|
2007-12-12 05:55:03 +00:00
|
|
|
* The basic mailbox structure should be 16-byte aligned.
|
2000-08-30 07:52:50 +00:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_setup_mbox(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
int error;
|
2006-02-04 22:14:20 +00:00
|
|
|
void *p;
|
2007-12-12 05:55:03 +00:00
|
|
|
uint32_t baddr;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Create a single tag describing a region large enough to hold the entire
|
|
|
|
* mailbox.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
error = bus_dma_tag_create(sc->amr_parent_dmat, /* parent */
|
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
|
|
|
16, 0, /* alignment,boundary */
|
2004-12-05 23:48:17 +00:00
|
|
|
BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
|
2000-08-30 07:52:50 +00:00
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
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
|
|
|
sizeof(struct amr_mailbox64), /* maxsize */
|
|
|
|
1, /* nsegments */
|
2000-08-30 07:52:50 +00:00
|
|
|
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
|
|
|
|
0, /* flags */
|
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
|
|
|
NULL, NULL, /* lockfunc, lockarg */
|
2000-08-30 07:52:50 +00:00
|
|
|
&sc->amr_mailbox_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate mailbox tag\n");
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the mailbox structure and permanently map it into
|
|
|
|
* controller-visible space.
|
|
|
|
*/
|
2002-10-30 22:00:11 +00:00
|
|
|
error = bus_dmamem_alloc(sc->amr_mailbox_dmat, (void **)&p, BUS_DMA_NOWAIT,
|
2000-08-30 07:52:50 +00:00
|
|
|
&sc->amr_mailbox_dmamap);
|
|
|
|
if (error) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate mailbox memory\n");
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
2002-10-30 22:00:11 +00:00
|
|
|
bus_dmamap_load(sc->amr_mailbox_dmat, sc->amr_mailbox_dmamap, p,
|
2007-12-12 05:55:03 +00:00
|
|
|
sizeof(struct amr_mailbox64), amr_sglist_helper, &baddr, 0);
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Conventional mailbox is inside the mailbox64 region.
|
|
|
|
*/
|
2007-12-12 05:55:03 +00:00
|
|
|
/* save physical base of the basic mailbox structure */
|
|
|
|
sc->amr_mailboxphys = baddr + offsetof(struct amr_mailbox64, mb);
|
2000-08-30 07:52:50 +00:00
|
|
|
bzero(p, sizeof(struct amr_mailbox64));
|
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
|
|
|
sc->amr_mailbox64 = (struct amr_mailbox64 *)p;
|
|
|
|
sc->amr_mailbox = &sc->amr_mailbox64->mb;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
return(0);
|
|
|
|
}
|
2007-12-12 05:55:03 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
amr_ccb_map(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
int ccbsize, error;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Passthrough and Extended passthrough structures will share the same
|
|
|
|
* memory.
|
|
|
|
*/
|
|
|
|
ccbsize = sizeof(union amr_ccb) * AMR_MAXCMD;
|
|
|
|
error = bus_dma_tag_create(sc->amr_parent_dmat, /* parent */
|
|
|
|
128, 0, /* alignment,boundary */
|
|
|
|
BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
|
|
|
|
BUS_SPACE_MAXADDR, /* highaddr */
|
|
|
|
NULL, NULL, /* filter, filterarg */
|
|
|
|
ccbsize, /* maxsize */
|
|
|
|
1, /* nsegments */
|
|
|
|
ccbsize, /* maxsegsize */
|
|
|
|
0, /* flags */
|
|
|
|
NULL, NULL, /* lockfunc, lockarg */
|
|
|
|
&sc->amr_ccb_dmat);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate ccb tag\n");
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(sc->amr_ccb_dmat, (void **)&sc->amr_ccb,
|
|
|
|
BUS_DMA_NOWAIT, &sc->amr_ccb_dmamap);
|
|
|
|
if (error) {
|
|
|
|
device_printf(sc->amr_dev, "can't allocate ccb memory\n");
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
bus_dmamap_load(sc->amr_ccb_dmat, sc->amr_ccb_dmamap, sc->amr_ccb,
|
|
|
|
ccbsize, amr_sglist_helper, &sc->amr_ccb_busaddr, 0);
|
|
|
|
bzero(sc->amr_ccb, ccbsize);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|