git: 60de2867c9fc - main - amr: remove
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 25 Nov 2021 07:46:55 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=60de2867c9fccac5ee3782fcc64fea6f0ae3ef06 commit 60de2867c9fccac5ee3782fcc64fea6f0ae3ef06 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2021-11-25 07:20:51 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-11-25 07:45:12 +0000 amr: remove Belatedly remove amr(4). It was slated to depart before 13.0 but was overlooked until now. Sponsored by: Netflix Relnotes: yes Reviewed by: scottl Differential Revision: https://reviews.freebsd.org/D33113 --- share/man/man4/amr.4 | 246 ---- sys/amd64/conf/GENERIC | 1 - sys/conf/NOTES | 2 - sys/conf/files | 4 - sys/dev/amr/amr.c | 2446 ------------------------------- sys/dev/amr/amr_cam.c | 627 -------- sys/dev/amr/amr_disk.c | 267 ---- sys/dev/amr/amr_linux.c | 87 -- sys/dev/amr/amr_pci.c | 705 --------- sys/dev/amr/amr_tables.h | 141 -- sys/dev/amr/amrio.h | 124 -- sys/dev/amr/amrreg.h | 657 --------- sys/dev/amr/amrvar.h | 384 ----- sys/i386/conf/GENERIC | 1 - sys/modules/Makefile | 1 - sys/modules/amr/Makefile | 21 - sys/modules/amr/amr_cam/Makefile | 9 - sys/modules/amr/amr_linux/Makefile | 8 - tools/kerneldoc/subsys/Doxyfile-dev_amr | 21 - 19 files changed, 5752 deletions(-) diff --git a/share/man/man4/amr.4 b/share/man/man4/amr.4 deleted file mode 100644 index 8ef14dfd1d9b..000000000000 --- a/share/man/man4/amr.4 +++ /dev/null @@ -1,246 +0,0 @@ -.\" -.\" Copyright (c) 2000 Jeroen Ruigrok van der Werven -.\" 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. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. -.\" -.\" $FreeBSD$ -.\" -.Dd March 29, 2006 -.Dt AMR 4 -.Os -.Sh NAME -.Nm amr -.Nd MegaRAID SCSI/ATA/SATA RAID driver -.Sh SYNOPSIS -To compile this driver into the kernel, -place the following lines in your -kernel configuration file: -.Bd -ragged -offset indent -.Cd "device pci" -.Cd "device scbus" -.Cd "device amr" -.Ed -.Pp -Alternatively, to load the driver as a -module at boot time, place the following line in -.Xr loader.conf 5 : -.Bd -literal -offset indent -amr_load="YES" -.Ed -.Sh DEPRECATION NOTICE -The -.Nm -driver is not present in -.Fx 13.0 . -.Sh DESCRIPTION -The -.Nm -driver provides support for LSI Logic MegaRAID SCSI, ATA and SATA -RAID controllers and legacy American Megatrends MegaRAID -SCSI RAID controllers, including models relabeled -and sold by Dell and Hewlett-Packard. -.Pp -LSI MegaRAID SAS controllers are supported by -.Xr mfi 4 -and will not work with this driver. -.Sh HARDWARE -Controllers supported by the -.Nm -driver include: -.Pp -.Bl -bullet -compact -.It -MegaRAID SATA 150-4 -.It -MegaRAID SATA 150-6 -.It -MegaRAID SATA 300-4X -.It -MegaRAID SATA 300-8X -.It -MegaRAID SCSI 320-1E -.It -MegaRAID SCSI 320-2E -.It -MegaRAID SCSI 320-4E -.It -MegaRAID SCSI 320-0X -.It -MegaRAID SCSI 320-2X -.It -MegaRAID SCSI 320-4X -.It -MegaRAID SCSI 320-0 -.It -MegaRAID SCSI 320-1 -.It -MegaRAID SCSI 320-2 -.It -MegaRAID SCSI 320-4 -.It -MegaRAID Series 418 -.It -MegaRAID i4 133 RAID -.It -MegaRAID Elite 1500 (Series 467) -.It -MegaRAID Elite 1600 (Series 493) -.It -MegaRAID Elite 1650 (Series 4xx) -.It -MegaRAID Enterprise 1200 (Series 428) -.It -MegaRAID Enterprise 1300 (Series 434) -.It -MegaRAID Enterprise 1400 (Series 438) -.It -MegaRAID Enterprise 1500 (Series 467) -.It -MegaRAID Enterprise 1600 (Series 471) -.It -MegaRAID Express 100 (Series 466WS) -.It -MegaRAID Express 200 (Series 466) -.It -MegaRAID Express 300 (Series 490) -.It -MegaRAID Express 500 (Series 475) -.It -Dell PERC -.It -Dell PERC 2/SC -.It -Dell PERC 2/DC -.It -Dell PERC 3/DCL -.It -Dell PERC 3/QC -.It -Dell PERC 4/DC -.It -Dell PERC 4/IM -.It -Dell PERC 4/SC -.It -Dell PERC 4/Di -.It -Dell PERC 4e/DC -.It -Dell PERC 4e/Di -.It -Dell PERC 4e/Si -.It -Dell PERC 4ei -.It -HP NetRAID-1/Si -.It -HP NetRAID-3/Si (D4943A) -.It -HP Embedded NetRAID -.It -Intel RAID Controller SRCS16 -.It -Intel RAID Controller SRCU42X -.El -.Sh DIAGNOSTICS -.Ss Driver initialisation/shutdown phase -.Bl -diag -.It amr%d: memory window not available -.It amr%d: I/O window not available -.Pp -The PCI BIOS did not allocate resources necessary for the correct operation of -the controller. -The driver cannot attach to this controller. -.It amr%d: busmaster bit not set, enabling -.Pp -The PCI BIOS did not enable busmaster DMA, -which is required for the correct operation of the controller. -The driver has enabled this bit and initialisation will proceed. -.It amr%d: can't allocate register window -.It amr%d: can't allocate interrupt -.It amr%d: can't set up interrupt -.It amr%d: can't allocate parent DMA tag -.It amr%d: can't allocate buffer DMA tag -.It amr%d: can't allocate scatter/gather DMA tag -.It amr%d: can't allocate s/g table -.It amr%d: can't allocate mailbox tag -.It amr%d: can't allocate mailbox memory -.Pp -A resource allocation error occurred while initialising the driver; -initialisation has failed and the driver will not attach to this controller. -.It amr%d: can't obtain configuration data from controller -.It amr%d: can't obtain product data from controller -.Pp -The driver was unable to obtain vital configuration data from the controller. -Initialisation has failed and the driver will not attach to this controller. -.It amr%d: can't establish configuration hook -.It amr%d: can't scan controller for drives -.Pp -The scan for logical drives managed by the controller failed. -No drives will be attached. -.It amr%d: device_add_child failed -.It amr%d: bus_generic_attach returned %d -.Pp -Creation of the logical drive instances failed; -attachment of one or more logical drives may have been aborted. -.It amr%d: flushing cache... -.Pp -The controller cache is being flushed prior to shutdown or detach. -.El -.Ss Operational diagnostics -.Bl -diag -.It amr%d: I/O beyond end of unit (%u,%d > %u) -.Pp -A partitioning error or disk corruption has caused an I/O request -beyond the end of the logical drive. -This may also occur if FlexRAID Virtual Sizing is enabled and -an I/O operation is attempted on a portion of the virtual drive -beyond the actual capacity available. -.It amr%d: polled command timeout -.Pp -An initialisation command timed out. -The initialisation process may fail as a result. -.It amr%d: bad slot %d completed -.Pp -The controller reported completion of a command that the driver did not issue. -This may result in data corruption, -and suggests a hardware or firmware problem with the system or controller. -.It amr%d: I/O error - %x -.Pp -An I/O error has occurred. -.El -.Sh SEE ALSO -.Xr cd 4 , -.Xr da 4 , -.Xr mfi 4 , -.Xr sa 4 , -.Xr scsi 4 -.Sh AUTHORS -.An -nosplit -The -.Nm -driver was written by -.An Mike Smith Aq Mt msmith@FreeBSD.org . -.Pp -This manual page was written by -.An Mike Smith Aq Mt msmith@FreeBSD.org -and -.An Jeroen Ruigrok van der Werven Aq Mt asmodai@FreeBSD.org . diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index afd386f5913e..9d15833e472a 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -180,7 +180,6 @@ device ses # Enclosure Services (SES and SAF-TE) #device ctl # CAM Target Layer # RAID controllers interfaced to the SCSI subsystem -device amr # AMI MegaRAID device arcmsr # Areca SATA II RAID device ciss # Compaq Smart RAID 5* device ips # IBM (Adaptec) ServeRAID diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 2221f8feb7dd..f0546dfca101 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1642,8 +1642,6 @@ device ciss # device ida # Compaq Smart RAID device mlx # Mylex DAC960 -device amr # AMI MegaRAID -device amrp # SCSI Passthrough interface (optional, CAM req.) device mfi # LSI MegaRAID SAS device mfip # LSI MegaRAID SAS passthrough, requires CAM options MFI_DEBUG diff --git a/sys/conf/files b/sys/conf/files index 637aed6bfb9c..650887cf54e6 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -890,10 +890,6 @@ dev/altera/pio/pio.c optional altera_pio dev/altera/pio/pio_if.m optional altera_pio dev/amdpm/amdpm.c optional amdpm pci | nfpm pci dev/amdsmb/amdsmb.c optional amdsmb pci -dev/amr/amr.c optional amr -dev/amr/amr_cam.c optional amrp amr -dev/amr/amr_disk.c optional amr -dev/amr/amr_pci.c optional amr pci # dev/ata/ata_if.m optional ata | atacore dev/ata/ata-all.c optional ata | atacore diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c deleted file mode 100644 index 1c4f252345e9..000000000000 --- a/sys/dev/amr/amr.c +++ /dev/null @@ -1,2446 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1999,2000 Michael Smith - * Copyright (c) 2000 BSDi - * Copyright (c) 2005 Scott Long - * 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. - */ -/*- - * Copyright (c) 2002 Eric Moore - * Copyright (c) 2002, 2004 LSI Logic Corporation - * 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. - * 3. The party using or redistributing the source code and binary forms - * agrees to the disclaimer below and the terms and conditions set forth - * herein. - * - * 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. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * Driver for the AMI MegaRaid family of controllers. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/sysctl.h> - -#include <sys/bio.h> -#include <sys/bus.h> -#include <sys/conf.h> -#include <sys/stat.h> - -#include <machine/bus.h> -#include <machine/cpu.h> -#include <machine/resource.h> -#include <sys/rman.h> - -#include <dev/pci/pcireg.h> -#include <dev/pci/pcivar.h> - -#include <dev/amr/amrio.h> -#include <dev/amr/amrreg.h> -#include <dev/amr/amrvar.h> -#define AMR_DEFINE_TABLES -#include <dev/amr/amr_tables.h> - -SYSCTL_NODE(_hw, OID_AUTO, amr, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, - "AMR driver parameters"); - -static d_open_t amr_open; -static d_close_t amr_close; -static d_ioctl_t amr_ioctl; - -static struct cdevsw amr_cdevsw = { - .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, - .d_open = amr_open, - .d_close = amr_close, - .d_ioctl = amr_ioctl, - .d_name = "amr", -}; - -int linux_no_adapter = 0; -/* - * Initialisation, bus interface. - */ -static void amr_startup(void *arg); - -/* - * Command wrappers - */ -static int amr_query_controller(struct amr_softc *sc); -static void *amr_enquiry(struct amr_softc *sc, size_t bufsize, - u_int8_t cmd, u_int8_t cmdsub, u_int8_t cmdqual, int *status); -static void amr_completeio(struct amr_command *ac); -static int amr_support_ext_cdb(struct amr_softc *sc); - -/* - * Command buffer allocation. - */ -static void amr_alloccmd_cluster(struct amr_softc *sc); -static void amr_freecmd_cluster(struct amr_command_cluster *acc); - -/* - * Command processing. - */ -static int amr_bio_command(struct amr_softc *sc, struct amr_command **acp); -static int amr_wait_command(struct amr_command *ac) __unused; -static int amr_mapcmd(struct amr_command *ac); -static void amr_unmapcmd(struct amr_command *ac); -static int amr_start(struct amr_command *ac); -static void amr_complete(void *context, ac_qhead_t *head); -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); -static void amr_abort_load(struct amr_command *ac); - -/* - * Interface-specific shims - */ -static int amr_quartz_submit_command(struct amr_command *ac); -static int amr_quartz_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave); -static int amr_quartz_poll_command(struct amr_command *ac); -static int amr_quartz_poll_command1(struct amr_softc *sc, struct amr_command *ac); - -static int amr_std_submit_command(struct amr_command *ac); -static int amr_std_get_work(struct amr_softc *sc, struct amr_mailbox *mbsave); -static int amr_std_poll_command(struct amr_command *ac); -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 - -/* - * Debugging - */ -static void amr_describe_controller(struct amr_softc *sc); -#ifdef AMR_DEBUG -#if 0 -static void amr_printcommand(struct amr_command *ac); -#endif -#endif - -static void amr_init_sysctl(struct amr_softc *sc); -static int amr_linux_ioctl_int(struct cdev *dev, u_long cmd, caddr_t addr, - int32_t flag, struct thread *td); - -static MALLOC_DEFINE(M_AMR, "amr", "AMR memory"); - -/******************************************************************************** - ******************************************************************************** - Inline Glue - ******************************************************************************** - ********************************************************************************/ - -/******************************************************************************** - ******************************************************************************** - Public Interfaces - ******************************************************************************** - ********************************************************************************/ - -/******************************************************************************** - * Initialise the controller and softc. - */ -int -amr_attach(struct amr_softc *sc) -{ - device_t child; - - debug_called(1); - - /* - * Initialise per-controller queues. - */ - amr_init_qhead(&sc->amr_freecmds); - amr_init_qhead(&sc->amr_ready); - TAILQ_INIT(&sc->amr_cmd_clusters); - bioq_init(&sc->amr_bioq); - - debug(2, "queue init done"); - - /* - * Configure for this controller type. - */ - if (AMR_IS_QUARTZ(sc)) { - sc->amr_submit_command = amr_quartz_submit_command; - sc->amr_get_work = amr_quartz_get_work; - sc->amr_poll_command = amr_quartz_poll_command; - sc->amr_poll_command1 = amr_quartz_poll_command1; - } else { - sc->amr_submit_command = amr_std_submit_command; - sc->amr_get_work = amr_std_get_work; - sc->amr_poll_command = amr_std_poll_command; - amr_std_attach_mailbox(sc); - } - -#ifdef AMR_BOARD_INIT - if ((AMR_IS_QUARTZ(sc) ? amr_quartz_init(sc) : amr_std_init(sc))) - return(ENXIO); -#endif - - /* - * Allocate initial commands. - */ - amr_alloccmd_cluster(sc); - - /* - * Quiz controller for features and limits. - */ - if (amr_query_controller(sc)) - return(ENXIO); - - debug(2, "controller query complete"); - - /* - * preallocate the remaining commands. - */ - while (sc->amr_nextslot < sc->amr_maxio) - amr_alloccmd_cluster(sc); - - /* - * Setup sysctls. - */ - amr_init_sysctl(sc); - - /* - * Attach our 'real' SCSI channels to CAM. - */ - 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); - } - - /* - * Create the control device. - */ - 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; - linux_no_adapter++; - if (device_get_unit(sc->amr_dev) == 0) - make_dev_alias(sc->amr_dev_t, "megadev0"); - - /* - * Schedule ourselves to bring the controller up once interrupts are - * available. - */ - 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); - } - - /* - * Print a little information about the controller. - */ - amr_describe_controller(sc); - - debug(2, "attach complete"); - return(0); -} - -/******************************************************************************** - * Locate disk resources and attach children to them. - */ -static void -amr_startup(void *arg) -{ - struct amr_softc *sc = (struct amr_softc *)arg; - struct amr_logdrive *dr; - int i, error; - - debug_called(1); - - /* get up-to-date drive information */ - if (amr_query_controller(sc)) { - device_printf(sc->amr_dev, "can't scan controller for drives\n"); - 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); - - dr->al_disk = device_add_child(sc->amr_dev, NULL, -1); - if (dr->al_disk == 0) - device_printf(sc->amr_dev, "device_add_child failed\n"); - device_set_ivars(dr->al_disk, dr); - } - } - - 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; - - /* pull ourselves off the intrhook chain */ - if (sc->amr_ich.ich_func) - config_intrhook_disestablish(&sc->amr_ich); - sc->amr_ich.ich_func = NULL; - - return; -} - -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, - ""); - 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, - ""); -} - -/******************************************************************************* - * Free resources associated with a controller instance - */ -void -amr_free(struct amr_softc *sc) -{ - struct amr_command_cluster *acc; - - /* detach from CAM */ - if (sc->amr_pass != NULL) - device_delete_child(sc->amr_dev, sc->amr_pass); - - /* 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); - } - - /* destroy control device */ - if( sc->amr_dev_t != (struct cdev *)NULL) - destroy_dev(sc->amr_dev_t); - - 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); -} - -/******************************************************************************* - * Receive a bio structure from a child device and queue it on a particular - * disk resource, then poke the disk resource to start as much work as it can. - */ -int -amr_submit_bio(struct amr_softc *sc, struct bio *bio) -{ - debug_called(2); - - mtx_lock(&sc->amr_list_lock); - amr_enqueue_bio(sc, bio); - amr_startio(sc); - mtx_unlock(&sc->amr_list_lock); - return(0); -} - -/******************************************************************************** - * Accept an open operation on the control device. - */ -static int -amr_open(struct cdev *dev, int flags, int fmt, struct thread *td) -{ - int unit = dev2unit(dev); - struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit); - - debug_called(1); - - sc->amr_state |= AMR_STATE_OPEN; - return(0); -} - -#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 - -/******************************************************************************** - * Accept the last close on the control device. - */ -static int -amr_close(struct cdev *dev, int flags, int fmt, struct thread *td) -{ - int unit = dev2unit(dev); - struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit); - - debug_called(1); - - sc->amr_state &= ~AMR_STATE_OPEN; - return (0); -} - -/******************************************************************************** - * Handle controller-specific control operations. - */ -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; - - sc->amr_drive[i].al_disk = 0; - } - } - -shutdown_out: - amr_startup(sc); -} - -/* - * Bug-for-bug compatibility with Linux! - * Some apps will send commands with inlen and outlen set to 0, - * even though they expect data to be transferred to them from the - * 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 - * 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. - */ -static unsigned long -amr_ioctl_buffer_length(unsigned long len) -{ - - if (len <= 4 * 1024) - return (4 * 1024); - if (len <= 8 * 1024) - return (8 * 1024); - if (len <= 32 * 1024) - return (32 * 1024); - if (len <= 64 * 1024) - return (64 * 1024); - return (len); -} - -int -amr_linux_ioctl_int(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag, - struct thread *td) -{ - 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; - int len, ac_flags = 0; - 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; - - if ((error = copyin(addr, &ali, sizeof(ali))) != 0) - return (error); - 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': - copyout(&linux_no_adapter, (void *)(uintptr_t)ali.data, - sizeof(linux_no_adapter)); - td->td_retval[0] = linux_no_adapter; - 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) { - 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; - - error = copyin((void *)(uintptr_t)mb->mb_physaddr, ap, - sizeof(struct amr_passthrough)); - if (error) - break; - - if (ap->ap_data_transfer_length) - dp = malloc(ap->ap_data_transfer_length, M_AMR, - 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; - } - - ac_flags = AMR_CMD_DATAIN|AMR_CMD_DATAOUT|AMR_CMD_CCB; - bzero(&ac->ac_mailbox, sizeof(ac->ac_mailbox)); - ac->ac_mailbox.mb_command = AMR_CMD_PASS; - ac->ac_flags = ac_flags; *** 4945 LINES SKIPPED ***