mlx4_en: Fix a kernel panic when waking tx queue
[safe/jmp/linux-2.6] / drivers / scsi / megaraid.c
index 4d59ae8..49eb061 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
+#include <linux/smp_lock.h>
 #include <scsi/scsicam.h>
 
 #include "scsi.h"
@@ -151,19 +152,19 @@ mega_setup_mailbox(adapter_t *adapter)
         */
        if( adapter->flag & BOARD_IOMAP ) {
 
-               outb_p(adapter->mbox_dma & 0xFF,
+               outb(adapter->mbox_dma & 0xFF,
                                adapter->host->io_port + MBOX_PORT0);
 
-               outb_p((adapter->mbox_dma >> 8) & 0xFF,
+               outb((adapter->mbox_dma >> 8) & 0xFF,
                                adapter->host->io_port + MBOX_PORT1);
 
-               outb_p((adapter->mbox_dma >> 16) & 0xFF,
+               outb((adapter->mbox_dma >> 16) & 0xFF,
                                adapter->host->io_port + MBOX_PORT2);
 
-               outb_p((adapter->mbox_dma >> 24) & 0xFF,
+               outb((adapter->mbox_dma >> 24) & 0xFF,
                                adapter->host->io_port + MBOX_PORT3);
 
-               outb_p(ENABLE_MBOX_BYTE,
+               outb(ENABLE_MBOX_BYTE,
                                adapter->host->io_port + ENABLE_MBOX_REGION);
 
                irq_ack(adapter);
@@ -1966,8 +1967,8 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
                        scb->state |= aor;
 
                        /*
-                        * Check if this command has firmare owenership. If
-                        * yes, we cannot reset this command. Whenever, f/w
+                        * Check if this command has firmware ownership. If
+                        * yes, we cannot reset this command. Whenever f/w
                         * completes this command, we will return appropriate
                         * status from ISR.
                         */
@@ -2020,7 +2021,7 @@ make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
 
        memcpy(*pdev, adapter->dev, sizeof(struct pci_dev));
 
-       if( pci_set_dma_mask(*pdev, DMA_32BIT_MASK) != 0 ) {
+       if( pci_set_dma_mask(*pdev, DMA_BIT_MASK(32)) != 0 ) {
                kfree(*pdev);
                return -1;
        }
@@ -3272,12 +3273,12 @@ mega_init_scb(adapter_t *adapter)
  * @filep - unused
  *
  * Routines for the character/ioctl interface to the driver. Find out if this
- * is a valid open. If yes, increment the module use count so that it cannot
- * be unloaded.
+ * is a valid open. 
  */
 static int
 megadev_open (struct inode *inode, struct file *filep)
 {
+       cycle_kernel_lock();
        /*
         * Only allow superuser to access private ioctl interface
         */
@@ -4401,6 +4402,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
        scb_t   *scb;
        int     rval;
 
+       scmd = scsi_allocate_command(GFP_KERNEL);
+       if (!scmd)
+               return -ENOMEM;
+
        /*
         * The internal commands share one command id and hence are
         * serialized. This is so because we want to reserve maximum number of
@@ -4411,12 +4416,11 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
        scb = &adapter->int_scb;
        memset(scb, 0, sizeof(scb_t));
 
-       scmd = &adapter->int_scmd;
-       memset(scmd, 0, sizeof(Scsi_Cmnd));
-
        sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
        scmd->device = sdev;
 
+       memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
+       scmd->cmnd = adapter->int_cdb;
        scmd->device->host = adapter->host;
        scmd->host_scribble = (void *)scb;
        scmd->cmnd[0] = MEGA_INTERNAL_CMD;
@@ -4455,6 +4459,8 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
 
        mutex_unlock(&adapter->int_mtx);
 
+       scsi_free_command(GFP_KERNEL, scmd);
+
        return rval;
 }
 
@@ -4787,10 +4793,10 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
        /* Set the Mode of addressing to 64 bit if we can */
        if ((adapter->flag & BOARD_64BIT) && (sizeof(dma_addr_t) == 8)) {
-               pci_set_dma_mask(pdev, DMA_64BIT_MASK);
+               pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
                adapter->has_64bit_addr = 1;
        } else  {
-               pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+               pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
                adapter->has_64bit_addr = 0;
        }
                
@@ -4996,7 +5002,7 @@ static int __init megaraid_init(void)
                max_mbox_busy_wait = MBOX_BUSY_WAIT;
 
 #ifdef CONFIG_PROC_FS
-       mega_proc_dir_entry = proc_mkdir("megaraid", &proc_root);
+       mega_proc_dir_entry = proc_mkdir("megaraid", NULL);
        if (!mega_proc_dir_entry) {
                printk(KERN_WARNING
                                "megaraid: failed to create megaraid root\n");
@@ -5005,7 +5011,7 @@ static int __init megaraid_init(void)
        error = pci_register_driver(&megaraid_pci_driver);
        if (error) {
 #ifdef CONFIG_PROC_FS
-               remove_proc_entry("megaraid", &proc_root);
+               remove_proc_entry("megaraid", NULL);
 #endif
                return error;
        }
@@ -5035,7 +5041,7 @@ static void __exit megaraid_exit(void)
        pci_unregister_driver(&megaraid_pci_driver);
 
 #ifdef CONFIG_PROC_FS
-       remove_proc_entry("megaraid", &proc_root);
+       remove_proc_entry("megaraid", NULL);
 #endif
 }