Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / drivers / scsi / ipr.c
index 999e91e..c09d775 100644 (file)
@@ -71,6 +71,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/libata.h>
+#include <linux/hdreg.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/processor.h>
@@ -151,13 +152,13 @@ module_param_named(log_level, ipr_log_level, uint, 0);
 MODULE_PARM_DESC(log_level, "Set to 0 - 4 for increasing verbosity of device driver");
 module_param_named(testmode, ipr_testmode, int, 0);
 MODULE_PARM_DESC(testmode, "DANGEROUS!!! Allows unsupported configurations");
-module_param_named(fastfail, ipr_fastfail, int, 0);
+module_param_named(fastfail, ipr_fastfail, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(fastfail, "Reduce timeouts and retries");
 module_param_named(transop_timeout, ipr_transop_timeout, int, 0);
 MODULE_PARM_DESC(transop_timeout, "Time in seconds to wait for adapter to come operational (default: 300)");
 module_param_named(enable_cache, ipr_enable_cache, int, 0);
 MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)");
-module_param_named(debug, ipr_debug, int, 0);
+module_param_named(debug, ipr_debug, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)");
 module_param_named(dual_ioa_raid, ipr_dual_ioa_raid, int, 0);
 MODULE_PARM_DESC(dual_ioa_raid, "Enable dual adapter RAID support. Set to 1 to enable. (default: 1)");
@@ -353,6 +354,8 @@ struct ipr_error_table_t ipr_error_table[] = {
        "9076: Configuration error, missing remote IOA"},
        {0x06679100, 0, IPR_DEFAULT_LOG_LEVEL,
        "4050: Enclosure does not support a required multipath function"},
+       {0x06690000, 0, IPR_DEFAULT_LOG_LEVEL,
+       "4070: Logically bad block written on device"},
        {0x06690200, 0, IPR_DEFAULT_LOG_LEVEL,
        "9041: Array protection temporarily suspended"},
        {0x06698200, 0, IPR_DEFAULT_LOG_LEVEL,
@@ -2183,7 +2186,7 @@ static void ipr_dump_location_data(struct ipr_ioa_cfg *ioa_cfg,
                sizeof(struct ipr_dump_entry_header);
        driver_dump->location_entry.hdr.data_type = IPR_DUMP_DATA_TYPE_ASCII;
        driver_dump->location_entry.hdr.id = IPR_DUMP_LOCATION_ID;
-       strcpy(driver_dump->location_entry.location, ioa_cfg->pdev->dev.bus_id);
+       strcpy(driver_dump->location_entry.location, dev_name(&ioa_cfg->pdev->dev));
        driver_dump->hdr.num_entries++;
 }
 
@@ -2455,20 +2458,14 @@ static ssize_t ipr_read_trace(struct kobject *kobj,
        struct Scsi_Host *shost = class_to_shost(dev);
        struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
        unsigned long lock_flags = 0;
-       int size = IPR_TRACE_SIZE;
-       char *src = (char *)ioa_cfg->trace;
-
-       if (off > size)
-               return 0;
-       if (off + count > size) {
-               size -= off;
-               count = size;
-       }
+       ssize_t ret;
 
        spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
-       memcpy(buf, &src[off], count);
+       ret = memory_read_from_buffer(buf, count, &off, ioa_cfg->trace,
+                               IPR_TRACE_SIZE);
        spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
-       return count;
+
+       return ret;
 }
 
 static struct bin_attribute ipr_trace_attr = {
@@ -3669,7 +3666,8 @@ static int ipr_slave_configure(struct scsi_device *sdev)
                        sdev->no_uld_attach = 1;
                }
                if (ipr_is_vset_device(res)) {
-                       sdev->timeout = IPR_VSET_RW_TIMEOUT;
+                       blk_queue_rq_timeout(sdev->request_queue,
+                                            IPR_VSET_RW_TIMEOUT);
                        blk_queue_max_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS);
                }
                if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res))
@@ -4913,8 +4911,11 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
        struct ipr_resource_entry *res;
 
        res = (struct ipr_resource_entry *)sdev->hostdata;
-       if (res && ipr_is_gata(res))
-               return ata_scsi_ioctl(sdev, cmd, arg);
+       if (res && ipr_is_gata(res)) {
+               if (cmd == HDIO_GET_IDENTITY)
+                       return -ENOTTY;
+               return ata_sas_scsi_ioctl(res->sata_port->ap, sdev, cmd, arg);
+       }
 
        return -EINVAL;
 }
@@ -5390,9 +5391,9 @@ static int ipr_ioa_reset_done(struct ipr_cmnd *ipr_cmd)
        list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
        wake_up_all(&ioa_cfg->reset_wait_q);
 
-       spin_unlock_irq(ioa_cfg->host->host_lock);
+       spin_unlock(ioa_cfg->host->host_lock);
        scsi_unblock_requests(ioa_cfg->host);
-       spin_lock_irq(ioa_cfg->host->host_lock);
+       spin_lock(ioa_cfg->host->host_lock);
 
        if (!ioa_cfg->allow_cmds)
                scsi_block_requests(ioa_cfg->host);
@@ -7148,6 +7149,7 @@ static void ipr_free_all_resources(struct ipr_ioa_cfg *ioa_cfg)
 
        ENTER;
        free_irq(pdev->irq, ioa_cfg);
+       pci_disable_msi(pdev);
        iounmap(ioa_cfg->hdw_dma_regs);
        pci_release_regions(pdev);
        ipr_free_mem(ioa_cfg);
@@ -7433,6 +7435,11 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
                goto out;
        }
 
+       if (!(rc = pci_enable_msi(pdev)))
+               dev_info(&pdev->dev, "MSI enabled\n");
+       else if (ipr_debug)
+               dev_info(&pdev->dev, "Cannot enable MSI\n");
+
        dev_info(&pdev->dev, "Found IOA with IRQ: %d\n", pdev->irq);
 
        host = scsi_host_alloc(&driver_template, sizeof(*ioa_cfg));
@@ -7474,7 +7481,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
                goto out_scsi_host_put;
        }
 
-       ipr_regs = ioremap(ipr_regs_pci, pci_resource_len(pdev, 0));
+       ipr_regs = pci_ioremap_bar(pdev, 0);
 
        if (!ipr_regs) {
                dev_err(&pdev->dev,
@@ -7491,7 +7498,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
 
        pci_set_master(pdev);
 
-       rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
        if (rc < 0) {
                dev_err(&pdev->dev, "Failed to set PCI DMA mask\n");
                goto cleanup_nomem;
@@ -7575,6 +7582,7 @@ out_release_regions:
 out_scsi_host_put:
        scsi_host_put(host);
 out_disable:
+       pci_disable_msi(pdev);
        pci_disable_device(pdev);
        goto out;
 }
@@ -7854,7 +7862,6 @@ static struct pci_driver ipr_driver = {
        .remove = ipr_remove,
        .shutdown = ipr_shutdown,
        .err_handler = &ipr_err_handler,
-       .dynids.use_driver_data = 1
 };
 
 /**