]> err.no Git - linux-2.6/commitdiff
[SCSI] megaraid_sas: switch fw_outstanding to an atomic_t
authorSumant Patro <sumantp@lsil.com>
Tue, 30 May 2006 19:03:37 +0000 (12:03 -0700)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Tue, 6 Jun 2006 14:57:18 +0000 (10:57 -0400)
This patch( originally submitted by Christoph Hellwig) removes
instance_lock and changes fw_outstanding variable data type to
atomic_t.

Signed-off-by: Sumant Patro <Sumant.Patro@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Documentation/scsi/ChangeLog.megaraid_sas
drivers/scsi/megaraid/megaraid_sas.c
drivers/scsi/megaraid/megaraid_sas.h

index 2dafa63bd370bd1632f08f73687e210f08636494..0a85a7e8120e5a7cbadc895fc038b58ea96d7815 100644 (file)
@@ -1,3 +1,16 @@
+
+1 Release Date    : Wed Feb 03 14:31:44 PST 2006 - Sumant Patro <Sumant.Patro@lsil.com>
+2 Current Version : 00.00.02.04
+3 Older Version   : 00.00.02.04 
+
+i.     Remove superflous instance_lock
+
+       gets rid of the otherwise superflous instance_lock and avoids an unsave 
+       unsynchronized access in the error handler.
+
+               - Christoph Hellwig <hch@lst.de>
+
+
 1 Release Date    : Wed Feb 03 14:31:44 PST 2006 - Sumant Patro <Sumant.Patro@lsil.com>
 2 Current Version : 00.00.02.04
 3 Older Version   : 00.00.02.04 
index 39729460b00e243b8be2b9257d9f71e11b769895..0c9516ff636ffdfa0e1bc9f576321137e7d4df72 100644 (file)
@@ -741,7 +741,6 @@ static int
 megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
 {
        u32 frame_count;
-       unsigned long flags;
        struct megasas_cmd *cmd;
        struct megasas_instance *instance;
 
@@ -776,9 +775,7 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
        /*
         * Issue the command to the FW
         */
-       spin_lock_irqsave(&instance->instance_lock, flags);
-       instance->fw_outstanding++;
-       spin_unlock_irqrestore(&instance->instance_lock, flags);
+       atomic_inc(&instance->fw_outstanding);
 
        instance->instancet->fire_cmd(cmd->frame_phys_addr ,cmd->frame_count-1,instance->reg_set);
 
@@ -826,19 +823,20 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 
        for (i = 0; i < wait_time; i++) {
 
-               if (!instance->fw_outstanding)
+               int outstanding = atomic_read(&instance->fw_outstanding);
+
+               if (!outstanding)
                        break;
 
                if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
                        printk(KERN_NOTICE "megasas: [%2d]waiting for %d "
-                              "commands to complete\n", i,
-                              instance->fw_outstanding);
+                              "commands to complete\n",i,outstanding);
                }
 
                msleep(1000);
        }
 
-       if (instance->fw_outstanding) {
+       if (atomic_read(&instance->fw_outstanding)) {
                instance->hw_crit_error = 1;
                return FAILED;
        }
@@ -1050,7 +1048,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
 {
        int exception = 0;
        struct megasas_header *hdr = &cmd->frame->hdr;
-       unsigned long flags;
 
        if (cmd->scmd) {
                cmd->scmd->SCp.ptr = (char *)0;
@@ -1082,9 +1079,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
 
                if (exception) {
 
-                       spin_lock_irqsave(&instance->instance_lock, flags);
-                       instance->fw_outstanding--;
-                       spin_unlock_irqrestore(&instance->instance_lock, flags);
+                       atomic_dec(&instance->fw_outstanding);
 
                        megasas_unmap_sgbuf(instance, cmd);
                        cmd->scmd->scsi_done(cmd->scmd);
@@ -1132,9 +1127,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                        break;
                }
 
-               spin_lock_irqsave(&instance->instance_lock, flags);
-               instance->fw_outstanding--;
-               spin_unlock_irqrestore(&instance->instance_lock, flags);
+               atomic_dec(&instance->fw_outstanding);
 
                megasas_unmap_sgbuf(instance, cmd);
                cmd->scmd->scsi_done(cmd->scmd);
@@ -2171,11 +2164,12 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
         */
        INIT_LIST_HEAD(&instance->cmd_pool);
 
+       atomic_set(&instance->fw_outstanding,0);
+
        init_waitqueue_head(&instance->int_cmd_wait_q);
        init_waitqueue_head(&instance->abort_cmd_wait_q);
 
        spin_lock_init(&instance->cmd_pool_lock);
-       spin_lock_init(&instance->instance_lock);
 
        sema_init(&instance->aen_mutex, 1);
        sema_init(&instance->ioctl_sem, MEGASAS_INT_CMDS);
index 89639f0c38ef2e3683f012328a763dd4755f6123..927d6ffef05f14c53367106e15fdbf9e21079c6c 100644 (file)
@@ -1077,9 +1077,8 @@ struct megasas_instance {
        struct pci_dev *pdev;
        u32 unique_id;
 
-       u32 fw_outstanding;
+       atomic_t fw_outstanding;
        u32 hw_crit_error;
-       spinlock_t instance_lock;
 
        struct megasas_instance_template *instancet;
 };