Add an ISA attachement to the aic7xxx driver to handle 284X controllers.
authorPeter Avalos <pavalos@dragonflybsd.org>
Fri, 6 Jul 2007 04:56:22 +0000 (04:56 +0000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Fri, 6 Jul 2007 04:56:22 +0000 (04:56 +0000)
The ISA probe uses an identify routine to probe all slot locations from
1 to 14 that do not conflict with other allocated resources.  This required
making aic7770.c part of the driver core when compiled as a module.

aic7xxx.c:
aic79xx.c:
aic_osm_lib.c:
        Use aic_scb_timer_start() consistently to start the watchdog timer.
        This removes a few places that verbatum copied the code in
        aic_scb_timer_start().

        During recovery processing, allow commands to still be queued to
        the controller.  The only requirement we have is that our recovery
        command be queued first - something the code already guaranteed.
        The only other change required to make this work is to prevent
        timers from being started for these newly queued commands.

Obtained-from: FreeBSD

15 files changed:
sys/dev/disk/aic7xxx/ahc/Makefile
sys/dev/disk/aic7xxx/ahc/ahc_eisa/Makefile
sys/dev/disk/aic7xxx/ahc/ahc_isa/Makefile [new file with mode: 0644]
sys/dev/disk/aic7xxx/ahc_eisa.c
sys/dev/disk/aic7xxx/ahc_isa.c [new file with mode: 0644]
sys/dev/disk/aic7xxx/ahc_pci.c
sys/dev/disk/aic7xxx/aic79xx.c
sys/dev/disk/aic7xxx/aic79xx.h
sys/dev/disk/aic7xxx/aic79xx_osm.c
sys/dev/disk/aic7xxx/aic7xxx.c
sys/dev/disk/aic7xxx/aic7xxx.h
sys/dev/disk/aic7xxx/aic7xxx_osm.c
sys/dev/disk/aic7xxx/aic7xxx_osm.h
sys/dev/disk/aic7xxx/aic_osm_lib.c
sys/dev/disk/aic7xxx/aic_osm_lib.h

index 26beb1a..fdc1b05 100644 (file)
@@ -1,10 +1,10 @@
 
 # $FreeBSD: src/sys/modules/aic7xxx/ahc/Makefile,v 1.2.2.1 2002/09/02 05:47:44 scottl Exp $
-# $DragonFly: src/sys/dev/disk/aic7xxx/ahc/Makefile,v 1.5 2005/04/21 14:43:58 joerg Exp $
+# $DragonFly: src/sys/dev/disk/aic7xxx/ahc/Makefile,v 1.6 2007/07/06 04:56:22 pavalos Exp $
 
 .PATH: ${.CURDIR}/..
 KMOD=  ahc
-SUBDIR=        ahc_eisa ahc_pci
+SUBDIR=        ahc_eisa ahc_isa ahc_pci
 
 BEFORE_DEPEND= aic7xxx_{seq,reg}.h
 
@@ -29,7 +29,7 @@ SRCS= ${GENSRCS}
 SRCS+= aic7xxx_reg_print.c
 CFLAGS+= -DAHC_REG_PRETTY_PRINT=1
 .endif
-SRCS+= aic7xxx.c aic7xxx_93cx6.c aic7xxx_osm.c
+SRCS+= aic7xxx.c aic7xxx_93cx6.c aic7xxx_osm.c aic7770.c
 SRCS+= opt_scsi.h opt_aic7xxx.h opt_cam.h
 SRCS+= device_if.h bus_if.h pci_if.h
 
index cd70466..a677549 100644 (file)
@@ -1,6 +1,6 @@
 
 # $FreeBSD: src/sys/modules/aic7xxx/ahc/ahc_eisa/Makefile,v 1.1.2.1 2002/09/02 05:47:45 scottl Exp $
-# $DragonFly: src/sys/dev/disk/aic7xxx/ahc/ahc_eisa/Makefile,v 1.3 2003/08/15 08:32:28 dillon Exp $
+# $DragonFly: src/sys/dev/disk/aic7xxx/ahc/ahc_eisa/Makefile,v 1.4 2007/07/06 04:56:22 pavalos Exp $
 
 .PATH: ${.CURDIR}/../..
 KMOD=          ahc_eisa
@@ -8,8 +8,8 @@ KMOD=           ahc_eisa
 ../aic7xxx_reg.h:
        ( cd .. ; ${MAKE} aic7xxx_reg.h )
 
-SRCS=  ahc_eisa.c aic7770.c ../aic7xxx_reg.h
-SRCS+= device_if.h bus_if.h pci_if.h
+SRCS=  ahc_eisa.c ../aic7xxx_reg.h
+SRCS+= device_if.h bus_if.h
 SRCS+= opt_scsi.h opt_cam.h opt_aic7xxx.h
 
 CFLAGS+=       -I${.CURDIR}/../../ -I..
diff --git a/sys/dev/disk/aic7xxx/ahc/ahc_isa/Makefile b/sys/dev/disk/aic7xxx/ahc/ahc_isa/Makefile
new file mode 100644 (file)
index 0000000..987eef0
--- /dev/null
@@ -0,0 +1,19 @@
+
+# $FreeBSD: src/sys/modules/aic7xxx/ahc/ahc_isa/Makefile,v 1.1 2004/08/17 02:32:30 gibbs Exp $
+# $DragonFly: src/sys/dev/disk/aic7xxx/ahc/ahc_isa/Makefile,v 1.1 2007/07/06 04:56:22 pavalos Exp $
+
+.PATH: ${.CURDIR}/../..
+KMOD=          ahc_isa
+
+../aic7xxx_reg.h:
+       ( cd .. ; ${MAKE} aic7xxx_reg.h )
+
+SRCS=  ahc_isa.c ../aic7xxx_reg.h
+SRCS+= device_if.h bus_if.h pci_if.h isa_if.h
+SRCS+= opt_scsi.h opt_cam.h opt_aic7xxx.h
+
+CFLAGS+=       -I${.CURDIR}/../.. -I..
+
+CLEANFILES=    ../aic7xxx_reg.h ../aic7xxx_seq.h
+
+.include <bsd.kmod.mk>
index d23ae95..40e5c67 100644 (file)
@@ -28,8 +28,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#13 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.33 2004/03/17 17:50:25 njl Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/ahc_eisa.c,v 1.8 2007/07/06 01:11:07 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.34 2004/08/17 00:14:30 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/ahc_eisa.c,v 1.9 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #include "aic7xxx_osm.h"
@@ -157,41 +157,6 @@ aic7770_attach(device_t dev)
        return (0);
 }
 
-int
-aic7770_map_registers(struct ahc_softc *ahc, u_int unused_ioport_arg)
-{
-       struct  resource *regs;
-       int     rid;
-
-       rid = 0;
-       regs = bus_alloc_resource_any(ahc->dev_softc, SYS_RES_IOPORT, &rid,
-                                     RF_ACTIVE);
-       if (regs == NULL) {
-               device_printf(ahc->dev_softc, "Unable to map I/O space?!\n");
-               return ENOMEM;
-       }
-       ahc->platform_data->regs_res_type = SYS_RES_IOPORT;
-       ahc->platform_data->regs_res_id = rid,
-       ahc->platform_data->regs = regs;
-       ahc->tag = rman_get_bustag(regs);
-       ahc->bsh = rman_get_bushandle(regs);
-       return (0);
-}
-
-int
-aic7770_map_int(struct ahc_softc *ahc, int irq)
-{
-       int zero;
-
-       zero = 0;
-       ahc->platform_data->irq =
-           bus_alloc_resource_any(ahc->dev_softc, SYS_RES_IRQ, &zero,
-                                  RF_ACTIVE);
-       if (ahc->platform_data->irq == NULL)
-               return (ENOMEM);
-       ahc->platform_data->irq_res_type = SYS_RES_IRQ;
-       return (ahc_map_int(ahc));
-}
 
 static device_method_t ahc_eisa_device_methods[] = {
        /* Device interface */
diff --git a/sys/dev/disk/aic7xxx/ahc_isa.c b/sys/dev/disk/aic7xxx/ahc_isa.c
new file mode 100644 (file)
index 0000000..5904be5
--- /dev/null
@@ -0,0 +1,302 @@
+/*
+ * FreeBSD, VLB/ISA product support functions
+ *
+ * Copyright (c) 2004 Justin T. Gibbs.
+ * 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,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ *
+ * $Id$
+ *
+ * $FreeBSD: src/sys/dev/aic7xxx/ahc_isa.c,v 1.5 2004/10/15 23:39:52 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/ahc_isa.c,v 1.1 2007/07/06 04:56:22 pavalos Exp $
+ */
+
+#include "aic7xxx_osm.h"
+
+#include <cpu/limits.h>                /* For CHAR_BIT */
+#include <bus/isa/isavar.h>    /* For ISA attach glue */
+
+
+static struct aic7770_identity *ahc_isa_find_device(bus_space_tag_t tag,
+                                                   bus_space_handle_t bsh);
+static void                    ahc_isa_identify(driver_t *driver,
+                                                device_t parent);
+static int                     ahc_isa_probe(device_t dev);
+static int                     ahc_isa_attach(device_t dev);
+
+/*
+ * Perform an EISA probe of the address with the addition
+ * of a "priming" step.  The 284X requires priming (a write
+ * to offset 0x80, the first EISA ID register) to ensure it
+ * is not mistaken as an EISA card.  Once we have the ID,
+ * lookup the controller in the aic7770 table of supported
+ * devices.
+ */
+static struct aic7770_identity *
+ahc_isa_find_device(bus_space_tag_t tag, bus_space_handle_t bsh) {
+       uint32_t  id;
+       u_int     id_size;
+       int       i;
+
+       id = 0;
+       id_size = sizeof(id);
+       for (i = 0; i < id_size; i++) {
+               bus_space_write_1(tag, bsh, 0x80, 0x80 + i);
+               id |= bus_space_read_1(tag, bsh, 0x80 + i)
+                  << ((id_size - i - 1) * CHAR_BIT);
+       }
+                           
+       return (aic7770_find_device(id));
+}
+
+static void
+ahc_isa_identify(driver_t *driver, device_t parent)
+{
+       int slot;
+       int max_slot;
+
+       max_slot = 14;
+       for (slot = 0; slot <= max_slot; slot++) {
+               struct aic7770_identity *entry;
+               bus_space_tag_t     tag;
+               bus_space_handle_t  bsh;
+               struct resource    *regs;
+               uint32_t            iobase;
+               int                 rid;
+
+               rid = 0;
+               iobase = (slot * AHC_EISA_SLOT_SIZE) + AHC_EISA_SLOT_OFFSET;
+               regs = bus_alloc_resource(parent, SYS_RES_IOPORT, &rid,
+                                         iobase, iobase, AHC_EISA_IOSIZE,
+                                         RF_ACTIVE);
+               if (regs == NULL) {
+                       if (bootverbose)
+                               kprintf("ahc_isa_probe %d: ioport 0x%x "
+                                      "alloc failed\n", slot, iobase);
+                       continue;
+               }
+
+               tag = rman_get_bustag(regs);
+               bsh = rman_get_bushandle(regs);
+
+               entry = ahc_isa_find_device(tag, bsh);
+               if (entry != NULL) {
+                       device_t child;
+
+                       child = BUS_ADD_CHILD(parent, parent, ISA_ORDER_SPECULATIVE,
+                                             "ahc", -1);
+                       if (child != NULL) {
+                               device_set_driver(child, driver);
+                               bus_set_resource(child, SYS_RES_IOPORT,
+                                                0, iobase, AHC_EISA_IOSIZE);
+                       }
+               }
+               bus_release_resource(parent, SYS_RES_IOPORT, rid, regs);
+       }
+}
+
+static int
+ahc_isa_probe(device_t dev)
+{
+       struct    aic7770_identity *entry;
+       bus_space_tag_t     tag;
+       bus_space_handle_t  bsh;
+       struct    resource *regs;
+       struct    resource *irq;
+       uint32_t  iobase;
+       u_int     intdef;
+       u_int     hcntrl;
+       int       irq_num;
+       int       error;
+       int       zero;
+
+       error = ENXIO;
+       zero = 0;
+       regs = NULL;
+       irq = NULL;
+
+       /* Skip probes for ISA PnP devices */
+       if (isa_get_logicalid(dev) != 0)
+               return (error);
+
+       regs = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &zero, RF_ACTIVE);
+       if (regs == NULL) {
+               device_printf(dev, "No resources allocated.\n");
+               return (ENOMEM);
+       }
+
+       iobase = rman_get_start(regs);
+       tag = rman_get_bustag(regs);
+       bsh = rman_get_bushandle(regs);
+
+       entry = ahc_isa_find_device(tag, bsh);
+       if (entry == NULL)
+               goto cleanup;
+
+       /* Pause the card preseving the IRQ type */
+       hcntrl = bus_space_read_1(tag, bsh, HCNTRL) & IRQMS;
+       bus_space_write_1(tag, bsh, HCNTRL, hcntrl | PAUSE);
+       while ((bus_space_read_1(tag, bsh, HCNTRL) & PAUSE) == 0)
+               ;
+
+       /* Make sure we have a valid interrupt vector */
+       intdef = bus_space_read_1(tag, bsh, INTDEF);
+       irq_num = intdef & VECTOR;
+       switch (irq_num) {
+       case 9: 
+       case 10:
+       case 11:
+       case 12:
+       case 14:
+       case 15:
+               break;
+       default:
+               device_printf(dev, "@0x%x: illegal irq setting %d\n",
+                             iobase, irq_num);
+               goto cleanup;
+       }
+
+       if (bus_set_resource(dev, SYS_RES_IRQ, zero, irq_num, 1) != 0)
+               goto cleanup;
+
+       /*
+        * The 284X only supports edge triggered interrupts,
+        * so do not claim RF_SHAREABLE.
+        */
+       irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &zero,
+                                    0 /*!(RF_ACTIVE|RF_SHAREABLE)*/);
+       if (irq != NULL) {
+               error = 0;
+               device_set_desc(dev, entry->name);
+       } else 
+               device_printf(dev, "@0x%x: irq %d allocation failed\n",
+                             iobase, irq_num);
+
+cleanup:
+       if (regs != NULL) {
+               bus_release_resource(dev, SYS_RES_IOPORT, zero, regs);
+               regs = NULL;
+       }
+
+       if (irq != NULL) {
+               bus_release_resource(dev, SYS_RES_IRQ, zero, irq);
+               irq = NULL;
+       }
+
+       return (error);
+}
+
+static int
+ahc_isa_attach(device_t dev)
+{
+       struct   aic7770_identity *entry;
+       bus_space_tag_t     tag;
+       bus_space_handle_t  bsh;
+       struct    resource *regs;
+       struct    ahc_softc *ahc;
+       char     *name;
+       int       zero;
+       int       error;
+
+       zero = 0;
+       regs = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &zero, RF_ACTIVE);
+       if (regs == NULL)
+               return (ENOMEM);
+
+       tag = rman_get_bustag(regs);
+       bsh = rman_get_bushandle(regs);
+       entry = ahc_isa_find_device(tag, bsh);
+       bus_release_resource(dev, SYS_RES_IOPORT, zero, regs);
+       if (entry == NULL)
+               return (ENODEV);
+
+       /*
+        * Allocate a softc for this card and
+        * set it up for attachment by our
+        * common detect routine.
+        */
+       name = kmalloc(strlen(device_get_nameunit(dev)) + 1, M_DEVBUF, M_NOWAIT);
+       if (name == NULL)
+               return (ENOMEM);
+       strcpy(name, device_get_nameunit(dev));
+       ahc = ahc_alloc(dev, name);
+       if (ahc == NULL)
+               return (ENOMEM);
+
+       ahc_set_unit(ahc, device_get_unit(dev));
+
+       /* Allocate a dmatag for our SCB DMA maps */
+       /* XXX Should be a child of the VLB/ISA bus dma tag */
+       error = aic_dma_tag_create(ahc, /*parent*/NULL, /*alignment*/1,
+                                  /*boundary*/0,
+                                  /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
+                                  /*highaddr*/BUS_SPACE_MAXADDR,
+                                  /*filter*/NULL, /*filterarg*/NULL,
+                                  /*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
+                                  /*nsegments*/AHC_NSEG,
+                                  /*maxsegsz*/AHC_MAXTRANSFER_SIZE,
+                                  /*flags*/0,
+                                  &ahc->parent_dmat);
+
+       if (error != 0) {
+               kprintf("ahc_isa_attach: Could not allocate DMA tag "
+                      "- error %d\n", error);
+               ahc_free(ahc);
+               return (ENOMEM);
+       }
+       ahc->dev_softc = dev;
+       error = aic7770_config(ahc, entry, /*unused ioport arg*/0);
+       if (error != 0) {
+               ahc_free(ahc);
+               return (error);
+       }
+
+       ahc_attach(ahc);
+       return (0);
+}
+
+static device_method_t ahc_isa_device_methods[] = {
+       /* Device interface */
+       DEVMETHOD(device_identify,      ahc_isa_identify),
+       DEVMETHOD(device_probe,         ahc_isa_probe),
+       DEVMETHOD(device_attach,        ahc_isa_attach),
+       DEVMETHOD(device_detach,        ahc_detach),
+       { 0, 0 }
+};
+
+static driver_t ahc_isa_driver = {
+       "ahc",
+       ahc_isa_device_methods,
+       sizeof(struct ahc_softc)
+};
+
+DRIVER_MODULE(ahc_isa, isa, ahc_isa_driver, ahc_devclass, 0, 0);
+MODULE_DEPEND(ahc_isa, ahc, 1, 1, 1);
+MODULE_VERSION(ahc_isa, 1);
index b7d8320..769fcca 100644 (file)
@@ -30,8 +30,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#19 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/ahc_pci.c,v 1.61 2004/03/17 17:50:25 njl Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/ahc_pci.c,v 1.11 2007/07/06 01:11:07 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/ahc_pci.c,v 1.62 2004/08/17 00:14:30 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/ahc_pci.c,v 1.12 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #include "aic7xxx_osm.h"
@@ -238,23 +238,4 @@ ahc_pci_map_registers(struct ahc_softc *ahc)
        return (0);
 }
 
-int
-ahc_pci_map_int(struct ahc_softc *ahc)
-{
-       int zero;
-
-       zero = 0;
-       ahc->platform_data->irq =
-           bus_alloc_resource_any(ahc->dev_softc, SYS_RES_IRQ, &zero,
-                                  RF_ACTIVE | RF_SHAREABLE);
-       if (ahc->platform_data->irq == NULL) {
-               device_printf(ahc->dev_softc,
-                             "bus_alloc_resource() failed to allocate IRQ\n");
-               return (ENOMEM);
-       }
-       ahc->platform_data->irq_res_type = SYS_RES_IRQ;
-       return (ahc_map_int(ahc));
-}
-
-
 #endif
index d8adb6d..0c7efdb 100644 (file)
@@ -39,8 +39,8 @@
  *
  * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#246 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.c,v 1.30 2004/08/04 17:55:33 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.c,v 1.21 2007/07/06 02:40:58 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.c,v 1.31 2004/08/17 00:14:30 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.c,v 1.22 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #include "aic79xx_osm.h"
@@ -8301,9 +8301,14 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
                ahd_queue_scb(ahd, scb);
                /*
                 * Ensure we have enough time to actually
-                * retrieve the sense.
+                * retrieve the sense, but only schedule
+                * the timer if we are not in recovery or
+                * this is a recovery SCB that is allowed
+                * to have an active timer.
                 */
-               aic_scb_timer_reset(scb, 5 * 1000000);
+               if (ahd->scb_data.recovery_scbs == 0
+                || (scb->flags & SCB_RECOVERY_SCB) != 0)
+                       aic_scb_timer_reset(scb, 5 * 1000000);
                break;
        }
        case SCSI_STATUS_OK:
@@ -9387,15 +9392,6 @@ bus_reset:
                         * In either case (selection or reselection),
                         * we will now issue a target reset to the
                         * timed-out device.
-                        *
-                        * Set the MK_MESSAGE control bit indicating
-                        * that we desire to send a message.  We
-                        * also set the disconnected flag since
-                        * in the paging case there is no guarantee
-                        * that our SCB control byte matches the
-                        * version on the card.  We don't want the
-                        * sequencer to abort the command thinking
-                        * an unsolicited reselection occurred.
                         */
                        scb->flags |= SCB_DEVICE_RESET;
                        scb->hscb->cdb_len = 0;
index 21f3f4a..76662fe 100644 (file)
@@ -39,8 +39,8 @@
  *
  * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#107 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.h,v 1.20 2004/08/04 17:55:34 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.h,v 1.9 2007/07/06 02:40:58 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.h,v 1.21 2004/08/17 00:14:30 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.h,v 1.10 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #ifndef _AIC79XX_H_
@@ -668,12 +668,15 @@ struct scb_data {
         */
        struct  scb *scbindex[AHD_SCB_MAX];
 
+       u_int            recovery_scbs; /* Transactions currently in recovery */
+
        /*
         * "Bus" addresses of our data structures.
         */
        bus_dma_tag_t    hscb_dmat;     /* dmat for our hardware SCB array */
        bus_dma_tag_t    sg_dmat;       /* dmat for our sg segments */
        bus_dma_tag_t    sense_dmat;    /* dmat for our sense buffers */
+
        SLIST_HEAD(, map_node) hscb_maps;
        SLIST_HEAD(, map_node) sg_maps;
        SLIST_HEAD(, map_node) sense_maps;
@@ -1069,6 +1072,8 @@ struct ahd_completion
        uint8_t         valid_tag;
 };
 
+#define AIC_SCB_DATA(softc) (&(softc)->scb_data)
+
 struct ahd_softc {
        bus_space_tag_t           tags[2];
        bus_space_handle_t        bshs[2];
index 213b281..5005592 100644 (file)
@@ -31,8 +31,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#35 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic79xx_osm.c,v 1.18 2004/08/04 17:55:34 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx_osm.c,v 1.16 2007/07/06 02:40:58 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic79xx_osm.c,v 1.19 2004/08/17 00:14:30 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx_osm.c,v 1.17 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #include "aic79xx_osm.h"
@@ -251,39 +251,31 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb)
        }
 #endif
 
-       /*
-        * If the recovery SCB completes, we have to be
-        * out of our timeout.
-        */
        if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
                struct  scb *list_scb;
 
-               /*
-                * We were able to complete the command successfully,
-                * so reinstate the timeouts for all other pending
-                * commands.
-                */
-               LIST_FOREACH(list_scb, &ahd->pending_scbs, pending_links) {
-                       union ccb *ccb;
-                       uint64_t time;
-
-                       ccb = list_scb->io_ctx;
-                       if (ccb->ccb_h.timeout == CAM_TIME_INFINITY)
-                               continue;
-
-                       time = ccb->ccb_h.timeout;
-                       time *= hz;
-                       time /= 1000;
-                       callout_reset(&ccb->ccb_h.timeout_ch, time,
-                           ahd_platform_timeout, list_scb);
-               }
+               ahd->scb_data.recovery_scbs--;
 
                if (aic_get_transaction_status(scb) == CAM_BDR_SENT
                 || aic_get_transaction_status(scb) == CAM_REQ_ABORTED)
                        aic_set_transaction_status(scb, CAM_CMD_TIMEOUT);
-               ahd_print_path(ahd, scb);
-               kprintf("no longer in timeout, status = %x\n",
-                      ccb->ccb_h.status);
+
+               if (ahd->scb_data.recovery_scbs == 0) {
+                       /*
+                        * All recovery actions have completed successfully,
+                        * so reinstate the timeouts for all other pending
+                        * commands.
+                        */
+                       LIST_FOREACH(list_scb,
+                                    &ahd->pending_scbs, pending_links) {
+
+                               aic_scb_timer_reset(scb, aic_get_timeout(scb));
+                       }
+
+                       ahd_print_path(ahd, scb);
+                       kprintf("no longer in timeout, status = %x\n",
+                              ccb->ccb_h.status);
+               }
        }
 
        /* Don't clobber any existing error state */
@@ -1107,18 +1099,7 @@ ahd_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
 
        ccb->ccb_h.status |= CAM_SIM_QUEUED;
 
-       if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
-               uint64_t time;
-
-               if (ccb->ccb_h.timeout == CAM_TIME_DEFAULT)
-                       ccb->ccb_h.timeout = 5 * 1000;
-
-               time = ccb->ccb_h.timeout;
-               time *= hz;
-               time /= 1000;
-               callout_reset(&ccb->ccb_h.timeout_ch, time,
-                   ahd_platform_timeout, scb);
-       }
+       aic_scb_timer_start(scb);
 
        if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) {
                /* Define a mapping from our tag to the SCB. */
index a5bc56d..2b78262 100644 (file)
@@ -39,8 +39,8 @@
  *
  * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#155 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.101 2004/08/13 21:39:14 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx.c,v 1.18 2007/07/06 02:44:30 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.102 2004/08/17 00:14:30 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx.c,v 1.19 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #include "aic7xxx_osm.h"
@@ -372,6 +372,9 @@ ahc_run_untagged_queue(struct ahc_softc *ahc, struct scb_tailq *queue)
        if ((scb = TAILQ_FIRST(queue)) != NULL
         && (scb->flags & SCB_ACTIVE) == 0) {
                scb->flags |= SCB_ACTIVE;
+               /*
+                * Timers are disabled while recovery is in progress.
+                */
                aic_scb_timer_start(scb);
                ahc_queue_scb(ahc, scb);
        }
@@ -573,9 +576,14 @@ ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat)
                        ahc_outb(ahc, RETURN_1, SEND_SENSE);
                        /*
                         * Ensure we have enough time to actually
-                        * retrieve the sense.
+                        * retrieve the sense, but only schedule
+                        * the timer if we are not in recovery or
+                        * this is a recovery SCB that is allowed
+                        * to have an active timer.
                         */
-                       aic_scb_timer_reset(scb, 5 * 1000000);
+                       if (ahc->scb_data->recovery_scbs == 0
+                        || (scb->flags & SCB_RECOVERY_SCB) != 0)
+                               aic_scb_timer_reset(scb, 5 * 1000000);
                        break;
                }
                default:
index fb7ca64..f09eb03 100644 (file)
@@ -39,8 +39,8 @@
  *
  * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.h#85 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.h,v 1.50 2003/12/17 00:02:09 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx.h,v 1.3 2007/07/06 00:01:16 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.h,v 1.52 2004/08/18 16:31:56 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx.h,v 1.4 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #ifndef _AIC7XXX_H_
@@ -614,6 +614,8 @@ struct scb_data {
        struct  scb *scbarray;          /* Array of kernel SCBs */
        struct  scsi_sense_data *sense; /* Per SCB sense data */
 
+       u_int   recovery_scbs;          /* Transactions currently in recovery */
+
        /*
         * "Bus" addresses of our data structures.
         */
@@ -921,6 +923,8 @@ typedef int (*ahc_bus_suspend_t)(struct ahc_softc *);
 typedef int (*ahc_bus_resume_t)(struct ahc_softc *);
 typedef void ahc_callback_t (void *);
 
+#define AIC_SCB_DATA(softc) ((softc)->scb_data)
+
 struct ahc_softc {
        bus_space_tag_t           tag;
        bus_space_handle_t        bsh;
@@ -1172,6 +1176,7 @@ struct aic7770_identity {
 extern struct aic7770_identity aic7770_ident_table[];
 extern const int ahc_num_aic7770_devs;
 
+#define AHC_EISA_SLOT_SIZE     0x1000
 #define AHC_EISA_SLOT_OFFSET   0xc00
 #define AHC_EISA_IOSIZE                0x100
 
index d2cc4cb..cade070 100644 (file)
@@ -30,8 +30,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.c#20 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.c,v 1.39 2003/12/17 00:02:10 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx_osm.c,v 1.15 2007/07/06 00:01:16 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.c,v 1.41 2004/08/17 00:14:31 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx_osm.c,v 1.16 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #include "aic7xxx_osm.h"
@@ -90,6 +90,20 @@ int
 ahc_map_int(struct ahc_softc *ahc)
 {
        int error;
+       int zero;
+       int shareable;
+
+       zero = 0;
+       shareable = (ahc->flags & AHC_EDGE_INTERRUPT) ? 0: RF_SHAREABLE;
+       ahc->platform_data->irq =
+           bus_alloc_resource_any(ahc->dev_softc, SYS_RES_IRQ, &zero,
+                                  RF_ACTIVE | shareable);
+       if (ahc->platform_data->irq == NULL) {
+               device_printf(ahc->dev_softc,
+                             "bus_alloc_resource() failed to allocate IRQ\n");
+               return (ENOMEM);
+       }
+       ahc->platform_data->irq_res_type = SYS_RES_IRQ;
 
        /* Hook up our interrupt handler */
        error = bus_setup_intr(ahc->dev_softc, ahc->platform_data->irq,
@@ -102,6 +116,27 @@ ahc_map_int(struct ahc_softc *ahc)
        return (error);
 }
 
+int
+aic7770_map_registers(struct ahc_softc *ahc, u_int unused_ioport_arg)
+{
+       struct  resource *regs;
+       int     rid;
+
+       rid = 0;
+       regs = bus_alloc_resource_any(ahc->dev_softc, SYS_RES_IOPORT, &rid,
+                                     RF_ACTIVE);
+       if (regs == NULL) {
+               device_printf(ahc->dev_softc, "Unable to map I/O space?!\n");
+               return ENOMEM;
+       }
+       ahc->platform_data->regs_res_type = SYS_RES_IOPORT;
+       ahc->platform_data->regs_res_id = rid,
+       ahc->platform_data->regs = regs;
+       ahc->tag = rman_get_bustag(regs);
+       ahc->bsh = rman_get_bushandle(regs);
+       return (0);
+}
+
 /*
  * Attach all the sub-devices we can find
  */
@@ -335,21 +370,28 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
        if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
                struct  scb *list_scb;
 
-               /*
-                * We were able to complete the command successfully,
-                * so renew the timeouts for all other pending
-                * commands.
-                */
-               LIST_FOREACH(list_scb, &ahc->pending_scbs, pending_links) {
-                       aic_scb_timer_reset(scb, aic_get_timeout(scb));
-               }
+               ahc->scb_data->recovery_scbs--;
 
                if (aic_get_transaction_status(scb) == CAM_BDR_SENT
                 || aic_get_transaction_status(scb) == CAM_REQ_ABORTED)
                        aic_set_transaction_status(scb, CAM_CMD_TIMEOUT);
-               ahc_print_path(ahc, scb);
-               kprintf("no longer in timeout, status = %x\n",
-                      ccb->ccb_h.status);
+
+               if (ahc->scb_data->recovery_scbs == 0) {
+                       /*
+                        * All recovery actions have completed successfully,
+                        * so reinstate the timeouts for all other pending
+                        * commands.
+                        */
+                        LIST_FOREACH(list_scb, &ahc->pending_scbs,
+                                     pending_links) {
+
+                               aic_scb_timer_reset(scb, aic_get_timeout(scb));
+                       }
+
+                       ahc_print_path(ahc, scb);
+                       kprintf("no longer in timeout, status = %x\n",
+                              ccb->ccb_h.status);
+               }
        }
 
        /* Don't clobber any existing error state */
@@ -1214,18 +1256,6 @@ ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
 
        ccb->ccb_h.status |= CAM_SIM_QUEUED;
 
-       if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
-               uint64_t time;
-
-               if (ccb->ccb_h.timeout == CAM_TIME_DEFAULT)
-                       ccb->ccb_h.timeout = 5 * 1000;
-
-               time = ccb->ccb_h.timeout;
-               time *= hz;
-               time /= 1000;
-               callout_reset(&ccb->ccb_h.timeout_ch, time, ahc_platform_timeout, scb);
-       }
-
        /*
         * We only allow one untagged transaction
         * per target in the initiator role unless
@@ -1248,6 +1278,11 @@ ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
        }
        scb->flags |= SCB_ACTIVE;
 
+       /*
+        * Timers are disabled while recovery is in progress.
+        */
+       aic_scb_timer_start(scb);
+
        if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) {
                /* Define a mapping from our tag to the SCB. */
                ahc->scb_data->scbindex[scb->hscb->tag] = scb;
index cdef8cb..61b09bd 100644 (file)
@@ -31,8 +31,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#18 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.h,v 1.25 2003/12/17 00:02:10 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx_osm.h,v 1.10 2007/07/06 00:01:16 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx_osm.h,v 1.27 2004/08/17 00:14:31 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx_osm.h,v 1.11 2007/07/06 04:56:22 pavalos Exp $
  */
 
 #ifndef _AIC7XXX_FREEBSD_H_
@@ -199,15 +199,35 @@ ahc_unlock(void)
        crit_exit_id("ahc");
 }
 
+/************************* Initialization/Teardown ****************************/
+int      ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg);
+void     ahc_platform_free(struct ahc_softc *ahc);
+int      ahc_map_int(struct ahc_softc *ahc);
+int      ahc_attach(struct ahc_softc *);
+int      ahc_softc_comp(struct ahc_softc *lahc, struct ahc_softc *rahc);
+int      ahc_detach(device_t);
+
 /********************************** PCI ***************************************/
 #ifdef AIC_PCI_CONFIG
 int ahc_pci_map_registers(struct ahc_softc *ahc);
-int ahc_pci_map_int(struct ahc_softc *ahc);
+#define ahc_pci_map_int ahc_map_int
 #endif /*AIC_PCI_CONFIG*/
 
 /******************************** VL/EISA *************************************/
 int aic7770_map_registers(struct ahc_softc *ahc, u_int port);
-int aic7770_map_int(struct ahc_softc *ahc, int irq);
+static __inline int aic7770_map_int(struct ahc_softc *, int);
+
+static __inline int
+aic7770_map_int(struct ahc_softc *ahc, int irq)
+{
+       /*
+        * The IRQ is unused in the FreeBSD
+        * implementation since the EISA and
+        * ISA attachments register the IRQ
+        * with newbus before the core is called.
+        */
+       return ahc_map_int(ahc);
+}
 
 /********************************* Debug **************************************/
 static __inline void   ahc_print_path(struct ahc_softc *, struct scb *);
@@ -230,14 +250,6 @@ void         ahc_notify_xfer_settings_change(struct ahc_softc *,
 void     ahc_platform_set_tags(struct ahc_softc *, struct ahc_devinfo *,
                                int /*enable*/);
 
-/************************* Initialization/Teardown ****************************/
-int      ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg);
-void     ahc_platform_free(struct ahc_softc *ahc);
-int      ahc_map_int(struct ahc_softc *ahc);
-int      ahc_attach(struct ahc_softc *);
-int      ahc_softc_comp(struct ahc_softc *lahc, struct ahc_softc *rahc);
-int      ahc_detach(device_t);
-
 /****************************** Interrupts ************************************/
 void                   ahc_platform_intr(void *);
 static __inline void   ahc_platform_flushwork(struct ahc_softc *ahc);
index 350a957..ff2568d 100644 (file)
@@ -31,8 +31,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic_osm_lib.c#5 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.c,v 1.2 2003/12/19 18:34:30 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic_osm_lib.c,v 1.1 2007/07/06 00:01:16 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.c,v 1.3 2004/08/17 00:14:31 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic_osm_lib.c,v 1.2 2007/07/06 04:56:22 pavalos Exp $
  */
 
 static void    aic_recovery_thread(void *arg);
@@ -46,15 +46,7 @@ aic_set_recoveryscb(struct aic_softc *aic, struct scb *scb)
 
                scb->flags |= SCB_RECOVERY_SCB;
 
-               /*
-                * Take all queued, but not sent SCBs out of the equation.
-                * Also ensure that no new CCBs are queued to us while we
-                * try to fix this problem.
-                */
-               if ((scb->io_ctx->ccb_h.status & CAM_RELEASE_SIMQ) == 0) {
-                       xpt_freeze_simq(SCB_GET_SIM(aic, scb), /*count*/1);
-                       scb->io_ctx->ccb_h.status |= CAM_RELEASE_SIMQ;
-               }
+               AIC_SCB_DATA(aic)->recovery_scbs++;
 
                /*
                 * Go through all of our pending SCBs and remove
index f6cb476..270ac47 100644 (file)
@@ -32,8 +32,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic_osm_lib.h#5 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.h,v 1.2 2004/05/11 20:33:42 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic_osm_lib.h,v 1.2 2007/07/06 01:42:34 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.h,v 1.3 2004/08/17 00:14:31 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic_osm_lib.h,v 1.3 2007/07/06 04:56:22 pavalos Exp $
  */
 
 /******************************** OS Includes *********************************/
@@ -221,7 +221,8 @@ static __inline void
 aic_scb_timer_start(struct scb *scb)
 {
        
-       if (scb->io_ctx->ccb_h.timeout != CAM_TIME_INFINITY) {
+       if (AIC_SCB_DATA(scb->aic_softc)->recovery_scbs == 0
+        && scb->io_ctx->ccb_h.timeout != CAM_TIME_INFINITY) {
                uint64_t time;
 
                time = scb->io_ctx->ccb_h.timeout;