[SCSI] pm8001: Fix bogus interrupt state flag issue.
authorSantosh Nayak <santoshprasadnayak@gmail.com>
Sun, 26 Feb 2012 13:33:30 +0000 (19:03 +0530)
committerJames Bottomley <JBottomley@Parallels.com>
Wed, 29 Feb 2012 22:49:55 +0000 (16:49 -0600)
Static checker is giving following warning:
" error: calling 'spin_unlock_irqrestore()' with bogus flags"

The code flow is as shown below:
process_oq() --> process_one_iomb --> mpi_sata_completion

In 'mpi_sata_completion'
the first call for 'spin_unlock_irqrestore()' is with flags=0,
which is as good as 'spin_unlock_irq()' ( unconditional interrupt
enabling).

So for better performance 'spin_unlock_irqrestore()' can be replaced
with 'spin_unlock_irq()' and 'spin_lock_irqsave()' can be replaced by
'spin_lock_irq()'.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
Acked-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/pm8001/pm8001_hwi.c

index 3920b49f4f57dc9db909f358f66513e2c47d0ac8..871d1c3fa01bc02accb3a24f1b9e95870752afd9 100644 (file)
@@ -2082,7 +2082,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 {
        struct sas_task *t;
        struct pm8001_ccb_info *ccb;
-       unsigned long flags = 0;
        u32 param;
        u32 status;
        u32 tag;
@@ -2221,9 +2220,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*in order to force CPU ordering*/
-                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+                       spin_unlock_irq(&pm8001_ha->lock);
                        t->task_done(t);
-                       spin_lock_irqsave(&pm8001_ha->lock, flags);
+                       spin_lock_irq(&pm8001_ha->lock);
                        return;
                }
                break;
@@ -2241,9 +2240,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
-                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+                       spin_unlock_irq(&pm8001_ha->lock);
                        t->task_done(t);
-                       spin_lock_irqsave(&pm8001_ha->lock, flags);
+                       spin_lock_irq(&pm8001_ha->lock);
                        return;
                }
                break;
@@ -2269,9 +2268,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/* ditto*/
-                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+                       spin_unlock_irq(&pm8001_ha->lock);
                        t->task_done(t);
-                       spin_lock_irqsave(&pm8001_ha->lock, flags);
+                       spin_lock_irq(&pm8001_ha->lock);
                        return;
                }
                break;
@@ -2336,9 +2335,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
-                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+                       spin_unlock_irq(&pm8001_ha->lock);
                        t->task_done(t);
-                       spin_lock_irqsave(&pm8001_ha->lock, flags);
+                       spin_lock_irq(&pm8001_ha->lock);
                        return;
                }
                break;
@@ -2360,9 +2359,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
-                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+                       spin_unlock_irq(&pm8001_ha->lock);
                        t->task_done(t);
-                       spin_lock_irqsave(&pm8001_ha->lock, flags);
+                       spin_lock_irq(&pm8001_ha->lock);
                        return;
                }
                break;
@@ -2380,31 +2379,31 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                ts->stat = SAS_DEV_NO_RESPONSE;
                break;
        }
-       spin_lock_irqsave(&t->task_state_lock, flags);
+       spin_lock_irq(&t->task_state_lock);
        t->task_state_flags &= ~SAS_TASK_STATE_PENDING;
        t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
        t->task_state_flags |= SAS_TASK_STATE_DONE;
        if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) {
-               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               spin_unlock_irq(&t->task_state_lock);
                PM8001_FAIL_DBG(pm8001_ha,
                        pm8001_printk("task 0x%p done with io_status 0x%x"
                        " resp 0x%x stat 0x%x but aborted by upper layer!\n",
                        t, status, ts->resp, ts->stat));
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
        } else if (t->uldd_task) {
-               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               spin_unlock_irq(&t->task_state_lock);
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                mb();/* ditto */
-               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+               spin_unlock_irq(&pm8001_ha->lock);
                t->task_done(t);
-               spin_lock_irqsave(&pm8001_ha->lock, flags);
+               spin_lock_irq(&pm8001_ha->lock);
        } else if (!t->uldd_task) {
-               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               spin_unlock_irq(&t->task_state_lock);
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                mb();/*ditto*/
-               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+               spin_unlock_irq(&pm8001_ha->lock);
                t->task_done(t);
-               spin_lock_irqsave(&pm8001_ha->lock, flags);
+               spin_lock_irq(&pm8001_ha->lock);
        }
 }
 
@@ -2412,7 +2411,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
        struct sas_task *t;
-       unsigned long flags = 0;
        struct task_status_struct *ts;
        struct pm8001_ccb_info *ccb;
        struct pm8001_device *pm8001_dev;
@@ -2492,9 +2490,9 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
-                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+                       spin_unlock_irq(&pm8001_ha->lock);
                        t->task_done(t);
-                       spin_lock_irqsave(&pm8001_ha->lock, flags);
+                       spin_lock_irq(&pm8001_ha->lock);
                        return;
                }
                break;
@@ -2592,31 +2590,31 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
                ts->stat = SAS_OPEN_TO;
                break;
        }
-       spin_lock_irqsave(&t->task_state_lock, flags);
+       spin_lock_irq(&t->task_state_lock);
        t->task_state_flags &= ~SAS_TASK_STATE_PENDING;
        t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
        t->task_state_flags |= SAS_TASK_STATE_DONE;
        if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) {
-               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               spin_unlock_irq(&t->task_state_lock);
                PM8001_FAIL_DBG(pm8001_ha,
                        pm8001_printk("task 0x%p done with io_status 0x%x"
                        " resp 0x%x stat 0x%x but aborted by upper layer!\n",
                        t, event, ts->resp, ts->stat));
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
        } else if (t->uldd_task) {
-               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               spin_unlock_irq(&t->task_state_lock);
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                mb();/* ditto */
-               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+               spin_unlock_irq(&pm8001_ha->lock);
                t->task_done(t);
-               spin_lock_irqsave(&pm8001_ha->lock, flags);
+               spin_lock_irq(&pm8001_ha->lock);
        } else if (!t->uldd_task) {
-               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               spin_unlock_irq(&t->task_state_lock);
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                mb();/*ditto*/
-               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+               spin_unlock_irq(&pm8001_ha->lock);
                t->task_done(t);
-               spin_lock_irqsave(&pm8001_ha->lock, flags);
+               spin_lock_irq(&pm8001_ha->lock);
        }
 }