⬢ DragonFlyBSD Kernel Audit
DF-4245 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/dpt/dpt_scsi.c b/sys/dev/raid/dpt/dpt_scsi.c
index ebc9e1a..8422e69 100644
--- a/sys/dev/raid/dpt/dpt_scsi.c
+++ b/sys/dev/raid/dpt/dpt_scsi.c
@@ -472,6 +472,7 @@ dpt_get_conf(dpt_softc_t *dpt, dpt_ccb_t *dccb, u_int32_t dccb_busaddr,
 
 	int	   ndx;
 	int	   result;
+	int	   spin;
 
 	cp = &dccb->eata_ccb;
 	bzero((void *)(uintptr_t)(volatile void *)dpt->sp, sizeof(*dpt->sp));
@@ -502,11 +503,19 @@ dpt_get_conf(dpt_softc_t *dpt, dpt_ccb_t *dccb, u_int32_t dccb_busaddr,
 	 * have optimized it a bit too much. Wait for the controller to
 	 * become ready
 	 */
+	spin = 0;
 	while (((status = dpt_inb(dpt, HA_RSTATUS)) != (HA_SREADY | HA_SSC)
 	     && (status != (HA_SREADY | HA_SSC | HA_SERROR))
 	     && (status != (HA_SDRDY | HA_SERROR | HA_SDRQ)))
 	    || (dpt_wait(dpt, HA_SBUSY, 0))) {
 
+		if (++spin > 60) {	/* dpt_wait burns up to ~1s per pass */
+			kprintf("dpt%d WARNING: Get_conf() HBA never ready\n",
+			       dpt->unit);
+			crit_exit();
+			return (0);
+		}
+
 		/*
 		 * RAID Drives still Spinning up? (This should only occur if
 		 * the DPT controller is in a NON PC (PCI?) platform).