Skip to contentSkip to conversation

arcmsr: Fix hardware wait loops

PATCH New Jeff Garzik 1 participant 2 messages Jul 27, 2007 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 arcmsr: Fix hardware wait loops

IMO this belongs in 2.6.23-rc.

Committed to 'arcmsr' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.git

commit f9f7b1384995626e1a80322faef3f7cca97aa7ae

Author: Jeff Garzik <[email protected]>
Date:   Fri Jul 27 12:57:38 2007 -0400

[SCSI] arcmsr: Fix hardware wait loops

Remove _interruptible, since receiving a signal while waiting on a hardware condition will simply cause the driver to busy-wait.

Using msleep_interruptible() is rarely the right thing to do, when waiting on a hardware condition to change.

Also, replace msleep with ssleep while doing this, where appropriate.

 drivers/scsi/arcmsr/arcmsr_hba.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

f9f7b1384995626e1a80322faef3f7cca97aa7ae

drivers/scsi/arcmsr/arcmsr_hba.c +5 -3
index 0ddfc21..ae26ed4 100644
@@ -540,7 +540,7 @@ static uint8_t arcmsr_wait_msgint_ready(struct AdapterControlBlock *acb)
 					, &reg->outbound_intstatus);
 				return 0x00;
 			}
-			msleep_interruptible(10);
+			msleep(10);
 		}/*max 1 seconds*/
 	} while (Retries++ < 20);/*max 20 sec*/
 	return 0xff;
@@ -1421,8 +1421,10 @@ static void arcmsr_iop_reset(struct AdapterControlBlock *acb)
 	if (atomic_read(&acb->ccboutstandingcount) != 0) {
 		/* talk to iop 331 outstanding command aborted */
 		arcmsr_abort_allcmd(acb);
+
 		/* wait for 3 sec for all command aborted*/
-		msleep_interruptible(3000);
+		ssleep(3);
+
 		/* disable all outbound interrupt */
 		intmask_org = arcmsr_disable_outbound_ints(acb);
 		/* clear all outbound posted Q */
@@ -1468,7 +1470,7 @@ static void arcmsr_abort_one_cmd(struct AdapterControlBlock *acb,
 	/*
 	** Wait for 3 sec for all command done.
 	*/
-	msleep_interruptible(3000);
+	ssleep(3);
 
 	intmask = arcmsr_disable_outbound_ints(acb);
 	arcmsr_polling_ccbdone(acb, ccb);
#1 lore raw

PATCH 2/2 arcmsr: irq handler fixes, cleanups, micro-opts

commit 97618f90f021d457c5078ab85f0f443553f93d51

Author: Jeff Garzik <[email protected]>
Date:   Fri Jul 27 12:58:00 2007 -0400

[SCSI] arcmsr: interrupt handling fixes, cleanups, micro-opts

* Remove IRQF_DISABLED, it is clearly wrong for this driver.

* Remove wasteful spin_lock_irqsave() in interrupt handler. The lighter-weight spin_lock() is all that's needed.

* Annotate with FIXME where arcmsr_interrupt() is called without any spinlock being acquired.

* Eliminate pointless cast from void pointer in arcmsr_do_interrupt()

 drivers/scsi/arcmsr/arcmsr_hba.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

97618f90f021d457c5078ab85f0f443553f93d51

drivers/scsi/arcmsr/arcmsr_hba.c +7 -9
index ae26ed4..d9fadb4 100644
@@ -159,14 +159,12 @@ static struct pci_driver arcmsr_pci_driver = {
 static irqreturn_t arcmsr_do_interrupt(int irq, void *dev_id)
 {
 	irqreturn_t handle_state;
-	struct AdapterControlBlock *acb;
-	unsigned long flags;
-
-	acb = (struct AdapterControlBlock *)dev_id;
+	struct AdapterControlBlock *acb = dev_id;
 
-	spin_lock_irqsave(acb->host->host_lock, flags);
+	spin_lock(acb->host->host_lock);
 	handle_state = arcmsr_interrupt(acb);
-	spin_unlock_irqrestore(acb->host->host_lock, flags);
+	spin_unlock(acb->host->host_lock);
+
 	return handle_state;
 }
 
@@ -331,7 +329,7 @@ static int arcmsr_probe(struct pci_dev *pdev,
 		goto out_iounmap;
 
 	error = request_irq(pdev->irq, arcmsr_do_interrupt,
-			IRQF_DISABLED | IRQF_SHARED, "arcmsr", acb);
+			    IRQF_SHARED, "arcmsr", acb);
 	if (error)
 		goto out_free_ccb_pool;
 
@@ -421,7 +419,7 @@ static void arcmsr_remove(struct pci_dev *pdev)
 	for (poll_count = 0; poll_count < 256; poll_count++) {
 		if (!atomic_read(&acb->ccboutstandingcount))
 			break;
-		arcmsr_interrupt(acb);
+		arcmsr_interrupt(acb);	/* FIXME: need spinlock */
 		msleep(25);
 	}
 
@@ -1452,7 +1450,7 @@ static int arcmsr_bus_reset(struct scsi_cmnd *cmd)
 	for (i = 0; i < 400; i++) {
 		if (!atomic_read(&acb->ccboutstandingcount))
 			break;
-		arcmsr_interrupt(acb);
+		arcmsr_interrupt(acb);	/* FIXME: need spinlock */
 		msleep(25);
 	}
 	arcmsr_iop_reset(acb);