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
|
2005-01-23 23:22:34 +00:00
|
|
|
* Copyright (c) 2005 Scott Long
|
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
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Driver for the AMI MegaRaid family of controllers.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.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/proc.h>
|
|
|
|
#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>
|
2000-08-30 07:52:50 +00:00
|
|
|
#include <sys/stat.h>
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
#include <machine/bus.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 <machine/cpu.h>
|
2000-08-30 07:52:50 +00:00
|
|
|
#include <machine/resource.h>
|
1999-10-07 02:23:12 +00:00
|
|
|
#include <sys/rman.h>
|
|
|
|
|
2003-08-22 05:54:52 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
2000-08-30 07:52:50 +00:00
|
|
|
|
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
|
|
|
#define AMR_DEFINE_TABLES
|
|
|
|
#include <dev/amr/amr_tables.h>
|
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
|
|
|
SYSCTL_NODE(_hw, OID_AUTO, amr, CTLFLAG_RD, 0, "AMR driver parameters");
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
static d_open_t amr_open;
|
|
|
|
static d_close_t amr_close;
|
|
|
|
static d_ioctl_t amr_ioctl;
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
static struct cdevsw amr_cdevsw = {
|
2004-02-21 21:10:55 +00:00
|
|
|
.d_version = D_VERSION,
|
|
|
|
.d_flags = D_NEEDGIANT,
|
2003-03-03 12:15:54 +00:00
|
|
|
.d_open = amr_open,
|
|
|
|
.d_close = amr_close,
|
|
|
|
.d_ioctl = amr_ioctl,
|
|
|
|
.d_name = "amr",
|
1999-10-07 02:23:12 +00:00
|
|
|
};
|
|
|
|
|
2006-05-03 16:45:15 +00:00
|
|
|
int linux_no_adapter = 0;
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Initialisation, bus interface.
|
|
|
|
*/
|
|
|
|
static void amr_startup(void *arg);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Command wrappers
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
static int amr_query_controller(struct amr_softc *sc);
|
|
|
|
static void *amr_enquiry(struct amr_softc *sc, size_t bufsize,
|
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
|
|
|
u_int8_t cmd, u_int8_t cmdsub, u_int8_t cmdqual, int *status);
|
2000-08-30 07:52:50 +00:00
|
|
|
static void amr_completeio(struct amr_command *ac);
|
2002-10-30 22:00:11 +00:00
|
|
|
static int amr_support_ext_cdb(struct amr_softc *sc);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Command buffer allocation.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
static void amr_alloccmd_cluster(struct amr_softc *sc);
|
|
|
|
static void amr_freecmd_cluster(struct amr_command_cluster *acc);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Command processing.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
static int amr_bio_command(struct amr_softc *sc, struct amr_command **acp);
|
2004-12-05 23:48:17 +00:00
|
|
|
static int amr_wait_command(struct amr_command *ac) __unused;
|
|
|
|
static int amr_mapcmd(struct amr_command *ac);
|
2000-08-30 07:52:50 +00:00
|
|
|
static void amr_unmapcmd(struct amr_command *ac);
|
|
|
|
static int amr_start(struct amr_command *ac);
|
2008-01-24 07:26:53 +00:00
|
|
|
static void amr_complete(void *context, ac_qhead_t *head);
|
2007-12-12 05:55:03 +00:00
|
|
|
static void amr_setup_sg(void *arg, bus_dma_segment_t *segs, int nsegments, int error);
|
|
|
|
static void amr_setup_data(void *arg, bus_dma_segment_t *segs, int nsegments, int error);
|
|
|
|
static void amr_setup_ccb(void *arg, bus_dma_segment_t *segs, int nsegments, int error);
|
2008-01-24 07:26:53 +00:00
|
|
|
static void amr_abort_load(struct amr_command *ac);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface-specific shims
|
|
|
|
*/
|
2006-02-02 17:50:59 +00:00
|
|
|
static int amr_quartz_submit_command(struct amr_command *ac);
|
2000-08-30 07:52:50 +00:00
|
|
|
static int amr_quartz_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave);
|
2002-12-11 20:59:46 +00:00
|
|
|
static int amr_quartz_poll_command(struct amr_command *ac);
|
2004-12-05 23:48:17 +00:00
|
|
|
static int amr_quartz_poll_command1(struct amr_softc *sc, struct amr_command *ac);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2006-02-02 17:50:59 +00:00
|
|
|
static int amr_std_submit_command(struct amr_command *ac);
|
2000-08-30 07:52:50 +00:00
|
|
|
static int amr_std_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave);
|
2002-12-11 20:59:46 +00:00
|
|
|
static int amr_std_poll_command(struct amr_command *ac);
|
2000-08-30 07:52:50 +00:00
|
|
|
static void amr_std_attach_mailbox(struct amr_softc *sc);
|
|
|
|
|
|
|
|
#ifdef AMR_BOARD_INIT
|
|
|
|
static int amr_quartz_init(struct amr_softc *sc);
|
|
|
|
static int amr_std_init(struct amr_softc *sc);
|
|
|
|
#endif
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Debugging
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
static void amr_describe_controller(struct amr_softc *sc);
|
|
|
|
#ifdef AMR_DEBUG
|
2002-12-11 20:59:46 +00:00
|
|
|
#if 0
|
2000-08-30 07:52:50 +00:00
|
|
|
static void amr_printcommand(struct amr_command *ac);
|
|
|
|
#endif
|
2002-12-11 20:59:46 +00:00
|
|
|
#endif
|
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 void amr_init_sysctl(struct amr_softc *sc);
|
2006-05-03 16:45:15 +00:00
|
|
|
static int amr_linux_ioctl_int(struct cdev *dev, u_long cmd, caddr_t addr,
|
2009-05-20 17:29:21 +00:00
|
|
|
int32_t flag, struct thread *td);
|
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
|
|
|
|
2011-11-07 06:44:47 +00:00
|
|
|
static MALLOC_DEFINE(M_AMR, "amr", "AMR memory");
|
2007-12-02 19:54:45 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
|
|
|
********************************************************************************
|
2000-08-30 07:52:50 +00:00
|
|
|
Inline Glue
|
1999-10-07 02:23:12 +00:00
|
|
|
********************************************************************************
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
2000-08-30 07:52:50 +00:00
|
|
|
********************************************************************************
|
|
|
|
Public Interfaces
|
|
|
|
********************************************************************************
|
|
|
|
********************************************************************************/
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Initialise the controller and softc.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
amr_attach(struct amr_softc *sc)
|
|
|
|
{
|
2008-11-03 00:53:54 +00:00
|
|
|
device_t child;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
debug_called(1);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise per-controller queues.
|
|
|
|
*/
|
2008-01-24 07:26:53 +00:00
|
|
|
amr_init_qhead(&sc->amr_freecmds);
|
|
|
|
amr_init_qhead(&sc->amr_ready);
|
2000-08-30 07:52:50 +00:00
|
|
|
TAILQ_INIT(&sc->amr_cmd_clusters);
|
2000-04-15 05:54:02 +00:00
|
|
|
bioq_init(&sc->amr_bioq);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug(2, "queue init done");
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
|
|
|
* Configure for this controller type.
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
if (AMR_IS_QUARTZ(sc)) {
|
1999-10-07 02:23:12 +00:00
|
|
|
sc->amr_submit_command = amr_quartz_submit_command;
|
|
|
|
sc->amr_get_work = amr_quartz_get_work;
|
2002-12-11 20:59:46 +00:00
|
|
|
sc->amr_poll_command = amr_quartz_poll_command;
|
2004-12-05 23:48:17 +00:00
|
|
|
sc->amr_poll_command1 = amr_quartz_poll_command1;
|
1999-10-07 02:23:12 +00:00
|
|
|
} else {
|
|
|
|
sc->amr_submit_command = amr_std_submit_command;
|
|
|
|
sc->amr_get_work = amr_std_get_work;
|
2002-12-11 20:59:46 +00:00
|
|
|
sc->amr_poll_command = amr_std_poll_command;
|
2010-01-07 21:01:37 +00:00
|
|
|
amr_std_attach_mailbox(sc);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
#ifdef AMR_BOARD_INIT
|
2009-10-28 15:22:58 +00:00
|
|
|
if ((AMR_IS_QUARTZ(sc) ? amr_quartz_init(sc) : amr_std_init(sc)))
|
2000-08-30 07:52:50 +00:00
|
|
|
return(ENXIO);
|
|
|
|
#endif
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
/*
|
|
|
|
* Allocate initial commands.
|
|
|
|
*/
|
|
|
|
amr_alloccmd_cluster(sc);
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Quiz controller for features and limits.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
if (amr_query_controller(sc))
|
|
|
|
return(ENXIO);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug(2, "controller query complete");
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
/*
|
|
|
|
* preallocate the remaining commands.
|
|
|
|
*/
|
|
|
|
while (sc->amr_nextslot < sc->amr_maxio)
|
|
|
|
amr_alloccmd_cluster(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
|
|
|
/*
|
|
|
|
* Setup sysctls.
|
|
|
|
*/
|
|
|
|
amr_init_sysctl(sc);
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Attach our 'real' SCSI channels to CAM.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2008-11-03 00:53:54 +00:00
|
|
|
child = device_add_child(sc->amr_dev, "amrp", -1);
|
|
|
|
sc->amr_pass = child;
|
|
|
|
if (child != NULL) {
|
|
|
|
device_set_softc(child, sc);
|
|
|
|
device_set_desc(child, "SCSI Passthrough Bus");
|
|
|
|
bus_generic_attach(sc->amr_dev);
|
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Create the control device.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
sc->amr_dev_t = make_dev(&amr_cdevsw, device_get_unit(sc->amr_dev), UID_ROOT, GID_OPERATOR,
|
|
|
|
S_IRUSR | S_IWUSR, "amr%d", device_get_unit(sc->amr_dev));
|
|
|
|
sc->amr_dev_t->si_drv1 = sc;
|
2006-05-03 16:45:15 +00:00
|
|
|
linux_no_adapter++;
|
|
|
|
if (device_get_unit(sc->amr_dev) == 0)
|
|
|
|
make_dev_alias(sc->amr_dev_t, "megadev0");
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Schedule ourselves to bring the controller up once interrupts are
|
|
|
|
* available.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
bzero(&sc->amr_ich, sizeof(struct intr_config_hook));
|
|
|
|
sc->amr_ich.ich_func = amr_startup;
|
|
|
|
sc->amr_ich.ich_arg = sc;
|
|
|
|
if (config_intrhook_establish(&sc->amr_ich) != 0) {
|
|
|
|
device_printf(sc->amr_dev, "can't establish configuration hook\n");
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-04-01 00:35:15 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Print a little information about the controller.
|
2000-04-01 00:35:15 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
amr_describe_controller(sc);
|
2000-04-01 00:35:15 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug(2, "attach complete");
|
1999-10-07 02:23:12 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Locate disk resources and attach children to them.
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
static void
|
|
|
|
amr_startup(void *arg)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_softc *sc = (struct amr_softc *)arg;
|
1999-10-07 02:23:12 +00:00
|
|
|
struct amr_logdrive *dr;
|
|
|
|
int i, error;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
/* pull ourselves off the intrhook chain */
|
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_ich.ich_func)
|
|
|
|
config_intrhook_disestablish(&sc->amr_ich);
|
|
|
|
sc->amr_ich.ich_func = NULL;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/* get up-to-date drive information */
|
|
|
|
if (amr_query_controller(sc)) {
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "can't scan controller for drives\n");
|
1999-10-07 02:23:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate over available drives */
|
|
|
|
for (i = 0, dr = &sc->amr_drive[0]; (i < AMR_MAXLD) && (dr->al_size != 0xffffffff); i++, dr++) {
|
|
|
|
/* are we already attached to this drive? */
|
|
|
|
if (dr->al_disk == 0) {
|
|
|
|
/* generate geometry information */
|
|
|
|
if (dr->al_size > 0x200000) { /* extended translation? */
|
|
|
|
dr->al_heads = 255;
|
|
|
|
dr->al_sectors = 63;
|
|
|
|
} else {
|
|
|
|
dr->al_heads = 64;
|
|
|
|
dr->al_sectors = 32;
|
|
|
|
}
|
|
|
|
dr->al_cylinders = dr->al_size / (dr->al_heads * dr->al_sectors);
|
|
|
|
|
1999-12-03 08:41:24 +00:00
|
|
|
dr->al_disk = device_add_child(sc->amr_dev, NULL, -1);
|
1999-10-07 02:23:12 +00:00
|
|
|
if (dr->al_disk == 0)
|
|
|
|
device_printf(sc->amr_dev, "device_add_child failed\n");
|
1999-12-03 08:41:24 +00:00
|
|
|
device_set_ivars(dr->al_disk, dr);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((error = bus_generic_attach(sc->amr_dev)) != 0)
|
|
|
|
device_printf(sc->amr_dev, "bus_generic_attach returned %d\n", error);
|
|
|
|
|
|
|
|
/* mark controller back up */
|
|
|
|
sc->amr_state &= ~AMR_STATE_SHUTDOWN;
|
|
|
|
|
|
|
|
/* interrupts will be enabled before we do anything more */
|
|
|
|
sc->amr_state |= AMR_STATE_INTEN;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
return;
|
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 void
|
|
|
|
amr_init_sysctl(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
|
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->amr_dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)),
|
|
|
|
OID_AUTO, "allow_volume_configure", CTLFLAG_RW, &sc->amr_allow_vol_config, 0,
|
|
|
|
"");
|
2008-01-24 07:26:53 +00:00
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->amr_dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)),
|
|
|
|
OID_AUTO, "nextslot", CTLFLAG_RD, &sc->amr_nextslot, 0,
|
|
|
|
"");
|
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->amr_dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)),
|
|
|
|
OID_AUTO, "busyslots", CTLFLAG_RD, &sc->amr_busyslots, 0,
|
|
|
|
"");
|
|
|
|
SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->amr_dev),
|
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->amr_dev)),
|
|
|
|
OID_AUTO, "maxio", CTLFLAG_RD, &sc->amr_maxio, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Free resources associated with a controller instance
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
void
|
|
|
|
amr_free(struct amr_softc *sc)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_command_cluster *acc;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* detach from CAM */
|
2008-11-03 00:53:54 +00:00
|
|
|
if (sc->amr_pass != NULL)
|
|
|
|
device_delete_child(sc->amr_dev, sc->amr_pass);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* throw away any command buffers */
|
|
|
|
while ((acc = TAILQ_FIRST(&sc->amr_cmd_clusters)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&sc->amr_cmd_clusters, acc, acc_link);
|
|
|
|
amr_freecmd_cluster(acc);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2002-12-11 20:59:46 +00:00
|
|
|
|
|
|
|
/* destroy control device */
|
2004-06-16 09:47:26 +00:00
|
|
|
if( sc->amr_dev_t != (struct cdev *)NULL)
|
2002-12-11 20:59:46 +00:00
|
|
|
destroy_dev(sc->amr_dev_t);
|
2005-01-16 07:34:26 +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 (mtx_initialized(&sc->amr_hw_lock))
|
|
|
|
mtx_destroy(&sc->amr_hw_lock);
|
|
|
|
|
|
|
|
if (mtx_initialized(&sc->amr_list_lock))
|
|
|
|
mtx_destroy(&sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2000-08-30 07:52:50 +00:00
|
|
|
* Receive a bio structure from a child device and queue it on a particular
|
1999-10-07 02:23:12 +00:00
|
|
|
* disk resource, then poke the disk resource to start as much work as it can.
|
|
|
|
*/
|
|
|
|
int
|
2000-08-30 07:52:50 +00:00
|
|
|
amr_submit_bio(struct amr_softc *sc, struct bio *bio)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(2);
|
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
|
|
|
mtx_lock(&sc->amr_list_lock);
|
2000-08-30 07:52:50 +00:00
|
|
|
amr_enqueue_bio(sc, bio);
|
1999-10-07 02:23:12 +00:00
|
|
|
amr_startio(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
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Accept an open operation on the control device.
|
|
|
|
*/
|
2002-09-28 17:15:38 +00:00
|
|
|
static int
|
2009-05-20 17:29:21 +00:00
|
|
|
amr_open(struct cdev *dev, int flags, int fmt, struct thread *td)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2008-09-27 08:51:18 +00:00
|
|
|
int unit = dev2unit(dev);
|
2009-08-20 19:17:53 +00:00
|
|
|
struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(1);
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
sc->amr_state |= AMR_STATE_OPEN;
|
|
|
|
return(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
|
|
|
#ifdef LSI
|
|
|
|
static int
|
|
|
|
amr_del_ld(struct amr_softc *sc, int drv_no, int status)
|
|
|
|
{
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
|
|
|
sc->amr_state &= ~AMR_STATE_QUEUE_FRZN;
|
|
|
|
sc->amr_state &= ~AMR_STATE_LD_DELETE;
|
|
|
|
sc->amr_state |= AMR_STATE_REMAP_LD;
|
|
|
|
debug(1, "State Set");
|
|
|
|
|
|
|
|
if (!status) {
|
|
|
|
debug(1, "disk begin destroyed %d",drv_no);
|
|
|
|
if (--amr_disks_registered == 0)
|
|
|
|
cdevsw_remove(&amrddisk_cdevsw);
|
|
|
|
debug(1, "disk begin destroyed success");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
amr_prepare_ld_delete(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
if (sc->ld_del_supported == 0)
|
|
|
|
return(ENOIOCTL);
|
|
|
|
|
|
|
|
sc->amr_state |= AMR_STATE_QUEUE_FRZN;
|
|
|
|
sc->amr_state |= AMR_STATE_LD_DELETE;
|
|
|
|
|
|
|
|
/* 5 minutes for the all the commands to be flushed.*/
|
|
|
|
tsleep((void *)&sc->ld_del_supported, PCATCH | PRIBIO,"delete_logical_drv",hz * 60 * 1);
|
|
|
|
if ( sc->amr_busyslots )
|
|
|
|
return(ENOIOCTL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Accept the last close on the control device.
|
|
|
|
*/
|
2002-09-28 17:15:38 +00:00
|
|
|
static int
|
2009-05-20 17:29:21 +00:00
|
|
|
amr_close(struct cdev *dev, int flags, int fmt, struct thread *td)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2008-09-27 08:51:18 +00:00
|
|
|
int unit = dev2unit(dev);
|
2009-08-20 19:17:53 +00:00
|
|
|
struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(1);
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
sc->amr_state &= ~AMR_STATE_OPEN;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Handle controller-specific control operations.
|
|
|
|
*/
|
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 void
|
|
|
|
amr_rescan_drives(struct cdev *dev)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = (struct amr_softc *)dev->si_drv1;
|
|
|
|
int i, error = 0;
|
|
|
|
|
|
|
|
sc->amr_state |= AMR_STATE_REMAP_LD;
|
|
|
|
while (sc->amr_busyslots) {
|
|
|
|
device_printf(sc->amr_dev, "idle controller\n");
|
|
|
|
amr_done(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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");
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2009-09-08 13:19:05 +00:00
|
|
|
sc->amr_drive[i].al_disk = 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shutdown_out:
|
|
|
|
amr_startup(sc);
|
|
|
|
}
|
|
|
|
|
2012-04-20 20:27:31 +00:00
|
|
|
/*
|
|
|
|
* Bug-for-bug compatibility with Linux!
|
|
|
|
* Some apps will send commands with inlen and outlen set to 0,
|
2016-05-03 03:41:25 +00:00
|
|
|
* even though they expect data to be transferred to them from the
|
2012-04-20 20:27:31 +00:00
|
|
|
* card. Linux accidentally allows this by allocating a 4KB
|
|
|
|
* buffer for the transfer anyways, but it then throws it away
|
|
|
|
* without copying it back to the app.
|
|
|
|
*
|
|
|
|
* The amr(4) firmware relies on this feature. In fact, it assumes
|
|
|
|
* the buffer is always a power of 2 up to a max of 64k. There is
|
|
|
|
* also at least one case where it assumes a buffer less than 16k is
|
2012-10-05 15:52:31 +00:00
|
|
|
* greater than 16k. However, forcing all buffers to a size of 32k
|
|
|
|
* causes stalls in the firmware. Force each command smaller than
|
|
|
|
* 64k up to the next power of two except that commands between 8k
|
|
|
|
* and 16k are rounded up to 32k instead of 16k.
|
2012-04-20 20:27:31 +00:00
|
|
|
*/
|
|
|
|
static unsigned long
|
|
|
|
amr_ioctl_buffer_length(unsigned long len)
|
|
|
|
{
|
|
|
|
|
2012-10-05 15:52:31 +00:00
|
|
|
if (len <= 4 * 1024)
|
|
|
|
return (4 * 1024);
|
|
|
|
if (len <= 8 * 1024)
|
|
|
|
return (8 * 1024);
|
2012-04-20 20:27:31 +00:00
|
|
|
if (len <= 32 * 1024)
|
|
|
|
return (32 * 1024);
|
|
|
|
if (len <= 64 * 1024)
|
|
|
|
return (64 * 1024);
|
|
|
|
return (len);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
amr_linux_ioctl_int(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag,
|
2009-05-20 17:29:21 +00:00
|
|
|
struct thread *td)
|
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_softc *sc = (struct amr_softc *)dev->si_drv1;
|
|
|
|
struct amr_command *ac;
|
|
|
|
struct amr_mailbox *mb;
|
|
|
|
struct amr_linux_ioctl ali;
|
|
|
|
void *dp, *temp;
|
|
|
|
int error;
|
2014-08-08 11:47:09 +00:00
|
|
|
int len, ac_flags = 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
|
|
|
int logical_drives_changed = 0;
|
|
|
|
u_int32_t linux_version = 0x02100000;
|
|
|
|
u_int8_t status;
|
|
|
|
struct amr_passthrough *ap; /* 60 bytes */
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
dp = NULL;
|
|
|
|
ac = NULL;
|
|
|
|
ap = NULL;
|
|
|
|
|
2006-01-14 17:59:28 +00:00
|
|
|
if ((error = copyin(addr, &ali, sizeof(ali))) != 0)
|
|
|
|
return (error);
|
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
|
|
|
switch (ali.ui.fcs.opcode) {
|
|
|
|
case 0x82:
|
|
|
|
switch(ali.ui.fcs.subopcode) {
|
|
|
|
case 'e':
|
|
|
|
copyout(&linux_version, (void *)(uintptr_t)ali.data,
|
|
|
|
sizeof(linux_version));
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm':
|
2006-05-03 16:45:15 +00:00
|
|
|
copyout(&linux_no_adapter, (void *)(uintptr_t)ali.data,
|
|
|
|
sizeof(linux_no_adapter));
|
|
|
|
td->td_retval[0] = linux_no_adapter;
|
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 = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("Unknown subopcode\n");
|
|
|
|
error = ENOIOCTL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x80:
|
|
|
|
case 0x81:
|
|
|
|
if (ali.ui.fcs.opcode == 0x80)
|
|
|
|
len = max(ali.outlen, ali.inlen);
|
|
|
|
else
|
|
|
|
len = ali.ui.fcs.length;
|
|
|
|
|
|
|
|
mb = (void *)&ali.mbox[0];
|
|
|
|
|
|
|
|
if ((ali.mbox[0] == FC_DEL_LOGDRV && ali.mbox[2] == OP_DEL_LOGDRV) || /* delete */
|
|
|
|
(ali.mbox[0] == AMR_CMD_CONFIG && ali.mbox[2] == 0x0d)) { /* create */
|
|
|
|
if (sc->amr_allow_vol_config == 0) {
|
|
|
|
error = EPERM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
logical_drives_changed = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ali.mbox[0] == AMR_CMD_PASS) {
|
2007-12-12 05:55:03 +00:00
|
|
|
mtx_lock(&sc->amr_list_lock);
|
|
|
|
while ((ac = amr_alloccmd(sc)) == NULL)
|
|
|
|
msleep(sc, &sc->amr_list_lock, PPAUSE, "amrioc", hz);
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
ap = &ac->ac_ccb->ccb_pthru;
|
|
|
|
|
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 = copyin((void *)(uintptr_t)mb->mb_physaddr, ap,
|
|
|
|
sizeof(struct amr_passthrough));
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ap->ap_data_transfer_length)
|
2007-12-02 19:54:45 +00:00
|
|
|
dp = malloc(ap->ap_data_transfer_length, M_AMR,
|
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
|
|
|
M_WAITOK | M_ZERO);
|
|
|
|
|
|
|
|
if (ali.inlen) {
|
|
|
|
error = copyin((void *)(uintptr_t)ap->ap_data_transfer_address,
|
|
|
|
dp, ap->ap_data_transfer_length);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
ac_flags = AMR_CMD_DATAIN|AMR_CMD_DATAOUT|AMR_CMD_CCB;
|
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
|
|
|
bzero(&ac->ac_mailbox, sizeof(ac->ac_mailbox));
|
|
|
|
ac->ac_mailbox.mb_command = AMR_CMD_PASS;
|
|
|
|
ac->ac_flags = ac_flags;
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_data = dp;
|
|
|
|
ac->ac_length = ap->ap_data_transfer_length;
|
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
|
|
|
temp = (void *)(uintptr_t)ap->ap_data_transfer_address;
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
mtx_lock(&sc->amr_list_lock);
|
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 = amr_wait_command(ac);
|
2006-04-08 05:08:17 +00:00
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
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 (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
status = ac->ac_status;
|
|
|
|
error = copyout(&status, &((struct amr_passthrough *)(uintptr_t)mb->mb_physaddr)->ap_scsi_status, sizeof(status));
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ali.outlen) {
|
|
|
|
error = copyout(dp, temp, ap->ap_data_transfer_length);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
error = copyout(ap->ap_request_sense_area, ((struct amr_passthrough *)(uintptr_t)mb->mb_physaddr)->ap_request_sense_area, ap->ap_request_sense_length);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
} else if (ali.mbox[0] == AMR_CMD_PASS_64) {
|
|
|
|
printf("No AMR_CMD_PASS_64\n");
|
|
|
|
error = ENOIOCTL;
|
|
|
|
break;
|
|
|
|
} else if (ali.mbox[0] == AMR_CMD_EXTPASS) {
|
|
|
|
printf("No AMR_CMD_EXTPASS\n");
|
|
|
|
error = ENOIOCTL;
|
|
|
|
break;
|
|
|
|
} else {
|
2012-04-20 20:27:31 +00:00
|
|
|
len = amr_ioctl_buffer_length(imax(ali.inlen, ali.outlen));
|
2008-01-24 07:26:53 +00:00
|
|
|
|
|
|
|
dp = malloc(len, M_AMR, M_WAITOK | M_ZERO);
|
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 (ali.inlen) {
|
|
|
|
error = copyin((void *)(uintptr_t)mb->mb_physaddr, dp, len);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mtx_lock(&sc->amr_list_lock);
|
|
|
|
while ((ac = amr_alloccmd(sc)) == NULL)
|
|
|
|
msleep(sc, &sc->amr_list_lock, PPAUSE, "amrioc", hz);
|
|
|
|
|
|
|
|
ac_flags = AMR_CMD_DATAIN|AMR_CMD_DATAOUT;
|
|
|
|
bzero(&ac->ac_mailbox, sizeof(ac->ac_mailbox));
|
|
|
|
bcopy(&ali.mbox[0], &ac->ac_mailbox, sizeof(ali.mbox));
|
|
|
|
|
|
|
|
ac->ac_length = len;
|
|
|
|
ac->ac_data = dp;
|
|
|
|
ac->ac_flags = ac_flags;
|
|
|
|
|
|
|
|
error = amr_wait_command(ac);
|
2006-04-08 05:08:17 +00:00
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
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 (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
status = ac->ac_status;
|
|
|
|
error = copyout(&status, &((struct amr_mailbox *)&((struct amr_linux_ioctl *)addr)->mbox[0])->mb_status, sizeof(status));
|
|
|
|
if (ali.outlen) {
|
2012-04-20 20:27:31 +00:00
|
|
|
error = copyout(dp, (void *)(uintptr_t)mb->mb_physaddr, ali.outlen);
|
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 (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
if (logical_drives_changed)
|
|
|
|
amr_rescan_drives(dev);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
debug(1, "unknown linux ioctl 0x%lx", cmd);
|
|
|
|
printf("unknown linux ioctl 0x%lx\n", cmd);
|
|
|
|
error = ENOIOCTL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, we know that there is a lock held and that these
|
|
|
|
* objects have been allocated.
|
|
|
|
*/
|
|
|
|
mtx_lock(&sc->amr_list_lock);
|
|
|
|
if (ac != NULL)
|
|
|
|
amr_releasecmd(ac);
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
if (dp != NULL)
|
2007-12-02 19:54:45 +00:00
|
|
|
free(dp, M_AMR);
|
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(error);
|
|
|
|
}
|
|
|
|
|
2002-09-28 17:15:38 +00:00
|
|
|
static int
|
2009-05-20 17:29:21 +00:00
|
|
|
amr_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_softc *sc = (struct amr_softc *)dev->si_drv1;
|
2004-08-16 17:23:09 +00:00
|
|
|
union {
|
|
|
|
void *_p;
|
|
|
|
struct amr_user_ioctl *au;
|
|
|
|
#ifdef AMR_IO_COMMAND32
|
|
|
|
struct amr_user_ioctl32 *au32;
|
|
|
|
#endif
|
|
|
|
int *result;
|
|
|
|
} arg;
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_command *ac;
|
|
|
|
struct amr_mailbox_ioctl *mbi;
|
2004-08-16 17:23:09 +00:00
|
|
|
void *dp, *au_buffer;
|
2012-04-20 20:27:31 +00:00
|
|
|
unsigned long au_length, real_length;
|
2004-08-16 17:23:09 +00:00
|
|
|
unsigned char *au_cmd;
|
2014-08-08 11:47:09 +00:00
|
|
|
int *au_statusp;
|
2007-12-12 05:55:03 +00:00
|
|
|
int error;
|
2005-03-04 06:11:00 +00:00
|
|
|
struct amr_passthrough *ap; /* 60 bytes */
|
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 logical_drives_changed = 0;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
2004-08-16 17:23:09 +00:00
|
|
|
arg._p = (void *)addr;
|
|
|
|
|
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 = 0;
|
|
|
|
dp = NULL;
|
|
|
|
ac = NULL;
|
|
|
|
ap = NULL;
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
switch(cmd) {
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
case AMR_IO_VERSION:
|
|
|
|
debug(1, "AMR_IO_VERSION");
|
2004-08-16 17:23:09 +00:00
|
|
|
*arg.result = AMR_IO_VERSION_NUMBER;
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
#ifdef AMR_IO_COMMAND32
|
|
|
|
/*
|
|
|
|
* Accept ioctl-s from 32-bit binaries on non-32-bit
|
|
|
|
* platforms, such as AMD. LSI's MEGAMGR utility is
|
|
|
|
* the only example known today... -mi
|
|
|
|
*/
|
|
|
|
case AMR_IO_COMMAND32:
|
|
|
|
debug(1, "AMR_IO_COMMAND32 0x%x", arg.au32->au_cmd[0]);
|
|
|
|
au_cmd = arg.au32->au_cmd;
|
|
|
|
au_buffer = (void *)(u_int64_t)arg.au32->au_buffer;
|
|
|
|
au_length = arg.au32->au_length;
|
|
|
|
au_statusp = &arg.au32->au_status;
|
2000-08-30 07:52:50 +00:00
|
|
|
break;
|
2004-08-16 17:23:09 +00:00
|
|
|
#endif
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
case AMR_IO_COMMAND:
|
2004-08-16 17:23:09 +00:00
|
|
|
debug(1, "AMR_IO_COMMAND 0x%x", arg.au->au_cmd[0]);
|
|
|
|
au_cmd = arg.au->au_cmd;
|
|
|
|
au_buffer = (void *)arg.au->au_buffer;
|
|
|
|
au_length = arg.au->au_length;
|
|
|
|
au_statusp = &arg.au->au_status;
|
|
|
|
break;
|
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
|
|
|
case 0xc0046d00:
|
|
|
|
case 0xc06e6d00: /* Linux emulation */
|
2006-05-03 16:45:15 +00:00
|
|
|
{
|
|
|
|
devclass_t devclass;
|
|
|
|
struct amr_linux_ioctl ali;
|
|
|
|
int adapter, error;
|
|
|
|
|
|
|
|
devclass = devclass_find("amr");
|
|
|
|
if (devclass == NULL)
|
|
|
|
return (ENOENT);
|
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
|
|
|
|
2006-05-03 16:45:15 +00:00
|
|
|
error = copyin(addr, &ali, sizeof(ali));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (ali.ui.fcs.opcode == 0x82)
|
|
|
|
adapter = 0;
|
|
|
|
else
|
|
|
|
adapter = (ali.ui.fcs.adapno) ^ 'm' << 8;
|
|
|
|
|
|
|
|
sc = devclass_get_softc(devclass, adapter);
|
|
|
|
if (sc == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
return (amr_linux_ioctl_int(sc->amr_dev_t, cmd, addr, 0, td));
|
2006-05-03 16:45:15 +00:00
|
|
|
}
|
2004-08-16 17:23:09 +00:00
|
|
|
default:
|
|
|
|
debug(1, "unknown ioctl 0x%lx", cmd);
|
|
|
|
return(ENOIOCTL);
|
|
|
|
}
|
|
|
|
|
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 ((au_cmd[0] == FC_DEL_LOGDRV && au_cmd[1] == OP_DEL_LOGDRV) || /* delete */
|
|
|
|
(au_cmd[0] == AMR_CMD_CONFIG && au_cmd[1] == 0x0d)) { /* create */
|
|
|
|
if (sc->amr_allow_vol_config == 0) {
|
|
|
|
error = EPERM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
logical_drives_changed = 1;
|
|
|
|
#ifdef LSI
|
|
|
|
if ((error = amr_prepare_ld_delete(sc)) != 0)
|
|
|
|
return (error);
|
|
|
|
#endif
|
|
|
|
}
|
2005-01-23 23:25:41 +00:00
|
|
|
|
2004-08-16 17:23:09 +00:00
|
|
|
/* handle inbound data buffer */
|
2012-04-20 20:27:31 +00:00
|
|
|
real_length = amr_ioctl_buffer_length(au_length);
|
2012-09-19 11:54:32 +00:00
|
|
|
dp = malloc(real_length, M_AMR, M_WAITOK|M_ZERO);
|
2005-01-23 23:25:41 +00:00
|
|
|
if (au_length != 0 && au_cmd[0] != 0x06) {
|
2005-01-16 07:34:26 +00:00
|
|
|
if ((error = copyin(au_buffer, dp, au_length)) != 0) {
|
2007-12-02 19:54:45 +00:00
|
|
|
free(dp, M_AMR);
|
2005-01-16 07:34:26 +00:00
|
|
|
return (error);
|
|
|
|
}
|
2004-08-16 17:23:09 +00:00
|
|
|
debug(2, "copyin %ld bytes from %p -> %p", au_length, au_buffer, dp);
|
|
|
|
}
|
|
|
|
|
2005-03-13 06:25:53 +00:00
|
|
|
/* Allocate this now before the mutex gets held */
|
|
|
|
|
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_lock(&sc->amr_list_lock);
|
|
|
|
while ((ac = amr_alloccmd(sc)) == NULL)
|
|
|
|
msleep(sc, &sc->amr_list_lock, PPAUSE, "amrioc", hz);
|
2004-08-16 17:23:09 +00:00
|
|
|
|
|
|
|
/* handle SCSI passthrough command */
|
|
|
|
if (au_cmd[0] == AMR_CMD_PASS) {
|
2005-01-16 07:34:26 +00:00
|
|
|
int len;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
ap = &ac->ac_ccb->ccb_pthru;
|
|
|
|
bzero(ap, sizeof(struct amr_passthrough));
|
|
|
|
|
2004-08-16 17:23:09 +00:00
|
|
|
/* copy cdb */
|
2005-01-16 07:34:26 +00:00
|
|
|
len = au_cmd[2];
|
2005-03-04 06:11:00 +00:00
|
|
|
ap->ap_cdb_length = len;
|
|
|
|
bcopy(au_cmd + 3, ap->ap_cdb, len);
|
2004-08-16 17:23:09 +00:00
|
|
|
|
|
|
|
/* build passthrough */
|
2005-03-04 06:11:00 +00:00
|
|
|
ap->ap_timeout = au_cmd[len + 3] & 0x07;
|
|
|
|
ap->ap_ars = (au_cmd[len + 3] & 0x08) ? 1 : 0;
|
|
|
|
ap->ap_islogical = (au_cmd[len + 3] & 0x80) ? 1 : 0;
|
|
|
|
ap->ap_logical_drive_no = au_cmd[len + 4];
|
|
|
|
ap->ap_channel = au_cmd[len + 5];
|
|
|
|
ap->ap_scsi_id = au_cmd[len + 6];
|
|
|
|
ap->ap_request_sense_length = 14;
|
|
|
|
ap->ap_data_transfer_length = au_length;
|
2004-08-16 17:23:09 +00:00
|
|
|
/* XXX what about the request-sense area? does the caller want it? */
|
|
|
|
|
|
|
|
/* build command */
|
|
|
|
ac->ac_mailbox.mb_command = AMR_CMD_PASS;
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_flags = AMR_CMD_CCB;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2004-08-16 17:23:09 +00:00
|
|
|
} else {
|
|
|
|
/* direct command to controller */
|
|
|
|
mbi = (struct amr_mailbox_ioctl *)&ac->ac_mailbox;
|
|
|
|
|
|
|
|
/* copy pertinent mailbox items */
|
|
|
|
mbi->mb_command = au_cmd[0];
|
|
|
|
mbi->mb_channel = au_cmd[1];
|
|
|
|
mbi->mb_param = au_cmd[2];
|
|
|
|
mbi->mb_pad[0] = au_cmd[3];
|
|
|
|
mbi->mb_drive = au_cmd[4];
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_flags = 0;
|
2004-08-16 17:23:09 +00:00
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
/* build the command */
|
|
|
|
ac->ac_data = dp;
|
2012-04-20 20:27:31 +00:00
|
|
|
ac->ac_length = real_length;
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_DATAIN|AMR_CMD_DATAOUT;
|
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
|
|
|
|
2004-08-16 17:23:09 +00:00
|
|
|
/* run the command */
|
2006-04-08 05:08:17 +00:00
|
|
|
error = amr_wait_command(ac);
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
if (error)
|
2004-08-16 17:23:09 +00:00
|
|
|
goto out;
|
2002-10-18 21:29:14 +00:00
|
|
|
|
2004-08-16 17:23:09 +00:00
|
|
|
/* copy out data and set status */
|
2005-01-16 07:34:26 +00:00
|
|
|
if (au_length != 0) {
|
2004-08-16 17:23:09 +00:00
|
|
|
error = copyout(dp, au_buffer, au_length);
|
2005-01-16 07:34:26 +00:00
|
|
|
}
|
2004-08-16 17:23:09 +00:00
|
|
|
debug(2, "copyout %ld bytes from %p -> %p", au_length, dp, au_buffer);
|
2012-09-19 11:54:32 +00:00
|
|
|
debug(2, "%p status 0x%x", dp, ac->ac_status);
|
2004-08-16 17:23:09 +00:00
|
|
|
*au_statusp = ac->ac_status;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2004-08-16 17:23:09 +00:00
|
|
|
out:
|
2005-01-16 07:34:26 +00:00
|
|
|
/*
|
|
|
|
* At this point, we know that there is a lock held and that these
|
|
|
|
* objects have been allocated.
|
|
|
|
*/
|
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_lock(&sc->amr_list_lock);
|
2005-03-13 06:25:53 +00:00
|
|
|
if (ac != NULL)
|
|
|
|
amr_releasecmd(ac);
|
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_unlock(&sc->amr_list_lock);
|
2005-03-13 06:25:53 +00:00
|
|
|
if (dp != NULL)
|
2007-12-02 19:54:45 +00:00
|
|
|
free(dp, M_AMR);
|
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
|
|
|
|
|
|
|
#ifndef LSI
|
|
|
|
if (logical_drives_changed)
|
|
|
|
amr_rescan_drives(dev);
|
|
|
|
#endif
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
return(error);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
********************************************************************************
|
|
|
|
Command Wrappers
|
|
|
|
********************************************************************************
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Interrogate the controller for the operational parameters we require.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_query_controller(struct amr_softc *sc)
|
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_enquiry3 *aex;
|
|
|
|
struct amr_prodinfo *ap;
|
|
|
|
struct amr_enquiry *ae;
|
|
|
|
int ldrv;
|
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 status;
|
2005-01-16 07:34:26 +00:00
|
|
|
|
2002-10-30 22:00:11 +00:00
|
|
|
/*
|
|
|
|
* Greater than 10 byte cdb support
|
|
|
|
*/
|
|
|
|
sc->support_ext_cdb = amr_support_ext_cdb(sc);
|
|
|
|
|
|
|
|
if(sc->support_ext_cdb) {
|
|
|
|
debug(2,"supports extended CDBs.");
|
|
|
|
}
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Try to issue an ENQUIRY3 command
|
|
|
|
*/
|
|
|
|
if ((aex = amr_enquiry(sc, 2048, AMR_CMD_CONFIG, AMR_CONFIG_ENQ3,
|
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
|
|
|
AMR_CONFIG_ENQ3_SOLICITED_FULL, &status)) != NULL) {
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Fetch current state of logical drives.
|
|
|
|
*/
|
|
|
|
for (ldrv = 0; ldrv < aex->ae_numldrives; ldrv++) {
|
|
|
|
sc->amr_drive[ldrv].al_size = aex->ae_drivesize[ldrv];
|
|
|
|
sc->amr_drive[ldrv].al_state = aex->ae_drivestate[ldrv];
|
|
|
|
sc->amr_drive[ldrv].al_properties = aex->ae_driveprop[ldrv];
|
|
|
|
debug(2, " drive %d: %d state %x properties %x\n", ldrv, sc->amr_drive[ldrv].al_size,
|
|
|
|
sc->amr_drive[ldrv].al_state, sc->amr_drive[ldrv].al_properties);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2007-12-02 19:54:45 +00:00
|
|
|
free(aex, M_AMR);
|
2000-04-01 00:35:15 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Get product info for channel count.
|
2000-04-01 00:35:15 +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 ((ap = amr_enquiry(sc, 2048, AMR_CMD_CONFIG, AMR_CONFIG_PRODUCT_INFO, 0, &status)) == NULL) {
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "can't obtain product data from controller\n");
|
|
|
|
return(1);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
sc->amr_maxdrives = 40;
|
|
|
|
sc->amr_maxchan = ap->ap_nschan;
|
|
|
|
sc->amr_maxio = ap->ap_maxio;
|
|
|
|
sc->amr_type |= AMR_TYPE_40LD;
|
2007-12-02 19:54:45 +00:00
|
|
|
free(ap, M_AMR);
|
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
|
|
|
ap = amr_enquiry(sc, 0, FC_DEL_LOGDRV, OP_SUP_DEL_LOGDRV, 0, &status);
|
2006-01-10 01:55:17 +00:00
|
|
|
if (ap != NULL)
|
2007-12-02 19:54:45 +00:00
|
|
|
free(ap, M_AMR);
|
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 (!status) {
|
|
|
|
sc->amr_ld_del_supported = 1;
|
|
|
|
device_printf(sc->amr_dev, "delete logical drives supported by controller\n");
|
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
} else {
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/* failed, try the 8LD ENQUIRY commands */
|
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 ((ae = (struct amr_enquiry *)amr_enquiry(sc, 2048, AMR_CMD_EXT_ENQUIRY2, 0, 0, &status)) == NULL) {
|
|
|
|
if ((ae = (struct amr_enquiry *)amr_enquiry(sc, 2048, AMR_CMD_ENQUIRY, 0, 0, &status)) == NULL) {
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "can't obtain configuration data from controller\n");
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
ae->ae_signature = 0;
|
|
|
|
}
|
|
|
|
|
2000-04-01 00:35:15 +00:00
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Fetch current state of logical drives.
|
2000-04-01 00:35:15 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
for (ldrv = 0; ldrv < ae->ae_ldrv.al_numdrives; ldrv++) {
|
|
|
|
sc->amr_drive[ldrv].al_size = ae->ae_ldrv.al_size[ldrv];
|
|
|
|
sc->amr_drive[ldrv].al_state = ae->ae_ldrv.al_state[ldrv];
|
|
|
|
sc->amr_drive[ldrv].al_properties = ae->ae_ldrv.al_properties[ldrv];
|
|
|
|
debug(2, " drive %d: %d state %x properties %x\n", ldrv, sc->amr_drive[ldrv].al_size,
|
|
|
|
sc->amr_drive[ldrv].al_state, sc->amr_drive[ldrv].al_properties);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
sc->amr_maxdrives = 8;
|
|
|
|
sc->amr_maxchan = ae->ae_adapter.aa_channels;
|
|
|
|
sc->amr_maxio = ae->ae_adapter.aa_maxio;
|
2007-12-02 19:54:45 +00:00
|
|
|
free(ae, M_AMR);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark remaining drives as unused.
|
|
|
|
*/
|
|
|
|
for (; ldrv < AMR_MAXLD; ldrv++)
|
|
|
|
sc->amr_drive[ldrv].al_size = 0xffffffff;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cap the maximum number of outstanding I/Os. AMI's Linux driver doesn't trust
|
|
|
|
* the controller's reported value, and lockups have been seen when we do.
|
|
|
|
*/
|
|
|
|
sc->amr_maxio = imin(sc->amr_maxio, AMR_LIMITCMD);
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Run a generic enquiry-style command.
|
|
|
|
*/
|
|
|
|
static void *
|
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
|
|
|
amr_enquiry(struct amr_softc *sc, size_t bufsize, u_int8_t cmd, u_int8_t cmdsub, u_int8_t cmdqual, int *status)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
void *result;
|
|
|
|
u_int8_t *mbox;
|
|
|
|
int error;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(1);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
error = 1;
|
|
|
|
result = NULL;
|
|
|
|
|
|
|
|
/* get ourselves a command buffer */
|
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_lock(&sc->amr_list_lock);
|
|
|
|
ac = amr_alloccmd(sc);
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
if (ac == NULL)
|
1999-10-07 02:23:12 +00:00
|
|
|
goto out;
|
|
|
|
/* allocate the response structure */
|
2007-12-02 19:54:45 +00:00
|
|
|
if ((result = malloc(bufsize, M_AMR, M_ZERO|M_NOWAIT)) == NULL)
|
1999-10-07 02:23:12 +00:00
|
|
|
goto out;
|
2000-08-30 07:52:50 +00:00
|
|
|
/* set command flags */
|
2004-12-05 23:48:17 +00:00
|
|
|
|
2004-09-14 16:36:12 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAIN;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* point the command at our data */
|
1999-10-07 02:23:12 +00:00
|
|
|
ac->ac_data = result;
|
|
|
|
ac->ac_length = bufsize;
|
|
|
|
|
|
|
|
/* build the command proper */
|
|
|
|
mbox = (u_int8_t *)&ac->ac_mailbox; /* XXX want a real structure for this? */
|
|
|
|
mbox[0] = cmd;
|
|
|
|
mbox[2] = cmdsub;
|
|
|
|
mbox[3] = cmdqual;
|
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
|
|
|
*status = 0;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-04-01 00:35:15 +00:00
|
|
|
/* can't assume that interrupts are going to work here, so play it safe */
|
2002-12-11 20:59:46 +00:00
|
|
|
if (sc->amr_poll_command(ac))
|
1999-10-07 02:23:12 +00:00
|
|
|
goto out;
|
|
|
|
error = ac->ac_status;
|
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
|
|
|
*status = ac->ac_status;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
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
|
|
|
mtx_lock(&sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
if (ac != NULL)
|
|
|
|
amr_releasecmd(ac);
|
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_unlock(&sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
if ((error != 0) && (result != NULL)) {
|
2007-12-02 19:54:45 +00:00
|
|
|
free(result, M_AMR);
|
1999-10-07 02:23:12 +00:00
|
|
|
result = NULL;
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Flush the controller's internal cache, return status.
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
int
|
1999-10-07 02:23:12 +00:00
|
|
|
amr_flush(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* get ourselves a command buffer */
|
|
|
|
error = 1;
|
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_lock(&sc->amr_list_lock);
|
|
|
|
ac = amr_alloccmd(sc);
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
if (ac == NULL)
|
1999-10-07 02:23:12 +00:00
|
|
|
goto out;
|
2000-08-30 07:52:50 +00:00
|
|
|
/* set command flags */
|
1999-10-07 02:23:12 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT;
|
|
|
|
|
|
|
|
/* build the command proper */
|
|
|
|
ac->ac_mailbox.mb_command = AMR_CMD_FLUSH;
|
|
|
|
|
2000-04-01 00:35:15 +00:00
|
|
|
/* we have to poll, as the system may be going down or otherwise damaged */
|
2002-12-11 20:59:46 +00:00
|
|
|
if (sc->amr_poll_command(ac))
|
1999-10-07 02:23:12 +00:00
|
|
|
goto out;
|
|
|
|
error = ac->ac_status;
|
|
|
|
|
|
|
|
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
|
|
|
mtx_lock(&sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
if (ac != NULL)
|
|
|
|
amr_releasecmd(ac);
|
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_unlock(&sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
2002-10-30 22:00:11 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Detect extented cdb >> greater than 10 byte cdb support
|
|
|
|
* returns '1' means this support exist
|
|
|
|
* returns '0' means this support doesn't exist
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_support_ext_cdb(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
u_int8_t *mbox;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* get ourselves a command buffer */
|
|
|
|
error = 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
|
|
|
mtx_lock(&sc->amr_list_lock);
|
|
|
|
ac = amr_alloccmd(sc);
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
if (ac == NULL)
|
2002-10-30 22:00:11 +00:00
|
|
|
goto out;
|
|
|
|
/* set command flags */
|
|
|
|
ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT;
|
|
|
|
|
|
|
|
/* build the command proper */
|
|
|
|
mbox = (u_int8_t *)&ac->ac_mailbox; /* XXX want a real structure for this? */
|
|
|
|
mbox[0] = 0xA4;
|
|
|
|
mbox[2] = 0x16;
|
|
|
|
|
|
|
|
|
|
|
|
/* we have to poll, as the system may be going down or otherwise damaged */
|
2002-12-11 20:59:46 +00:00
|
|
|
if (sc->amr_poll_command(ac))
|
2002-10-30 22:00:11 +00:00
|
|
|
goto out;
|
|
|
|
if( ac->ac_status == AMR_STATUS_SUCCESS ) {
|
|
|
|
error = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
mtx_lock(&sc->amr_list_lock);
|
2002-10-30 22:00:11 +00:00
|
|
|
if (ac != NULL)
|
|
|
|
amr_releasecmd(ac);
|
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_unlock(&sc->amr_list_lock);
|
2002-10-30 22:00:11 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
2000-08-30 07:52:50 +00:00
|
|
|
* Try to find I/O work for the controller from one or more of the work queues.
|
1999-10-07 02:23:12 +00:00
|
|
|
*
|
2000-08-30 07:52:50 +00:00
|
|
|
* We make the assumption that if the controller is not ready to take a command
|
|
|
|
* at some given time, it will generate an interrupt at some later time when
|
|
|
|
* it is.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
void
|
1999-10-07 02:23:12 +00:00
|
|
|
amr_startio(struct amr_softc *sc)
|
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_command *ac;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* spin until something prevents us from doing any work */
|
|
|
|
for (;;) {
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
/* Don't bother to queue commands no bounce buffers are available. */
|
|
|
|
if (sc->amr_state & AMR_STATE_QUEUE_FRZN)
|
|
|
|
break;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* try to get a ready command */
|
|
|
|
ac = amr_dequeue_ready(sc);
|
|
|
|
|
|
|
|
/* if that failed, build a command from a bio */
|
|
|
|
if (ac == NULL)
|
|
|
|
(void)amr_bio_command(sc, &ac);
|
|
|
|
|
|
|
|
/* if that failed, build a command from a ccb */
|
2008-11-03 00:53:54 +00:00
|
|
|
if ((ac == NULL) && (sc->amr_cam_command != NULL))
|
|
|
|
sc->amr_cam_command(sc, &ac);
|
2002-10-18 21:29:14 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* if we don't have anything to do, give up */
|
|
|
|
if (ac == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* try to give the command to the controller; if this fails save it for later and give up */
|
|
|
|
if (amr_start(ac)) {
|
|
|
|
debug(2, "controller busy, command deferred");
|
|
|
|
amr_requeue_ready(ac); /* XXX schedule retry very soon? */
|
|
|
|
break;
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Handle completion of an I/O command.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
amr_completeio(struct amr_command *ac)
|
|
|
|
{
|
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 amrd_softc *sc = ac->ac_bio->bio_disk->d_drv1;
|
|
|
|
static struct timeval lastfail;
|
|
|
|
static int curfail;
|
2005-01-16 07:34:26 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
if (ac->ac_status != AMR_STATUS_SUCCESS) { /* could be more verbose here? */
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_bio->bio_error = EIO;
|
|
|
|
ac->ac_bio->bio_flags |= BIO_ERROR;
|
2000-04-01 00:35:15 +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 (ppsratecheck(&lastfail, &curfail, 1))
|
|
|
|
device_printf(sc->amrd_dev, "I/O error - 0x%x\n", ac->ac_status);
|
2000-08-30 07:52:50 +00:00
|
|
|
/* amr_printcommand(ac);*/
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
amrd_intr(ac->ac_bio);
|
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_lock(&ac->ac_sc->amr_list_lock);
|
2000-08-30 07:52:50 +00:00
|
|
|
amr_releasecmd(ac);
|
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_unlock(&ac->ac_sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
********************************************************************************
|
|
|
|
Command Processing
|
|
|
|
********************************************************************************
|
|
|
|
********************************************************************************/
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Convert a bio off the top of the bio queue into a command.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_bio_command(struct amr_softc *sc, struct amr_command **acp)
|
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
struct amrd_softc *amrd;
|
|
|
|
struct bio *bio;
|
|
|
|
int error;
|
|
|
|
int blkcount;
|
|
|
|
int driveno;
|
|
|
|
int cmd;
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
ac = NULL;
|
2000-08-30 07:52:50 +00:00
|
|
|
error = 0;
|
|
|
|
|
2005-01-16 07:34:26 +00:00
|
|
|
/* get a command */
|
|
|
|
if ((ac = amr_alloccmd(sc)) == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* get a bio to work on */
|
2005-01-16 07:34:26 +00:00
|
|
|
if ((bio = amr_dequeue_bio(sc)) == NULL) {
|
|
|
|
amr_releasecmd(ac);
|
|
|
|
return (0);
|
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/* connect the bio to the command */
|
|
|
|
ac->ac_complete = amr_completeio;
|
|
|
|
ac->ac_bio = bio;
|
|
|
|
ac->ac_data = bio->bio_data;
|
|
|
|
ac->ac_length = bio->bio_bcount;
|
2006-10-31 21:19:25 +00:00
|
|
|
cmd = 0;
|
|
|
|
switch (bio->bio_cmd) {
|
|
|
|
case BIO_READ:
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_DATAIN;
|
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)) {
|
|
|
|
cmd = AMR_CMD_LREAD64;
|
|
|
|
ac->ac_flags |= AMR_CMD_SG64;
|
|
|
|
} else
|
|
|
|
cmd = AMR_CMD_LREAD;
|
2006-10-31 21:19:25 +00:00
|
|
|
break;
|
|
|
|
case BIO_WRITE:
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_DATAOUT;
|
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)) {
|
|
|
|
cmd = AMR_CMD_LWRITE64;
|
|
|
|
ac->ac_flags |= AMR_CMD_SG64;
|
|
|
|
} else
|
|
|
|
cmd = AMR_CMD_LWRITE;
|
2006-10-31 21:19:25 +00:00
|
|
|
break;
|
|
|
|
case BIO_FLUSH:
|
|
|
|
ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT;
|
|
|
|
cmd = AMR_CMD_FLUSH;
|
|
|
|
break;
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
2003-02-24 21:49:27 +00:00
|
|
|
amrd = (struct amrd_softc *)bio->bio_disk->d_drv1;
|
2000-08-30 07:52:50 +00:00
|
|
|
driveno = amrd->amrd_drive - sc->amr_drive;
|
2016-04-26 15:03:15 +00:00
|
|
|
blkcount = howmany(bio->bio_bcount, AMR_BLKSIZE);
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
ac->ac_mailbox.mb_command = cmd;
|
2016-03-10 00:36:52 +00:00
|
|
|
if (bio->bio_cmd == BIO_READ || bio->bio_cmd == BIO_WRITE) {
|
2006-10-31 21:19:25 +00:00
|
|
|
ac->ac_mailbox.mb_blkcount = blkcount;
|
|
|
|
ac->ac_mailbox.mb_lba = bio->bio_pblkno;
|
|
|
|
if ((bio->bio_pblkno + blkcount) > sc->amr_drive[driveno].al_size) {
|
|
|
|
device_printf(sc->amr_dev,
|
|
|
|
"I/O beyond end of unit (%lld,%d > %lu)\n",
|
|
|
|
(long long)bio->bio_pblkno, blkcount,
|
|
|
|
(u_long)sc->amr_drive[driveno].al_size);
|
|
|
|
}
|
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_mailbox.mb_drive = driveno;
|
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_state & AMR_STATE_REMAP_LD)
|
|
|
|
ac->ac_mailbox.mb_drive |= 0x80;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* we fill in the s/g related data when the command is mapped */
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
*acp = ac;
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Take a command, submit it to the controller and sleep until it completes
|
|
|
|
* or fails. Interrupts must be enabled, returns nonzero on error.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_wait_command(struct amr_command *ac)
|
|
|
|
{
|
2005-07-29 01:47:36 +00:00
|
|
|
int error = 0;
|
2006-04-08 02:23:27 +00:00
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(1);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
ac->ac_complete = NULL;
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_SLEEP;
|
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 ((error = amr_start(ac)) != 0) {
|
1999-10-07 02:23:12 +00:00
|
|
|
return(error);
|
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
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2005-07-29 01:47:36 +00:00
|
|
|
while ((ac->ac_flags & AMR_CMD_BUSY) && (error != EWOULDBLOCK)) {
|
2006-04-08 05:08:17 +00:00
|
|
|
error = msleep(ac,&sc->amr_list_lock, PRIBIO, "amrwcmd", 0);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2006-04-08 02:23:27 +00:00
|
|
|
|
2005-07-29 01:47:36 +00:00
|
|
|
return(error);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Take a command, submit it to the controller and busy-wait for it to return.
|
|
|
|
* Returns nonzero on error. Can be safely called with interrupts enabled.
|
|
|
|
*/
|
|
|
|
static int
|
2002-12-11 20:59:46 +00:00
|
|
|
amr_std_poll_command(struct amr_command *ac)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
2000-08-30 07:52:50 +00:00
|
|
|
int error, count;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(2);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
ac->ac_complete = NULL;
|
|
|
|
if ((error = amr_start(ac)) != 0)
|
|
|
|
return(error);
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
do {
|
|
|
|
/*
|
|
|
|
* Poll for completion, although the interrupt handler may beat us to it.
|
|
|
|
* Note that the timeout here is somewhat arbitrary.
|
|
|
|
*/
|
|
|
|
amr_done(sc);
|
2000-08-30 07:52:50 +00:00
|
|
|
DELAY(1000);
|
|
|
|
} while ((ac->ac_flags & AMR_CMD_BUSY) && (count++ < 1000));
|
|
|
|
if (!(ac->ac_flags & AMR_CMD_BUSY)) {
|
1999-10-07 02:23:12 +00:00
|
|
|
error = 0;
|
|
|
|
} else {
|
2000-08-30 07:52:50 +00:00
|
|
|
/* XXX the slot is now marked permanently busy */
|
1999-10-07 02:23:12 +00:00
|
|
|
error = EIO;
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "polled command timeout\n");
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
static void
|
|
|
|
amr_setup_polled_dmamap(void *arg, bus_dma_segment_t *segs, int nsegs, int err)
|
|
|
|
{
|
|
|
|
struct amr_command *ac = arg;
|
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
2007-12-12 05:55:03 +00:00
|
|
|
int mb_channel;
|
2004-12-05 23:48:17 +00:00
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
if (err) {
|
|
|
|
device_printf(sc->amr_dev, "error %d in %s", err, __FUNCTION__);
|
|
|
|
ac->ac_status = AMR_STATUS_ABORTED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
amr_setup_sg(arg, segs, nsegs, err);
|
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
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
/* for AMR_CMD_CONFIG Read/Write the s/g count goes elsewhere */
|
|
|
|
mb_channel = ((struct amr_mailbox_ioctl *)&ac->ac_mailbox)->mb_channel;
|
|
|
|
if (ac->ac_mailbox.mb_command == AMR_CMD_CONFIG &&
|
|
|
|
((mb_channel == AMR_CONFIG_READ_NVRAM_CONFIG) ||
|
|
|
|
(mb_channel == AMR_CONFIG_WRITE_NVRAM_CONFIG)))
|
|
|
|
((struct amr_mailbox_ioctl *)&ac->ac_mailbox)->mb_param = ac->ac_nsegments;
|
|
|
|
|
|
|
|
ac->ac_mailbox.mb_nsgelem = ac->ac_nsegments;
|
|
|
|
ac->ac_mailbox.mb_physaddr = ac->ac_mb_physaddr;
|
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 (AC_IS_SG64(ac)) {
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_sg64_hi = 0;
|
|
|
|
ac->ac_sg64_lo = ac->ac_sgbusaddr;
|
2005-06-23 00:21:25 +00:00
|
|
|
}
|
2007-12-12 05:55:03 +00:00
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
sc->amr_poll_command1(sc, ac);
|
|
|
|
}
|
|
|
|
|
2002-12-11 20:59:46 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Take a command, submit it to the controller and busy-wait for it to return.
|
|
|
|
* Returns nonzero on error. Can be safely called with interrupts enabled.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_quartz_poll_command(struct amr_command *ac)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
2005-11-06 15:13:42 +00:00
|
|
|
int error;
|
2002-12-11 20:59:46 +00:00
|
|
|
|
|
|
|
debug_called(2);
|
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
error = 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
|
|
|
if (AC_IS_SG64(ac)) {
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_tag = sc->amr_buffer64_dmat;
|
|
|
|
ac->ac_datamap = ac->ac_dma64map;
|
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
|
|
|
} else {
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_tag = sc->amr_buffer_dmat;
|
|
|
|
ac->ac_datamap = ac->ac_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
|
|
|
}
|
|
|
|
|
2002-12-11 20:59:46 +00:00
|
|
|
/* now we have a slot, we can map the command (unmapped in amr_complete) */
|
2004-12-05 23:48:17 +00:00
|
|
|
if (ac->ac_data != 0) {
|
2007-12-12 05:55:03 +00:00
|
|
|
if (bus_dmamap_load(ac->ac_tag, ac->ac_datamap, ac->ac_data,
|
|
|
|
ac->ac_length, amr_setup_polled_dmamap, ac, BUS_DMA_NOWAIT) != 0) {
|
2004-12-05 23:48:17 +00:00
|
|
|
error = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error = amr_quartz_poll_command1(sc, ac);
|
|
|
|
}
|
2002-12-11 20:59:46 +00:00
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
amr_quartz_poll_command1(struct amr_softc *sc, struct amr_command *ac)
|
|
|
|
{
|
|
|
|
int count, error;
|
2002-12-11 20:59:46 +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
|
|
|
mtx_lock(&sc->amr_hw_lock);
|
2005-01-23 23:25:41 +00:00
|
|
|
if ((sc->amr_state & AMR_STATE_INTEN) == 0) {
|
2003-10-10 22:49:40 +00:00
|
|
|
count=0;
|
|
|
|
while (sc->amr_busyslots) {
|
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
|
|
|
msleep(sc, &sc->amr_hw_lock, PRIBIO | PCATCH, "amrpoll", hz);
|
2003-10-10 22:49:40 +00:00
|
|
|
if(count++>10) {
|
|
|
|
break;
|
|
|
|
}
|
2003-01-09 21:02:28 +00:00
|
|
|
}
|
|
|
|
|
2003-10-10 22:49:40 +00:00
|
|
|
if(sc->amr_busyslots) {
|
|
|
|
device_printf(sc->amr_dev, "adapter is busy\n");
|
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_unlock(&sc->amr_hw_lock);
|
|
|
|
if (ac->ac_data != NULL) {
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dmamap_unload(ac->ac_tag, ac->ac_datamap);
|
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
|
|
|
}
|
2003-10-10 22:49:40 +00:00
|
|
|
ac->ac_status=0;
|
|
|
|
return(1);
|
|
|
|
}
|
2002-12-11 20:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bcopy(&ac->ac_mailbox, (void *)(uintptr_t)(volatile void *)sc->amr_mailbox, AMR_MBOX_CMDSIZE);
|
|
|
|
|
|
|
|
/* clear the poll/ack fields in the mailbox */
|
|
|
|
sc->amr_mailbox->mb_ident = 0xFE;
|
|
|
|
sc->amr_mailbox->mb_nstatus = 0xFF;
|
|
|
|
sc->amr_mailbox->mb_status = 0xFF;
|
|
|
|
sc->amr_mailbox->mb_poll = 0;
|
|
|
|
sc->amr_mailbox->mb_ack = 0;
|
2003-01-09 21:02:28 +00:00
|
|
|
sc->amr_mailbox->mb_busy = 1;
|
2002-12-11 20:59:46 +00:00
|
|
|
|
|
|
|
AMR_QPUT_IDB(sc, sc->amr_mailboxphys | AMR_QIDB_SUBMIT);
|
|
|
|
|
2006-02-02 17:50:59 +00:00
|
|
|
while(sc->amr_mailbox->mb_nstatus == 0xFF)
|
|
|
|
DELAY(1);
|
|
|
|
while(sc->amr_mailbox->mb_status == 0xFF)
|
|
|
|
DELAY(1);
|
2002-12-13 17:27:44 +00:00
|
|
|
ac->ac_status=sc->amr_mailbox->mb_status;
|
|
|
|
error = (ac->ac_status !=AMR_STATUS_SUCCESS) ? 1:0;
|
2006-02-02 17:50:59 +00:00
|
|
|
while(sc->amr_mailbox->mb_poll != 0x77)
|
|
|
|
DELAY(1);
|
2002-12-11 20:59:46 +00:00
|
|
|
sc->amr_mailbox->mb_poll = 0;
|
|
|
|
sc->amr_mailbox->mb_ack = 0x77;
|
|
|
|
|
|
|
|
/* acknowledge that we have the commands */
|
|
|
|
AMR_QPUT_IDB(sc, sc->amr_mailboxphys | AMR_QIDB_ACK);
|
2006-02-02 17:50:59 +00:00
|
|
|
while(AMR_QGET_IDB(sc) & AMR_QIDB_ACK)
|
|
|
|
DELAY(1);
|
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_unlock(&sc->amr_hw_lock);
|
2002-12-11 20:59:46 +00:00
|
|
|
|
|
|
|
/* unmap the command's data buffer */
|
2005-06-23 00:21:25 +00:00
|
|
|
if (ac->ac_flags & AMR_CMD_DATAIN) {
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dmamap_sync(ac->ac_tag, ac->ac_datamap, BUS_DMASYNC_POSTREAD);
|
2005-06-23 00:21:25 +00:00
|
|
|
}
|
|
|
|
if (ac->ac_flags & AMR_CMD_DATAOUT) {
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dmamap_sync(ac->ac_tag, ac->ac_datamap, BUS_DMASYNC_POSTWRITE);
|
2005-06-23 00:21:25 +00:00
|
|
|
}
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dmamap_unload(ac->ac_tag, ac->ac_datamap);
|
2002-12-11 20:59:46 +00:00
|
|
|
|
2002-12-13 17:27:44 +00:00
|
|
|
return(error);
|
2002-12-11 20:59:46 +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 __inline int
|
|
|
|
amr_freeslot(struct amr_command *ac)
|
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_softc *sc = ac->ac_sc;
|
|
|
|
int slot;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
debug_called(3);
|
|
|
|
|
2005-01-16 07:34:26 +00:00
|
|
|
slot = ac->ac_slot;
|
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_busycmd[slot] == NULL)
|
|
|
|
panic("amr: slot %d not busy?\n", slot);
|
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
|
|
|
sc->amr_busycmd[slot] = NULL;
|
|
|
|
atomic_subtract_int(&sc->amr_busyslots, 1);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2005-01-16 07:34:26 +00:00
|
|
|
return (0);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
2000-08-30 07:52:50 +00:00
|
|
|
* Map/unmap (ac)'s data in the controller's addressable space as required.
|
|
|
|
*
|
|
|
|
* These functions may be safely called multiple times on a given command.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
|
|
|
static void
|
2007-12-12 05:55:03 +00:00
|
|
|
amr_setup_sg(void *arg, bus_dma_segment_t *segs, int nsegments, int error)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
|
|
|
struct amr_command *ac = (struct amr_command *)arg;
|
|
|
|
struct amr_sgentry *sg;
|
2007-12-12 05:55:03 +00:00
|
|
|
struct amr_sg64entry *sg64;
|
|
|
|
int flags, i;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(3);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* get base address of s/g table */
|
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
|
|
|
sg = ac->ac_sg.sg32;
|
2007-12-12 05:55:03 +00:00
|
|
|
sg64 = ac->ac_sg.sg64;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
if (AC_IS_SG64(ac)) {
|
|
|
|
ac->ac_nsegments = nsegments;
|
|
|
|
ac->ac_mb_physaddr = 0xffffffff;
|
|
|
|
for (i = 0; i < nsegments; i++, sg64++) {
|
|
|
|
sg64->sg_addr = segs[i].ds_addr;
|
|
|
|
sg64->sg_count = segs[i].ds_len;
|
2002-10-30 22:00:11 +00:00
|
|
|
}
|
2002-10-18 21:29:14 +00:00
|
|
|
} else {
|
2007-12-12 05:55:03 +00:00
|
|
|
/* decide whether we need to populate the s/g table */
|
2002-10-30 22:00:11 +00:00
|
|
|
if (nsegments < 2) {
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_nsegments = 0;
|
|
|
|
ac->ac_mb_physaddr = segs[0].ds_addr;
|
2002-10-30 22:00:11 +00:00
|
|
|
} else {
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_nsegments = nsegments;
|
|
|
|
ac->ac_mb_physaddr = ac->ac_sgbusaddr;
|
2002-10-30 22:00:11 +00:00
|
|
|
for (i = 0; i < nsegments; i++, sg++) {
|
2002-10-18 21:29:14 +00:00
|
|
|
sg->sg_addr = segs[i].ds_addr;
|
|
|
|
sg->sg_count = segs[i].ds_len;
|
2002-10-30 22:00:11 +00:00
|
|
|
}
|
2002-10-18 21:29:14 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-05 23:48:17 +00:00
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
flags = 0;
|
2004-12-05 23:48:17 +00:00
|
|
|
if (ac->ac_flags & AMR_CMD_DATAIN)
|
2007-12-12 05:55:03 +00:00
|
|
|
flags |= BUS_DMASYNC_PREREAD;
|
2004-12-05 23:48:17 +00:00
|
|
|
if (ac->ac_flags & AMR_CMD_DATAOUT)
|
2007-12-12 05:55:03 +00:00
|
|
|
flags |= BUS_DMASYNC_PREWRITE;
|
|
|
|
bus_dmamap_sync(ac->ac_tag, ac->ac_datamap, flags);
|
2004-12-05 23:48:17 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_MAPPED;
|
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 void
|
2007-12-12 05:55:03 +00:00
|
|
|
amr_setup_data(void *arg, bus_dma_segment_t *segs, int nsegs, int err)
|
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
|
|
|
{
|
2007-12-12 05:55:03 +00:00
|
|
|
struct amr_command *ac = arg;
|
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
|
|
|
int mb_channel;
|
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
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
if (err) {
|
|
|
|
device_printf(sc->amr_dev, "error %d in %s", err, __FUNCTION__);
|
|
|
|
amr_abort_load(ac);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
amr_setup_sg(arg, segs, nsegs, err);
|
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
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
/* for AMR_CMD_CONFIG Read/Write the s/g count goes elsewhere */
|
|
|
|
mb_channel = ((struct amr_mailbox_ioctl *)&ac->ac_mailbox)->mb_channel;
|
|
|
|
if (ac->ac_mailbox.mb_command == AMR_CMD_CONFIG &&
|
|
|
|
((mb_channel == AMR_CONFIG_READ_NVRAM_CONFIG) ||
|
|
|
|
(mb_channel == AMR_CONFIG_WRITE_NVRAM_CONFIG)))
|
|
|
|
((struct amr_mailbox_ioctl *)&ac->ac_mailbox)->mb_param = ac->ac_nsegments;
|
|
|
|
|
|
|
|
ac->ac_mailbox.mb_nsgelem = ac->ac_nsegments;
|
|
|
|
ac->ac_mailbox.mb_physaddr = ac->ac_mb_physaddr;
|
|
|
|
if (AC_IS_SG64(ac)) {
|
|
|
|
ac->ac_sg64_hi = 0;
|
|
|
|
ac->ac_sg64_lo = ac->ac_sgbusaddr;
|
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
|
|
|
}
|
|
|
|
|
2006-02-02 17:50:59 +00:00
|
|
|
if (sc->amr_submit_command(ac) == EBUSY) {
|
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
|
|
|
amr_freeslot(ac);
|
|
|
|
amr_requeue_ready(ac);
|
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2007-12-12 05:55:03 +00:00
|
|
|
|
2006-07-17 19:45:47 +00:00
|
|
|
static void
|
2007-12-12 05:55:03 +00:00
|
|
|
amr_setup_ccb(void *arg, bus_dma_segment_t *segs, int nsegs, int err)
|
2006-07-17 19:45:47 +00:00
|
|
|
{
|
2007-12-12 05:55:03 +00:00
|
|
|
struct amr_command *ac = arg;
|
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
|
|
|
struct amr_passthrough *ap = &ac->ac_ccb->ccb_pthru;
|
|
|
|
struct amr_ext_passthrough *aep = &ac->ac_ccb->ccb_epthru;
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
if (err) {
|
|
|
|
device_printf(sc->amr_dev, "error %d in %s", err, __FUNCTION__);
|
|
|
|
amr_abort_load(ac);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
/* Set up the mailbox portion of the command to point at the ccb */
|
|
|
|
ac->ac_mailbox.mb_nsgelem = 0;
|
|
|
|
ac->ac_mailbox.mb_physaddr = ac->ac_ccb_busaddr;
|
|
|
|
|
|
|
|
amr_setup_sg(arg, segs, nsegs, err);
|
|
|
|
|
|
|
|
switch (ac->ac_mailbox.mb_command) {
|
|
|
|
case AMR_CMD_EXTPASS:
|
|
|
|
aep->ap_no_sg_elements = ac->ac_nsegments;
|
|
|
|
aep->ap_data_transfer_address = ac->ac_mb_physaddr;
|
|
|
|
break;
|
|
|
|
case AMR_CMD_PASS:
|
|
|
|
ap->ap_no_sg_elements = ac->ac_nsegments;
|
|
|
|
ap->ap_data_transfer_address = ac->ac_mb_physaddr;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("Unknown ccb command");
|
2006-07-17 19:45:47 +00:00
|
|
|
}
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
if (sc->amr_submit_command(ac) == EBUSY) {
|
|
|
|
amr_freeslot(ac);
|
|
|
|
amr_requeue_ready(ac);
|
2006-07-17 19:45:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
static int
|
1999-10-07 02:23:12 +00:00
|
|
|
amr_mapcmd(struct amr_command *ac)
|
|
|
|
{
|
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_dmamap_callback_t *cb;
|
1999-10-07 02:23:12 +00:00
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
|
|
|
|
2000-11-28 19:28:22 +00:00
|
|
|
debug_called(3);
|
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 (AC_IS_SG64(ac)) {
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_tag = sc->amr_buffer64_dmat;
|
|
|
|
ac->ac_datamap = ac->ac_dma64map;
|
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
|
|
|
} else {
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_tag = sc->amr_buffer_dmat;
|
|
|
|
ac->ac_datamap = ac->ac_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
|
|
|
}
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
if (ac->ac_flags & AMR_CMD_CCB)
|
|
|
|
cb = amr_setup_ccb;
|
|
|
|
else
|
|
|
|
cb = amr_setup_data;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* if the command involves data at all, and hasn't been mapped */
|
2004-12-05 23:48:17 +00:00
|
|
|
if ((ac->ac_flags & AMR_CMD_MAPPED) == 0 && (ac->ac_data != NULL)) {
|
2006-07-17 19:45:47 +00:00
|
|
|
/* map the data buffers into bus space and build the s/g list */
|
2007-12-12 05:55:03 +00:00
|
|
|
if (bus_dmamap_load(ac->ac_tag, ac->ac_datamap, ac->ac_data,
|
|
|
|
ac->ac_length, cb, ac, 0) == EINPROGRESS) {
|
2006-07-17 19:45:47 +00:00
|
|
|
sc->amr_state |= AMR_STATE_QUEUE_FRZN;
|
|
|
|
}
|
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
|
|
|
} else {
|
2006-02-02 17:50:59 +00:00
|
|
|
if (sc->amr_submit_command(ac) == EBUSY) {
|
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
|
|
|
amr_freeslot(ac);
|
|
|
|
amr_requeue_ready(ac);
|
|
|
|
}
|
2005-03-04 06:11:00 +00:00
|
|
|
}
|
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
return (0);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
amr_unmapcmd(struct amr_command *ac)
|
|
|
|
{
|
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 flag;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-11-28 19:28:22 +00:00
|
|
|
debug_called(3);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* if the command involved data at all and was mapped */
|
|
|
|
if (ac->ac_flags & AMR_CMD_MAPPED) {
|
|
|
|
|
|
|
|
if (ac->ac_data != NULL) {
|
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
|
|
|
|
|
|
|
flag = 0;
|
2000-08-30 07:52:50 +00:00
|
|
|
if (ac->ac_flags & AMR_CMD_DATAIN)
|
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
|
|
|
flag |= BUS_DMASYNC_POSTREAD;
|
2000-08-30 07:52:50 +00:00
|
|
|
if (ac->ac_flags & AMR_CMD_DATAOUT)
|
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
|
|
|
flag |= BUS_DMASYNC_POSTWRITE;
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
bus_dmamap_sync(ac->ac_tag, ac->ac_datamap, flag);
|
|
|
|
bus_dmamap_unload(ac->ac_tag, ac->ac_datamap);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_flags &= ~AMR_CMD_MAPPED;
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
static void
|
|
|
|
amr_abort_load(struct amr_command *ac)
|
|
|
|
{
|
|
|
|
ac_qhead_t head;
|
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
|
|
|
|
|
|
|
mtx_assert(&sc->amr_list_lock, MA_OWNED);
|
|
|
|
|
|
|
|
ac->ac_status = AMR_STATUS_ABORTED;
|
|
|
|
amr_init_qhead(&head);
|
|
|
|
amr_enqueue_completed(ac, &head);
|
|
|
|
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
amr_complete(sc, &head);
|
|
|
|
mtx_lock(&sc->amr_list_lock);
|
|
|
|
}
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
2000-08-30 07:52:50 +00:00
|
|
|
* Take a command and give it to the controller, returns 0 if successful, or
|
|
|
|
* EBUSY if the command should be retried later.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_start(struct amr_command *ac)
|
|
|
|
{
|
2004-12-05 23:48:17 +00:00
|
|
|
struct amr_softc *sc;
|
|
|
|
int error = 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
|
|
|
int slot;
|
2002-10-18 21:29:14 +00:00
|
|
|
|
2000-11-28 19:28:22 +00:00
|
|
|
debug_called(3);
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/* mark command as busy so that polling consumer can tell */
|
2004-12-05 23:48:17 +00:00
|
|
|
sc = ac->ac_sc;
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_flags |= AMR_CMD_BUSY;
|
|
|
|
|
|
|
|
/* get a command slot (freed in amr_done) */
|
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
|
|
|
slot = ac->ac_slot;
|
|
|
|
if (sc->amr_busycmd[slot] != NULL)
|
|
|
|
panic("amr: slot %d busy?\n", slot);
|
|
|
|
sc->amr_busycmd[slot] = ac;
|
|
|
|
atomic_add_int(&sc->amr_busyslots, 1);
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2004-12-05 23:48:17 +00:00
|
|
|
/* Now we have a slot, we can map the command (unmapped in amr_complete). */
|
|
|
|
if ((error = amr_mapcmd(ac)) == ENOMEM) {
|
|
|
|
/*
|
2016-05-03 03:41:25 +00:00
|
|
|
* Memory resources are short, so free the slot and let this be tried
|
2004-12-05 23:48:17 +00:00
|
|
|
* later.
|
|
|
|
*/
|
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
|
|
|
amr_freeslot(ac);
|
2004-12-05 23:48:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Extract one or more completed commands from the controller (sc)
|
|
|
|
*
|
1999-10-26 23:18:57 +00:00
|
|
|
* Returns nonzero if any commands on the work queue were marked as completed.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2005-01-16 07:34:26 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
int
|
1999-10-07 02:23:12 +00:00
|
|
|
amr_done(struct amr_softc *sc)
|
|
|
|
{
|
2008-01-24 07:26:53 +00:00
|
|
|
ac_qhead_t head;
|
1999-10-07 02:23:12 +00:00
|
|
|
struct amr_command *ac;
|
|
|
|
struct amr_mailbox mbox;
|
2000-08-30 07:52:50 +00:00
|
|
|
int i, idx, result;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-11-28 19:28:22 +00:00
|
|
|
debug_called(3);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/* See if there's anything for us to do */
|
|
|
|
result = 0;
|
2008-01-24 07:26:53 +00:00
|
|
|
amr_init_qhead(&head);
|
2000-04-01 00:35:15 +00:00
|
|
|
|
|
|
|
/* loop collecting completed commands */
|
|
|
|
for (;;) {
|
|
|
|
/* poll for a completed command's identifier and status */
|
|
|
|
if (sc->amr_get_work(sc, &mbox)) {
|
|
|
|
result = 1;
|
|
|
|
|
|
|
|
/* iterate over completed commands in this result */
|
|
|
|
for (i = 0; i < mbox.mb_nstatus; i++) {
|
|
|
|
/* get pointer to busy command */
|
|
|
|
idx = mbox.mb_completed[i] - 1;
|
|
|
|
ac = sc->amr_busycmd[idx];
|
|
|
|
|
|
|
|
/* really a busy command? */
|
|
|
|
if (ac != NULL) {
|
|
|
|
|
|
|
|
/* pull the command from the busy index */
|
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
|
|
|
amr_freeslot(ac);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* save status for later use */
|
|
|
|
ac->ac_status = mbox.mb_status;
|
2008-01-24 07:26:53 +00:00
|
|
|
amr_enqueue_completed(ac, &head);
|
2000-08-30 07:52:50 +00:00
|
|
|
debug(3, "completed command with status %x", mbox.mb_status);
|
|
|
|
} else {
|
|
|
|
device_printf(sc->amr_dev, "bad slot %d completed\n", idx);
|
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
|
|
|
} else
|
2000-08-30 07:52:50 +00:00
|
|
|
break; /* no work */
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2004-12-05 23:48:17 +00:00
|
|
|
|
2000-04-01 00:35:15 +00:00
|
|
|
/* handle completion and timeouts */
|
2008-01-24 07:26:53 +00:00
|
|
|
amr_complete(sc, &head);
|
2004-12-05 23:48:17 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Do completion processing on done commands on (sc)
|
|
|
|
*/
|
2005-01-16 07:34:26 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
static void
|
2008-01-24 07:26:53 +00:00
|
|
|
amr_complete(void *context, ac_qhead_t *head)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_softc *sc = (struct amr_softc *)context;
|
|
|
|
struct amr_command *ac;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-11-28 19:28:22 +00:00
|
|
|
debug_called(3);
|
2000-04-01 00:35:15 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* pull completed commands off the queue */
|
|
|
|
for (;;) {
|
2008-01-24 07:26:53 +00:00
|
|
|
ac = amr_dequeue_completed(sc, head);
|
2000-08-30 07:52:50 +00:00
|
|
|
if (ac == NULL)
|
|
|
|
break;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* unmap the command's data buffer */
|
|
|
|
amr_unmapcmd(ac);
|
2000-04-01 00:35:15 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* Is there a completion handler?
|
|
|
|
*/
|
|
|
|
if (ac->ac_complete != NULL) {
|
2006-04-08 02:23:27 +00:00
|
|
|
/* unbusy the command */
|
|
|
|
ac->ac_flags &= ~AMR_CMD_BUSY;
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_complete(ac);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/*
|
2000-08-30 07:52:50 +00:00
|
|
|
* Is someone sleeping on this one?
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2006-04-08 02:23:27 +00:00
|
|
|
} else {
|
2006-04-08 05:08:17 +00:00
|
|
|
mtx_lock(&sc->amr_list_lock);
|
2006-04-08 02:23:27 +00:00
|
|
|
ac->ac_flags &= ~AMR_CMD_BUSY;
|
2006-04-08 05:08:17 +00:00
|
|
|
if (ac->ac_flags & AMR_CMD_SLEEP) {
|
|
|
|
/* unbusy the command */
|
|
|
|
wakeup(ac);
|
|
|
|
}
|
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
|
|
|
}
|
2003-01-09 21:02:28 +00:00
|
|
|
|
|
|
|
if(!sc->amr_busyslots) {
|
|
|
|
wakeup(sc);
|
|
|
|
}
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
2005-01-16 07:34:26 +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
|
|
|
mtx_lock(&sc->amr_list_lock);
|
2005-01-16 07:34:26 +00:00
|
|
|
sc->amr_state &= ~AMR_STATE_QUEUE_FRZN;
|
|
|
|
amr_startio(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
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
********************************************************************************
|
|
|
|
Command Buffer Management
|
|
|
|
********************************************************************************
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Get a new command buffer.
|
|
|
|
*
|
|
|
|
* This may return NULL in low-memory cases.
|
|
|
|
*
|
|
|
|
* If possible, we recycle a command buffer that's been used before.
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_command *
|
1999-10-07 02:23:12 +00:00
|
|
|
amr_alloccmd(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(3);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
ac = amr_dequeue_free(sc);
|
2005-01-16 07:34:26 +00:00
|
|
|
if (ac == NULL) {
|
|
|
|
sc->amr_state |= AMR_STATE_QUEUE_FRZN;
|
2000-08-30 07:52:50 +00:00
|
|
|
return(NULL);
|
2005-01-16 07:34:26 +00:00
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/* clear out significant fields */
|
|
|
|
ac->ac_status = 0;
|
1999-10-07 02:23:12 +00:00
|
|
|
bzero(&ac->ac_mailbox, sizeof(struct amr_mailbox));
|
2000-08-30 07:52:50 +00:00
|
|
|
ac->ac_flags = 0;
|
|
|
|
ac->ac_bio = NULL;
|
|
|
|
ac->ac_data = NULL;
|
|
|
|
ac->ac_complete = NULL;
|
2008-01-24 07:26:53 +00:00
|
|
|
ac->ac_retries = 0;
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_tag = NULL;
|
|
|
|
ac->ac_datamap = NULL;
|
1999-10-07 02:23:12 +00:00
|
|
|
return(ac);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Release a command buffer for recycling.
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
void
|
1999-10-07 02:23:12 +00:00
|
|
|
amr_releasecmd(struct amr_command *ac)
|
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(3);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
amr_enqueue_free(ac);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
2000-08-30 07:52:50 +00:00
|
|
|
* Allocate a new command cluster and initialise it.
|
1999-10-07 02:23:12 +00:00
|
|
|
*/
|
2002-09-28 17:15:38 +00:00
|
|
|
static void
|
2000-08-30 07:52:50 +00:00
|
|
|
amr_alloccmd_cluster(struct amr_softc *sc)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2000-08-30 07:52:50 +00:00
|
|
|
struct amr_command_cluster *acc;
|
|
|
|
struct amr_command *ac;
|
2005-11-06 15:13:42 +00:00
|
|
|
int i, nextslot;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
2008-01-24 07:26:53 +00:00
|
|
|
/*
|
|
|
|
* If we haven't found the real limit yet, let us have a couple of
|
|
|
|
* commands in order to be able to probe.
|
|
|
|
*/
|
|
|
|
if (sc->amr_maxio == 0)
|
|
|
|
sc->amr_maxio = 2;
|
|
|
|
|
2005-01-16 07:34:26 +00:00
|
|
|
if (sc->amr_nextslot > sc->amr_maxio)
|
|
|
|
return;
|
2007-12-02 19:54:45 +00:00
|
|
|
acc = malloc(AMR_CMD_CLUSTERSIZE, M_AMR, M_NOWAIT | M_ZERO);
|
2000-08-30 07:52:50 +00:00
|
|
|
if (acc != NULL) {
|
2005-01-16 07:34:26 +00:00
|
|
|
nextslot = sc->amr_nextslot;
|
2008-01-24 07:26:53 +00:00
|
|
|
mtx_lock(&sc->amr_list_lock);
|
2000-08-30 07:52:50 +00:00
|
|
|
TAILQ_INSERT_TAIL(&sc->amr_cmd_clusters, acc, acc_link);
|
2008-01-24 07:26:53 +00:00
|
|
|
mtx_unlock(&sc->amr_list_lock);
|
2000-08-30 07:52:50 +00:00
|
|
|
for (i = 0; i < AMR_CMD_CLUSTERCOUNT; i++) {
|
|
|
|
ac = &acc->acc_command[i];
|
|
|
|
ac->ac_sc = sc;
|
2005-01-16 07:34:26 +00:00
|
|
|
ac->ac_slot = nextslot;
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* The SG table for each slot is a fixed size and is assumed to
|
|
|
|
* to hold 64-bit s/g objects when the driver is configured to do
|
|
|
|
* 64-bit DMA. 32-bit DMA commands still use the same table, but
|
|
|
|
* cast down to 32-bit objects.
|
|
|
|
*/
|
|
|
|
if (AMR_IS_SG64(sc)) {
|
|
|
|
ac->ac_sgbusaddr = sc->amr_sgbusaddr +
|
|
|
|
(ac->ac_slot * AMR_NSEG * sizeof(struct amr_sg64entry));
|
|
|
|
ac->ac_sg.sg64 = sc->amr_sg64table + (ac->ac_slot * AMR_NSEG);
|
|
|
|
} else {
|
|
|
|
ac->ac_sgbusaddr = sc->amr_sgbusaddr +
|
|
|
|
(ac->ac_slot * AMR_NSEG * sizeof(struct amr_sgentry));
|
|
|
|
ac->ac_sg.sg32 = sc->amr_sgtable + (ac->ac_slot * AMR_NSEG);
|
|
|
|
}
|
|
|
|
|
2007-12-12 05:55:03 +00:00
|
|
|
ac->ac_ccb = sc->amr_ccb + ac->ac_slot;
|
|
|
|
ac->ac_ccb_busaddr = sc->amr_ccb_busaddr +
|
|
|
|
(ac->ac_slot * sizeof(union amr_ccb));
|
|
|
|
|
|
|
|
if (bus_dmamap_create(sc->amr_buffer_dmat, 0, &ac->ac_dmamap))
|
|
|
|
break;
|
|
|
|
if (AMR_IS_SG64(sc) &&
|
|
|
|
(bus_dmamap_create(sc->amr_buffer64_dmat, 0,&ac->ac_dma64map)))
|
|
|
|
break;
|
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
|
|
|
amr_releasecmd(ac);
|
2005-01-16 07:34:26 +00:00
|
|
|
if (++nextslot > sc->amr_maxio)
|
|
|
|
break;
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
2005-01-16 07:34:26 +00:00
|
|
|
sc->amr_nextslot = nextslot;
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Free a command cluster
|
|
|
|
*/
|
2002-09-28 17:15:38 +00:00
|
|
|
static void
|
2000-08-30 07:52:50 +00:00
|
|
|
amr_freecmd_cluster(struct amr_command_cluster *acc)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = acc->acc_command[0].ac_sc;
|
|
|
|
int i;
|
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 (i = 0; i < AMR_CMD_CLUSTERCOUNT; i++) {
|
2008-01-24 07:26:53 +00:00
|
|
|
if (acc->acc_command[i].ac_sc == NULL)
|
|
|
|
break;
|
2000-08-30 07:52:50 +00:00
|
|
|
bus_dmamap_destroy(sc->amr_buffer_dmat, acc->acc_command[i].ac_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
|
|
|
if (AMR_IS_SG64(sc))
|
|
|
|
bus_dmamap_destroy(sc->amr_buffer64_dmat, acc->acc_command[i].ac_dma64map);
|
|
|
|
}
|
2007-12-02 19:54:45 +00:00
|
|
|
free(acc, M_AMR);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
********************************************************************************
|
|
|
|
Interface-specific Shims
|
|
|
|
********************************************************************************
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Tell the controller that the mailbox contains a valid command
|
|
|
|
*/
|
2000-08-30 07:52:50 +00:00
|
|
|
static int
|
2006-02-02 17:50:59 +00:00
|
|
|
amr_quartz_submit_command(struct amr_command *ac)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2006-02-02 17:50:59 +00:00
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
2008-01-24 07:26:53 +00:00
|
|
|
static struct timeval lastfail;
|
|
|
|
static int curfail;
|
2006-02-02 17:50:59 +00:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
mtx_lock(&sc->amr_hw_lock);
|
2008-07-20 16:50:14 +00:00
|
|
|
while (sc->amr_mailbox->mb_busy && (i++ < 10)) {
|
2006-02-02 17:50:59 +00:00
|
|
|
DELAY(1);
|
2008-07-20 16:50:14 +00:00
|
|
|
/* This is a no-op read that flushes pending mailbox updates */
|
|
|
|
AMR_QGET_ODB(sc);
|
|
|
|
}
|
2006-02-02 17:50:59 +00:00
|
|
|
if (sc->amr_mailbox->mb_busy) {
|
|
|
|
mtx_unlock(&sc->amr_hw_lock);
|
2008-01-24 07:26:53 +00:00
|
|
|
if (ac->ac_retries++ > 1000) {
|
|
|
|
if (ppsratecheck(&lastfail, &curfail, 1))
|
|
|
|
device_printf(sc->amr_dev, "Too many retries on command %p. "
|
|
|
|
"Controller is likely dead\n", ac);
|
|
|
|
ac->ac_retries = 0;
|
|
|
|
}
|
2006-02-02 17:50:59 +00:00
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the slot number so that we can locate this command when complete.
|
|
|
|
* Note that ident = 0 seems to be special, so we don't use it.
|
|
|
|
*/
|
|
|
|
ac->ac_mailbox.mb_ident = ac->ac_slot + 1; /* will be coppied into mbox */
|
|
|
|
bcopy(&ac->ac_mailbox, (void *)(uintptr_t)(volatile void *)sc->amr_mailbox, 14);
|
|
|
|
sc->amr_mailbox->mb_busy = 1;
|
|
|
|
sc->amr_mailbox->mb_poll = 0;
|
|
|
|
sc->amr_mailbox->mb_ack = 0;
|
|
|
|
sc->amr_mailbox64->sg64_hi = ac->ac_sg64_hi;
|
|
|
|
sc->amr_mailbox64->sg64_lo = ac->ac_sg64_lo;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
AMR_QPUT_IDB(sc, sc->amr_mailboxphys | AMR_QIDB_SUBMIT);
|
2006-02-02 17:50:59 +00:00
|
|
|
mtx_unlock(&sc->amr_hw_lock);
|
2000-08-30 07:52:50 +00:00
|
|
|
return(0);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
static int
|
2006-02-02 17:50:59 +00:00
|
|
|
amr_std_submit_command(struct amr_command *ac)
|
1999-10-07 02:23:12 +00:00
|
|
|
{
|
2006-02-02 17:50:59 +00:00
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
2008-01-24 07:26:53 +00:00
|
|
|
static struct timeval lastfail;
|
|
|
|
static int curfail;
|
2006-02-02 17:50:59 +00:00
|
|
|
|
|
|
|
mtx_lock(&sc->amr_hw_lock);
|
|
|
|
if (AMR_SGET_MBSTAT(sc) & AMR_SMBOX_BUSYFLAG) {
|
|
|
|
mtx_unlock(&sc->amr_hw_lock);
|
2008-01-24 07:26:53 +00:00
|
|
|
if (ac->ac_retries++ > 1000) {
|
|
|
|
if (ppsratecheck(&lastfail, &curfail, 1))
|
|
|
|
device_printf(sc->amr_dev, "Too many retries on command %p. "
|
|
|
|
"Controller is likely dead\n", ac);
|
|
|
|
ac->ac_retries = 0;
|
|
|
|
}
|
2006-02-02 17:50:59 +00:00
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the slot number so that we can locate this command when complete.
|
|
|
|
* Note that ident = 0 seems to be special, so we don't use it.
|
|
|
|
*/
|
|
|
|
ac->ac_mailbox.mb_ident = ac->ac_slot + 1; /* will be coppied into mbox */
|
|
|
|
bcopy(&ac->ac_mailbox, (void *)(uintptr_t)(volatile void *)sc->amr_mailbox, 14);
|
|
|
|
sc->amr_mailbox->mb_busy = 1;
|
|
|
|
sc->amr_mailbox->mb_poll = 0;
|
|
|
|
sc->amr_mailbox->mb_ack = 0;
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
AMR_SPOST_COMMAND(sc);
|
2006-02-02 17:50:59 +00:00
|
|
|
mtx_unlock(&sc->amr_hw_lock);
|
2000-08-30 07:52:50 +00:00
|
|
|
return(0);
|
1999-10-07 02:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Claim any work that the controller has completed; acknowledge completion,
|
|
|
|
* save details of the completion in (mbsave)
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_quartz_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave)
|
|
|
|
{
|
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 worked, i;
|
1999-10-07 02:23:12 +00:00
|
|
|
u_int32_t outd;
|
2006-01-26 22:39:12 +00:00
|
|
|
u_int8_t nstatus;
|
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
|
|
|
u_int8_t completed[46];
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
debug_called(3);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
worked = 0;
|
|
|
|
|
|
|
|
/* work waiting for us? */
|
|
|
|
if ((outd = AMR_QGET_ODB(sc)) == AMR_QODB_READY) {
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/* acknowledge interrupt */
|
|
|
|
AMR_QPUT_ODB(sc, AMR_QODB_READY);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
2005-01-16 07:34:26 +00:00
|
|
|
while ((nstatus = sc->amr_mailbox->mb_nstatus) == 0xff)
|
2006-02-02 17:50:59 +00:00
|
|
|
DELAY(1);
|
2005-01-16 07:34:26 +00:00
|
|
|
sc->amr_mailbox->mb_nstatus = 0xff;
|
|
|
|
|
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
|
|
|
/* wait until fw wrote out all completions */
|
|
|
|
for (i = 0; i < nstatus; i++) {
|
|
|
|
while ((completed[i] = sc->amr_mailbox->mb_completed[i]) == 0xff)
|
2006-02-02 17:50:59 +00:00
|
|
|
DELAY(1);
|
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_mailbox->mb_completed[i] = 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save information for later processing */
|
2005-01-16 07:34:26 +00:00
|
|
|
mbsave->mb_nstatus = nstatus;
|
2006-01-26 22:39:12 +00:00
|
|
|
mbsave->mb_status = sc->amr_mailbox->mb_status;
|
|
|
|
sc->amr_mailbox->mb_status = 0xff;
|
|
|
|
|
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 (i = 0; i < nstatus; i++)
|
|
|
|
mbsave->mb_completed[i] = completed[i];
|
2005-01-16 07:34:26 +00:00
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/* acknowledge that we have the commands */
|
2005-01-16 07:34:26 +00:00
|
|
|
AMR_QPUT_IDB(sc, AMR_QIDB_ACK);
|
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 0
|
2000-09-11 23:19:13 +00:00
|
|
|
#ifndef AMR_QUARTZ_GOFASTER
|
2000-08-30 07:52:50 +00:00
|
|
|
/*
|
|
|
|
* This waits for the controller to notice that we've taken the
|
|
|
|
* command from it. It's very inefficient, and we shouldn't do it,
|
|
|
|
* but if we remove this code, we stop completing commands under
|
|
|
|
* load.
|
|
|
|
*
|
|
|
|
* Peter J says we shouldn't do this. The documentation says we
|
|
|
|
* should. Who is right?
|
|
|
|
*/
|
1999-10-07 02:23:12 +00:00
|
|
|
while(AMR_QGET_IDB(sc) & AMR_QIDB_ACK)
|
|
|
|
; /* XXX aiee! what if it dies? */
|
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
|
|
|
#endif
|
2000-08-30 07:52:50 +00:00
|
|
|
#endif
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
worked = 1; /* got some work */
|
|
|
|
}
|
|
|
|
|
|
|
|
return(worked);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
amr_std_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave)
|
|
|
|
{
|
2005-11-06 15:13:42 +00:00
|
|
|
int worked;
|
1999-10-07 02:23:12 +00:00
|
|
|
u_int8_t istat;
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
debug_called(3);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
worked = 0;
|
|
|
|
|
|
|
|
/* check for valid interrupt status */
|
|
|
|
istat = AMR_SGET_ISTAT(sc);
|
|
|
|
if ((istat & AMR_SINTR_VALID) != 0) {
|
|
|
|
AMR_SPUT_ISTAT(sc, istat); /* ack interrupt status */
|
|
|
|
|
|
|
|
/* save mailbox, which contains a list of completed commands */
|
2000-08-30 07:52:50 +00:00
|
|
|
bcopy((void *)(uintptr_t)(volatile void *)sc->amr_mailbox, mbsave, sizeof(*mbsave));
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
AMR_SACK_INTERRUPT(sc); /* acknowledge we have the mailbox */
|
|
|
|
worked = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(worked);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Notify the controller of the mailbox location.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
amr_std_attach_mailbox(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* program the mailbox physical address */
|
|
|
|
AMR_SBYTE_SET(sc, AMR_SMBOX_0, sc->amr_mailboxphys & 0xff);
|
|
|
|
AMR_SBYTE_SET(sc, AMR_SMBOX_1, (sc->amr_mailboxphys >> 8) & 0xff);
|
|
|
|
AMR_SBYTE_SET(sc, AMR_SMBOX_2, (sc->amr_mailboxphys >> 16) & 0xff);
|
|
|
|
AMR_SBYTE_SET(sc, AMR_SMBOX_3, (sc->amr_mailboxphys >> 24) & 0xff);
|
|
|
|
AMR_SBYTE_SET(sc, AMR_SMBOX_ENABLE, AMR_SMBOX_ADDR);
|
|
|
|
|
|
|
|
/* clear any outstanding interrupt and enable interrupts proper */
|
|
|
|
AMR_SACK_INTERRUPT(sc);
|
|
|
|
AMR_SENABLE_INTR(sc);
|
|
|
|
}
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
#ifdef AMR_BOARD_INIT
|
|
|
|
/********************************************************************************
|
|
|
|
* Initialise the controller
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
amr_quartz_init(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
int status, ostatus;
|
|
|
|
|
|
|
|
device_printf(sc->amr_dev, "initial init status %x\n", AMR_QGET_INITSTATUS(sc));
|
|
|
|
|
|
|
|
AMR_QRESET(sc);
|
|
|
|
|
|
|
|
ostatus = 0xff;
|
|
|
|
while ((status = AMR_QGET_INITSTATUS(sc)) != AMR_QINIT_DONE) {
|
|
|
|
if (status != ostatus) {
|
|
|
|
device_printf(sc->amr_dev, "(%x) %s\n", status, amr_describe_code(amr_table_qinit, status));
|
|
|
|
ostatus = status;
|
|
|
|
}
|
|
|
|
switch (status) {
|
|
|
|
case AMR_QINIT_NOMEM:
|
|
|
|
return(ENOMEM);
|
|
|
|
|
|
|
|
case AMR_QINIT_SCAN:
|
|
|
|
/* XXX we could print channel/target here */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
amr_std_init(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
int status, ostatus;
|
|
|
|
|
|
|
|
device_printf(sc->amr_dev, "initial init status %x\n", AMR_SGET_INITSTATUS(sc));
|
|
|
|
|
|
|
|
AMR_SRESET(sc);
|
|
|
|
|
|
|
|
ostatus = 0xff;
|
|
|
|
while ((status = AMR_SGET_INITSTATUS(sc)) != AMR_SINIT_DONE) {
|
|
|
|
if (status != ostatus) {
|
|
|
|
device_printf(sc->amr_dev, "(%x) %s\n", status, amr_describe_code(amr_table_sinit, status));
|
|
|
|
ostatus = status;
|
|
|
|
}
|
|
|
|
switch (status) {
|
|
|
|
case AMR_SINIT_NOMEM:
|
|
|
|
return(ENOMEM);
|
|
|
|
|
|
|
|
case AMR_SINIT_INPROG:
|
|
|
|
/* XXX we could print channel/target here? */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
|
|
|
********************************************************************************
|
|
|
|
Debugging
|
|
|
|
********************************************************************************
|
|
|
|
********************************************************************************/
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Identify the controller and print some information about it.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
amr_describe_controller(struct amr_softc *sc)
|
|
|
|
{
|
|
|
|
struct amr_prodinfo *ap;
|
|
|
|
struct amr_enquiry *ae;
|
|
|
|
char *prod;
|
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 status;
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to get 40LD product info, which tells us what the card is labelled as.
|
|
|
|
*/
|
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 ((ap = amr_enquiry(sc, 2048, AMR_CMD_CONFIG, AMR_CONFIG_PRODUCT_INFO, 0, &status)) != NULL) {
|
2002-10-18 21:29:14 +00:00
|
|
|
device_printf(sc->amr_dev, "<LSILogic %.80s> Firmware %.16s, BIOS %.16s, %dMB RAM\n",
|
2000-08-30 07:52:50 +00:00
|
|
|
ap->ap_product, ap->ap_firmware, ap->ap_bios,
|
|
|
|
ap->ap_memsize);
|
|
|
|
|
2007-12-02 19:54:45 +00:00
|
|
|
free(ap, M_AMR);
|
2000-08-30 07:52:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try 8LD extended ENQUIRY to get controller signature, and use lookup table.
|
|
|
|
*/
|
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 ((ae = (struct amr_enquiry *)amr_enquiry(sc, 2048, AMR_CMD_EXT_ENQUIRY2, 0, 0, &status)) != NULL) {
|
2000-08-30 07:52:50 +00:00
|
|
|
prod = amr_describe_code(amr_table_adaptertype, ae->ae_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
|
|
|
} else if ((ae = (struct amr_enquiry *)amr_enquiry(sc, 2048, AMR_CMD_ENQUIRY, 0, 0, &status)) != NULL) {
|
2000-08-30 07:52:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to work it out based on the PCI signatures.
|
|
|
|
*/
|
|
|
|
switch (pci_get_device(sc->amr_dev)) {
|
|
|
|
case 0x9010:
|
|
|
|
prod = "Series 428";
|
|
|
|
break;
|
|
|
|
case 0x9060:
|
|
|
|
prod = "Series 434";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
prod = "unknown controller";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2005-03-31 04:58:10 +00:00
|
|
|
device_printf(sc->amr_dev, "<unsupported controller>\n");
|
|
|
|
return;
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
2001-03-28 14:11:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* HP NetRaid controllers have a special encoding of the firmware and
|
|
|
|
* BIOS versions. The AMI version seems to have it as strings whereas
|
|
|
|
* the HP version does it with a leading uppercase character and two
|
|
|
|
* binary numbers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(ae->ae_adapter.aa_firmware[2] >= 'A' &&
|
|
|
|
ae->ae_adapter.aa_firmware[2] <= 'Z' &&
|
|
|
|
ae->ae_adapter.aa_firmware[1] < ' ' &&
|
|
|
|
ae->ae_adapter.aa_firmware[0] < ' ' &&
|
|
|
|
ae->ae_adapter.aa_bios[2] >= 'A' &&
|
|
|
|
ae->ae_adapter.aa_bios[2] <= 'Z' &&
|
|
|
|
ae->ae_adapter.aa_bios[1] < ' ' &&
|
|
|
|
ae->ae_adapter.aa_bios[0] < ' ') {
|
|
|
|
|
|
|
|
/* this looks like we have an HP NetRaid version of the MegaRaid */
|
|
|
|
|
|
|
|
if(ae->ae_signature == AMR_SIG_438) {
|
2002-12-30 21:18:15 +00:00
|
|
|
/* the AMI 438 is a NetRaid 3si in HP-land */
|
2001-03-28 14:11:15 +00:00
|
|
|
prod = "HP NetRaid 3si";
|
|
|
|
}
|
|
|
|
|
|
|
|
device_printf(sc->amr_dev, "<%s> Firmware %c.%02d.%02d, BIOS %c.%02d.%02d, %dMB RAM\n",
|
|
|
|
prod, ae->ae_adapter.aa_firmware[2],
|
|
|
|
ae->ae_adapter.aa_firmware[1],
|
|
|
|
ae->ae_adapter.aa_firmware[0],
|
|
|
|
ae->ae_adapter.aa_bios[2],
|
|
|
|
ae->ae_adapter.aa_bios[1],
|
|
|
|
ae->ae_adapter.aa_bios[0],
|
|
|
|
ae->ae_adapter.aa_memorysize);
|
|
|
|
} else {
|
|
|
|
device_printf(sc->amr_dev, "<%s> Firmware %.4s, BIOS %.4s, %dMB RAM\n",
|
|
|
|
prod, ae->ae_adapter.aa_firmware, ae->ae_adapter.aa_bios,
|
|
|
|
ae->ae_adapter.aa_memorysize);
|
|
|
|
}
|
2007-12-02 19:54:45 +00:00
|
|
|
free(ae, M_AMR);
|
2000-08-30 07:52:50 +00:00
|
|
|
}
|
|
|
|
|
2003-10-10 22:49:40 +00:00
|
|
|
int
|
|
|
|
amr_dump_blocks(struct amr_softc *sc, int unit, u_int32_t lba, void *data, int blks)
|
|
|
|
{
|
|
|
|
struct amr_command *ac;
|
|
|
|
int error = EIO;
|
|
|
|
|
|
|
|
debug_called(1);
|
|
|
|
|
2005-01-23 23:25:41 +00:00
|
|
|
sc->amr_state |= AMR_STATE_INTEN;
|
2003-10-10 22:49:40 +00:00
|
|
|
|
|
|
|
/* get ourselves a command buffer */
|
|
|
|
if ((ac = amr_alloccmd(sc)) == NULL)
|
|
|
|
goto out;
|
|
|
|
/* set command flags */
|
|
|
|
ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT;
|
|
|
|
|
|
|
|
/* point the command at our data */
|
|
|
|
ac->ac_data = data;
|
|
|
|
ac->ac_length = blks * AMR_BLKSIZE;
|
|
|
|
|
|
|
|
/* build the command proper */
|
|
|
|
ac->ac_mailbox.mb_command = AMR_CMD_LWRITE;
|
|
|
|
ac->ac_mailbox.mb_blkcount = blks;
|
|
|
|
ac->ac_mailbox.mb_lba = lba;
|
|
|
|
ac->ac_mailbox.mb_drive = unit;
|
|
|
|
|
|
|
|
/* can't assume that interrupts are going to work here, so play it safe */
|
|
|
|
if (sc->amr_poll_command(ac))
|
|
|
|
goto out;
|
|
|
|
error = ac->ac_status;
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (ac != NULL)
|
|
|
|
amr_releasecmd(ac);
|
|
|
|
|
2005-01-23 23:25:41 +00:00
|
|
|
sc->amr_state &= ~AMR_STATE_INTEN;
|
2003-10-10 22:49:40 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-08-30 07:52:50 +00:00
|
|
|
#ifdef AMR_DEBUG
|
1999-10-07 02:23:12 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* Print the command (ac) in human-readable format
|
|
|
|
*/
|
2002-12-11 20:59:46 +00:00
|
|
|
#if 0
|
1999-10-07 02:23:12 +00:00
|
|
|
static void
|
|
|
|
amr_printcommand(struct amr_command *ac)
|
|
|
|
{
|
|
|
|
struct amr_softc *sc = ac->ac_sc;
|
|
|
|
struct amr_sgentry *sg;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
device_printf(sc->amr_dev, "cmd %x ident %d drive %d\n",
|
|
|
|
ac->ac_mailbox.mb_command, ac->ac_mailbox.mb_ident, ac->ac_mailbox.mb_drive);
|
|
|
|
device_printf(sc->amr_dev, "blkcount %d lba %d\n",
|
|
|
|
ac->ac_mailbox.mb_blkcount, ac->ac_mailbox.mb_lba);
|
1999-12-12 20:53:31 +00:00
|
|
|
device_printf(sc->amr_dev, "virtaddr %p length %lu\n", ac->ac_data, (unsigned long)ac->ac_length);
|
2000-04-01 00:35:15 +00:00
|
|
|
device_printf(sc->amr_dev, "sg physaddr %08x nsg %d\n",
|
1999-10-07 02:23:12 +00:00
|
|
|
ac->ac_mailbox.mb_physaddr, ac->ac_mailbox.mb_nsgelem);
|
2000-08-30 07:52:50 +00:00
|
|
|
device_printf(sc->amr_dev, "ccb %p bio %p\n", ac->ac_ccb_data, ac->ac_bio);
|
1999-10-07 02:23:12 +00:00
|
|
|
|
|
|
|
/* get base address of s/g table */
|
|
|
|
sg = sc->amr_sgtable + (ac->ac_slot * AMR_NSEG);
|
|
|
|
for (i = 0; i < ac->ac_mailbox.mb_nsgelem; i++, sg++)
|
|
|
|
device_printf(sc->amr_dev, " %x/%d\n", sg->sg_addr, sg->sg_count);
|
|
|
|
}
|
2000-08-30 07:52:50 +00:00
|
|
|
#endif
|
2002-12-11 20:59:46 +00:00
|
|
|
#endif
|