Skip to contentSkip to conversation

lpfc: replace spin_lock with spin_lock_irqsave

PATCH New Tomohiro Kusumi 1 participant 1 message Feb 7, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lpfc: replace spin_lock with spin_lock_irqsave

Hi

lpfc_sli_intr_handler() takes spinlock phba->hbalock without disabling irq on local cpu. This patch replaces normal spin_lock/unlock with irqsave/restore.

Although current code won't cause any deadlock (since this is interrupt context), the code looks strange to me because all the other intr handlers (sp,fp and s4 handlers) use irqsave/restore. Especially where the code takes the spinlock with spin_lock and release it with spin_unlock_irq when DEFER_ERATT bit is set.

thanks,
Tomohiro Kusumi

---

drivers/scsi/lpfc/lpfc_sli.c +5 -5
diff -aNur linux-2.6.33-rc7.org/drivers/scsi/lpfc/lpfc_sli.c linux-2.6.33-rc7/drivers/scsi/lpfc/lpfc_sli.c
@@ -8213,7 +8213,7 @@
 {
 	struct lpfc_hba  *phba;
 	irqreturn_t sp_irq_rc, fp_irq_rc;
-	unsigned long status1, status2;
+	unsigned long status1, status2, iflag;
 	uint32_t hc_copy;
 
 	/*
@@ -8229,10 +8229,10 @@
 	if (lpfc_intr_state_check(phba))
 		return IRQ_NONE;
 
-	spin_lock(&phba->hbalock);
+	spin_lock_irqsave(&phba->hbalock, iflag);
 	phba->ha_copy = readl(phba->HAregaddr);
 	if (unlikely(!phba->ha_copy)) {
-		spin_unlock(&phba->hbalock);
+		spin_unlock_irqrestore(&phba->hbalock, iflag);
 		return IRQ_NONE;
 	} else if (phba->ha_copy & HA_ERATT) {
 		if (phba->hba_flag & HBA_ERATT_HANDLED)
@@ -8247,7 +8247,7 @@
 	 * If there is deferred error attention, do not check for any interrupt.
 	 */
 	if (unlikely(phba->hba_flag & DEFER_ERATT)) {
-		spin_unlock_irq(&phba->hbalock);
+		spin_unlock_irqrestore(&phba->hbalock, iflag);
 		return IRQ_NONE;
 	}
 
@@ -8259,7 +8259,7 @@
 	writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr);
 	writel(hc_copy, phba->HCregaddr);
 	readl(phba->HAregaddr); /* flush */
-	spin_unlock(&phba->hbalock);
+	spin_unlock_irqrestore(&phba->hbalock, iflag);
 
 	/*
 	 * Invokes slow-path host attention interrupt handling as appropriate.