Skip to contentSkip to conversation

AIC94XX: nmi timeout fix

PATCH New [email protected] 1 participant 1 message Nov 1, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 AIC94XX: nmi timeout fix

Few of us have seen the AIC94XX driver get stuck reading the ATOMICSTATCTL register in a loop for ever. The possible immortal loop in asd_ddbsite_update_word() is made mortal now! Retry worked just fine!

drivers/scsi/aic94xx/aic94xx_reg.h +18 -8
diff -r 5f7a0e8a8265 drivers/scsi/aic94xx/aic94xx_reg.h
@@ -226,20 +226,30 @@ static inline int asd_ddbsite_update_wor
 					  u16 oldval, u16 newval)
 {
 	u8  done;
+	int retries = 100;
+	int i;
+
 	u16 oval = asd_ddbsite_read_word(asd_ha, ddb_site_no, offs);
 	if (oval != oldval)
 		return -EAGAIN;
 	asd_write_reg_word(asd_ha, AOLDDATA, oldval);
 	asd_write_reg_word(asd_ha, ANEWDATA, newval);
-	do {
+	for (i = 0; i < retries; i++) {
 		done = asd_read_reg_byte(asd_ha, ATOMICSTATCTL);
-	} while (!(done & ATOMICDONE));
-	if (done & ATOMICERR)
-		return -EFAULT;	  /* parity error */
-	else if (done & ATOMICWIN)
-		return 0;	  /* success */
-	else
-		return -EAGAIN;	  /* oldval different than current value */
+		if (done & ATOMICDONE) {
+			if (done & ATOMICERR)
+				return -EFAULT;	  /* parity error */
+			else if (done & ATOMICWIN)
+				return 0;	  /* success */
+			else
+				/* oldval different than current value */
+				return -EAGAIN;
+		}
+	}
+
+	/* ATOMICDONE is not set after repeated retries! Broken chip? */
+	WARN_ON(1);
+	return -EAGAIN;
 }
 
 static inline int asd_ddbsite_update_byte(struct asd_ha_struct *asd_ha,