Merge HEAD from ../scsi-misc-2.6-old
authorJames Bottomley <jejb@mulgrave.(none)>
Fri, 28 Oct 2005 16:41:41 +0000 (11:41 -0500)
committerJames Bottomley <jejb@mulgrave.(none)>
Fri, 28 Oct 2005 16:41:41 +0000 (11:41 -0500)
1  2 
drivers/scsi/Kconfig
drivers/scsi/Makefile
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/aacraid.h
drivers/scsi/aacraid/linit.c

diff --combined drivers/scsi/Kconfig
@@@ -229,24 -229,41 +229,48 @@@ config SCSI_FC_ATTR
  
  config SCSI_ISCSI_ATTRS
        tristate "iSCSI Transport Attributes"
-       depends on SCSI
+       depends on SCSI && NET
        help
          If you wish to export transport-specific information about
          each attached iSCSI device to sysfs, say Y.
          Otherwise, say N.
  
 +config SCSI_SAS_ATTRS
 +      tristate "SAS Transport Attributes"
 +      depends on SCSI
 +      help
 +        If you wish to export transport-specific information about
 +        each attached SAS device to sysfs, say Y.
 +
  endmenu
  
  menu "SCSI low-level drivers"
        depends on SCSI!=n
  
+ config ISCSI_TCP
+       tristate "iSCSI Initiator over TCP/IP"
+       depends on SCSI && INET
+       select CRYPTO
+       select CRYPTO_MD5
+       select CRYPTO_CRC32C
+       select SCSI_ISCSI_ATTRS
+       help
+        The iSCSI Driver provides a host with the ability to access storage
+        through an IP network. The driver uses the iSCSI protocol to transport
+        SCSI requests and responses over a TCP/IP network between the host
+        (the "initiator") and "targets".  Architecturally, the iSCSI driver
+        combines with the host's TCP/IP stack, network drivers, and Network
+        Interface Card (NIC) to provide the same functions as a SCSI or a
+        Fibre Channel (FC) adapter driver with a Host Bus Adapter (HBA).
+        To compile this driver as a module, choose M here: the
+        module will be called iscsi_tcp.
+        The userspace component needed to initialize the driver, documentation,
+        and sample configuration files can be found here:
+        http://linux-iscsi.sf.net
  config SGIWD93_SCSI
        tristate "SGI WD93C93 SCSI Driver"
        depends on SGI_IP22 && SCSI
@@@ -489,11 -506,11 +513,11 @@@ config SCSI_SATA_N
  
          If unsure, say N.
  
 -config SCSI_SATA_PROMISE
 -      tristate "Promise SATA TX2/TX4 support"
 +config SCSI_PDC_ADMA
 +      tristate "Pacific Digital ADMA support"
        depends on SCSI_SATA && PCI
        help
 -        This option enables support for Promise Serial ATA TX2/TX4.
 +        This option enables support for Pacific Digital ADMA controllers
  
          If unsure, say N.
  
@@@ -505,14 -522,6 +529,14 @@@ config SCSI_SATA_QSTO
  
          If unsure, say N.
  
 +config SCSI_SATA_PROMISE
 +      tristate "Promise SATA TX2/TX4 support"
 +      depends on SCSI_SATA && PCI
 +      help
 +        This option enables support for Promise Serial ATA TX2/TX4.
 +
 +        If unsure, say N.
 +
  config SCSI_SATA_SX4
        tristate "Promise SATA SX4 support"
        depends on SCSI_SATA && PCI && EXPERIMENTAL
@@@ -529,14 -538,6 +553,14 @@@ config SCSI_SATA_SI
  
          If unsure, say N.
  
 +config SCSI_SATA_SIL24
 +      tristate "Silicon Image 3124/3132 SATA support"
 +      depends on SCSI_SATA && PCI && EXPERIMENTAL
 +      help
 +        This option enables support for Silicon Image 3124/3132 Serial ATA.
 +
 +        If unsure, say N.
 +
  config SCSI_SATA_SIS
        tristate "SiS 964/180 SATA support"
        depends on SCSI_SATA && PCI && EXPERIMENTAL
@@@ -569,11 -570,6 +593,11 @@@ config SCSI_SATA_VITESS
  
          If unsure, say N.
  
 +config SCSI_SATA_INTEL_COMBINED
 +      bool
 +      depends on IDE=y && !BLK_DEV_IDE_SATA && (SCSI_SATA_AHCI || SCSI_ATA_PIIX)
 +      default y
 +
  config SCSI_BUSLOGIC
        tristate "BusLogic SCSI support"
        depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
diff --combined drivers/scsi/Makefile
@@@ -31,8 -31,8 +31,9 @@@ obj-$(CONFIG_RAID_ATTRS)      += raid_class.
  obj-$(CONFIG_SCSI_SPI_ATTRS)  += scsi_transport_spi.o
  obj-$(CONFIG_SCSI_FC_ATTRS)   += scsi_transport_fc.o
  obj-$(CONFIG_SCSI_ISCSI_ATTRS)        += scsi_transport_iscsi.o
 +obj-$(CONFIG_SCSI_SAS_ATTRS)  += scsi_transport_sas.o
  
+ obj-$(CONFIG_ISCSI_TCP)       += iscsi_tcp.o
  obj-$(CONFIG_SCSI_AMIGA7XX)   += amiga7xx.o   53c7xx.o
  obj-$(CONFIG_A3000_SCSI)      += a3000.o      wd33c93.o
  obj-$(CONFIG_A2091_SCSI)      += a2091.o      wd33c93.o
@@@ -99,7 -99,6 +100,7 @@@ obj-$(CONFIG_SCSI_DC395x)    += dc395x.
  obj-$(CONFIG_SCSI_DC390T)     += tmscsim.o
  obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o
  obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/
 +obj-$(CONFIG_MEGARAID_SAS)    += megaraid/
  obj-$(CONFIG_SCSI_ACARD)      += atp870u.o
  obj-$(CONFIG_SCSI_SUNESP)     += esp.o
  obj-$(CONFIG_SCSI_GDTH)               += gdth.o
@@@ -130,7 -129,6 +131,7 @@@ obj-$(CONFIG_SCSI_ATA_PIIX)        += libata.
  obj-$(CONFIG_SCSI_SATA_PROMISE)       += libata.o sata_promise.o
  obj-$(CONFIG_SCSI_SATA_QSTOR) += libata.o sata_qstor.o
  obj-$(CONFIG_SCSI_SATA_SIL)   += libata.o sata_sil.o
 +obj-$(CONFIG_SCSI_SATA_SIL24) += libata.o sata_sil24.o
  obj-$(CONFIG_SCSI_SATA_VIA)   += libata.o sata_via.o
  obj-$(CONFIG_SCSI_SATA_VITESSE)       += libata.o sata_vsc.o
  obj-$(CONFIG_SCSI_SATA_SIS)   += libata.o sata_sis.o
@@@ -138,7 -136,6 +139,7 @@@ obj-$(CONFIG_SCSI_SATA_SX4)        += libata.
  obj-$(CONFIG_SCSI_SATA_NV)    += libata.o sata_nv.o
  obj-$(CONFIG_SCSI_SATA_ULI)   += libata.o sata_uli.o
  obj-$(CONFIG_SCSI_SATA_MV)    += libata.o sata_mv.o
 +obj-$(CONFIG_SCSI_PDC_ADMA)   += libata.o pdc_adma.o
  
  obj-$(CONFIG_ARM)             += arm/
  
@@@ -313,37 -313,18 +313,37 @@@ int aac_get_containers(struct aac_dev *
                }
                dresp = (struct aac_mount *)fib_data(fibptr);
  
 +              if ((le32_to_cpu(dresp->status) == ST_OK) &&
 +                  (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) {
 +                      dinfo->command = cpu_to_le32(VM_NameServe64);
 +                      dinfo->count = cpu_to_le32(index);
 +                      dinfo->type = cpu_to_le32(FT_FILESYS);
 +
 +                      if (fib_send(ContainerCommand,
 +                                  fibptr,
 +                                  sizeof(struct aac_query_mount),
 +                                  FsaNormal,
 +                                  1, 1,
 +                                  NULL, NULL) < 0)
 +                              continue;
 +              } else
 +                      dresp->mnt[0].capacityhigh = 0;
 +
                dprintk ((KERN_DEBUG
 -                "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%u\n",
 +                "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n",
                  (int)index, (int)le32_to_cpu(dresp->status),
                  (int)le32_to_cpu(dresp->mnt[0].vol),
                  (int)le32_to_cpu(dresp->mnt[0].state),
 -                (unsigned)le32_to_cpu(dresp->mnt[0].capacity)));
 +                ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
 +                  (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32)));
                if ((le32_to_cpu(dresp->status) == ST_OK) &&
                    (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
                    (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
                        fsa_dev_ptr[index].valid = 1;
                        fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol);
 -                      fsa_dev_ptr[index].size = le32_to_cpu(dresp->mnt[0].capacity);
 +                      fsa_dev_ptr[index].size
 +                        = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
 +                          (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
                        if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
                                    fsa_dev_ptr[index].ro = 1;
                }
@@@ -479,7 -460,7 +479,7 @@@ static int aac_get_container_name(struc
   *    is updated in the struct fsa_dev_info structure rather than returned.
   */
   
 -static int probe_container(struct aac_dev *dev, int cid)
 +int probe_container(struct aac_dev *dev, int cid)
  {
        struct fsa_dev_info *fsa_dev_ptr;
        int status;
  
        dresp = (struct aac_mount *) fib_data(fibptr);
  
 +      if ((le32_to_cpu(dresp->status) == ST_OK) &&
 +          (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) {
 +              dinfo->command = cpu_to_le32(VM_NameServe64);
 +              dinfo->count = cpu_to_le32(cid);
 +              dinfo->type = cpu_to_le32(FT_FILESYS);
 +
 +              if (fib_send(ContainerCommand,
 +                          fibptr,
 +                          sizeof(struct aac_query_mount),
 +                          FsaNormal,
 +                          1, 1,
 +                          NULL, NULL) < 0)
 +                      goto error;
 +      } else
 +              dresp->mnt[0].capacityhigh = 0;
 +
        if ((le32_to_cpu(dresp->status) == ST_OK) &&
            (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
            (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
                fsa_dev_ptr[cid].valid = 1;
                fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol);
 -              fsa_dev_ptr[cid].size = le32_to_cpu(dresp->mnt[0].capacity);
 +              fsa_dev_ptr[cid].size
 +                = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
 +                  (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
                if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
                        fsa_dev_ptr[cid].ro = 1;
        }
@@@ -608,17 -571,43 +608,43 @@@ static char *container_types[] = 
   * files instead of in OS dependant driver source.
   */
  
- static void setinqstr(int devtype, void *data, int tindex)
+ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
  {
        struct scsi_inq *str;
-       struct aac_driver_ident *mp;
  
-       mp = aac_get_driver_ident(devtype);
-    
        str = (struct scsi_inq *)(data); /* cast data to scsi inq block */
-       inqstrcpy (mp->vname, str->vid); 
-       inqstrcpy (mp->model, str->pid); /* last six chars reserved for vol type */
+       memset(str, ' ', sizeof(*str));
+       if (dev->supplement_adapter_info.AdapterTypeText[0]) {
+               char * cp = dev->supplement_adapter_info.AdapterTypeText;
+               int c = sizeof(str->vid);
+               while (*cp && *cp != ' ' && --c)
+                       ++cp;
+               c = *cp;
+               *cp = '\0';
+               inqstrcpy (dev->supplement_adapter_info.AdapterTypeText,
+                 str->vid); 
+               *cp = c;
+               while (*cp && *cp != ' ')
+                       ++cp;
+               while (*cp == ' ')
+                       ++cp;
+               /* last six chars reserved for vol type */
+               c = 0;
+               if (strlen(cp) > sizeof(str->pid)) {
+                       c = cp[sizeof(str->pid)];
+                       cp[sizeof(str->pid)] = '\0';
+               }
+               inqstrcpy (cp, str->pid);
+               if (c)
+                       cp[sizeof(str->pid)] = c;
+       } else {
+               struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype);
+    
+               inqstrcpy (mp->vname, str->vid); 
+               /* last six chars reserved for vol type */
+               inqstrcpy (mp->model, str->pid);
+       }
  
        if (tindex < (sizeof(container_types)/sizeof(char *))){
                char *findit = str->pid;
                /* RAID is superfluous in the context of a RAID device */
                if (memcmp(findit-4, "RAID", 4) == 0)
                        *(findit -= 4) = ' ';
-               inqstrcpy (container_types[tindex], findit + 1);
+               if (((findit - str->pid) + strlen(container_types[tindex]))
+                < (sizeof(str->pid) + sizeof(str->prl)))
+                       inqstrcpy (container_types[tindex], findit + 1);
        }
        inqstrcpy ("V1.0", str->prl);
  }
@@@ -692,7 -683,7 +720,7 @@@ int aac_get_adapter_info(struct aac_dev
                         fibptr, 
                         sizeof(*info),
                         FsaNormal, 
 -                       1, 1, 
 +                       -1, 1, /* First `interrupt' command uses special wait */
                         NULL, 
                         NULL);
  
                dev->dac_support = (dacmode!=0);
        }
        if(dev->dac_support != 0) {
-               if (!pci_set_dma_mask(dev->pdev, 0xFFFFFFFFFFFFFFFFULL) &&
-                       !pci_set_consistent_dma_mask(dev->pdev, 0xFFFFFFFFFFFFFFFFULL)) {
+               if (!pci_set_dma_mask(dev->pdev, DMA_64BIT_MASK) &&
+                       !pci_set_consistent_dma_mask(dev->pdev, DMA_64BIT_MASK)) {
                        printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n",
                                dev->name, dev->id);
-               } else if (!pci_set_dma_mask(dev->pdev, 0xFFFFFFFFULL) &&
-                       !pci_set_consistent_dma_mask(dev->pdev, 0xFFFFFFFFULL)) {
+               } else if (!pci_set_dma_mask(dev->pdev, DMA_32BIT_MASK) &&
+                       !pci_set_consistent_dma_mask(dev->pdev, DMA_32BIT_MASK)) {
                        printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n",
                                dev->name, dev->id);
                        dev->dac_support = 0;
        if (!(dev->raw_io_interface)) {
                dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size -
                        sizeof(struct aac_fibhdr) -
 -                      sizeof(struct aac_write) + sizeof(struct sgmap)) /
 -                              sizeof(struct sgmap);
 +                      sizeof(struct aac_write) + sizeof(struct sgentry)) /
 +                              sizeof(struct sgentry);
                if (dev->dac_support) {
                        /* 
                         * 38 scatter gather elements 
                                (dev->max_fib_size -
                                sizeof(struct aac_fibhdr) -
                                sizeof(struct aac_write64) +
 -                              sizeof(struct sgmap64)) /
 -                                      sizeof(struct sgmap64);
 +                              sizeof(struct sgentry64)) /
 +                                      sizeof(struct sgentry64);
                }
                dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
                if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) {
@@@ -891,40 -882,7 +919,40 @@@ static void io_callback(void *context, 
        dev = (struct aac_dev *)scsicmd->device->host->hostdata;
        cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
  
 -      dprintk((KERN_DEBUG "io_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3], jiffies));
 +      if (nblank(dprintk(x))) {
 +              u64 lba;
 +              switch (scsicmd->cmnd[0]) {
 +              case WRITE_6:
 +              case READ_6:
 +                      lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
 +                          (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
 +                      break;
 +              case WRITE_16:
 +              case READ_16:
 +                      lba = ((u64)scsicmd->cmnd[2] << 56) |
 +                            ((u64)scsicmd->cmnd[3] << 48) |
 +                            ((u64)scsicmd->cmnd[4] << 40) |
 +                            ((u64)scsicmd->cmnd[5] << 32) |
 +                            ((u64)scsicmd->cmnd[6] << 24) |
 +                            (scsicmd->cmnd[7] << 16) |
 +                            (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
 +                      break;
 +              case WRITE_12:
 +              case READ_12:
 +                      lba = ((u64)scsicmd->cmnd[2] << 24) |
 +                            (scsicmd->cmnd[3] << 16) |
 +                            (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
 +                      break;
 +              default:
 +                      lba = ((u64)scsicmd->cmnd[2] << 24) |
 +                             (scsicmd->cmnd[3] << 16) |
 +                             (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
 +                      break;
 +              }
 +              printk(KERN_DEBUG
 +                "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
 +                smp_processor_id(), (unsigned long long)lba, jiffies);
 +      }
  
        if (fibptr == NULL)
                BUG();
  
  static int aac_read(struct scsi_cmnd * scsicmd, int cid)
  {
 -      u32 lba;
 +      u64 lba;
        u32 count;
        int status;
  
        /*
         *      Get block address and transfer length
         */
 -      if (scsicmd->cmnd[0] == READ_6) /* 6 byte command */
 -      {
 +      switch (scsicmd->cmnd[0]) {
 +      case READ_6:
                dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid));
  
 -              lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
 +              lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | 
 +                      (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
                count = scsicmd->cmnd[4];
  
                if (count == 0)
                        count = 256;
 -      } else {
 +              break;
 +      case READ_16:
 +              dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", cid));
 +
 +              lba =   ((u64)scsicmd->cmnd[2] << 56) |
 +                      ((u64)scsicmd->cmnd[3] << 48) |
 +                      ((u64)scsicmd->cmnd[4] << 40) |
 +                      ((u64)scsicmd->cmnd[5] << 32) |
 +                      ((u64)scsicmd->cmnd[6] << 24) | 
 +                      (scsicmd->cmnd[7] << 16) |
 +                      (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
 +              count = (scsicmd->cmnd[10] << 24) | 
 +                      (scsicmd->cmnd[11] << 16) |
 +                      (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
 +              break;
 +      case READ_12:
 +              dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", cid));
 +
 +              lba = ((u64)scsicmd->cmnd[2] << 24) | 
 +                      (scsicmd->cmnd[3] << 16) |
 +                      (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
 +              count = (scsicmd->cmnd[6] << 24) | 
 +                      (scsicmd->cmnd[7] << 16) |
 +                      (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
 +              break;
 +      default:
                dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid));
  
 -              lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
 +              lba = ((u64)scsicmd->cmnd[2] << 24) | 
 +                      (scsicmd->cmnd[3] << 16) | 
 +                      (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
                count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
 +              break;
        }
 -      dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %u, t = %ld.\n",
 +      dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n",
          smp_processor_id(), (unsigned long long)lba, jiffies));
 +      if ((!(dev->raw_io_interface) || !(dev->raw_io_64)) &&
 +              (lba & 0xffffffff00000000LL)) {
 +              dprintk((KERN_DEBUG "aac_read: Illegal lba\n"));
 +              scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | 
 +                      SAM_STAT_CHECK_CONDITION;
 +              set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
 +                          HARDWARE_ERROR,
 +                          SENCODE_INTERNAL_TARGET_FAILURE,
 +                          ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
 +                          0, 0);
 +              memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
 +                (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
 +                  ? sizeof(scsicmd->sense_buffer)
 +                  : sizeof(dev->fsa_dev[cid].sense_data));
 +              scsicmd->scsi_done(scsicmd);
 +              return 0;
 +      }
        /*
         *      Alocate and initialize a Fib
         */
        if (dev->raw_io_interface) {
                struct aac_raw_io *readcmd;
                readcmd = (struct aac_raw_io *) fib_data(cmd_fibcontext);
 -              readcmd->block[0] = cpu_to_le32(lba);
 -              readcmd->block[1] = 0;
 +              readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff));
 +              readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
                readcmd->count = cpu_to_le32(count<<9);
                readcmd->cid = cpu_to_le16(cid);
                readcmd->flags = cpu_to_le16(1);
                readcmd->command = cpu_to_le32(VM_CtHostRead64);
                readcmd->cid = cpu_to_le16(cid);
                readcmd->sector_count = cpu_to_le16(count);
 -              readcmd->block = cpu_to_le32(lba);
 +              readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                readcmd->pad   = 0;
                readcmd->flags = 0; 
  
                readcmd = (struct aac_read *) fib_data(cmd_fibcontext);
                readcmd->command = cpu_to_le32(VM_CtBlockRead);
                readcmd->cid = cpu_to_le32(cid);
 -              readcmd->block = cpu_to_le32(lba);
 +              readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                readcmd->count = cpu_to_le32(count * 512);
  
                aac_build_sg(scsicmd, &readcmd->sg);
  
  static int aac_write(struct scsi_cmnd * scsicmd, int cid)
  {
 -      u32 lba;
 +      u64 lba;
        u32 count;
        int status;
        u16 fibsize;
                count = scsicmd->cmnd[4];
                if (count == 0)
                        count = 256;
 +      } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */
 +              dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", cid));
 +
 +              lba =   ((u64)scsicmd->cmnd[2] << 56) |
 +                      ((u64)scsicmd->cmnd[3] << 48) |
 +                      ((u64)scsicmd->cmnd[4] << 40) |
 +                      ((u64)scsicmd->cmnd[5] << 32) |
 +                      ((u64)scsicmd->cmnd[6] << 24) | 
 +                      (scsicmd->cmnd[7] << 16) |
 +                      (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
 +              count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) |
 +                      (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
 +      } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */
 +              dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", cid));
 +
 +              lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16)
 +                  | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
 +              count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16)
 +                    | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
        } else {
                dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid));
 -              lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
 +              lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
                count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
        }
 -      dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %u, t = %ld.\n",
 +      dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n",
          smp_processor_id(), (unsigned long long)lba, jiffies));
 +      if ((!(dev->raw_io_interface) || !(dev->raw_io_64))
 +       && (lba & 0xffffffff00000000LL)) {
 +              dprintk((KERN_DEBUG "aac_write: Illegal lba\n"));
 +              scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
 +              set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
 +                          HARDWARE_ERROR,
 +                          SENCODE_INTERNAL_TARGET_FAILURE,
 +                          ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
 +                          0, 0);
 +              memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
 +                (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
 +                  ? sizeof(scsicmd->sense_buffer)
 +                  : sizeof(dev->fsa_dev[cid].sense_data));
 +              scsicmd->scsi_done(scsicmd);
 +              return 0;
 +      }
        /*
         *      Allocate and initialize a Fib then setup a BlockWrite command
         */
        if (dev->raw_io_interface) {
                struct aac_raw_io *writecmd;
                writecmd = (struct aac_raw_io *) fib_data(cmd_fibcontext);
 -              writecmd->block[0] = cpu_to_le32(lba);
 -              writecmd->block[1] = 0;
 +              writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff));
 +              writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
                writecmd->count = cpu_to_le32(count<<9);
                writecmd->cid = cpu_to_le16(cid);
                writecmd->flags = 0; 
                writecmd->command = cpu_to_le32(VM_CtHostWrite64);
                writecmd->cid = cpu_to_le16(cid);
                writecmd->sector_count = cpu_to_le16(count); 
 -              writecmd->block = cpu_to_le32(lba);
 +              writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                writecmd->pad   = 0;
                writecmd->flags = 0;
  
                writecmd = (struct aac_write *) fib_data(cmd_fibcontext);
                writecmd->command = cpu_to_le32(VM_CtBlockWrite);
                writecmd->cid = cpu_to_le32(cid);
 -              writecmd->block = cpu_to_le32(lba);
 +              writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
                writecmd->count = cpu_to_le32(count * 512);
                writecmd->sg.count = cpu_to_le32(1);
                /* ->stable is not used - it did mean which type of write */
@@@ -1438,7 -1315,6 +1466,6 @@@ int aac_scsi_cmd(struct scsi_cmnd * scs
        struct Scsi_Host *host = scsicmd->device->host;
        struct aac_dev *dev = (struct aac_dev *)host->hostdata;
        struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
-       int cardtype = dev->cardtype;
        int ret;
        
        /*
                         */
                        if ((fsa_dev_ptr[cid].valid & 1) == 0) {
                                switch (scsicmd->cmnd[0]) {
 +                              case SERVICE_ACTION_IN:
 +                                      if (!(dev->raw_io_interface) ||
 +                                          !(dev->raw_io_64) ||
 +                                          ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
 +                                              break;
                                case INQUIRY:
                                case READ_CAPACITY:
                                case TEST_UNIT_READY:
                                        spin_unlock_irq(host->host_lock);
                                        probe_container(dev, cid);
 +                                      if ((fsa_dev_ptr[cid].valid & 1) == 0)
 +                                              fsa_dev_ptr[cid].valid = 0;
                                        spin_lock_irq(host->host_lock);
                                        if (fsa_dev_ptr[cid].valid == 0) {
                                                scsicmd->result = DID_NO_CONNECT << 16;
                memset(&inq_data, 0, sizeof (struct inquiry_data));
  
                inq_data.inqd_ver = 2;  /* claim compliance to SCSI-2 */
 -              inq_data.inqd_dtq = 0x80;       /* set RMB bit to one indicating that the medium is removable */
                inq_data.inqd_rdf = 2;  /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */
                inq_data.inqd_len = 31;
                /*Format for "pad2" is  RelAdr | WBus32 | WBus16 |  Sync  | Linked |Reserved| CmdQue | SftRe */
                 *      see: <vendor>.c i.e. aac.c
                 */
                if (scsicmd->device->id == host->this_id) {
-                       setinqstr(cardtype, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *)));
+                       setinqstr(dev, (void *) (inq_data.inqd_vid), (sizeof(container_types)/sizeof(char *)));
                        inq_data.inqd_pdt = INQD_PDT_PROC;      /* Processor device */
                        aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
                        scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
                        scsicmd->scsi_done(scsicmd);
                        return 0;
                }
-               setinqstr(cardtype, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type);
+               setinqstr(dev, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type);
                inq_data.inqd_pdt = INQD_PDT_DA;        /* Direct/random access device */
                aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
                return aac_get_container_name(scsicmd, cid);
        }
 +      case SERVICE_ACTION_IN:
 +              if (!(dev->raw_io_interface) ||
 +                  !(dev->raw_io_64) ||
 +                  ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
 +                      break;
 +      {
 +              u64 capacity;
 +              char cp[12];
 +              unsigned int offset = 0;
 +
 +              dprintk((KERN_DEBUG "READ CAPACITY_16 command.\n"));
 +              capacity = fsa_dev_ptr[cid].size - 1;
 +              if (scsicmd->cmnd[13] > 12) {
 +                      offset = scsicmd->cmnd[13] - 12;
 +                      if (offset > sizeof(cp))
 +                              break;
 +                      memset(cp, 0, offset);
 +                      aac_internal_transfer(scsicmd, cp, 0, offset);
 +              }
 +              cp[0] = (capacity >> 56) & 0xff;
 +              cp[1] = (capacity >> 48) & 0xff;
 +              cp[2] = (capacity >> 40) & 0xff;
 +              cp[3] = (capacity >> 32) & 0xff;
 +              cp[4] = (capacity >> 24) & 0xff;
 +              cp[5] = (capacity >> 16) & 0xff;
 +              cp[6] = (capacity >> 8) & 0xff;
 +              cp[7] = (capacity >> 0) & 0xff;
 +              cp[8] = 0;
 +              cp[9] = 0;
 +              cp[10] = 2;
 +              cp[11] = 0;
 +              aac_internal_transfer(scsicmd, cp, offset, sizeof(cp));
 +
 +              /* Do not cache partition table for arrays */
 +              scsicmd->device->removable = 1;
 +
 +              scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 +              scsicmd->scsi_done(scsicmd);
 +
 +              return 0;
 +      }
 +
        case READ_CAPACITY:
        {
                u32 capacity;
                char cp[8];
  
                dprintk((KERN_DEBUG "READ CAPACITY command.\n"));
 -              if (fsa_dev_ptr[cid].size <= 0x100000000LL)
 +              if (fsa_dev_ptr[cid].size <= 0x100000000ULL)
                        capacity = fsa_dev_ptr[cid].size - 1;
                else
                        capacity = (u32)-1;
                cp[6] = 2;
                cp[7] = 0;
                aac_internal_transfer(scsicmd, cp, 0, sizeof(cp));
 +              /* Do not cache partition table for arrays */
 +              scsicmd->device->removable = 1;
  
                scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
                scsicmd->scsi_done(scsicmd);
        {
                case READ_6:
                case READ_10:
 +              case READ_12:
 +              case READ_16:
                        /*
                         *      Hack to keep track of ordinal number of the device that
                         *      corresponds to a container. Needed to convert
                         */
                         
                        spin_unlock_irq(host->host_lock);
 -                      if  (scsicmd->request->rq_disk)
 -                              memcpy(fsa_dev_ptr[cid].devname,
 -                                      scsicmd->request->rq_disk->disk_name,
 -                                      8);
 -
 +                      if (scsicmd->request->rq_disk)
 +                              strlcpy(fsa_dev_ptr[cid].devname,
 +                              scsicmd->request->rq_disk->disk_name,
 +                              min(sizeof(fsa_dev_ptr[cid].devname),
 +                              sizeof(scsicmd->request->rq_disk->disk_name) + 1));
                        ret = aac_read(scsicmd, cid);
                        spin_lock_irq(host->host_lock);
                        return ret;
  
                case WRITE_6:
                case WRITE_10:
 +              case WRITE_12:
 +              case WRITE_16:
                        spin_unlock_irq(host->host_lock);
                        ret = aac_write(scsicmd, cid);
                        spin_lock_irq(host->host_lock);
@@@ -1950,8 -1772,6 +1977,8 @@@ static void aac_srb_callback(void *cont
                case  WRITE_10:
                case  READ_12:
                case  WRITE_12:
 +              case  READ_16:
 +              case  WRITE_16:
                        if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {
                                printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");
                        } else {
                                sizeof(scsicmd->sense_buffer) :
                                le32_to_cpu(srbreply->sense_data_size);
  #ifdef AAC_DETAILED_STATUS_INFO
 -              dprintk((KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n", 
 -                                      le32_to_cpu(srbreply->status), len));
 +              printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
 +                                      le32_to_cpu(srbreply->status), len);
  #endif
                memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
                
@@@ -1,10 -1,6 +1,10 @@@
  #if (!defined(dprintk))
  # define dprintk(x)
  #endif
 +/* eg: if (nblank(dprintk(x))) */
 +#define _nblank(x) #x
 +#define nblank(x) _nblank(x)[0]
 +
  
  /*------------------------------------------------------------------------------
   *              D E F I N E S
@@@ -19,7 -15,7 +19,7 @@@
  #define AAC_MAX_LUN           (8)
  
  #define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
 -#define AAC_MAX_32BIT_SGBCOUNT        ((unsigned short)512)
 +#define AAC_MAX_32BIT_SGBCOUNT        ((unsigned short)256)
  
  /*
   * These macros convert from physical channels to virtual channels
@@@ -306,6 -302,7 +306,6 @@@ enum aac_queue_types 
   */
  
  #define               FsaNormal       1
 -#define               FsaHigh         2
  
  /*
   * Define the FIB. The FIB is the where all the requested data and
@@@ -549,6 -546,8 +549,6 @@@ struct aac_queue 
                    /* This is only valid for adapter to host command queues. */ 
        spinlock_t              *lock;          /* Spinlock for this queue must take this lock before accessing the lock */
        spinlock_t              lockdata;       /* Actual lock (used only on one side of the lock) */
 -      unsigned long           SavedIrql;      /* Previous IRQL when the spin lock is taken */
 -      u32                     padding;        /* Padding - FIXME - can remove I believe */
        struct list_head        cmdq;           /* A queue of FIBs which need to be prcessed by the FS thread. This is */
                                                /* only valid for command queues which receive entries from the adapter. */
        struct list_head        pendingq;       /* A queue of outstanding fib's to the adapter. */
@@@ -777,9 -776,7 +777,9 @@@ struct fsa_dev_info 
        u64             last;
        u64             size;
        u32             type;
 +      u32             config_waiting_on;
        u16             queue_depth;
 +      u8              config_needed;
        u8              valid;
        u8              ro;
        u8              locked;
@@@ -1015,7 -1012,6 +1015,7 @@@ struct aac_de
        /* macro side-effects BEWARE */
  #     define                  raw_io_interface \
          init->InitStructRevision==cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4)
 +      u8                      raw_io_64;
        u8                      printf_enabled;
  };
  
@@@ -1366,10 -1362,8 +1366,10 @@@ struct aac_srb_repl
  #define               VM_CtBlockVerify64      18
  #define               VM_CtHostRead64         19
  #define               VM_CtHostWrite64        20
 +#define               VM_DrvErrTblLog         21
 +#define               VM_NameServe64          22
  
 -#define               MAX_VMCOMMAND_NUM       21      /* used for sizing stats array - leave last */
 +#define               MAX_VMCOMMAND_NUM       23      /* used for sizing stats array - leave last */
  
  /*
   *    Descriptive information (eg, vital stats)
@@@ -1478,7 -1472,6 +1478,7 @@@ struct aac_mntent 
                                                   manager (eg, filesystem) */
        __le32                  altoid;         /* != oid <==> snapshot or 
                                                   broken mirror exists */
 +      __le32                  capacityhigh;
  };
  
  #define FSCS_NOTCLEAN 0x0001  /* fsck is neccessary before mounting */
@@@ -1560,7 -1553,7 +1560,7 @@@ struct fib_ioct
  
  struct revision
  {
-       __le32 compat;
+       u32 compat;
        __le32 version;
        __le32 build;
  };
@@@ -1714,7 -1707,6 +1714,7 @@@ extern struct aac_common aac_config
  #define               AifCmdJobProgress       2       /* Progress report */
  #define                       AifJobCtrZero   101     /* Array Zero progress */
  #define                       AifJobStsSuccess 1      /* Job completes */
 +#define                       AifJobStsRunning 102    /* Job running */
  #define               AifCmdAPIReport         3       /* Report from other user of API */
  #define               AifCmdDriverNotify      4       /* Notify host driver of event */
  #define                       AifDenMorphComplete 200 /* A morph operation completed */
@@@ -1785,7 -1777,6 +1785,7 @@@ int fib_adapter_complete(struct fib * f
  struct aac_driver_ident* aac_get_driver_ident(int devtype);
  int aac_get_adapter_info(struct aac_dev* dev);
  int aac_send_shutdown(struct aac_dev *dev);
 +int probe_container(struct aac_dev *dev, int cid);
  extern int numacb;
  extern int acbsize;
  extern char aac_driver_version[];
@@@ -453,9 -453,9 +453,9 @@@ static int aac_eh_reset(struct scsi_cmn
                /*
                 * We can exit If all the commands are complete
                 */
 +              spin_unlock_irq(host->host_lock);
                if (active == 0)
                        return SUCCESS;
 -              spin_unlock_irq(host->host_lock);
                ssleep(1);
                spin_lock_irq(host->host_lock);
        }
@@@ -748,12 -748,11 +748,12 @@@ static int __devinit aac_probe_one(stru
                unique_id++;
        }
  
 -      if (pci_enable_device(pdev))
 +      error = pci_enable_device(pdev);
 +      if (error)
                goto out;
  
-       if (pci_set_dma_mask(pdev, 0xFFFFFFFFULL) || 
-                       pci_set_consistent_dma_mask(pdev, 0xFFFFFFFFULL))
+       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) || 
+                       pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))
                goto out;
        /*
         * If the quirk31 bit is set, the adapter needs adapter
        shost->irq = pdev->irq;
        shost->base = pci_resource_start(pdev, 0);
        shost->unique_id = unique_id;
 +      shost->max_cmd_len = 16;
  
        aac = (struct aac_dev *)shost->hostdata;
        aac->scsi_host_ptr = shost;     
         * address space.
         */
        if (aac_drivers[index].quirks & AAC_QUIRK_31BIT)
-               if (pci_set_dma_mask(pdev, 0xFFFFFFFFULL))
-                       goto out_free_fibs;
+               if (pci_set_dma_mask(pdev, DMA_32BIT_MASK))
+                       goto out_deinit;
+  
        aac->maximum_num_channels = aac_drivers[index].channels;
 -      aac_get_adapter_info(aac);
 +      error = aac_get_adapter_info(aac);
 +      if (error < 0)
 +              goto out_deinit;
  
        /*
         * Lets override negotiations and drop the maximum SG limit to 34
@@@ -931,8 -927,8 +931,8 @@@ static int __init aac_init(void
        printk(KERN_INFO "Adaptec %s driver (%s)\n",
          AAC_DRIVERNAME, aac_driver_version);
  
 -      error = pci_module_init(&aac_pci_driver);
 -      if (error)
 +      error = pci_register_driver(&aac_pci_driver);
 +      if (error < 0)
                return error;
  
        aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops);