[SCSI] aacraid: ignore adapter reset check polarity
[sfrench/cifs-2.6.git] / drivers / scsi / aacraid / linit.c
index 6650f6fa989056a547eee75cc0ee9bb5daccbbdc..fdfbad0903fdf30945175719574109dcea12f8dd 100644 (file)
@@ -275,9 +275,9 @@ static const char *aac_info(struct Scsi_Host *shost)
 
 /**
  *     aac_get_driver_ident
- *     @devtype: index into lookup table
+ *     @devtype: index into lookup table
  *
- *     Returns a pointer to the entry in the driver lookup table.
+ *     Returns a pointer to the entry in the driver lookup table.
  */
 
 struct aac_driver_ident* aac_get_driver_ident(int devtype)
@@ -404,6 +404,7 @@ static int aac_slave_configure(struct scsi_device *sdev)
        struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata;
        if ((sdev->type == TYPE_DISK) &&
                        (sdev_channel(sdev) != CONTAINER_CHANNEL) &&
+                       (!aac->jbod || sdev->inq_periph_qual) &&
                        (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2))) {
                if (expose_physicals == 0)
                        return -ENXIO;
@@ -411,7 +412,8 @@ static int aac_slave_configure(struct scsi_device *sdev)
                        sdev->no_uld_attach = 1;
        }
        if (sdev->tagged_supported && (sdev->type == TYPE_DISK) &&
-                       (sdev_channel(sdev) == CONTAINER_CHANNEL)) {
+                       (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2)) &&
+                       !sdev->no_uld_attach) {
                struct scsi_device * dev;
                struct Scsi_Host *host = sdev->host;
                unsigned num_lsu = 0;
@@ -430,8 +432,11 @@ static int aac_slave_configure(struct scsi_device *sdev)
                                ++num_lsu;
                __shost_for_each_device(dev, host) {
                        if (dev->tagged_supported && (dev->type == TYPE_DISK) &&
-                               (sdev_channel(dev) == CONTAINER_CHANNEL)) {
-                               if (!aac->fsa_dev[sdev_id(dev)].valid)
+                                       (!aac->raid_scsi_mode ||
+                                               (sdev_channel(sdev) != 2)) &&
+                                       !dev->no_uld_attach) {
+                               if ((sdev_channel(dev) != CONTAINER_CHANNEL)
+                                || !aac->fsa_dev[sdev_id(dev)].valid)
                                        ++num_lsu;
                        } else
                                ++num_one;
@@ -444,9 +449,6 @@ static int aac_slave_configure(struct scsi_device *sdev)
                else if (depth < 2)
                        depth = 2;
                scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, depth);
-               if (!(((struct aac_dev *)host->hostdata)->adapter_info.options &
-                               AAC_OPT_NEW_COMM))
-                       blk_queue_max_segment_size(sdev->request_queue, 65536);
        } else
                scsi_adjust_queue_depth(sdev, 0, 1);
 
@@ -639,7 +641,7 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
           AAC_OPTION_MU_RESET) &&
          aac_check_reset &&
          ((aac_check_reset != 1) ||
-          (aac->supplement_adapter_info.SupportedOptions2 &
+          !(aac->supplement_adapter_info.SupportedOptions2 &
            AAC_OPTION_IGNORE_RESET)))
                aac_reset_adapter(aac, 2); /* Bypass wait for command quiesce */
        return SUCCESS; /* Cause an immediate retry of the command with a ten second delay after successful tur */
@@ -790,6 +792,25 @@ static ssize_t aac_show_vendor(struct class_device *class_dev,
        return len;
 }
 
+static ssize_t aac_show_flags(struct class_device *class_dev, char *buf)
+{
+       int len = 0;
+       struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
+
+       if (nblank(dprintk(x)))
+               len = snprintf(buf, PAGE_SIZE, "dprintk\n");
+#ifdef AAC_DETAILED_STATUS_INFO
+       len += snprintf(buf + len, PAGE_SIZE - len,
+                       "AAC_DETAILED_STATUS_INFO\n");
+#endif
+       if (dev->raw_io_interface && dev->raw_io_64)
+               len += snprintf(buf + len, PAGE_SIZE - len,
+                               "SAI_READ_CAPACITY_16\n");
+       if (dev->jbod)
+               len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n");
+       return len;
+}
+
 static ssize_t aac_show_kernel_version(struct class_device *class_dev,
                char *buf)
 {
@@ -899,6 +920,13 @@ static struct class_device_attribute aac_vendor = {
        },
        .show = aac_show_vendor,
 };
+static struct class_device_attribute aac_flags = {
+       .attr = {
+               .name = "flags",
+               .mode = S_IRUGO,
+       },
+       .show = aac_show_flags,
+};
 static struct class_device_attribute aac_kernel_version = {
        .attr = {
                .name = "hba_kernel_version",
@@ -953,6 +981,7 @@ static struct class_device_attribute aac_reset = {
 static struct class_device_attribute *aac_attrs[] = {
        &aac_model,
        &aac_vendor,
+       &aac_flags,
        &aac_kernel_version,
        &aac_monitor_version,
        &aac_bios_version,
@@ -975,33 +1004,32 @@ static const struct file_operations aac_cfg_fops = {
 
 static struct scsi_host_template aac_driver_template = {
        .module                         = THIS_MODULE,
-       .name                           = "AAC",
+       .name                           = "AAC",
        .proc_name                      = AAC_DRIVERNAME,
-       .info                           = aac_info,
-       .ioctl                          = aac_ioctl,
+       .info                           = aac_info,
+       .ioctl                          = aac_ioctl,
 #ifdef CONFIG_COMPAT
        .compat_ioctl                   = aac_compat_ioctl,
 #endif
-       .queuecommand                   = aac_queuecommand,
-       .bios_param                     = aac_biosparm,
+       .queuecommand                   = aac_queuecommand,
+       .bios_param                     = aac_biosparm,
        .shost_attrs                    = aac_attrs,
        .slave_configure                = aac_slave_configure,
        .change_queue_depth             = aac_change_queue_depth,
        .sdev_attrs                     = aac_dev_attrs,
        .eh_abort_handler               = aac_eh_abort,
        .eh_host_reset_handler          = aac_eh_reset,
-       .can_queue                      = AAC_NUM_IO_FIB,
-       .this_id                        = MAXIMUM_NUM_CONTAINERS,
-       .sg_tablesize                   = 16,
-       .max_sectors                    = 128,
+       .can_queue                      = AAC_NUM_IO_FIB,
+       .this_id                        = MAXIMUM_NUM_CONTAINERS,
+       .sg_tablesize                   = 16,
+       .max_sectors                    = 128,
 #if (AAC_NUM_IO_FIB > 256)
        .cmd_per_lun                    = 256,
 #else
-       .cmd_per_lun                    = AAC_NUM_IO_FIB,
+       .cmd_per_lun                    = AAC_NUM_IO_FIB,
 #endif
        .use_clustering                 = ENABLE_CLUSTERING,
-       .use_sg_chaining                = ENABLE_SG_CHAINING,
-       .emulated                       = 1,
+       .emulated                       = 1,
 };
 
 static void __aac_shutdown(struct aac_dev * aac)
@@ -1011,6 +1039,8 @@ static void __aac_shutdown(struct aac_dev * aac)
        aac_send_shutdown(aac);
        aac_adapter_disable_int(aac);
        free_irq(aac->pdev->irq, aac);
+       if (aac->msi)
+               pci_disable_msi(aac->pdev);
 }
 
 static int __devinit aac_probe_one(struct pci_dev *pdev,
@@ -1106,21 +1136,25 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
         * Lets override negotiations and drop the maximum SG limit to 34
         */
        if ((aac_drivers[index].quirks & AAC_QUIRK_34SG) &&
-                       (aac->scsi_host_ptr->sg_tablesize > 34)) {
-               aac->scsi_host_ptr->sg_tablesize = 34;
-               aac->scsi_host_ptr->max_sectors
-                 = (aac->scsi_host_ptr->sg_tablesize * 8) + 112;
+                       (shost->sg_tablesize > 34)) {
+               shost->sg_tablesize = 34;
+               shost->max_sectors = (shost->sg_tablesize * 8) + 112;
        }
 
        if ((aac_drivers[index].quirks & AAC_QUIRK_17SG) &&
-                       (aac->scsi_host_ptr->sg_tablesize > 17)) {
-               aac->scsi_host_ptr->sg_tablesize = 17;
-               aac->scsi_host_ptr->max_sectors
-                 = (aac->scsi_host_ptr->sg_tablesize * 8) + 112;
+                       (shost->sg_tablesize > 17)) {
+               shost->sg_tablesize = 17;
+               shost->max_sectors = (shost->sg_tablesize * 8) + 112;
        }
 
+       error = pci_set_dma_max_seg_size(pdev,
+               (aac->adapter_info.options & AAC_OPT_NEW_COMM) ?
+                       (shost->max_sectors << 9) : 65536);
+       if (error)
+               goto out_deinit;
+
        /*
-        * Firware printf works only with older firmware.
+        * Firmware printf works only with older firmware.
         */
        if (aac_drivers[index].quirks & AAC_QUIRK_34SG)
                aac->printf_enabled = 1;
@@ -1132,7 +1166,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
         * all containers are on the virtual channel 0 (CONTAINER_CHANNEL)
         * physical channels are address by their actual physical number+1
         */
-       if ((aac->nondasd_support == 1) || expose_physicals)
+       if (aac->nondasd_support || expose_physicals || aac->jbod)
                shost->max_channel = aac->maximum_num_channels;
        else
                shost->max_channel = 0;
@@ -1222,7 +1256,7 @@ static struct pci_driver aac_pci_driver = {
        .id_table       = aac_pci_tbl,
        .probe          = aac_probe_one,
        .remove         = __devexit_p(aac_remove_one),
-       .shutdown       = aac_shutdown,
+       .shutdown       = aac_shutdown,
 };
 
 static int __init aac_init(void)
@@ -1239,7 +1273,7 @@ static int __init aac_init(void)
        aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops);
        if (aac_cfg_major < 0) {
                printk(KERN_WARNING
-                      "aacraid: unable to register \"aac\" device.\n");
+                       "aacraid: unable to register \"aac\" device.\n");
        }
 
        return 0;